gpudevice should never allocate pixels for its backend
BUG=
R=bsalomon@google.com, mtklein@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/109013002
git-svn-id: http://skia.googlecode.com/svn/trunk@12554 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 07a946e..9580d22 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -155,6 +155,20 @@
return bitmap;
}
+/*
+ * Calling SkBitmapDevice with individual params asks it to allocate pixel memory.
+ * We never want that, so we always need to call it with a bitmap argument
+ * (which says take my allocate (or lack thereof)).
+ *
+ * This is a REALLY good reason to finish the clean-up of SkBaseDevice, and have
+ * SkGpuDevice inherit from that instead of SkBitmapDevice.
+ */
+static SkBitmap make_bitmap(SkBitmap::Config config, int width, int height, bool isOpaque) {
+ SkBitmap bm;
+ bm.setConfig(config, width, height, isOpaque);
+ return bm;
+}
+
SkGpuDevice* SkGpuDevice::Create(GrSurface* surface) {
SkASSERT(NULL != surface);
if (NULL == surface->asRenderTarget() || NULL == surface->getContext()) {
@@ -210,7 +224,7 @@
int width,
int height,
int sampleCount)
- : SkBitmapDevice(config, width, height, false /*isOpaque*/) {
+ : SkBitmapDevice(make_bitmap(config, width, height, false /*isOpaque*/)) {
fDrawProcs = NULL;