Loading graphics/java/android/graphics/drawable/GradientDrawable.java +19 −19 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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: Loading Loading @@ -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])) { Loading @@ -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; Loading Loading @@ -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> Loading Loading
graphics/java/android/graphics/drawable/GradientDrawable.java +19 −19 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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: Loading Loading @@ -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])) { Loading @@ -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; Loading Loading @@ -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> Loading