summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/AccessibilityController.java64
-rw-r--r--services/core/java/com/android/server/wm/WindowAnimator.java3
2 files changed, 19 insertions, 48 deletions
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 77b4a74ab109..1577cef9de00 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -448,16 +448,16 @@ final class AccessibilityController {
}
}
- void drawMagnifiedRegionBorderIfNeeded(int displayId) {
+ void drawMagnifiedRegionBorderIfNeeded(int displayId, SurfaceControl.Transaction t) {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(
TAG + ".drawMagnifiedRegionBorderIfNeeded",
FLAGS_MAGNIFICATION_CALLBACK,
- "displayId=" + displayId);
+ "displayId=" + displayId + "; transaction={" + t + "}");
}
final DisplayMagnifier displayMagnifier = mDisplayMagnifiers.get(displayId);
if (displayMagnifier != null) {
- displayMagnifier.drawMagnifiedRegionBorderIfNeeded();
+ displayMagnifier.drawMagnifiedRegionBorderIfNeeded(t);
}
// Not relevant for the window observer.
}
@@ -855,12 +855,12 @@ final class AccessibilityController {
.sendToTarget();
}
- void drawMagnifiedRegionBorderIfNeeded() {
+ void drawMagnifiedRegionBorderIfNeeded(SurfaceControl.Transaction t) {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".drawMagnifiedRegionBorderIfNeeded",
- FLAGS_MAGNIFICATION_CALLBACK);
+ FLAGS_MAGNIFICATION_CALLBACK, "transition={" + t + "}");
}
- mMagnifedViewport.drawWindowIfNeeded();
+ mMagnifedViewport.drawWindowIfNeeded(t);
}
void dump(PrintWriter pw, String prefix) {
@@ -1106,11 +1106,11 @@ final class AccessibilityController {
}
void setMagnifiedRegionBorderShown(boolean shown, boolean animate) {
- if (mWindow.setShown(shown, animate)) {
+ if (shown) {
mFullRedrawNeeded = true;
- // Clear the old region, so recomputeBounds will refresh the current region.
mOldMagnificationRegion.set(0, 0, 0, 0);
}
+ mWindow.setShown(shown, animate);
}
void getMagnifiedFrameInContentCoords(Rect rect) {
@@ -1128,9 +1128,9 @@ final class AccessibilityController {
return mMagnificationSpec;
}
- void drawWindowIfNeeded() {
+ void drawWindowIfNeeded(SurfaceControl.Transaction t) {
recomputeBounds();
- mWindow.postDrawIfNeeded();
+ mWindow.drawIfNeeded(t);
}
void destroyWindow() {
@@ -1158,7 +1158,7 @@ final class AccessibilityController {
mWindow.dump(pw, prefix);
}
- private final class ViewportWindow implements Runnable {
+ private final class ViewportWindow {
private static final String SURFACE_TITLE = "Magnification Overlay";
private final Region mBounds = new Region();
@@ -1166,18 +1166,15 @@ final class AccessibilityController {
private final Paint mPaint = new Paint();
private final SurfaceControl mSurfaceControl;
- /** After initialization, it should only be accessed from animation thread. */
- private final SurfaceControl.Transaction mTransaction;
private final BLASTBufferQueue mBlastBufferQueue;
private final Surface mSurface;
private final AnimationController mAnimationController;
private boolean mShown;
- private boolean mLastSurfaceShown;
private int mAlpha;
- private volatile boolean mInvalidated;
+ private boolean mInvalidated;
ViewportWindow(Context context) {
SurfaceControl surfaceControl = null;
@@ -1205,7 +1202,6 @@ final class AccessibilityController {
InputMonitor.setTrustedOverlayInputInfo(mSurfaceControl, t,
mDisplayContent.getDisplayId(), "Magnification Overlay");
t.apply();
- mTransaction = t;
mSurface = mBlastBufferQueue.createSurface();
mAnimationController = new AnimationController(context,
@@ -1223,11 +1219,10 @@ final class AccessibilityController {
mInvalidated = true;
}
- /** Returns {@code true} if the shown state is changed. */
- boolean setShown(boolean shown, boolean animate) {
+ void setShown(boolean shown, boolean animate) {
synchronized (mService.mGlobalLock) {
if (mShown == shown) {
- return false;
+ return;
}
mShown = shown;
mAnimationController.onFrameShownStateChanged(shown, animate);
@@ -1235,7 +1230,6 @@ final class AccessibilityController {
Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown);
}
}
- return true;
}
@SuppressWarnings("unused")
@@ -1291,22 +1285,7 @@ final class AccessibilityController {
mService.scheduleAnimationLocked();
}
- void postDrawIfNeeded() {
- if (mInvalidated) {
- mService.mAnimationHandler.post(this);
- }
- }
-
- @Override
- public void run() {
- drawIfNeeded();
- }
-
- /**
- * This method must only be called by animation handler directly to make sure
- * thread safe and there is no lock held outside.
- */
- private void drawIfNeeded() {
+ void drawIfNeeded(SurfaceControl.Transaction t) {
// Drawing variables (alpha, dirty rect, and bounds) access is synchronized
// using WindowManagerGlobalLock. Grab copies of these values before
// drawing on the canvas so that drawing can be performed outside of the lock.
@@ -1335,7 +1314,6 @@ final class AccessibilityController {
}
}
- final boolean showSurface;
// Draw without holding WindowManagerGlobalLock.
if (alpha > 0) {
Canvas canvas = null;
@@ -1351,17 +1329,9 @@ final class AccessibilityController {
mPaint.setAlpha(alpha);
canvas.drawPath(drawingBounds.getBoundaryPath(), mPaint);
mSurface.unlockCanvasAndPost(canvas);
- showSurface = true;
+ t.show(mSurfaceControl);
} else {
- showSurface = false;
- }
-
- if (showSurface && !mLastSurfaceShown) {
- mTransaction.show(mSurfaceControl).apply();
- mLastSurfaceShown = true;
- } else if (!showSurface && mLastSurfaceShown) {
- mTransaction.hide(mSurfaceControl).apply();
- mLastSurfaceShown = false;
+ t.hide(mSurfaceControl);
}
}
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index c4e1d6e51e70..750fd509e50f 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -148,7 +148,8 @@ public class WindowAnimator {
dc.checkAppWindowsReadyToShow();
if (accessibilityController.hasCallbacks()) {
- accessibilityController.drawMagnifiedRegionBorderIfNeeded(dc.mDisplayId);
+ accessibilityController.drawMagnifiedRegionBorderIfNeeded(dc.mDisplayId,
+ mTransaction);
}
if (dc.isAnimating(animationFlags, ANIMATION_TYPE_ALL)) {