summaryrefslogtreecommitdiff
path: root/core/java/android/widget/Magnifier.java
diff options
context:
space:
mode:
authorVishnu Nair <vishnun@google.com>2021-04-26 10:27:50 -0700
committerVishnu Nair <vishnun@google.com>2021-04-26 10:27:50 -0700
commitf752c800d35afcf9c25e27071c15e50266a3f00a (patch)
tree62f9aedefb71331275b7b60bf4301a94f5e3a9ed /core/java/android/widget/Magnifier.java
parent692496d964491e16dea0b01004f11653eecd0b98 (diff)
Fix Magnifier position updates
When the magnifier content moves relative to the parent surface, it will call setPosition on the content surface control. This conflicts with position updates called by the BlastBufferQueue adapter causing a flicker on screen. Fix this by providing a wrapper surface to BlastBufferQueue adapater to send buffer updates. Fixes: 186072574 Test: Select text and see magnifier surface does not flicker or move around Change-Id: Idfcc06a5d90f400f69e5cbe91008a0cb59fd4646
Diffstat (limited to 'core/java/android/widget/Magnifier.java')
-rw-r--r--core/java/android/widget/Magnifier.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java
index 18dd7995ae87..33890b80869d 100644
--- a/core/java/android/widget/Magnifier.java
+++ b/core/java/android/widget/Magnifier.java
@@ -939,6 +939,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 mBbqSurfaceControl;
private final BLASTBufferQueue mBBQ;
private final SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction();
private final Surface mSurface;
@@ -1008,11 +1009,19 @@ public final class Magnifier {
mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
.setName("magnifier surface")
.setFlags(SurfaceControl.HIDDEN)
- .setBLASTLayer()
+ .setContainerLayer()
.setParent(parentSurfaceControl)
.setCallsite("InternalPopupWindow")
.build();
- mBBQ = new BLASTBufferQueue("magnifier surface", mSurfaceControl,
+ mBbqSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
+ .setName("magnifier surface bbq wrapper")
+ .setHidden(false)
+ .setBLASTLayer()
+ .setParent(mSurfaceControl)
+ .setCallsite("InternalPopupWindow")
+ .build();
+
+ mBBQ = new BLASTBufferQueue("magnifier surface", mBbqSurfaceControl,
surfaceWidth, surfaceHeight, PixelFormat.TRANSLUCENT);
mSurface = mBBQ.createSurface();
@@ -1073,7 +1082,7 @@ public final class Magnifier {
}
if (mContentHeight < contentHeight) {
// Grows the surface height as necessary.
- mBBQ.update(mSurfaceControl, mContentWidth, contentHeight,
+ mBBQ.update(mBbqSurfaceControl, mContentWidth, contentHeight,
PixelFormat.TRANSLUCENT);
mRenderer.setSurface(mSurface);
@@ -1270,7 +1279,10 @@ public final class Magnifier {
mRenderer.destroy();
mSurface.destroy();
mBBQ.destroy();
- new SurfaceControl.Transaction().remove(mSurfaceControl).apply();
+ new SurfaceControl.Transaction()
+ .remove(mSurfaceControl)
+ .remove(mBbqSurfaceControl)
+ .apply();
mSurfaceSession.kill();
mHandler.removeCallbacks(mMagnifierUpdater);
if (mBitmap != null) {