diff options
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 0df8a0bded48..9a25be804002 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -816,12 +816,7 @@ public final class ViewRootImpl implements ViewParent, private final SurfaceSyncer mSurfaceSyncer = new SurfaceSyncer(); private int mLastSyncId = -1; private SurfaceSyncer.SyncBufferCallback mSyncBufferCallback; - - /** - * Keeps track of the last frame number that was attempted to draw. Should only be accessed on - * the RenderThread. - */ - private long mRtLastAttemptedDrawFrameNum = 0; + private int mNumSyncsInProgress = 0; private HashSet<ScrollCaptureCallback> mRootScrollCaptureCallbacks; @@ -4249,7 +4244,7 @@ public final class ViewRootImpl implements ViewParent, mHasPendingTransactions = false; try { - boolean canUseAsync = draw(fullRedrawNeeded); + boolean canUseAsync = draw(fullRedrawNeeded, usingAsyncReport && mSyncBuffer); if (usingAsyncReport && !canUseAsync) { mAttachInfo.mThreadedRenderer.setFrameCallback(null); usingAsyncReport = false; @@ -4409,7 +4404,7 @@ public final class ViewRootImpl implements ViewParent, } } - private boolean draw(boolean fullRedrawNeeded) { + private boolean draw(boolean fullRedrawNeeded, boolean forceDraw) { Surface surface = mSurface; if (!surface.isValid()) { return false; @@ -4546,6 +4541,9 @@ public final class ViewRootImpl implements ViewParent, useAsyncReport = true; + if (forceDraw) { + mAttachInfo.mThreadedRenderer.forceDrawNextFrame(); + } mAttachInfo.mThreadedRenderer.draw(mView, mAttachInfo, this); } else { // If we get here with a disabled & requested hardware renderer, something went @@ -10864,9 +10862,28 @@ public final class ViewRootImpl implements ViewParent, }); } - public final SurfaceSyncer.SyncTarget mSyncTarget = this::readyToSync; + public final SurfaceSyncer.SyncTarget mSyncTarget = new SurfaceSyncer.SyncTarget() { + @Override + public void onReadyToSync(SurfaceSyncer.SyncBufferCallback syncBufferCallback) { + readyToSync(syncBufferCallback); + } + + @Override + public void onSyncComplete() { + mHandler.postAtFrontOfQueue(() -> { + if (--mNumSyncsInProgress == 0 && mAttachInfo.mThreadedRenderer != null) { + HardwareRenderer.setRtAnimationsEnabled(true); + } + }); + } + }; private void readyToSync(SurfaceSyncer.SyncBufferCallback syncBufferCallback) { + mNumSyncsInProgress++; + if (mAttachInfo.mThreadedRenderer != null) { + HardwareRenderer.setRtAnimationsEnabled(false); + } + if (mSyncBufferCallback != null) { Log.d(mTag, "Already set sync for the next draw."); mSyncBufferCallback.onBufferReady(null); |
