summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-06-19 16:15:53 -0700
committerAlan Viverette <alanv@google.com>2014-06-19 16:15:53 -0700
commit07c661e677b354c2298a2b81f19fd24e5ab1b0e0 (patch)
tree94f4d02e1748586e0a0c026908a351183f4bee05 /graphics
parent8bf102b1d2f044d8430c50be23776eab2e2e1c08 (diff)
downloadframeworks_base-07c661e677b354c2298a2b81f19fd24e5ab1b0e0.zip
frameworks_base-07c661e677b354c2298a2b81f19fd24e5ab1b0e0.tar.gz
frameworks_base-07c661e677b354c2298a2b81f19fd24e5ab1b0e0.tar.bz2
Put dither in GradientDrawable constant state
Previously the dither attribute would be dropped when cloning a gradient drawable from constant state. Also fixes ShapeDrawable theme extraction. BUG: 15754194 Change-Id: I3071f5b8236cfa6acb549627a3dfac0618518dbf
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/GradientDrawable.java18
-rw-r--r--graphics/java/android/graphics/drawable/ShapeDrawable.java3
2 files changed, 13 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 005b8ef..28cd869 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -135,7 +135,6 @@ public class GradientDrawable extends Drawable {
private Paint mStrokePaint; // optional, set by the caller
private ColorFilter mColorFilter; // optional, set by the caller
private int mAlpha = 0xFF; // modified by the caller
- private boolean mDither;
private final Path mPath = new Path();
private final RectF mRect = new RectF();
@@ -543,7 +542,7 @@ public class GradientDrawable extends Drawable {
if (mLayerPaint == null) {
mLayerPaint = new Paint();
}
- mLayerPaint.setDither(mDither);
+ mLayerPaint.setDither(st.mDither);
mLayerPaint.setAlpha(mAlpha);
mLayerPaint.setColorFilter(mColorFilter);
@@ -561,14 +560,14 @@ public class GradientDrawable extends Drawable {
individual paints
*/
mFillPaint.setAlpha(currFillAlpha);
- mFillPaint.setDither(mDither);
+ mFillPaint.setDither(st.mDither);
mFillPaint.setColorFilter(mColorFilter);
- if (mColorFilter != null && mGradientState.mColorStateList == null) {
+ if (mColorFilter != null && st.mColorStateList == null) {
mFillPaint.setColor(mAlpha << 24);
}
if (haveStroke) {
mStrokePaint.setAlpha(currStrokeAlpha);
- mStrokePaint.setDither(mDither);
+ mStrokePaint.setDither(st.mDither);
mStrokePaint.setColorFilter(mColorFilter);
}
}
@@ -804,8 +803,8 @@ public class GradientDrawable extends Drawable {
@Override
public void setDither(boolean dither) {
- if (dither != mDither) {
- mDither = dither;
+ if (dither != mGradientState.mDither) {
+ mGradientState.mDither = dither;
invalidateSelf();
}
}
@@ -1015,7 +1014,7 @@ public class GradientDrawable extends Drawable {
state.mThemeAttrs = a.extractThemeAttrs();
state.mShape = a.getInt(R.styleable.GradientDrawable_shape, state.mShape);
- mDither = a.getBoolean(R.styleable.GradientDrawable_dither, mDither);
+ state.mDither = a.getBoolean(R.styleable.GradientDrawable_dither, state.mDither);
if (state.mShape == RING) {
state.mInnerRadius = a.getDimensionPixelSize(
@@ -1459,6 +1458,8 @@ public class GradientDrawable extends Drawable {
public float mThicknessRatio = DEFAULT_THICKNESS_RATIO;
public int mInnerRadius = -1;
public int mThickness = -1;
+ public boolean mDither = false;
+
private float mCenterX = 0.5f;
private float mCenterY = 0.5f;
private float mGradientRadius = 0.5f;
@@ -1510,6 +1511,7 @@ public class GradientDrawable extends Drawable {
mThicknessRatio = state.mThicknessRatio;
mInnerRadius = state.mInnerRadius;
mThickness = state.mThickness;
+ mDither = state.mDither;
mCenterX = state.mCenterX;
mCenterY = state.mCenterY;
mGradientRadius = state.mGradientRadius;
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java
index beb300d..369bb59 100644
--- a/graphics/java/android/graphics/drawable/ShapeDrawable.java
+++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java
@@ -416,6 +416,9 @@ public class ShapeDrawable extends Drawable {
final ShapeState state = mShapeState;
final Paint paint = state.mPaint;
+ // Extract the theme attributes, if any.
+ state.mThemeAttrs = a.extractThemeAttrs();
+
int color = paint.getColor();
color = a.getColor(R.styleable.ShapeDrawable_color, color);
paint.setColor(color);