diff options
author | Romain Guy <romainguy@google.com> | 2012-11-26 15:19:09 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-11-27 11:03:22 -0800 |
commit | 5769fcd88a6b53aa9394d869a9428c80e61a1565 (patch) | |
tree | 235649c50d28edbdb1f9f932264ffcbd154d25e8 /graphics | |
parent | 1f58497e7dbab1b16e97c73b65559b852d0c2803 (diff) | |
download | frameworks_base-5769fcd88a6b53aa9394d869a9428c80e61a1565.zip frameworks_base-5769fcd88a6b53aa9394d869a9428c80e61a1565.tar.gz frameworks_base-5769fcd88a6b53aa9394d869a9428c80e61a1565.tar.bz2 |
Add new mipMap attribute to BitmapDrawable
This attribute can be used to enable/disable mipmapping on bitmaps.
See Bitmap.setHasMipMap() for details.
Change-Id: I13cc800a258b6876a94e2a9605dcec4ea4f1ea48
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/BitmapDrawable.java | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index e82ccd4..6e41d34 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -243,7 +243,7 @@ public class BitmapDrawable extends Drawable { public int getGravity() { return mBitmapState.mGravity; } - + /** Set the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity * @param gravity the gravity @@ -257,16 +257,58 @@ public class BitmapDrawable extends Drawable { } /** + * Enables or disables the mipmap hint for this drawable's bitmap. + * See {@link Bitmap#setHasMipMap(boolean)} for more information. + * + * If the bitmap is null calling this method has no effect. + * + * @param mipMap True if the bitmap should use mipmaps, false otherwise. + * + * @see #hasMipMap() + */ + public void setMipMap(boolean mipMap) { + if (mBitmapState.mBitmap != null) { + mBitmapState.mBitmap.setHasMipMap(mipMap); + invalidateSelf(); + } + } + + /** + * Indicates whether the mipmap hint is enabled on this drawable's bitmap. + * + * @return True if the mipmap hint is set, false otherwise. If the bitmap + * is null, this method always returns false. + * + * @see #setMipMap(boolean) + */ + public boolean hasMipMap() { + return mBitmapState.mBitmap != null && mBitmapState.mBitmap.hasMipMap(); + } + + /** * Enables or disables anti-aliasing for this drawable. Anti-aliasing affects * the edges of the bitmap only so it applies only when the drawable is rotated. * * @param aa True if the bitmap should be anti-aliased, false otherwise. + * + * @see #hasAntiAlias() */ public void setAntiAlias(boolean aa) { mBitmapState.mPaint.setAntiAlias(aa); invalidateSelf(); } - + + /** + * Indicates whether anti-aliasing is enabled for this drawable. + * + * @return True if anti-aliasing is enabled, false otherwise. + * + * @see #setAntiAlias(boolean) + */ + public boolean hasAntiAlias() { + return mBitmapState.mPaint.isAntiAlias(); + } + @Override public void setFilterBitmap(boolean filter) { mBitmapState.mPaint.setFilterBitmap(filter); @@ -451,6 +493,8 @@ public class BitmapDrawable extends Drawable { mBitmapState.mBitmap = bitmap; setBitmap(bitmap); setTargetDensity(r.getDisplayMetrics()); + setMipMap(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_mipMap, + bitmap.hasMipMap())); final Paint paint = mBitmapState.mPaint; paint.setAntiAlias(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_antialias, |