Merge "InsetController: Release leashes from RenderThread" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-09 20:53:47 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 3 deletions

View File

@@ -992,4 +992,23 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
return mViewRoot.mWindowAttributes.insetsFlags.behavior;
}
/**
* At the time we receive new leashes (e.g. InsetsSourceConsumer is processing
* setControl) we need to release the old leash. But we may have already scheduled
* a SyncRtSurfaceTransaction applier to use it from the RenderThread. To avoid
* synchronization issues we also release from the RenderThread so this release
* happens after any existing items on the work queue.
*/
public void releaseSurfaceControlFromRt(SurfaceControl sc) {
if (mViewRoot.mView != null && mViewRoot.mView.isHardwareAccelerated()) {
mViewRoot.registerRtFrameCallback(frame -> {
sc.release();
});
// Make sure a frame gets scheduled.
mViewRoot.mView.invalidate();
} else {
sc.release();
}
}
}

View File

@@ -117,7 +117,7 @@ public class InsetsSourceConsumer {
}
}
if (lastControl != null) {
lastControl.release();
lastControl.release(mController);
}
}

View File

@@ -94,9 +94,9 @@ public class InsetsSourceControl implements Parcelable {
dest.writeParcelable(mSurfacePosition, 0 /* flags*/);
}
public void release() {
public void release(InsetsController controller) {
if (mLeash != null) {
mLeash.release();
controller.releaseSurfaceControlFromRt(mLeash);
}
}