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

Unified Diff: src/core/SkBitmapDevice.cpp

Issue 926843003: Move canvas->surface association to the device subclasses (Closed) Base URL: https://skia.googlesource.com/skia.git@skimage-filters-03-sksurface-set-root-device-simple
Patch Set: Created 5 years, 10 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
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapDevice.cpp
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 1f17e6fac12d30212f62819c75cd6fa47b6986ea..f902e59f72fe625851c3c3cfad1bf9502a08b7e9 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -69,11 +69,10 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties&
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
}
-SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
- const SkDeviceProperties* props) {
+bool SkBitmapDevice::CreateBackendBitmap(const SkImageInfo& origInfo, SkBitmap* target) {
SkAlphaType newAT = origInfo.alphaType();
if (!valid_for_bitmap_device(origInfo, &newAT)) {
- return NULL;
+ return false;
}
const SkImageInfo info = origInfo.makeAlphaType(newAT);
@@ -81,17 +80,26 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
if (kUnknown_SkColorType == info.colorType()) {
if (!bitmap.setInfo(info)) {
- return NULL;
+ return false;
}
} else {
if (!bitmap.tryAllocPixels(info)) {
- return NULL;
+ return false;
}
if (!bitmap.info().isOpaque()) {
bitmap.eraseColor(SK_ColorTRANSPARENT);
}
}
+ target->swap(bitmap);
+ return true;
+}
+SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info,
+ const SkDeviceProperties* props) {
+ SkBitmap bitmap;
+ if (!CreateBackendBitmap(info, &bitmap)) {
+ return NULL;
+ }
if (props) {
return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
} else {
@@ -103,7 +111,7 @@ SkImageInfo SkBitmapDevice::imageInfo() const {
return fBitmap.info();
}
-void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
+void SkBitmapDevice::replaceBitmapBackend(const SkBitmap& bm) {
SkASSERT(bm.width() == fBitmap.width());
SkASSERT(bm.height() == fBitmap.height());
fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698