Merge "SyncRtSurfaceTransactionApplier: Improve thread safety" into sc-dev
This commit is contained in:
@@ -54,20 +54,21 @@ public class SyncRtSurfaceTransactionApplier {
|
|||||||
/**
|
/**
|
||||||
* Schedules applying surface parameters on the next frame.
|
* Schedules applying surface parameters on the next frame.
|
||||||
*
|
*
|
||||||
* @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
|
* @param params The surface parameters to apply.
|
||||||
* this method to avoid synchronization issues.
|
|
||||||
*/
|
*/
|
||||||
public void scheduleApply(final SurfaceParams... params) {
|
public void scheduleApply(final SurfaceParams... params) {
|
||||||
if (mTargetViewRootImpl == null) {
|
if (mTargetViewRootImpl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mTargetSc = mTargetViewRootImpl.getSurfaceControl();
|
mTargetSc = mTargetViewRootImpl.getSurfaceControl();
|
||||||
|
final Transaction t = new Transaction();
|
||||||
|
applyParams(t, params);
|
||||||
|
|
||||||
mTargetViewRootImpl.registerRtFrameCallback(frame -> {
|
mTargetViewRootImpl.registerRtFrameCallback(frame -> {
|
||||||
if (mTargetSc == null || !mTargetSc.isValid()) {
|
if (mTargetSc == null || !mTargetSc.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Transaction t = new Transaction();
|
applyTransaction(t, frame);
|
||||||
applyParams(t, frame, params);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure a frame gets scheduled.
|
// Make sure a frame gets scheduled.
|
||||||
@@ -78,15 +79,17 @@ public class SyncRtSurfaceTransactionApplier {
|
|||||||
* Applies surface parameters on the next frame.
|
* Applies surface parameters on the next frame.
|
||||||
* @param t transaction to apply all parameters in.
|
* @param t transaction to apply all parameters in.
|
||||||
* @param frame frame to synchronize to. Set -1 when sync is not required.
|
* @param frame frame to synchronize to. Set -1 when sync is not required.
|
||||||
* @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
|
* @param params The surface parameters to apply.
|
||||||
* this method to avoid synchronization issues.
|
|
||||||
*/
|
*/
|
||||||
void applyParams(Transaction t, long frame, final SurfaceParams... params) {
|
void applyParams(Transaction t, final SurfaceParams... params) {
|
||||||
for (int i = params.length - 1; i >= 0; i--) {
|
for (int i = params.length - 1; i >= 0; i--) {
|
||||||
SurfaceParams surfaceParams = params[i];
|
SurfaceParams surfaceParams = params[i];
|
||||||
SurfaceControl surface = surfaceParams.surface;
|
SurfaceControl surface = surfaceParams.surface;
|
||||||
applyParams(t, surfaceParams, mTmpFloat9);
|
applyParams(t, surfaceParams, mTmpFloat9);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyTransaction(Transaction t, long frame) {
|
||||||
if (mTargetViewRootImpl != null) {
|
if (mTargetViewRootImpl != null) {
|
||||||
mTargetViewRootImpl.mergeWithNextTransaction(t, frame);
|
mTargetViewRootImpl.mergeWithNextTransaction(t, frame);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -127,7 +127,9 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host {
|
|||||||
// Window doesn't support hardware acceleration, no synchronization for now.
|
// Window doesn't support hardware acceleration, no synchronization for now.
|
||||||
// TODO(b/149342281): use mViewRoot.mSurface.getNextFrameNumber() to sync on every
|
// TODO(b/149342281): use mViewRoot.mSurface.getNextFrameNumber() to sync on every
|
||||||
// frame instead.
|
// frame instead.
|
||||||
mApplier.applyParams(new SurfaceControl.Transaction(), -1 /* frame */, params);
|
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||||
|
mApplier.applyParams(t, params);
|
||||||
|
mApplier.applyTransaction(t, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user