Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index 4ac7b29826e790d0d45f2eaecb3a794856a14d5f..e13769a20af7eb08107b2cd5fe9cd1c0eebd49e9 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -2549,3 +2549,22 @@ SkCanvas* SkCanvas::NewRaster(const SkImageInfo& info) { |
} |
return SkNEW_ARGS(SkCanvas, (bitmap)); |
} |
+ |
+SkCanvas* SkCanvas::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
+ if (!supported_for_raster_canvas(info)) { |
+ return NULL; |
+ } |
+ |
+ SkBitmap bitmap; |
+ if (!bitmap.installPixels(info, pixels, rowBytes)) { |
+ return NULL; |
+ } |
+ |
+ // should this functionality be moved into allocPixels()? |
+ if (!bitmap.info().isOpaque()) { |
+ bitmap.eraseColor(0); |
+ } |
+ return SkNEW_ARGS(SkCanvas, (bitmap)); |
+} |
+ |
+ |