OSDN Git Service

WM: Only update magnification bounds when they are visible
authorAdrian Roos <roosa@google.com>
Thu, 19 Apr 2018 16:49:39 +0000 (18:49 +0200)
committerAdrian Roos <roosa@google.com>
Thu, 19 Apr 2018 16:49:39 +0000 (18:49 +0200)
Fixes an issue where the magnification bounds would continuously
update whenever the bounds change, even when the magnification
overlay was not actually visible.

This caused a lot of jank when resizing the stacks in split screen.

Change-Id: Iad801b06c4cba6b972553e377692491f133be40e
Fixes: 78276993
Test: Enable magnification, enter split screen mode, drag resize handle, verify theres no jank

services/core/java/com/android/server/wm/AccessibilityController.java

index 608d0aa..68be50c 100644 (file)
@@ -811,36 +811,35 @@ final class AccessibilityController {
                             return;
                         }
                         mInvalidated = false;
-                        Canvas canvas = null;
-                        try {
-                            // Empty dirty rectangle means unspecified.
-                            if (mDirtyRect.isEmpty()) {
-                                mBounds.getBounds(mDirtyRect);
+                        if (mAlpha > 0) {
+                            Canvas canvas = null;
+                            try {
+                                // Empty dirty rectangle means unspecified.
+                                if (mDirtyRect.isEmpty()) {
+                                    mBounds.getBounds(mDirtyRect);
+                                }
+                                mDirtyRect.inset(-mHalfBorderWidth, -mHalfBorderWidth);
+                                canvas = mSurface.lockCanvas(mDirtyRect);
+                                if (DEBUG_VIEWPORT_WINDOW) {
+                                    Slog.i(LOG_TAG, "Dirty rect: " + mDirtyRect);
+                                }
+                            } catch (IllegalArgumentException iae) {
+                                /* ignore */
+                            } catch (Surface.OutOfResourcesException oore) {
+                                /* ignore */
+                            }
+                            if (canvas == null) {
+                                return;
                             }
-                            mDirtyRect.inset(- mHalfBorderWidth, - mHalfBorderWidth);
-                            canvas = mSurface.lockCanvas(mDirtyRect);
                             if (DEBUG_VIEWPORT_WINDOW) {
-                                Slog.i(LOG_TAG, "Dirty rect: " + mDirtyRect);
+                                Slog.i(LOG_TAG, "Bounds: " + mBounds);
                             }
-                        } catch (IllegalArgumentException iae) {
-                            /* ignore */
-                        } catch (Surface.OutOfResourcesException oore) {
-                            /* ignore */
-                        }
-                        if (canvas == null) {
-                            return;
-                        }
-                        if (DEBUG_VIEWPORT_WINDOW) {
-                            Slog.i(LOG_TAG, "Bounds: " + mBounds);
-                        }
-                        canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR);
-                        mPaint.setAlpha(mAlpha);
-                        Path path = mBounds.getBoundaryPath();
-                        canvas.drawPath(path, mPaint);
+                            canvas.drawColor(Color.TRANSPARENT, Mode.CLEAR);
+                            mPaint.setAlpha(mAlpha);
+                            Path path = mBounds.getBoundaryPath();
+                            canvas.drawPath(path, mPaint);
 
-                        mSurface.unlockCanvasAndPost(canvas);
-
-                        if (mAlpha > 0) {
+                            mSurface.unlockCanvasAndPost(canvas);
                             mSurfaceControl.show();
                         } else {
                             mSurfaceControl.hide();