diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-04 15:30:57 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-04 15:30:57 +0000 |
commit | 11db6fa9b9fc30b1f504d9f53e0f6ae7149cc5c5 (patch) | |
tree | 4b59e3ba85a2a65abbc17ea7933bc38dbcd6b3ab | |
parent | b511be5a9b6bf194062b79206ac1ec0204aed8ee (diff) |
convert gm tool to use surfaces instead of devices
BUG=skia:
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/148783003
git-svn-id: http://skia.googlecode.com/svn/trunk@13301 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/gmmain.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 1e2adbfc1a..687ee45a66 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -38,6 +38,7 @@ #include "SkScalar.h" #include "SkStream.h" #include "SkString.h" +#include "SkSurface.h" #include "SkTArray.h" #include "SkTDict.h" #include "SkTileGridPicture.h" @@ -559,26 +560,31 @@ public: bool deferred) { SkISize size (gm->getISize()); setup_bitmap(gRec, size, bitmap); + SkImageInfo info; + bitmap->asImageInfo(&info); + SkAutoTUnref<SkSurface> surface; SkAutoTUnref<SkCanvas> canvas; if (gRec.fBackend == kRaster_Backend) { - SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*bitmap))); + surface.reset(SkSurface::NewRasterDirect(info, + bitmap->getPixels(), + bitmap->rowBytes())); if (deferred) { - canvas.reset(SkDeferredCanvas::Create(device)); + canvas.reset(SkDeferredCanvas::Create(surface)); } else { - canvas.reset(SkNEW_ARGS(SkCanvas, (device))); + canvas.reset(SkRef(surface->getCanvas())); } invokeGM(gm, canvas, false, deferred); canvas->flush(); } #if SK_SUPPORT_GPU else { // GPU - SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(gpuTarget)); + surface.reset(SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTarget())); if (deferred) { - canvas.reset(SkDeferredCanvas::Create(device)); + canvas.reset(SkDeferredCanvas::Create(surface)); } else { - canvas.reset(SkNEW_ARGS(SkCanvas, (device))); + canvas.reset(SkRef(surface->getCanvas())); } invokeGM(gm, canvas, false, deferred); // the device is as large as the current rendertarget, so |