From 2e8fd2e525063fd6962c5a958d4aaca8b3974f79 Mon Sep 17 00:00:00 2001 From: Dave Burke Date: Wed, 26 Jan 2011 19:21:28 +0000 Subject: [PATCH] Have different x-fade rates for zoom in vs zoom out. Tweak up transitions to make zooming feel faster. bug:3394378 Change-Id: I39a7e5785c3ab44d0245267a3137e7f87489efcd --- .../platform/graphics/android/BaseLayerAndroid.cpp | 8 ++++--- .../platform/graphics/android/GLWebViewState.cpp | 25 +++++++++++++++++----- WebCore/platform/graphics/android/GLWebViewState.h | 12 +++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 52ef8caed..b6177aaa5 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -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); diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index 252eeabde..3b66b0436 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -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)); } diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h index 3f933caa3..81dcb9e0a 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.h +++ b/WebCore/platform/graphics/android/GLWebViewState.h @@ -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; -- 2.11.0