diff options
-rw-r--r-- | core/java/android/webkit/WebView.java | 4 | ||||
-rw-r--r-- | core/java/android/webkit/ZoomManager.java | 29 |
2 files changed, 30 insertions, 3 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 6363299..e26fd6f 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3734,6 +3734,10 @@ public class WebView extends AbsoluteLayout return; } + if (canvas.isHardwareAccelerated()) { + mZoomManager.setHardwareAccelerated(); + } + int saveCount = canvas.save(); if (mInOverScrollMode && !getSettings() .getUseWebViewBackgroundForOverscrollBackground()) { diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java index b47fe86..efbcd58 100644 --- a/core/java/android/webkit/ZoomManager.java +++ b/core/java/android/webkit/ZoomManager.java @@ -183,6 +183,9 @@ class ZoomManager { private ScaleGestureDetector mScaleDetector; private boolean mPinchToZoomAnimating = false; + private boolean mHardwareAccelerated = false; + private boolean mInHWAcceleratedZoom = false; + public ZoomManager(WebView webView, CallbackProxy callbackProxy) { mWebView = webView; mCallbackProxy = callbackProxy; @@ -384,6 +387,10 @@ class ZoomManager { scale = getReadingLevelScale(); } + if (mHardwareAccelerated) { + mInHWAcceleratedZoom = true; + } + setZoomScale(scale, reflowText); if (oldScale != mActualScale) { @@ -447,8 +454,18 @@ class ZoomManager { - titleHeight, mWebView.getViewHeight(), Math.round(mWebView.getContentHeight() * zoomScale)) + titleHeight) + mWebView.getScrollY(); - canvas.translate(tx, ty); - canvas.scale(zoomScale, zoomScale); + if (mHardwareAccelerated) { + mWebView.updateScrollCoordinates(mWebView.getScrollX() - tx, mWebView.getScrollY() - ty); + setZoomScale(zoomScale, false); + + if (mZoomScale == 0) { + // We've reached the end of the zoom animation. + mInHWAcceleratedZoom = false; + } + } else { + canvas.translate(tx, ty); + canvas.scale(zoomScale, zoomScale); + } } public boolean isZoomAnimating() { @@ -493,12 +510,14 @@ class ZoomManager { mActualScale = scale; mInvActualScale = 1 / scale; - if (!mWebView.drawHistory()) { + if (!mWebView.drawHistory() && !mInHWAcceleratedZoom) { // If history Picture is drawn, don't update scroll. They will // be updated when we get out of that mode. // update our scroll so we don't appear to jump // i.e. keep the center of the doc in the center of the view + // If this is part of a zoom on a HW accelerated canvas, we + // have already updated the scroll so don't do it again. int oldX = mWebView.getScrollX(); int oldY = mWebView.getScrollY(); float ratio = scale * oldInvScale; @@ -1020,4 +1039,8 @@ class ZoomManager { return null; } } + + public void setHardwareAccelerated() { + mHardwareAccelerated = true; + } } |