Loading services/core/java/com/android/server/wm/AccessibilityController.java +17 −47 Original line number Diff line number Diff line Loading @@ -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. } Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -1128,9 +1128,9 @@ final class AccessibilityController { return mMagnificationSpec; } void drawWindowIfNeeded() { void drawWindowIfNeeded(SurfaceControl.Transaction t) { recomputeBounds(); mWindow.postDrawIfNeeded(); mWindow.drawIfNeeded(t); } void destroyWindow() { Loading Loading @@ -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(); Loading @@ -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; Loading Loading @@ -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, Loading @@ -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); Loading @@ -1235,7 +1230,6 @@ final class AccessibilityController { Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown); } } return true; } @SuppressWarnings("unused") Loading Loading @@ -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. Loading Loading @@ -1335,7 +1314,6 @@ final class AccessibilityController { } } final boolean showSurface; // Draw without holding WindowManagerGlobalLock. if (alpha > 0) { Canvas canvas = null; Loading @@ -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); } } Loading services/core/java/com/android/server/wm/WindowAnimator.java +2 −1 Original line number Diff line number Diff line Loading @@ -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)) { Loading Loading
services/core/java/com/android/server/wm/AccessibilityController.java +17 −47 Original line number Diff line number Diff line Loading @@ -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. } Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -1128,9 +1128,9 @@ final class AccessibilityController { return mMagnificationSpec; } void drawWindowIfNeeded() { void drawWindowIfNeeded(SurfaceControl.Transaction t) { recomputeBounds(); mWindow.postDrawIfNeeded(); mWindow.drawIfNeeded(t); } void destroyWindow() { Loading Loading @@ -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(); Loading @@ -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; Loading Loading @@ -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, Loading @@ -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); Loading @@ -1235,7 +1230,6 @@ final class AccessibilityController { Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown); } } return true; } @SuppressWarnings("unused") Loading Loading @@ -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. Loading Loading @@ -1335,7 +1314,6 @@ final class AccessibilityController { } } final boolean showSurface; // Draw without holding WindowManagerGlobalLock. if (alpha > 0) { Canvas canvas = null; Loading @@ -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); } } Loading
services/core/java/com/android/server/wm/WindowAnimator.java +2 −1 Original line number Diff line number Diff line Loading @@ -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)) { Loading