From 0bbae0836426ba2704e38e7f90a9d0ca502ab71d Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 15 Jun 2010 18:03:40 -0700 Subject: Add new API to check whether a Bitmap was modified. Bitmap.getGenerationId() can be used by caches to find out if a Bitmap has been modified. This simply exposes an existing Skia API. This change also adds a small test app for Canvas hardware acceleration. The new Bitmap API is required to implement a texture cache. Change-Id: I8547b146cd14c8afe1a2327fcd6d71b1b1cb68fc --- graphics/java/android/graphics/Bitmap.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 7ca3741..e261cfa 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -172,6 +172,19 @@ public final class Bitmap implements Parcelable { } /** + * Returns the generation ID of this bitmap. The generation ID changes + * whenever the bitmap is modified. This can be used as an efficient way to + * check if a bitmap has changed. + * + * @return The current generation ID for this bitmap. + * + * @hide + */ + public int getGenerationId() { + return nativeGenerationId(mNativeBitmap); + } + + /** * This is called by methods that want to throw an exception if the bitmap * has already been recycled. */ @@ -1041,6 +1054,7 @@ public final class Bitmap implements Parcelable { private static native void nativeCopyPixelsToBuffer(int nativeBitmap, Buffer dst); private static native void nativeCopyPixelsFromBuffer(int nb, Buffer src); + private static native int nativeGenerationId(int nativeBitmap); private static native Bitmap nativeCreateFromParcel(Parcel p); // returns true on success -- cgit v1.1