OSDN Git Service

Have different x-fade rates for zoom in vs zoom out.
authorDave Burke <daveburke@google.com>
Wed, 26 Jan 2011 19:21:28 +0000 (19:21 +0000)
committerDave Burke <daveburke@google.com>
Thu, 27 Jan 2011 19:42:39 +0000 (19:42 +0000)
Tweak up transitions to make zooming feel faster.
bug:3394378

Change-Id: I39a7e5785c3ab44d0245267a3137e7f87489efcd

WebCore/platform/graphics/android/BaseLayerAndroid.cpp
WebCore/platform/graphics/android/GLWebViewState.cpp
WebCore/platform/graphics/android/GLWebViewState.h

index 52ef8ca..b6177aa 100644 (file)
@@ -195,13 +195,15 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale)
     // the two pages (current one and future one with the new scale factor)
     if (m_glWebViewState->scaleRequestState() == GLWebViewState::kReceivedNewScale) {
         TiledPage* nextTiledPage = m_glWebViewState->backPage();
-        double transitionTime = m_glWebViewState->transitionTime(currentTime);
+        double transitionTime = (scale < m_glWebViewState->currentScale()) ?
+            m_glWebViewState->zoomOutTransitionTime(currentTime) :
+            m_glWebViewState->zoomInTransitionTime(currentTime);
 
         float newTilesTransparency = 1;
         if (scale < m_glWebViewState->currentScale())
-            newTilesTransparency = 1 - m_glWebViewState->transparency(currentTime);
+            newTilesTransparency = 1 - m_glWebViewState->zoomOutTransparency(currentTime);
         else
-            transparency = m_glWebViewState->transparency(currentTime);
+            transparency = m_glWebViewState->zoomInTransparency(currentTime);
 
         nextTiledPage->draw(newTilesTransparency, viewportTileBounds);
 
index 252eeab..3b66b04 100644 (file)
@@ -201,17 +201,32 @@ void GLWebViewState::scheduleUpdate(const double& currentTime,
     }
 }
 
-double GLWebViewState::transitionTime(double currentTime)
+double GLWebViewState::zoomInTransitionTime(double currentTime)
 {
     if (m_transitionTime == -1)
-        m_transitionTime = currentTime + s_transitionDelay;
+        m_transitionTime = currentTime + s_zoomInTransitionDelay;
     return m_transitionTime;
 }
 
-float GLWebViewState::transparency(double currentTime)
+double GLWebViewState::zoomOutTransitionTime(double currentTime)
 {
-    float t = transitionTime(currentTime) - currentTime;
-    t *= s_invTransitionDelay;
+    if (m_transitionTime == -1)
+        m_transitionTime = currentTime + s_zoomOutTransitionDelay;
+    return m_transitionTime;
+}
+
+
+float GLWebViewState::zoomInTransparency(double currentTime)
+{
+    float t = zoomInTransitionTime(currentTime) - currentTime;
+    t *= s_invZoomInTransitionDelay;
+    return fmin(1, fmax(0, t));
+}
+
+float GLWebViewState::zoomOutTransparency(double currentTime)
+{
+    float t = zoomOutTransitionTime(currentTime) - currentTime;
+    t *= s_invZoomOutTransitionDelay;
     return fmin(1, fmax(0, t));
 }
 
index 3f933ca..81dcb9e 100644 (file)
@@ -164,8 +164,10 @@ public:
     void setFutureViewport(const SkIRect& viewport) { m_futureViewportTileBounds = viewport; }
     double updateTime() const { return m_updateTime; }
     void setUpdateTime(double value) { m_updateTime = value; }
-    double transitionTime(double currentTime);
-    float transparency(double currentTime);
+    double zoomInTransitionTime(double currentTime);
+    double zoomOutTransitionTime(double currentTime);
+    float zoomInTransparency(double currentTime);
+    float zoomOutTransparency(double currentTime);
     void resetTransitionTime() { m_transitionTime = -1; }
 
     unsigned int paintBaseLayerContent(SkCanvas* canvas);
@@ -217,8 +219,10 @@ private:
     static const double s_updateDelay = 0.1; // 100 ms
 
     // Delay for the transition between the two pages
-    static const double s_transitionDelay = 0.5; // 500 ms
-    static const double s_invTransitionDelay = 2;
+    static const double s_zoomInTransitionDelay = 0.1; // 100 ms
+    static const double s_invZoomInTransitionDelay = 10;
+    static const double s_zoomOutTransitionDelay = 0.2; // 200 ms
+    static const double s_invZoomOutTransitionDelay = 5;
 
     GLScaleState m_scaleRequestState;
     float m_currentScale;