Index: src/core/SkBitmapDevice.cpp |
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp |
index 119a434cc9cde8a5077a18702ba2394e67a183f8..c7bf98f1cd3b6c77d381173a4064c486f73047da 100644 |
--- a/src/core/SkBitmapDevice.cpp |
+++ b/src/core/SkBitmapDevice.cpp |
@@ -15,6 +15,7 @@ |
#include "SkPath.h" |
#include "SkPixelRef.h" |
#include "SkPixmap.h" |
+#include "SkRasterCanvasLayerAllocator.h" |
#include "SkShader.h" |
#include "SkSurface.h" |
#include "SkXfermode.h" |
@@ -129,9 +130,22 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
fBitmap.lockPixels(); |
} |
-SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) { |
+SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*, |
+ SkRasterCanvasLayerAllocator* alloc) { |
const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixelGeometry); |
- return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
+ SkBitmapDevice* dev = nullptr; |
+ if (alloc) { |
+ SkBitmap bitmap; |
+ size_t rowBytes; |
+ void* layer = alloc->allocateLayer(cinfo.fInfo, &rowBytes); |
+ if (layer && |
+ bitmap.installPixels(cinfo.fInfo, layer, rowBytes)) { |
+ dev = new SkBitmapDevice(bitmap); |
+ } |
+ } else { |
+ dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
+ } |
+ return dev; |
} |
const SkBitmap& SkBitmapDevice::onAccessBitmap() { |