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

Unified Diff: src/utils/SkDeferredCanvas.cpp

Issue 16040002: Changing SkDeferredCanvas to use factories for creation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDeferredCanvas.cpp
===================================================================
--- src/utils/SkDeferredCanvas.cpp (revision 9282)
+++ src/utils/SkDeferredCanvas.cpp (working copy)
@@ -139,7 +139,9 @@
//-----------------------------------------------------------------------------
class DeferredDevice : public SkDevice {
public:
+#ifdef SK_DEVELOPER
explicit DeferredDevice(SkDevice* immediateDevice);
+#endif
explicit DeferredDevice(SkSurface* surface);
~DeferredDevice();
@@ -255,6 +257,7 @@
size_t fBitmapSizeThreshold;
};
+#ifdef SK_DEVELOPER
DeferredDevice::DeferredDevice(SkDevice* immediateDevice)
: SkDevice(SkBitmap::kNo_Config,
immediateDevice->width(), immediateDevice->height(),
@@ -265,6 +268,7 @@
fPipeController.setPlaybackCanvas(fImmediateCanvas);
this->init();
}
+#endif
DeferredDevice::DeferredDevice(SkSurface* surface)
: SkDevice(SkBitmap::kNo_Config,
@@ -527,6 +531,7 @@
SkDeferredCanvas* fCanvas;
};
+#if !SK_DEFERRED_CANVAS_USES_FACTORIES
SkDeferredCanvas::SkDeferredCanvas() {
this->init();
}
@@ -540,7 +545,24 @@
this->init();
this->INHERITED::setDevice(SkNEW_ARGS(DeferredDevice, (surface)))->unref();
}
+#endif
+SkDeferredCanvas* SkDeferredCanvas::Create(SkSurface* surface) {
+ SkAutoTUnref<DeferredDevice> deferredDevice(SkNEW_ARGS(DeferredDevice, (surface)));
+ return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice));
+}
+
+#ifdef SK_DEVELOPER
+SkDeferredCanvas* SkDeferredCanvas::Create(SkDevice* device) {
+ SkAutoTUnref<DeferredDevice> deferredDevice(SkNEW_ARGS(DeferredDevice, (device)));
+ return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice));
+}
+#endif
+
+SkDeferredCanvas::SkDeferredCanvas(DeferredDevice* device) : SkCanvas (device) {
+ this->init();
+}
+
void SkDeferredCanvas::init() {
fDeferredDrawing = true; // On by default
}
@@ -622,20 +644,21 @@
}
SkDevice* SkDeferredCanvas::setDevice(SkDevice* device) {
+#if SK_DEFERRED_CANVAS_USES_FACTORIES
+ SkASSERT(0); // setDevice is deprecated
+#else
this->INHERITED::setDevice(SkNEW_ARGS(DeferredDevice, (device)))->unref();
+#endif
return device;
}
SkSurface* SkDeferredCanvas::setSurface(SkSurface* surface) {
DeferredDevice* deferredDevice = this->getDeferredDevice();
- if (NULL != deferredDevice) {
- // By swapping the surface into the existing device, we preserve
- // all pending commands, which can help to seamlessly recover from
- // a lost accelerated graphics context.
- deferredDevice->setSurface(surface);
- } else {
- this->INHERITED::setDevice(SkNEW_ARGS(DeferredDevice, (surface)))->unref();
- }
+ SkASSERT(NULL != deferredDevice);
+ // By swapping the surface into the existing device, we preserve
+ // all pending commands, which can help to seamlessly recover from
+ // a lost accelerated graphics context.
+ deferredDevice->setSurface(surface);
return surface;
}
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698