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
This commit is contained in:
parent
b511be5a9b
commit
11db6fa9b9
@ -38,6 +38,7 @@
|
|||||||
#include "SkScalar.h"
|
#include "SkScalar.h"
|
||||||
#include "SkStream.h"
|
#include "SkStream.h"
|
||||||
#include "SkString.h"
|
#include "SkString.h"
|
||||||
|
#include "SkSurface.h"
|
||||||
#include "SkTArray.h"
|
#include "SkTArray.h"
|
||||||
#include "SkTDict.h"
|
#include "SkTDict.h"
|
||||||
#include "SkTileGridPicture.h"
|
#include "SkTileGridPicture.h"
|
||||||
@ -559,26 +560,31 @@ public:
|
|||||||
bool deferred) {
|
bool deferred) {
|
||||||
SkISize size (gm->getISize());
|
SkISize size (gm->getISize());
|
||||||
setup_bitmap(gRec, size, bitmap);
|
setup_bitmap(gRec, size, bitmap);
|
||||||
|
SkImageInfo info;
|
||||||
|
bitmap->asImageInfo(&info);
|
||||||
|
|
||||||
|
SkAutoTUnref<SkSurface> surface;
|
||||||
SkAutoTUnref<SkCanvas> canvas;
|
SkAutoTUnref<SkCanvas> canvas;
|
||||||
|
|
||||||
if (gRec.fBackend == kRaster_Backend) {
|
if (gRec.fBackend == kRaster_Backend) {
|
||||||
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*bitmap)));
|
surface.reset(SkSurface::NewRasterDirect(info,
|
||||||
|
bitmap->getPixels(),
|
||||||
|
bitmap->rowBytes()));
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
canvas.reset(SkDeferredCanvas::Create(device));
|
canvas.reset(SkDeferredCanvas::Create(surface));
|
||||||
} else {
|
} else {
|
||||||
canvas.reset(SkNEW_ARGS(SkCanvas, (device)));
|
canvas.reset(SkRef(surface->getCanvas()));
|
||||||
}
|
}
|
||||||
invokeGM(gm, canvas, false, deferred);
|
invokeGM(gm, canvas, false, deferred);
|
||||||
canvas->flush();
|
canvas->flush();
|
||||||
}
|
}
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
else { // GPU
|
else { // GPU
|
||||||
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(gpuTarget));
|
surface.reset(SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTarget()));
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
canvas.reset(SkDeferredCanvas::Create(device));
|
canvas.reset(SkDeferredCanvas::Create(surface));
|
||||||
} else {
|
} else {
|
||||||
canvas.reset(SkNEW_ARGS(SkCanvas, (device)));
|
canvas.reset(SkRef(surface->getCanvas()));
|
||||||
}
|
}
|
||||||
invokeGM(gm, canvas, false, deferred);
|
invokeGM(gm, canvas, false, deferred);
|
||||||
// the device is as large as the current rendertarget, so
|
// the device is as large as the current rendertarget, so
|
||||||
|
Loading…
Reference in New Issue
Block a user