Merge "Set mSyncBuffer to true when VRI did not initiate the sync request" into tm-dev am: 700cdec45b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17746204

Change-Id: I4999f9a517d9ac89ae8a58aadf05e3fd95933c53
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chavi Weingarten
2022-04-14 14:32:45 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 17 deletions

View File

@@ -967,7 +967,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
final boolean redrawNeeded = sizeChanged || creating || hintChanged
|| (mVisible && !mDrawFinished);
boolean shouldSyncBuffer =
redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInSync();
redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInLocalSync();
SyncBufferTransactionCallback syncBufferTransactionCallback = null;
if (shouldSyncBuffer) {
syncBufferTransactionCallback = new SyncBufferTransactionCallback();

View File

@@ -319,6 +319,8 @@ public final class ViewRootImpl implements ViewParent,
*/
private static final int SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS = 2500;
private static final int UNSET_SYNC_ID = -1;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();
@@ -815,7 +817,7 @@ public final class ViewRootImpl implements ViewParent,
}
private final SurfaceSyncer mSurfaceSyncer = new SurfaceSyncer();
private int mLastSyncId = -1;
private int mSyncId = UNSET_SYNC_ID;
private SurfaceSyncer.SyncBufferCallback mSyncBufferCallback;
private int mNumSyncsInProgress = 0;
@@ -3463,21 +3465,21 @@ public final class ViewRootImpl implements ViewParent,
mReportNextDraw = false;
mSyncBufferCallback = null;
mSyncBuffer = false;
if (mLastSyncId != -1) {
mSurfaceSyncer.markSyncReady(mLastSyncId);
mLastSyncId = -1;
if (isInLocalSync()) {
mSurfaceSyncer.markSyncReady(mSyncId);
mSyncId = UNSET_SYNC_ID;
}
}
}
private void createSyncIfNeeded() {
// Started a sync already or there's nothing needing to sync
if (mLastSyncId != -1 || !mReportNextDraw) {
if (isInLocalSync() || !mReportNextDraw) {
return;
}
final int seqId = mSyncSeqId;
mLastSyncId = mSurfaceSyncer.setupSync(transaction -> {
mSyncId = mSurfaceSyncer.setupSync(transaction -> {
// Callback will be invoked on executor thread so post to main thread.
mHandler.postAtFrontOfQueue(() -> {
mSurfaceChangedTransaction.merge(transaction);
@@ -3485,9 +3487,9 @@ public final class ViewRootImpl implements ViewParent,
});
});
if (DEBUG_BLAST) {
Log.d(mTag, "Setup new sync id=" + mLastSyncId);
Log.d(mTag, "Setup new sync id=" + mSyncId);
}
mSurfaceSyncer.addToSync(mLastSyncId, mSyncTarget);
mSurfaceSyncer.addToSync(mSyncId, mSyncTarget);
}
private void notifyContentCatpureEvents() {
@@ -4123,17 +4125,19 @@ public final class ViewRootImpl implements ViewParent,
return mAttachInfo.mThreadedRenderer != null && mAttachInfo.mThreadedRenderer.isEnabled();
}
boolean addToSync(SurfaceSyncer.SyncTarget syncable) {
if (mLastSyncId == -1) {
return false;
void addToSync(SurfaceSyncer.SyncTarget syncable) {
if (!isInLocalSync()) {
return;
}
mSurfaceSyncer.addToSync(mLastSyncId, syncable);
return true;
mSurfaceSyncer.addToSync(mSyncId, syncable);
}
public boolean isInSync() {
return mLastSyncId != -1;
/**
* This VRI is currently in the middle of a sync request, but specifically one initiated from
* within VRI.
*/
public boolean isInLocalSync() {
return mSyncId != UNSET_SYNC_ID;
}
private void addFrameCommitCallbackIfNeeded() {
@@ -10895,6 +10899,10 @@ public final class ViewRootImpl implements ViewParent,
private void readyToSync(SurfaceSyncer.SyncBufferCallback syncBufferCallback) {
mNumSyncsInProgress++;
if (!isInLocalSync()) {
// Always sync the buffer if the sync request did not come from VRI.
mSyncBuffer = true;
}
if (mAttachInfo.mThreadedRenderer != null) {
HardwareRenderer.setRtAnimationsEnabled(false);
}