Removing deprecated constructors and setDevice from SkDeferredCanvas
R=senorblanco@google.com, senorblanco@chromium.org
BUR=crbug.com/270143
Author: junov@chromium.org
Review URL: https://chromiumcodereview.appspot.com/22385011
git-svn-id: http://skia.googlecode.com/svn/trunk@10657 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/DeferredCanvasBench.cpp b/bench/DeferredCanvasBench.cpp
index 5ef64db..9e7e7238 100644
--- a/bench/DeferredCanvasBench.cpp
+++ b/bench/DeferredCanvasBench.cpp
@@ -29,12 +29,7 @@
SkDevice *device = canvas->getDevice()->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false);
- SkAutoTUnref<SkDeferredCanvas> deferredCanvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(device));
device->unref();
initDeferredCanvas(deferredCanvas);
diff --git a/bench/DeferredSurfaceCopyBench.cpp b/bench/DeferredSurfaceCopyBench.cpp
index 483507b..cbf96d0 100644
--- a/bench/DeferredSurfaceCopyBench.cpp
+++ b/bench/DeferredSurfaceCopyBench.cpp
@@ -53,12 +53,7 @@
{
surface = SkSurface::NewRaster(info);
}
- SkAutoTUnref<SkDeferredCanvas> drawingCanvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(surface));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (surface)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(surface));
surface->unref();
for (int iteration = 0; iteration < N; iteration++) {
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 2248753..9cb7468 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -792,12 +792,7 @@
switch(benchMode) {
case kDeferredSilent_benchModes:
case kDeferred_benchModes:
- canvas =
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(device);
-#else
- SkNEW_ARGS(SkDeferredCanvas, (device));
-#endif
+ canvas = SkDeferredCanvas::Create(device);
break;
case kRecord_benchModes:
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY,
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 958a511..67259f1 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -519,11 +519,7 @@
if (gRec.fBackend == kRaster_Backend) {
SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*bitmap)));
if (deferred) {
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
canvas.reset(SkDeferredCanvas::Create(device));
-#else
- canvas.reset(SkNEW_ARGS(SkDeferredCanvas, (device)));
-#endif
} else {
canvas.reset(SkNEW_ARGS(SkCanvas, (device)));
}
@@ -534,11 +530,7 @@
else { // GPU
SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(gpuTarget));
if (deferred) {
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
canvas.reset(SkDeferredCanvas::Create(device));
-#else
- canvas.reset(SkNEW_ARGS(SkDeferredCanvas, (device)));
-#endif
} else {
canvas.reset(SkNEW_ARGS(SkCanvas, (device)));
}
diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h
index f961605..77229a7 100644
--- a/include/utils/SkDeferredCanvas.h
+++ b/include/utils/SkDeferredCanvas.h
@@ -15,11 +15,6 @@
class SkImage;
class SkSurface;
-#if !defined(SK_DEFERRED_CANVAS_USES_FACTORIES)
-// This is temporary, for rolling the API change into Chromium/Blink
-#define SK_DEFERRED_CANVAS_USES_FACTORIES 0
-#endif
-
/** \class SkDeferredCanvas
Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred
drawing. The main difference between this class and SkPictureRecord (the
@@ -38,42 +33,10 @@
*/
static SkDeferredCanvas* Create(SkSurface* surface);
-#ifdef SK_DEVELOPER
- static SkDeferredCanvas* Create(SkDevice* device); // Used for testing
-#endif
-
-#if !SK_DEFERRED_CANVAS_USES_FACTORIES
- /** DEPRECATED
- */
- SkDeferredCanvas();
-
- /** DEPRACATED, use create instead
- Construct a canvas with the specified device to draw into.
- Equivalent to calling default constructor, then setDevice.
- @param device Specifies a device for the canvas to draw into.
- */
- explicit SkDeferredCanvas(SkDevice* device);
-
- /** DEPRECATED, use create instead
- Construct a canvas with the specified surface to draw into.
- This constructor must be used for newImageSnapshot to work.
- @param surface Specifies a surface for the canvas to draw into.
- */
- explicit SkDeferredCanvas(SkSurface* surface);
-#endif
+ static SkDeferredCanvas* Create(SkDevice* device);
virtual ~SkDeferredCanvas();
- /** DEPRECATED
- * Specify a device to be used by this canvas. Calling setDevice will
- * release the previously set device, if any. Takes a reference on the
- * device.
- *
- * @param device The device that the canvas will raw into
- * @return The device argument, for convenience.
- */
- virtual SkDevice* setDevice(SkDevice* device);
-
/**
* Specify the surface to be used by this canvas. Calling setSurface will
* release the previously set surface or device. Takes a reference on the
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 44b431e..05daf63 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -550,33 +550,15 @@
SkDeferredCanvas* fCanvas;
};
-#if !SK_DEFERRED_CANVAS_USES_FACTORIES
-SkDeferredCanvas::SkDeferredCanvas() {
- this->init();
-}
-
-SkDeferredCanvas::SkDeferredCanvas(SkDevice* device) {
- this->init();
- this->setDevice(device);
-}
-
-SkDeferredCanvas::SkDeferredCanvas(SkSurface* surface) {
- 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();
@@ -662,15 +644,6 @@
SkDeferredCanvas::~SkDeferredCanvas() {
}
-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();
SkASSERT(NULL != deferredDevice);
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index e45efa6..26896fc 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -780,12 +780,7 @@
SkBitmap deferredStore;
createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkDevice deferredDevice(deferredStore);
- SkAutoTUnref<SkDeferredCanvas> deferredCanvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&deferredDevice));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&deferredDevice)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(&deferredDevice));
testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat);
testStep->draw(deferredCanvas, reporter);
testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat);
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 220d820..15474f5 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -34,12 +34,7 @@
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000);
@@ -89,12 +84,7 @@
static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter) {
SkAutoTUnref<MockSurface> surface(SkNEW_ARGS(MockSurface, (10, 10)));
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(surface.get()));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (surface.get())));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
SkBitmap srcBitmap;
srcBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
@@ -270,12 +260,7 @@
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000);
@@ -295,12 +280,7 @@
SkIntToScalar(1), SkIntToScalar(1));
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// verify that frame is intially fresh
REPORTER_ASSERT(reporter, canvas->isFreshFrame());
@@ -473,12 +453,7 @@
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
MockDevice mockDevice(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&mockDevice));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&mockDevice)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&mockDevice));
canvas->setMaxRecordingStorage(160000);
SkBitmap sourceImage;
@@ -529,12 +504,7 @@
store.allocPixels();
SkDevice device(store);
NotificationCounter notificationCounter;
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(¬ificationCounter);
const int imageCount = 2;
@@ -617,12 +587,7 @@
store.allocPixels();
SkDevice device(store);
NotificationCounter notificationCounter;
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(¬ificationCounter);
canvas->clear(0x0);
REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawCommandsCount);
@@ -642,12 +607,7 @@
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// test will fail if nbIterations is not in sync with
// BITMAPS_TO_KEEP in SkGPipeWrite.cpp
const int nbIterations = 5;
@@ -693,12 +653,7 @@
// 1 under : should not store the image
{
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(39999);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
size_t newBytesAllocated = canvas->storageAllocatedForRecording();
@@ -708,12 +663,7 @@
// exact value : should store the image
{
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40000);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
size_t newBytesAllocated = canvas->storageAllocatedForRecording();
@@ -723,12 +673,7 @@
// 1 over : should still store the image
{
SkDevice device(store);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40001);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
size_t newBytesAllocated = canvas->storageAllocatedForRecording();
@@ -768,12 +713,7 @@
#endif
SkASSERT(NULL != surface);
SkAutoTUnref<SkSurface> aur(surface);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(surface));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (surface)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface));
SkImage* image1 = canvas->newImageSnapshot();
SkAutoTUnref<SkImage> aur_i1(image1);
@@ -848,12 +788,7 @@
SkAutoTUnref<SkSurface> aur2(alternateSurface);
PixelPtr pixels1 = getSurfacePixelPtr(surface, useGpu);
PixelPtr pixels2 = getSurfacePixelPtr(alternateSurface, useGpu);
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(surface));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (surface)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface));
SkAutoTUnref<SkImage> image1(canvas->newImageSnapshot());
canvas->setSurface(alternateSurface);
SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot());
@@ -874,12 +809,7 @@
store.allocPixels();
SkDevice device(store);
NotificationCounter notificationCounter;
- SkAutoTUnref<SkDeferredCanvas> canvas(
-#if SK_DEFERRED_CANVAS_USES_FACTORIES
- SkDeferredCanvas::Create(&device));
-#else
- SkNEW_ARGS(SkDeferredCanvas, (&device)));
-#endif
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(¬ificationCounter);
SkAutoTUnref<SkDevice> secondaryDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque()));