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
This commit is contained in:
parent
1904df0413
commit
cb62224996
@ -29,12 +29,7 @@ protected:
|
||||
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);
|
||||
|
@ -53,12 +53,7 @@ protected:
|
||||
{
|
||||
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++) {
|
||||
|
@ -792,12 +792,7 @@ int tool_main(int argc, char** argv) {
|
||||
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,
|
||||
|
@ -519,11 +519,7 @@ public:
|
||||
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 @@ public:
|
||||
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)));
|
||||
}
|
||||
|
@ -15,11 +15,6 @@ class DeferredDevice;
|
||||
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 @@ public:
|
||||
*/
|
||||
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
|
||||
|
@ -550,33 +550,15 @@ private:
|
||||
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 @@ void SkDeferredCanvas::silentFlush() {
|
||||
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);
|
||||
|
@ -780,12 +780,7 @@ public:
|
||||
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);
|
||||
|
@ -34,12 +34,7 @@ static void TestDeferredCanvasBitmapAccess(skiatest::Reporter* reporter) {
|
||||
|
||||
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 @@ public:
|
||||
|
||||
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 @@ static void TestDeferredCanvasFlush(skiatest::Reporter* reporter) {
|
||||
|
||||
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 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
|
||||
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 @@ static void TestDeferredCanvasMemoryLimit(skiatest::Reporter* reporter) {
|
||||
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 @@ static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
|
||||
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 @@ static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) {
|
||||
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 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) {
|
||||
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 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
|
||||
// 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 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
|
||||
// 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 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
|
||||
// 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 @@ static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFac
|
||||
#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 @@ static void TestDeferredCanvasSetSurface(skiatest::Reporter* reporter, GrContext
|
||||
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 @@ static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
|
||||
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()));
|
||||
|
Loading…
Reference in New Issue
Block a user