Skip to content

Commit 47d3d87

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "Do pause painting better"
2 parents d68b6f1 + 834f66b commit 47d3d87

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

core/java/android/webkit/DebugFlags.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ class DebugFlags {
4242
public static final boolean WEB_BACK_FORWARD_LIST = false;
4343
public static final boolean WEB_SETTINGS = false;
4444
public static final boolean WEB_SYNC_MANAGER = false;
45-
public static final boolean WEB_TEXT_VIEW = false;
4645
public static final boolean WEB_VIEW = false;
4746
public static final boolean WEB_VIEW_CORE = false;
48-
/*
49-
* Set to true to allow the WebTextView to draw on top of the web page in a
50-
* different color with no background so you can see how the two line up.
51-
*/
52-
public static final boolean DRAW_WEBTEXTVIEW = false;
47+
public static final boolean MEASURE_PAGE_SWAP_FPS = false;
5348
}

core/java/android/webkit/WebViewClassic.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4717,10 +4717,10 @@ void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator,
47174717
queueFull = nativeSetBaseLayer(mNativeClass, layer, invalRegion,
47184718
showVisualIndicator, isPictureAfterFirstLayout);
47194719

4720-
if (layer == 0 || isPictureAfterFirstLayout) {
4721-
mWebViewCore.resumeWebKitDraw();
4722-
} else if (queueFull) {
4720+
if (queueFull) {
47234721
mWebViewCore.pauseWebKitDraw();
4722+
} else {
4723+
mWebViewCore.resumeWebKitDraw();
47244724
}
47254725

47264726
if (mHTML5VideoViewProxy != null) {
@@ -8615,9 +8615,19 @@ public interface PageSwapDelegate {
86158615
void onPageSwapOccurred(boolean notifyAnimationStarted);
86168616
}
86178617

8618+
long mLastSwapTime;
8619+
double mAverageSwapFps;
8620+
86188621
/** Called by JNI when pages are swapped (only occurs with hardware
86198622
* acceleration) */
86208623
protected void pageSwapCallback(boolean notifyAnimationStarted) {
8624+
if (DebugFlags.MEASURE_PAGE_SWAP_FPS) {
8625+
long now = System.currentTimeMillis();
8626+
long diff = now - mLastSwapTime;
8627+
mAverageSwapFps = ((1000.0 / diff) + mAverageSwapFps) / 2;
8628+
Log.d(LOGTAG, "page swap fps: " + mAverageSwapFps);
8629+
mLastSwapTime = now;
8630+
}
86218631
mWebViewCore.resumeWebKitDraw();
86228632
if (notifyAnimationStarted) {
86238633
mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);

core/java/android/webkit/WebViewCore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ private void webkitDraw(DrawData draw) {
22712271
mFirstLayoutForNonStandardLoad = false;
22722272
}
22732273
if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw NEW_PICTURE_MSG_ID");
2274+
pauseWebKitDraw();
22742275
Message.obtain(mWebViewClassic.mPrivateHandler,
22752276
WebViewClassic.NEW_PICTURE_MSG_ID, draw).sendToTarget();
22762277
}

0 commit comments

Comments
 (0)