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; |
} |