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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* 8 /*
9 * Code for the "gm" (Golden Master) rendering comparison tool. 9 * Code for the "gm" (Golden Master) rendering comparison tool.
10 * 10 *
(...skipping 20 matching lines...) Expand all
31 #include "SkImageDecoder.h" 31 #include "SkImageDecoder.h"
32 #include "SkImageEncoder.h" 32 #include "SkImageEncoder.h"
33 #include "SkJSONCPP.h" 33 #include "SkJSONCPP.h"
34 #include "SkOSFile.h" 34 #include "SkOSFile.h"
35 #include "SkPDFRasterizer.h" 35 #include "SkPDFRasterizer.h"
36 #include "SkPicture.h" 36 #include "SkPicture.h"
37 #include "SkRefCnt.h" 37 #include "SkRefCnt.h"
38 #include "SkScalar.h" 38 #include "SkScalar.h"
39 #include "SkStream.h" 39 #include "SkStream.h"
40 #include "SkString.h" 40 #include "SkString.h"
41 #include "SkSurface.h"
41 #include "SkTArray.h" 42 #include "SkTArray.h"
42 #include "SkTDict.h" 43 #include "SkTDict.h"
43 #include "SkTileGridPicture.h" 44 #include "SkTileGridPicture.h"
44 #include "SamplePipeControllers.h" 45 #include "SamplePipeControllers.h"
45 46
46 #ifdef SK_DEBUG 47 #ifdef SK_DEBUG
47 static const bool kDebugOnly = true; 48 static const bool kDebugOnly = true;
48 #else 49 #else
49 static const bool kDebugOnly = false; 50 static const bool kDebugOnly = false;
50 #endif 51 #endif
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 gm->draw(canvas); 553 gm->draw(canvas);
553 canvas->setDrawFilter(NULL); 554 canvas->setDrawFilter(NULL);
554 } 555 }
555 556
556 static ErrorCombination generate_image(GM* gm, const ConfigData& gRec, 557 static ErrorCombination generate_image(GM* gm, const ConfigData& gRec,
557 GrSurface* gpuTarget, 558 GrSurface* gpuTarget,
558 SkBitmap* bitmap, 559 SkBitmap* bitmap,
559 bool deferred) { 560 bool deferred) {
560 SkISize size (gm->getISize()); 561 SkISize size (gm->getISize());
561 setup_bitmap(gRec, size, bitmap); 562 setup_bitmap(gRec, size, bitmap);
563 SkImageInfo info;
564 bitmap->asImageInfo(&info);
562 565
566 SkAutoTUnref<SkSurface> surface;
563 SkAutoTUnref<SkCanvas> canvas; 567 SkAutoTUnref<SkCanvas> canvas;
564 568
565 if (gRec.fBackend == kRaster_Backend) { 569 if (gRec.fBackend == kRaster_Backend) {
566 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*bitma p))); 570 surface.reset(SkSurface::NewRasterDirect(info,
571 bitmap->getPixels(),
572 bitmap->rowBytes()));
567 if (deferred) { 573 if (deferred) {
568 canvas.reset(SkDeferredCanvas::Create(device)); 574 canvas.reset(SkDeferredCanvas::Create(surface));
569 } else { 575 } else {
570 canvas.reset(SkNEW_ARGS(SkCanvas, (device))); 576 canvas.reset(SkRef(surface->getCanvas()));
571 } 577 }
572 invokeGM(gm, canvas, false, deferred); 578 invokeGM(gm, canvas, false, deferred);
573 canvas->flush(); 579 canvas->flush();
574 } 580 }
575 #if SK_SUPPORT_GPU 581 #if SK_SUPPORT_GPU
576 else { // GPU 582 else { // GPU
577 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(gpuTarget)); 583 surface.reset(SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTa rget()));
578 if (deferred) { 584 if (deferred) {
579 canvas.reset(SkDeferredCanvas::Create(device)); 585 canvas.reset(SkDeferredCanvas::Create(surface));
580 } else { 586 } else {
581 canvas.reset(SkNEW_ARGS(SkCanvas, (device))); 587 canvas.reset(SkRef(surface->getCanvas()));
582 } 588 }
583 invokeGM(gm, canvas, false, deferred); 589 invokeGM(gm, canvas, false, deferred);
584 // the device is as large as the current rendertarget, so 590 // the device is as large as the current rendertarget, so
585 // we explicitly only readback the amount we expect (in 591 // we explicitly only readback the amount we expect (in
586 // size) overwrite our previous allocation 592 // size) overwrite our previous allocation
587 bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, 593 bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
588 size.fHeight); 594 size.fHeight);
589 canvas->readPixels(bitmap, 0, 0); 595 canvas->readPixels(bitmap, 0, 0);
590 } 596 }
591 #endif 597 #endif
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 if (FLAGS_forceBWtext) { 2419 if (FLAGS_forceBWtext) {
2414 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2420 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2415 } 2421 }
2416 } 2422 }
2417 2423
2418 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2424 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2419 int main(int argc, char * const argv[]) { 2425 int main(int argc, char * const argv[]) {
2420 return tool_main(argc, (char**) argv); 2426 return tool_main(argc, (char**) argv);
2421 } 2427 }
2422 #endif 2428 #endif
OLDNEW
« 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