diff options
| author | Robert Carr <racarr@google.com> | 2019-08-26 16:20:55 -0700 |
|---|---|---|
| committer | Robert Carr <racarr@google.com> | 2019-08-27 13:25:51 -0700 |
| commit | 64660bedad0dad36fa9ca9c1544701383c1f5f32 (patch) | |
| tree | 589e36dee27b8e53561efd9d9a170f600507a867 /core/java/android/widget/Magnifier.java | |
| parent | aaf6ce298da522f032b44ff3c963cfbfcc217cfb (diff) | |
Avoid global transaction in magnifier
It's not good to use the global transaction from the render thread
like this as the UI thread could also be using it from SurfaceView. Transaction
objects require external synchronization so we could be corrupting them.
Bug: 140070297
Test: Builds
Change-Id: I17b4c1417d45cc825fca380350c326ed6b3edcf6
Diffstat (limited to 'core/java/android/widget/Magnifier.java')
| -rw-r--r-- | core/java/android/widget/Magnifier.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java index d3c69725b45b..f58b6d192fde 100644 --- a/core/java/android/widget/Magnifier.java +++ b/core/java/android/widget/Magnifier.java @@ -800,6 +800,7 @@ public final class Magnifier { // The surface we allocate for the magnifier content + shadow. private final SurfaceSession mSurfaceSession; private final SurfaceControl mSurfaceControl; + private final SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction(); private final Surface mSurface; // The renderer used for the allocated surface. private final ThreadedRenderer.SimpleRenderer mRenderer; @@ -1081,16 +1082,16 @@ public final class Magnifier { return; } // Show or move the window at the content draw frame. - SurfaceControl.openTransaction(); - mSurfaceControl.deferTransactionUntil(mSurface, frame); + mTransaction.deferTransactionUntilSurface(mSurfaceControl, mSurface, frame); if (updateWindowPosition) { - mSurfaceControl.setPosition(pendingX, pendingY); + mTransaction.setPosition(mSurfaceControl, pendingX, pendingY); } if (firstDraw) { - mSurfaceControl.setLayer(SURFACE_Z); - mSurfaceControl.show(); + mTransaction.setLayer(mSurfaceControl, SURFACE_Z) + .show(mSurfaceControl); + } - SurfaceControl.closeTransaction(); + mTransaction.apply(); }; mRenderer.setLightCenter(mDisplay, pendingX, pendingY); } else { |
