diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-10-30 17:25:37 -0400 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-10-30 17:25:37 -0400 |
commit | 46c77c203439b3b37c99d09e326df4b1fe08c10b (patch) | |
tree | 70d29abbfbb1106cd0830b33bc7e69e6fb151b1e /android/view/RectShadowPainter.java | |
parent | 47ed54e5d312f899507d28d6e95ccc18a0de19fe (diff) | |
download | android-28-46c77c203439b3b37c99d09e326df4b1fe08c10b.tar.gz |
Import Android SDK Platform P [4423826]
/google/data/ro/projects/android/fetch_artifact \
--bid 4423826 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4423826.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: I45f7bdc9b9c1cdcba75386623ae5f3ead6db4da8
Diffstat (limited to 'android/view/RectShadowPainter.java')
-rw-r--r-- | android/view/RectShadowPainter.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/android/view/RectShadowPainter.java b/android/view/RectShadowPainter.java index 5665d4f3..88771a76 100644 --- a/android/view/RectShadowPainter.java +++ b/android/view/RectShadowPainter.java @@ -19,8 +19,10 @@ package android.view; import com.android.layoutlib.bridge.impl.GcSnapshot; import com.android.layoutlib.bridge.impl.ResourceHelper; +import android.graphics.BaseCanvas_Delegate; import android.graphics.Canvas; import android.graphics.Canvas_Delegate; +import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Outline; import android.graphics.Paint; @@ -46,7 +48,8 @@ public class RectShadowPainter { private static final int END_COLOR = ResourceHelper.getColor("#03000000"); private static final float PERPENDICULAR_ANGLE = 90f; - public static void paintShadow(Outline viewOutline, float elevation, Canvas canvas) { + public static void paintShadow(Outline viewOutline, float elevation, Canvas canvas, + float alpha) { Rect outline = new Rect(); if (!viewOutline.getRect(outline)) { assert false : "Outline is not a rect shadow"; @@ -74,9 +77,16 @@ public class RectShadowPainter { edgePaint.setAntiAlias(false); float outerArcRadius = radius + shadowSize; int[] colors = {START_COLOR, START_COLOR, END_COLOR}; + if (alpha != 1f) { + // Correct colors using the given component alpha + for (int i = 0; i < colors.length; i++) { + colors[i] = Color.argb((int) (Color.alpha(colors[i]) * alpha), Color.red(colors[i]), + Color.green(colors[i]), Color.blue(colors[i])); + } + } cornerPaint.setShader(new RadialGradient(0, 0, outerArcRadius, colors, new float[]{0f, radius / outerArcRadius, 1f}, TileMode.CLAMP)); - edgePaint.setShader(new LinearGradient(0, 0, -shadowSize, 0, START_COLOR, END_COLOR, + edgePaint.setShader(new LinearGradient(0, 0, -shadowSize, 0, colors[0], colors[2], TileMode.CLAMP)); Path path = new Path(); path.setFillType(FillType.EVEN_ODD); @@ -184,7 +194,8 @@ public class RectShadowPainter { /** * Differs from {@link RectF#isEmpty()} as this first converts the rect to int and then checks. * <p/> - * This is required because {@link Canvas_Delegate#native_drawRect(long, float, float, float, + * This is required because {@link BaseCanvas_Delegate#native_drawRect(long, float, float, + * float, * float, long)} casts the co-ordinates to int and we want to ensure that it doesn't end up * drawing empty rectangles, which results in IllegalArgumentException. */ |