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

Unified Diff: include/core/SkCanvas.h

Issue 196923004: add NewRasterDirect for creating a canvas drawing to pre-allocated pixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »
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 716720bc3ecf033718798f56d248ad777440612c..27bd6225d71eaf84f3bb2dad7525ad1ed4004d70 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -88,6 +88,27 @@ public:
}
/**
+ * Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the
+ * specified pixels. To access the pixels after drawing to them, the caller should call
+ * flush() or call peekPixels(...).
+ *
+ * On failure, return NULL. This can fail for several reasons:
+ * 1. invalid ImageInfo (e.g. negative dimensions)
+ * 2. unsupported ImageInfo for a canvas
+ * - kUnknown_SkColorType, kIndex_8_SkColorType
+ * - kIgnore_SkAlphaType
+ * - this list is not complete, so others may also be unsupported
+ *
+ * Note: it is valid to request a supported ImageInfo, but with zero
+ * dimensions.
+ */
+ static SkCanvas* NewRasterDirect(const SkImageInfo&, void*, size_t);
+
+ static SkCanvas* NewRasterDirectN32(int width, int height, SkPMColor* pixels, size_t rowBytes) {
+ return NewRasterDirect(SkImageInfo::MakeN32Premul(width, height), pixels, rowBytes);
+ }
+
+ /**
* 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698