diff options
| author | 2011-01-26 10:19:39 +0000 | |
|---|---|---|
| committer | 2011-01-27 15:41:48 +0000 | |
| commit | 811ba6c6a270f3ba248a61f12c3112d85da8b99a (patch) | |
| tree | 57309353b9fa7787ca50ab9b58f29d8c27e35516 | |
| parent | e38ba4acbe6f1536997ffb98d662fc3eff07add8 (diff) | |
Implement the double tap to zoom animation with HW accleration.
Bug: 3164010
Change-Id: I6d3b5973ee0aa95dd810755263e615e226cc965b
| -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 2a2b3af05a3f..2d6c7f5a6e40 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3732,6 +3732,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 b47fe86ec6ce..efbcd5811db8 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; + } } |