From 298f9278fdcdbadf83f67f277992ff8b2fda8e99 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 9 Aug 2016 13:08:01 -0700 Subject: [PATCH] Account for scaling of surfaceInset area in magnification. We don't want to scale the actual size of the surface as we were doing prior to ag/1101405 but we do need to adjust the top and left corners so that the content will be at the same position despite the inset area being scaled up. Bug: 30399709 Change-Id: I30df4d3ef593d4f2869fdf378ee9bc3469619d5d --- .../com/android/server/wm/WindowStateAnimator.java | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index e374ee91389f..c2ec8c1e4c85 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -926,6 +926,22 @@ class WindowStateAnimator { mPendingDestroySurface = null; } + void applyMagnificationSpec(MagnificationSpec spec, Matrix transform) { + final int surfaceInsetLeft = mWin.mAttrs.surfaceInsets.left; + final int surfaceInsetTop = mWin.mAttrs.surfaceInsets.top; + + if (spec != null && !spec.isNop()) { + float scale = spec.scale; + transform.postScale(scale, scale); + transform.postTranslate(spec.offsetX, spec.offsetY); + + // As we are scaling the whole surface, to keep the content + // in the same position we will also have to scale the surfaceInsets. + transform.postTranslate(-(surfaceInsetLeft*scale - surfaceInsetLeft), + -(surfaceInsetTop*scale - surfaceInsetTop)); + } + } + void computeShownFrameLocked() { final boolean selfTransformation = mHasLocalTransformation; Transformation attachedTransformation = @@ -1016,10 +1032,7 @@ class WindowStateAnimator { if (mService.mAccessibilityController != null && displayId == DEFAULT_DISPLAY) { MagnificationSpec spec = mService.mAccessibilityController .getMagnificationSpecForWindowLocked(mWin); - if (spec != null && !spec.isNop()) { - tmpMatrix.postScale(spec.scale, spec.scale); - tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); - } + applyMagnificationSpec(spec, tmpMatrix); } // "convert" it into SurfaceFlinger's format @@ -1118,10 +1131,7 @@ class WindowStateAnimator { tmpMatrix.setScale(mWin.mGlobalScale, mWin.mGlobalScale); tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset); - if (spec != null && !spec.isNop()) { - tmpMatrix.postScale(spec.scale, spec.scale); - tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); - } + applyMagnificationSpec(spec, tmpMatrix); tmpMatrix.getValues(tmpFloats); -- 2.11.0