diff options
| author | Chris Craik <ccraik@google.com> | 2012-02-06 10:00:58 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-06 10:00:58 -0800 |
| commit | d5544ac710f5ae9ee023c850e4490ccb5ebdf74b (patch) | |
| tree | 6e539c86eb7371f392a8395b20f5cd382e0603a4 /core/java | |
| parent | 37f6934e863de13926975ff5c4e60b9ee9fa79cc (diff) | |
| parent | 4390c6b4a6b38b1c25fdf6b10b1310ff73c4f9ce (diff) | |
Merge "Pause webkit painting when UI tile painting queue is full"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 36 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 31 |
2 files changed, 48 insertions, 19 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index dcddd4713e9e..3f5b45e739c0 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2654,7 +2654,7 @@ public class WebView extends AbsoluteLayout checkThread(); mContentWidth = 0; mContentHeight = 0; - setBaseLayer(0, null, false, false, false); + setBaseLayer(0, null, false, false); mWebViewCore.sendMessage(EventHub.CLEAR_CONTENT); } @@ -4521,6 +4521,8 @@ public class WebView extends AbsoluteLayout if (canvas.isHardwareAccelerated()) { mZoomManager.setHardwareAccelerated(); + } else { + mWebViewCore.resumeWebKitDraw(); } int saveCount = canvas.save(); @@ -4763,11 +4765,19 @@ public class WebView extends AbsoluteLayout } void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator, - boolean isPictureAfterFirstLayout, boolean registerPageSwapCallback) { + boolean isPictureAfterFirstLayout) { if (mNativeClass == 0) return; - nativeSetBaseLayer(mNativeClass, layer, invalRegion, showVisualIndicator, - isPictureAfterFirstLayout, registerPageSwapCallback); + boolean queueFull; + queueFull = nativeSetBaseLayer(mNativeClass, layer, invalRegion, + showVisualIndicator, isPictureAfterFirstLayout); + + if (layer == 0 || isPictureAfterFirstLayout) { + mWebViewCore.resumeWebKitDraw(); + } else if (queueFull) { + mWebViewCore.pauseWebKitDraw(); + } + if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.setBaseLayer(layer); } @@ -9049,6 +9059,7 @@ public class WebView extends AbsoluteLayout /** @hide Called by JNI when pages are swapped (only occurs with hardware * acceleration) */ protected void pageSwapCallback(boolean notifyAnimationStarted) { + mWebViewCore.resumeWebKitDraw(); if (inEditingMode()) { didUpdateWebTextViewDimensions(ANYWHERE); } @@ -9071,13 +9082,9 @@ public class WebView extends AbsoluteLayout boolean isPictureAfterFirstLayout = viewState != null; if (updateBaseLayer) { - // Request a callback on pageSwap (to reposition the webtextview) - boolean registerPageSwapCallback = - !mZoomManager.isFixedLengthAnimationInProgress() && inEditingMode(); - setBaseLayer(draw.mBaseLayer, draw.mInvalRegion, getSettings().getShowVisualIndicator(), - isPictureAfterFirstLayout, registerPageSwapCallback); + isPictureAfterFirstLayout); } final Point viewSize = draw.mViewSize; // We update the layout (i.e. request a layout from the @@ -9755,11 +9762,6 @@ public class WebView extends AbsoluteLayout } } - /** @hide call pageSwapCallback upon next page swap */ - protected void registerPageSwapCallback() { - nativeRegisterPageSwapCallback(mNativeClass); - } - /** @hide discard all textures from tiles */ protected void discardAllTextures() { nativeDiscardAllTextures(); @@ -9922,10 +9924,9 @@ public class WebView extends AbsoluteLayout private native void nativeSetFindIsEmpty(); private native void nativeSetFindIsUp(boolean isUp); private native void nativeSetHeightCanMeasure(boolean measure); - private native void nativeSetBaseLayer(int nativeInstance, + private native boolean nativeSetBaseLayer(int nativeInstance, int layer, Region invalRegion, - boolean showVisualIndicator, boolean isPictureAfterFirstLayout, - boolean registerPageSwapCallback); + boolean showVisualIndicator, boolean isPictureAfterFirstLayout); private native int nativeGetBaseLayer(); private native void nativeShowCursorTimed(); private native void nativeReplaceBaseContent(int content); @@ -9937,7 +9938,6 @@ public class WebView extends AbsoluteLayout private native void nativeStopGL(); private native Rect nativeSubtractLayers(Rect content); private native int nativeTextGeneration(); - private native void nativeRegisterPageSwapCallback(int nativeInstance); private native void nativeDiscardAllTextures(); private native void nativeTileProfilingStart(); private native float nativeTileProfilingStop(); diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 8582dbcb4af3..ebf3e2188f20 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -2169,7 +2169,36 @@ public final class WebViewCore { .obtainMessage(WebView.INVAL_RECT_MSG_ID)); } + private Boolean m_skipDrawFlag = false; + private boolean m_drawWasSkipped = false; + + void pauseWebKitDraw() { + synchronized (m_skipDrawFlag) { + if (!m_skipDrawFlag) { + m_skipDrawFlag = true; + } + } + } + + void resumeWebKitDraw() { + synchronized (m_skipDrawFlag) { + if (m_skipDrawFlag && m_drawWasSkipped) { + // a draw was dropped, send a retry + m_drawWasSkipped = false; + mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW)); + } + m_skipDrawFlag = false; + } + } + private void webkitDraw() { + synchronized (m_skipDrawFlag) { + if (m_skipDrawFlag) { + m_drawWasSkipped = true; + return; + } + } + mDrawIsScheduled = false; DrawData draw = new DrawData(); if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw start"); @@ -2178,7 +2207,7 @@ public final class WebViewCore { if (draw.mBaseLayer == 0) { if (mWebView != null && !mWebView.isPaused()) { if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw abort, resending draw message"); - mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW)); + mEventHub.sendMessageDelayed(Message.obtain(null, EventHub.WEBKIT_DRAW), 10); } else { if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw abort, webview paused"); } |
