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

Side by Side Diff: bench/DeferredSurfaceCopyBench.cpp

Issue 16040002: Changing SkDeferredCanvas to use factories for creation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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 | « bench/DeferredCanvasBench.cpp ('k') | bench/benchmain.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 #include "GrRenderTarget.h" 10 #include "GrRenderTarget.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #if SK_SUPPORT_GPU 46 #if SK_SUPPORT_GPU
47 GrRenderTarget* rt = reinterpret_cast<GrRenderTarget*>( 47 GrRenderTarget* rt = reinterpret_cast<GrRenderTarget*>(
48 canvas->getDevice()->accessRenderTarget()); 48 canvas->getDevice()->accessRenderTarget());
49 if (NULL != rt) { 49 if (NULL != rt) {
50 surface = SkSurface::NewRenderTarget(rt->getContext(), info, rt->num Samples()); 50 surface = SkSurface::NewRenderTarget(rt->getContext(), info, rt->num Samples());
51 } else 51 } else
52 #endif 52 #endif
53 { 53 {
54 surface = SkSurface::NewRaster(info); 54 surface = SkSurface::NewRaster(info);
55 } 55 }
56 SkDeferredCanvas drawingCanvas(surface); 56 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(
57 #if SK_DEFERRED_CANVAS_USES_FACTORIES
58 SkDeferredCanvas::Create(surface));
59 #else
60 SkNEW_ARGS(SkDeferredCanvas, (surface)));
61 #endif
57 surface->unref(); 62 surface->unref();
58 63
59 for (int iteration = 0; iteration < N; iteration++) { 64 for (int iteration = 0; iteration < N; iteration++) {
60 drawingCanvas.clear(0); 65 drawingCanvas->clear(0);
61 SkAutoTUnref<SkImage> image(drawingCanvas.newImageSnapshot()); 66 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot());
62 SkPaint paint; 67 SkPaint paint;
63 if (!fDiscardableContents) { 68 if (!fDiscardableContents) {
64 // If paint is not opaque, prior canvas contents are 69 // If paint is not opaque, prior canvas contents are
65 // not discardable because they are needed for compositing. 70 // not discardable because they are needed for compositing.
66 paint.setAlpha(127); 71 paint.setAlpha(127);
67 } 72 }
68 drawingCanvas.drawRect(fullCanvasRect, paint); 73 drawingCanvas->drawRect(fullCanvasRect, paint);
69 // Trigger copy on write, which should be faster in the discardable case. 74 // Trigger copy on write, which should be faster in the discardable case.
70 drawingCanvas.flush(); 75 drawingCanvas->flush();
71 } 76 }
72 } 77 }
73 78
74 private: 79 private:
75 bool fDiscardableContents; 80 bool fDiscardableContents;
76 81
77 typedef SkBenchmark INHERITED; 82 typedef SkBenchmark INHERITED;
78 }; 83 };
79 84
80 ////////////////////////////////////////////////////////////////////////////// 85 //////////////////////////////////////////////////////////////////////////////
81 86
82 static SkBenchmark* Fact0(void* p) { return new DeferredSurfaceCopyBench(p, fals e); } 87 static SkBenchmark* Fact0(void* p) { return new DeferredSurfaceCopyBench(p, fals e); }
83 static SkBenchmark* Fact1(void* p) { return new DeferredSurfaceCopyBench(p, true ); } 88 static SkBenchmark* Fact1(void* p) { return new DeferredSurfaceCopyBench(p, true ); }
84 89
85 static BenchRegistry gReg0(Fact0); 90 static BenchRegistry gReg0(Fact0);
86 static BenchRegistry gReg1(Fact1); 91 static BenchRegistry gReg1(Fact1);
OLDNEW
« no previous file with comments | « bench/DeferredCanvasBench.cpp ('k') | bench/benchmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698