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

Unified Diff: include/core/SkCanvas.h

Issue 791763002: Revert of remove (dumb) canvas::NewRaster, and rename surface::NewRasterPMColor to N32Premul (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « gyp/skia_for_chromium_defines.gypi ('k') | include/core/SkSurface.h » ('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 46dc3774f0b2f6c6e1d987de8493f700bf351955..ff60c57fa7ec325a7678fbb8e1e28629b83e71a2 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -60,6 +60,35 @@
class SK_API SkCanvas : public SkRefCnt {
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 caller can access the pixels after drawing into this canvas by
+ * calling readPixels() or peekPixels().
+ *
+ * If the requested ImageInfo is opaque (either the colortype is
+ * intrinsically opaque like RGB_565, or the info's alphatype is kOpaque)
+ * then the pixel memory may be uninitialized. Otherwise, the pixel memory
+ * will be initialized to 0, which is interpreted as transparent.
+ *
+ * On failure, return NULL. This can fail for several reasons:
+ * 1. the memory allocation failed (e.g. request is too large)
+ * 2. invalid ImageInfo (e.g. negative dimensions)
+ * 3. 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* NewRaster(const SkImageInfo&);
+
+ static SkCanvas* NewRasterN32(int width, int height) {
+ return NewRaster(SkImageInfo::MakeN32Premul(width, height));
+ }
/**
* Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | include/core/SkSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698