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

Unified Diff: src/core/SkBitmapDevice.cpp

Issue 1763143002: WIP RasterCanvasLayerAllocator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test and some further work Created 4 years, 7 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
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() {

Powered by Google App Engine
This is Rietveld 408576698