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

Unified Diff: include/core/SkCanvas.h

Issue 183533004: add SkCanvas::NewRaster factory -- a very common use-case in chrome (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index e9d4933d177112fed795e36746e3d482e414d4a8..80e5db26f83017fda33fbe1a0f1550a83976323c 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -49,6 +49,22 @@ public:
SK_DECLARE_INST_COUNT(SkCanvas)
/**
+ * Attempt to allocate an offscreen raster canvas, matching the ImageInfo.
+ * On success, return a new canvas that will draw into that offscreen.
+ * The pixels will be uninitialized if the ImageInfo's alpha was kOpaque,
+ * else they will be initialized to 0. The caller can access the pixels
scroggo 2014/02/27 19:16:06 How about initializing them to SK_ColorTRANSPARENT
+ * after drawing into this canvas by calling readPixels() or peekPixels().
+ *
+ * If the offscreen cannot be allocated, or the requested ImageInfo is not
+ * supported, then NULL is returned.
+ */
+ static SkCanvas* NewRaster(const SkImageInfo&);
+
+ static SkCanvas* NewRasterN32(int width, int height) {
+ return NewRaster(SkImageInfo::MakeN32Premul(width, height));
+ }
+
+ /**
* Creates an empty canvas with no backing device/pixels, and zero
* dimensions.
*/
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698