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

Side by Side Diff: bench/DeferredSurfaceCopyBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 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/DisplacementBench.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"
11 #endif 11 #endif
12 #include "SkBenchmark.h" 12 #include "SkBenchmark.h"
13 #include "SkDeferredCanvas.h" 13 #include "SkDeferredCanvas.h"
14 #include "SkDevice.h" 14 #include "SkDevice.h"
15 #include "SkImage.h" 15 #include "SkImage.h"
16 #include "SkSurface.h" 16 #include "SkSurface.h"
17 17
18 class DeferredSurfaceCopyBench : public SkBenchmark { 18 class DeferredSurfaceCopyBench : public SkBenchmark {
19 enum { 19 enum {
20 N = SkBENCHLOOP(5),
21 kSurfaceWidth = 1000, 20 kSurfaceWidth = 1000,
22 kSurfaceHeight = 1000, 21 kSurfaceHeight = 1000,
23 }; 22 };
24 public: 23 public:
25 DeferredSurfaceCopyBench(void* param, bool discardableContents) : SkBenchmar k(param) { 24 DeferredSurfaceCopyBench(void* param, bool discardableContents) : SkBenchmar k(param) {
26 fDiscardableContents = discardableContents; 25 fDiscardableContents = discardableContents;
27 } 26 }
28 27
29 protected: 28 protected:
30 virtual const char* onGetName() SK_OVERRIDE { 29 virtual const char* onGetName() SK_OVERRIDE {
(...skipping 18 matching lines...) Expand all
49 if (NULL != rt) { 48 if (NULL != rt) {
50 surface = SkSurface::NewRenderTarget(rt->getContext(), info, rt->num Samples()); 49 surface = SkSurface::NewRenderTarget(rt->getContext(), info, rt->num Samples());
51 } else 50 } else
52 #endif 51 #endif
53 { 52 {
54 surface = SkSurface::NewRaster(info); 53 surface = SkSurface::NewRaster(info);
55 } 54 }
56 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(su rface)); 55 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(su rface));
57 surface->unref(); 56 surface->unref();
58 57
59 for (int iteration = 0; iteration < N; iteration++) { 58 for (int iteration = 0; iteration < this->getLoops(); iteration++) {
60 drawingCanvas->clear(0); 59 drawingCanvas->clear(0);
61 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot()); 60 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot());
62 SkPaint paint; 61 SkPaint paint;
63 if (!fDiscardableContents) { 62 if (!fDiscardableContents) {
64 // If paint is not opaque, prior canvas contents are 63 // If paint is not opaque, prior canvas contents are
65 // not discardable because they are needed for compositing. 64 // not discardable because they are needed for compositing.
66 paint.setAlpha(127); 65 paint.setAlpha(127);
67 } 66 }
68 drawingCanvas->drawRect(fullCanvasRect, paint); 67 drawingCanvas->drawRect(fullCanvasRect, paint);
69 // Trigger copy on write, which should be faster in the discardable case. 68 // Trigger copy on write, which should be faster in the discardable case.
70 drawingCanvas->flush(); 69 drawingCanvas->flush();
71 } 70 }
72 } 71 }
73 72
74 private: 73 private:
75 bool fDiscardableContents; 74 bool fDiscardableContents;
76 75
77 typedef SkBenchmark INHERITED; 76 typedef SkBenchmark INHERITED;
78 }; 77 };
79 78
80 ////////////////////////////////////////////////////////////////////////////// 79 //////////////////////////////////////////////////////////////////////////////
81 80
82 static SkBenchmark* Fact0(void* p) { return new DeferredSurfaceCopyBench(p, fals e); } 81 static SkBenchmark* Fact0(void* p) { return new DeferredSurfaceCopyBench(p, fals e); }
83 static SkBenchmark* Fact1(void* p) { return new DeferredSurfaceCopyBench(p, true ); } 82 static SkBenchmark* Fact1(void* p) { return new DeferredSurfaceCopyBench(p, true ); }
84 83
85 static BenchRegistry gReg0(Fact0); 84 static BenchRegistry gReg0(Fact0);
86 static BenchRegistry gReg1(Fact1); 85 static BenchRegistry gReg1(Fact1);
OLDNEW
« no previous file with comments | « bench/DeferredCanvasBench.cpp ('k') | bench/DisplacementBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698