diff options
| author | John Reck <jreck@google.com> | 2011-11-09 16:23:07 -0800 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-11-09 17:19:43 -0800 |
| commit | 5f1c549132150c85edfa8982c4da5c0fd41d8919 (patch) | |
| tree | 034cea3504eafbe3f329fe0b69c6ac3aa71fcb8a /core/java/android/webkit/WebView.java | |
| parent | 36a7f2a9adfa21ec31f00d496fef82e68931c860 (diff) | |
| download | frameworks_base-5f1c549132150c85edfa8982c4da5c0fd41d8919.zip frameworks_base-5f1c549132150c85edfa8982c4da5c0fd41d8919.tar.gz frameworks_base-5f1c549132150c85edfa8982c4da5c0fd41d8919.tar.bz2 | |
Pause drawing when not visible
Bug: 5594608
If onPause is called or if the view or view's window is no longer
visible, pause webview drawing. Calls to onDraw will continue to work,
but animations and other continual drawing will stop
Change-Id: I11640f087852d1a9a33b945ff72297fab1d25b94
Diffstat (limited to 'core/java/android/webkit/WebView.java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 35efabc..c8f0270 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3254,6 +3254,26 @@ public class WebView extends AbsoluteLayout if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.pauseAndDispatch(); } + if (mNativeClass != 0) { + nativeSetPauseDrawing(mNativeClass, true); + } + } + } + + @Override + protected void onWindowVisibilityChanged(int visibility) { + super.onWindowVisibilityChanged(visibility); + updateDrawingState(); + } + + void updateDrawingState() { + if (mNativeClass == 0 || mIsPaused) return; + if (getWindowVisibility() != VISIBLE) { + nativeSetPauseDrawing(mNativeClass, true); + } else if (getVisibility() != VISIBLE) { + nativeSetPauseDrawing(mNativeClass, true); + } else { + nativeSetPauseDrawing(mNativeClass, false); } } @@ -3265,6 +3285,9 @@ public class WebView extends AbsoluteLayout if (mIsPaused) { mIsPaused = false; mWebViewCore.sendMessage(EventHub.ON_RESUME); + if (mNativeClass != 0) { + nativeSetPauseDrawing(mNativeClass, false); + } } } @@ -5599,6 +5622,7 @@ public class WebView extends AbsoluteLayout if (visibility != View.VISIBLE && mZoomManager != null) { mZoomManager.dismissZoomPicker(); } + updateDrawingState(); } /** @@ -8403,6 +8427,9 @@ public class WebView extends AbsoluteLayout setNewPicture(mDelaySetPicture, true); mDelaySetPicture = null; } + if (mIsPaused) { + nativeSetPauseDrawing(mNativeClass, true); + } break; case UPDATE_TEXTFIELD_TEXT_MSG_ID: // Make sure that the textfield is currently focused @@ -9584,4 +9611,5 @@ public class WebView extends AbsoluteLayout * See {@link ComponentCallbacks2} for the trim levels and descriptions */ private static native void nativeOnTrimMemory(int level); + private static native void nativeSetPauseDrawing(int instance, boolean pause); } |
