diff options
Diffstat (limited to 'graphics/java')
-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 edc8d72..3092f96 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> |