Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: gm/gmmain.cpp

Issue 148783003: convert gm tool to use surfaces instead of devices (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gmmain.cpp
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 1e2adbfc1af64fa6f79f9b81f7ff751c677298ce..687ee45a663310c0782969d57029fe562fae915e 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698