Skip to content

Commit d0051c0

Browse files
committed
Send animation start notification back to webkit from ui thread
bug:5239801 depends on external/webkit CL: https://android-git.corp.google.com/g/#/c/152559/ Change-Id: I647b5a82680f570c918227dbf57521b862dcfe25
1 parent 9b518d9 commit d0051c0

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

core/java/android/webkit/WebView.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,14 +4604,15 @@ private void drawCoreAndCursorRing(Canvas canvas, int color,
46044604
boolean UIAnimationsRunning = false;
46054605
// Currently for each draw we compute the animation values;
46064606
// We may in the future decide to do that independently.
4607-
if (mNativeClass != 0 && nativeEvaluateLayersAnimations(mNativeClass)) {
4607+
if (mNativeClass != 0 && !canvas.isHardwareAccelerated()
4608+
&& nativeEvaluateLayersAnimations(mNativeClass)) {
46084609
UIAnimationsRunning = true;
46094610
// If we have unfinished (or unstarted) animations,
46104611
// we ask for a repaint. We only need to do this in software
46114612
// rendering (with hardware rendering we already have a different
46124613
// method of requesting a repaint)
4613-
if (!canvas.isHardwareAccelerated())
4614-
invalidate();
4614+
mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
4615+
invalidate();
46154616
}
46164617

46174618
// decide which adornments to draw
@@ -8796,10 +8797,13 @@ private void setTouchHighlightRects(ArrayList<Rect> rects) {
87968797

87978798
/** @hide Called by JNI when pages are swapped (only occurs with hardware
87988799
* acceleration) */
8799-
protected void pageSwapCallback() {
8800+
protected void pageSwapCallback(boolean notifyAnimationStarted) {
88008801
if (inEditingMode()) {
88018802
didUpdateWebTextViewDimensions(ANYWHERE);
88028803
}
8804+
if (notifyAnimationStarted) {
8805+
mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
8806+
}
88038807
}
88048808

88058809
void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {

core/java/android/webkit/WebViewCore.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,12 @@ protected void enterFullscreenForVideoLayer(int layerId, String url) {
519519
/**
520520
* Update the layers' content
521521
*/
522-
private native boolean nativeUpdateLayers(int baseLayer);
522+
private native boolean nativeUpdateLayers(int nativeClass, int baseLayer);
523+
524+
/**
525+
* Notify webkit that animations have begun (on the hardware accelerated content)
526+
*/
527+
private native void nativeNotifyAnimationStarted(int nativeClass);
523528

524529
private native boolean nativeFocusBoundsChanged();
525530

@@ -1035,6 +1040,8 @@ public class EventHub {
10351040

10361041
static final int PLUGIN_SURFACE_READY = 195;
10371042

1043+
static final int NOTIFY_ANIMATION_STARTED = 196;
1044+
10381045
// private message ids
10391046
private static final int DESTROY = 200;
10401047

@@ -1594,6 +1601,10 @@ public void handleMessage(Message msg) {
15941601
nativePluginSurfaceReady();
15951602
break;
15961603

1604+
case NOTIFY_ANIMATION_STARTED:
1605+
nativeNotifyAnimationStarted(mNativeClass);
1606+
break;
1607+
15971608
case ADD_PACKAGE_NAMES:
15981609
if (BrowserFrame.sJavaBridge == null) {
15991610
throw new IllegalStateException("No WebView " +
@@ -2015,7 +2026,7 @@ private void webkitDrawLayers() {
20152026
return;
20162027
}
20172028
// Directly update the layers we last passed to the UI side
2018-
if (nativeUpdateLayers(mLastDrawData.mBaseLayer)) {
2029+
if (nativeUpdateLayers(mNativeClass, mLastDrawData.mBaseLayer)) {
20192030
// If anything more complex than position has been touched, let's do a full draw
20202031
webkitDraw();
20212032
}

tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public void onFinish() {
110110
* been redrawn.
111111
*/
112112
@Override
113-
protected void pageSwapCallback() {
113+
protected void pageSwapCallback(boolean startAnim) {
114114
mContentInvalMillis = System.currentTimeMillis() - mContentInvalMillis;
115-
super.pageSwapCallback();
115+
super.pageSwapCallback(startAnim);
116116
Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis
117117
+ "millis");
118118
mIsTesting = true;

0 commit comments

Comments
 (0)