diff options
author | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-28 17:39:08 +0000 |
---|---|---|
committer | junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-28 17:39:08 +0000 |
commit | 66070a527c480d1cef5f7f7136f68d4f17b68f06 (patch) | |
tree | 5e8c8779673d7d012a825ab37caea551c37c2a80 /gm | |
parent | bb6a3178c3e79c8549b332e4ce84c64b59964f1e (diff) |
Changing SkDeferredCanvas to use factories for creation
The objective of this change is to remove all calls to
SkCanvas::setDevice. The factory API is hidden behind
a build flag in order to ease the roll into chromium.
A side-effect of the factory pattern is that it will
no longer be possible to allocate a SkDeferredCanvas on
the stack. This changes nothing for chrome, but it
impacts skia test programs.
Review URL: https://codereview.chromium.org/16040002
git-svn-id: http://skia.googlecode.com/svn/trunk@9298 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/gmmain.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 3c4f27dafb..6a9d77d876 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -490,11 +490,15 @@ public: SkAutoTUnref<SkCanvas> canvas; if (gRec.fBackend == kRaster_Backend) { - SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap)); + SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*bitmap))); if (deferred) { - canvas.reset(new SkDeferredCanvas(device)); +#if SK_DEFERRED_CANVAS_USES_FACTORIES + canvas.reset(SkDeferredCanvas::Create(device)); +#else + canvas.reset(SkNEW_ARGS(SkDeferredCanvas, (device))); +#endif } else { - canvas.reset(new SkCanvas(device)); + canvas.reset(SkNEW_ARGS(SkCanvas, (device))); } invokeGM(gm, canvas, false, deferred); canvas->flush(); @@ -503,9 +507,13 @@ public: else { // GPU SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(gpuTarget)); if (deferred) { - canvas.reset(new SkDeferredCanvas(device)); +#if SK_DEFERRED_CANVAS_USES_FACTORIES + canvas.reset(SkDeferredCanvas::Create(device)); +#else + canvas.reset(SkNEW_ARGS(SkDeferredCanvas, (device))); +#endif } else { - canvas.reset(new SkCanvas(device)); + canvas.reset(SkNEW_ARGS(SkCanvas, (device))); } invokeGM(gm, canvas, false, deferred); // the device is as large as the current rendertarget, so |