From 69364f5b5ee49182db3f47f7473858412bc8c8fc Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Thu, 19 Apr 2018 18:49:39 +0200 Subject: [PATCH] WM: Only update magnification bounds when they are visible 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 --- .../android/server/wm/AccessibilityController.java | 51 +++++++++++----------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 608d0aa5875f..68be50c2689a 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -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(); -- 2.11.0