diff options
author | Alan Viverette <alanv@google.com> | 2015-01-06 11:01:36 -0800 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2015-01-06 11:01:36 -0800 |
commit | f4c068b72e2dee2e6944488ef00b64c93217d7e8 (patch) | |
tree | d788d4c6de77ab1e30696a97dbd0675777c57a19 /graphics | |
parent | 304ea5aac77cae03b4e8440a7c73c18086d96a20 (diff) | |
download | frameworks_base-f4c068b72e2dee2e6944488ef00b64c93217d7e8.zip frameworks_base-f4c068b72e2dee2e6944488ef00b64c93217d7e8.tar.gz frameworks_base-f4c068b72e2dee2e6944488ef00b64c93217d7e8.tar.bz2 |
Add getDither, getFilterBitmap to Drawable for CTS testing
Also removes unnecessary overrides from PictureDrawable.
Change-Id: I13539b5204e8c0d8b9912da14de7ceae62720e3f
Diffstat (limited to 'graphics')
8 files changed, 53 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index f2b635a..945ae2e 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -357,6 +357,11 @@ public class BitmapDrawable extends Drawable { invalidateSelf(); } + @Override + public boolean getDither() { + return mBitmapState.mPaint.isDither(); + } + /** * Indicates the repeat behavior of this drawable on the X axis. * diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index 0e38cc0..fa269e0 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -274,6 +274,14 @@ public abstract class Drawable { public void setDither(boolean dither) {} /** + * @return whether this drawable dither its colors + * @see #setDither(boolean) + */ + public boolean getDither() { + return false; + } + + /** * Set to true to have the drawable filter its bitmap when scaled or rotated * (for drawables that use bitmaps). If the drawable does not use bitmaps, * this call is ignored. This can improve the look when scaled or rotated, @@ -282,6 +290,14 @@ public abstract class Drawable { public void setFilterBitmap(boolean filter) {} /** + * @return whether this drawable filters its bitmap + * @see #setFilterBitmap(boolean) + */ + public boolean getFilterBitmap() { + return false; + } + + /** * Implement this interface if you want to create an animated drawable that * extends {@link android.graphics.drawable.Drawable Drawable}. * Upon retrieving a drawable, use diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 39ef10c..557f563 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -167,6 +167,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override + public boolean getDither() { + return mDrawableContainerState.mDither; + } + + @Override public void setColorFilter(ColorFilter cf) { mDrawableContainerState.mHasColorFilter = (cf != null); diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 7882705..cc2de22 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -822,6 +822,11 @@ public class GradientDrawable extends Drawable { } @Override + public boolean getDither() { + return mGradientState.mDither; + } + + @Override public ColorFilter getColorFilter() { return mColorFilter; } diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index 4aa5f59..daf4427 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -648,6 +648,18 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override + public boolean getDither() { + final ChildDrawable[] array = mLayerState.mChildren; + if (mLayerState.mNum > 0) { + // All layers should have the same dither set on them - just return + // the first one + return array[0].mDrawable.getDither(); + } else { + return super.getDither(); + } + } + + @Override public void setAlpha(int alpha) { final ChildDrawable[] array = mLayerState.mChildren; final int N = mLayerState.mNum; diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java index a6299be..617bf7c 100644 --- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java +++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java @@ -374,6 +374,11 @@ public class NinePatchDrawable extends Drawable { } @Override + public boolean getDither() { + return mPaint == null ? DEFAULT_DITHER : mPaint.isDither(); + } + + @Override public void setAutoMirrored(boolean mirrored) { mNinePatchState.mAutoMirrored = mirrored; } diff --git a/graphics/java/android/graphics/drawable/PictureDrawable.java b/graphics/java/android/graphics/drawable/PictureDrawable.java index 6dcda1f..583cffb 100644 --- a/graphics/java/android/graphics/drawable/PictureDrawable.java +++ b/graphics/java/android/graphics/drawable/PictureDrawable.java @@ -88,12 +88,6 @@ public class PictureDrawable extends Drawable { } @Override - public void setFilterBitmap(boolean filter) {} - - @Override - public void setDither(boolean dither) {} - - @Override public void setColorFilter(ColorFilter colorFilter) {} @Override diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index c49bc8c..c208c03 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -329,6 +329,11 @@ public class ShapeDrawable extends Drawable { } @Override + public boolean getDither() { + return mShapeState.mPaint.isDither(); + } + + @Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); updateShape(); |