Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: include/core/SkImage.h

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkDevice.h ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « include/core/SkDevice.h ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698