diff options
author | Alan Viverette <alanv@google.com> | 2014-09-12 23:14:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-12 23:14:33 +0000 |
commit | 6d325763120d2123633e358b34c3975545e81fe0 (patch) | |
tree | 8102edd5d7aad7ddc1f334d554cb0daf3be2f7d2 /graphics | |
parent | 6225dd239f6dcffb49bd1e1f33fdbb00623f378a (diff) | |
parent | 888b4cf73c9663be37c4faa1249cef1a6a8f8c38 (diff) | |
download | frameworks_base-6d325763120d2123633e358b34c3975545e81fe0.zip frameworks_base-6d325763120d2123633e358b34c3975545e81fe0.tar.gz frameworks_base-6d325763120d2123633e358b34c3975545e81fe0.tar.bz2 |
Merge "Report button opacity for current state, fix button shadows" into lmp-dev
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/GradientDrawable.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 2916d6c..cd6297b 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -825,7 +825,7 @@ public class GradientDrawable extends Drawable { @Override public int getOpacity() { - return (mAlpha == 255 && mGradientState.mOpaqueOverBounds) ? + return (mAlpha == 255 && mGradientState.mOpaqueOverBounds && isOpaqueForState()) ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT; } @@ -1414,12 +1414,25 @@ public class GradientDrawable extends Drawable { return mGradientState; } + private boolean isOpaqueForState() { + if (mGradientState.mStrokeWidth >= 0 && mStrokePaint != null + && !isOpaque(mStrokePaint.getColor())) { + return false; + } + + if (!isOpaque(mFillPaint.getColor())) { + return false; + } + + return true; + } + @Override public void getOutline(Outline outline) { final GradientState st = mGradientState; final Rect bounds = getBounds(); // only report non-zero alpha if shape being drawn is opaque - outline.setAlpha(st.mOpaqueOverShape ? (mAlpha / 255.0f) : 0.0f); + outline.setAlpha(st.mOpaqueOverShape && isOpaqueForState() ? (mAlpha / 255.0f) : 0.0f); switch (st.mShape) { case RECTANGLE: @@ -1617,19 +1630,6 @@ public class GradientDrawable extends Drawable { mOpaqueOverBounds = false; mOpaqueOverShape = false; - // First test opacity of all colors - if (mStrokeWidth > 0) { - if (mStrokeColorStateList != null) { - if (!mStrokeColorStateList.isOpaque()) { - return; - } - } - } - - if (mColorStateList != null && !mColorStateList.isOpaque()) { - return; - } - if (mColors != null) { for (int i = 0; i < mColors.length; i++) { if (!isOpaque(mColors[i])) { @@ -1651,10 +1651,6 @@ public class GradientDrawable extends Drawable { && mRadiusArray == null; } - private static boolean isOpaque(int color) { - return ((color >> 24) & 0xff) == 0xff; - } - public void setStroke( int width, ColorStateList colorStateList, float dashWidth, float dashGap) { mStrokeWidth = width; @@ -1690,6 +1686,10 @@ public class GradientDrawable extends Drawable { } } + static boolean isOpaque(int color) { + return ((color >> 24) & 0xff) == 0xff; + } + /** * Creates a new themed GradientDrawable based on the specified constant state. * <p> |