Index: include/core/SkImage.h |
diff --git a/include/core/SkImage.h b/include/core/SkImage.h |
index ec855166195d863bd014156deda1bf03742f2451..5d2ae24ef752490e7d24072242286a4aecd2ef62 100644 |
--- a/include/core/SkImage.h |
+++ b/include/core/SkImage.h |
@@ -187,4 +187,38 @@ private: |
void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) const; |
}; |
+/** A helper for common in pixel access done with CPU: lock pixels of the rendering of the |
+ * image in N32 format, or fail. The condition bitmap->getPixels() != NULL signifies success. |
+ * Will unref the image if succesful, as this may save memory. |
+ */ |
+class SkAutoAdoptImageAsN32Bitmap : SkNoncopyable { |
+public: |
+ /** |
+ * @param image image to adopt as bitmap. will be reset(NULL) if operation is successful. |
+ */ |
+ SkAutoAdoptImageAsN32Bitmap(SkAutoTUnref<const SkImage>& image, SkBitmap* bitmap); |
+ ~SkAutoAdoptImageAsN32Bitmap() { |
+ if (fBitmap) { |
+ fBitmap->unlockPixels(); |
+ } |
+ } |
+private: |
+ SkBitmap* fBitmap; |
+}; |
+ |
+/** A helper for common in pixel access done with CPU: lock pixels of the rendering of the |
+ * image in N32 format, or fail. The condition bitmap->getPixels() != NULL signifies success. |
+ */ |
+class SkAutoImageAsN32Bitmap : SkNoncopyable { |
+public: |
+ SkAutoImageAsN32Bitmap(const SkImage* image, SkBitmap* bitmap); |
+ ~SkAutoImageAsN32Bitmap() { |
+ if (fBitmap) { |
+ fBitmap->unlockPixels(); |
+ } |
+ } |
+private: |
+ SkBitmap* fBitmap; |
+}; |
+ |
#endif |