Skip to content

Commit f270a15

Browse files
camaelonAndroid (Google) Code Review
authored andcommitted
Merge "Streamline the layers update codepath. Directly update the layers transform and position. This makes updates faster and less dependent on other webkit work."
2 parents 30c845f + dc221e0 commit f270a15

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

core/java/android/webkit/WebViewCore.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ protected void enterFullscreenForVideoLayer(int layerId, String url) {
518518
/**
519519
* Update the layers' content
520520
*/
521-
private native int nativeUpdateLayers(Region invalRegion);
521+
private native boolean nativeUpdateLayers(int baseLayer);
522522

523523
private native boolean nativeFocusBoundsChanged();
524524

@@ -2004,18 +2004,25 @@ static class DrawData {
20042004
boolean mFocusSizeChanged;
20052005
}
20062006

2007+
DrawData mLastDrawData = null;
2008+
20072009
// Only update the layers' content, not the base surface
20082010
// PictureSet.
20092011
private void webkitDrawLayers() {
20102012
mDrawLayersIsScheduled = false;
2011-
if (mDrawIsScheduled) {
2013+
if (mDrawIsScheduled || mLastDrawData == null) {
20122014
removeMessages(EventHub.WEBKIT_DRAW);
20132015
webkitDraw();
20142016
return;
20152017
}
2016-
DrawData draw = new DrawData();
2017-
draw.mBaseLayer = nativeUpdateLayers(draw.mInvalRegion);
2018-
webkitDraw(draw);
2018+
// Directly update the layers we last passed to the UI side
2019+
if (nativeUpdateLayers(mLastDrawData.mBaseLayer)) {
2020+
// If anything more complex than position has been touched, let's do a full draw
2021+
webkitDraw();
2022+
} else {
2023+
Message.obtain(mWebView.mPrivateHandler,
2024+
WebView.INVAL_RECT_MSG_ID).sendToTarget();
2025+
}
20192026
}
20202027

20212028
private void webkitDraw() {
@@ -2032,6 +2039,7 @@ private void webkitDraw() {
20322039
}
20332040
return;
20342041
}
2042+
mLastDrawData = draw;
20352043
webkitDraw(draw);
20362044
}
20372045

0 commit comments

Comments
 (0)