diff options
| author | Mike Reed <reed@google.com> | 2009-10-07 11:38:05 -0700 |
|---|---|---|
| committer | Mike Reed <reed@google.com> | 2009-10-07 11:38:05 -0700 |
| commit | a78b0a2d9ebb38b86ed802b3d86de07d0b301262 (patch) | |
| tree | 5e4e7e0e5045af26ebf82a07bdd9d7a0d47ee8df /graphics | |
| parent | 4625758d0b909ccfc9f40b707666b1b21e9e8ffd (diff) | |
| download | frameworks_base-a78b0a2d9ebb38b86ed802b3d86de07d0b301262.zip frameworks_base-a78b0a2d9ebb38b86ed802b3d86de07d0b301262.tar.gz frameworks_base-a78b0a2d9ebb38b86ed802b3d86de07d0b301262.tar.bz2 | |
add (hidden) setHasAlpha() to allow clients like the view's cache to hint that a bitmap is opaque.
Knowing that a 32bit bitmap is opaque is a performance boost for some blits.
Diffstat (limited to 'graphics')
| -rw-r--r-- | graphics/java/android/graphics/Bitmap.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 216dea0..5aa88b0 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -684,12 +684,35 @@ public final class Bitmap implements Parcelable { return Config.nativeToConfig(nativeConfig(mNativeBitmap)); } - /** Returns true if the bitmap's pixels support levels of alpha */ + /** Returns true if the bitmap's config supports per-pixel alpha, and + * if the pixels may contain non-opaque alpha values. For some configs, + * this is always false (e.g. RGB_565), since they do not support per-pixel + * alpha. However, for configs that do, the bitmap may be flagged to be + * known that all of its pixels are opaque. In this case hasAlpha() will + * also return false. If a config such as ARGB_8888 is not so flagged, + * it will return true by default. + */ public final boolean hasAlpha() { return nativeHasAlpha(mNativeBitmap); } /** + * Tell the bitmap if all of the pixels are known to be opaque (false) + * or if some of the pixels may contain non-opaque alpha values (true). + * Note, for some configs (e.g. RGB_565) this call is ignore, since it does + * not support per-pixel alpha values. + * + * This is meant as a drawing hint, as in some cases a bitmap that is known + * to be opaque can take a faster drawing case than one that may have + * non-opaque per-pixel alpha values. + * + * @hide + */ + public void setHasAlpha(boolean hasAlpha) { + nativeSetHasAlpha(mNativeBitmap, hasAlpha); + } + + /** * Fills the bitmap's pixels with the specified {@link Color}. * * @throws IllegalStateException if the bitmap is not mutable. @@ -1018,6 +1041,7 @@ public final class Bitmap implements Parcelable { int[] offsetXY); private static native void nativePrepareToDraw(int nativeBitmap); + private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha); /* package */ final int ni() { return mNativeBitmap; |
