diff options
author | 2020-03-09 20:53:47 +0000 | |
---|---|---|
committer | 2020-03-09 20:53:47 +0000 | |
commit | 672e0e80ba0f33286d75f98fe4ffae45f5671a66 (patch) | |
tree | b3be980da93dd7d6bfcaeaea7700d6116b27709b | |
parent | 1667d235ea0251acd6d86f1f488ee6fe000ba740 (diff) | |
parent | 521e363a0ff5b90bec8f1fb6d5e10156af713a76 (diff) |
Merge "InsetController: Release leashes from RenderThread" into rvc-dev
-rw-r--r-- | core/java/android/view/InsetsController.java | 19 | ||||
-rw-r--r-- | core/java/android/view/InsetsSourceConsumer.java | 2 | ||||
-rw-r--r-- | core/java/android/view/InsetsSourceControl.java | 4 |
3 files changed, 22 insertions, 3 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index 573d8fc65c84..f52960c5c3e0 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -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(); + } + } } diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index f07f1ce186fe..252fc0c82cf7 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -117,7 +117,7 @@ public class InsetsSourceConsumer { } } if (lastControl != null) { - lastControl.release(); + lastControl.release(mController); } } diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java index 29ba56a5fbb9..75f6eab798ce 100644 --- a/core/java/android/view/InsetsSourceControl.java +++ b/core/java/android/view/InsetsSourceControl.java @@ -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); } } |