From bd391f9aa13877ebf3b6fd69f19fac058bbdd9fd Mon Sep 17 00:00:00 2001 From: Mihai Popa Date: Tue, 8 Jan 2019 20:07:01 +0000 Subject: [PATCH] [Magnifier-71] Adapt surface buffer to elevation The surface created for the magnifier is larger than the magnifier content, in order to leave space for drawing the shadow. In I066082fb17cfb8c483c49b7011abfa9dca9de77a we made the elevation a customizable property of Magnifier using the Builder class. However, the buffer allocated for drawing the shadow remained a fixed value, insufficient for large elevations, when shadows were getting clipped. This CL fixes this, by making the allocated surface large enough to accomodate the shadow. Bug: none Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest Change-Id: I462c50510820614dc033a42b347e9672ce39a4c6 --- core/java/android/widget/Magnifier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java index 5c2871e1e205c..51aacf99c1f2b 100644 --- a/core/java/android/widget/Magnifier.java +++ b/core/java/android/widget/Magnifier.java @@ -831,8 +831,8 @@ public final class Magnifier { mContentWidth = width; mContentHeight = height; - mOffsetX = (int) (0.1f * width); - mOffsetY = (int) (0.1f * height); + mOffsetX = (int) (1.05f * elevation); + mOffsetY = (int) (1.05f * elevation); // Setup the surface we will use for drawing the content and shadow. mSurfaceWidth = mContentWidth + 2 * mOffsetX; mSurfaceHeight = mContentHeight + 2 * mOffsetY;