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

Unified Diff: src/core/SkBitmapDevice.cpp

Issue 1763143002: WIP RasterCanvasLayerAllocator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add allocator-constancy sanitycheck Created 4 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
Index: src/core/SkBitmapDevice.cpp
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index fc0e63e9ae0b4ad93ea9806e243e1d6ae6549540..36d46f3abf5337cb04e8f744e6f03009ccea74ed 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -14,6 +14,7 @@
#include "SkPath.h"
#include "SkPixelRef.h"
#include "SkPixmap.h"
+#include "SkRasterCanvasLayerAllocator.h"
#include "SkShader.h"
#include "SkSurface.h"
#include "SkXfermode.h"
@@ -128,9 +129,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