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

Side by Side Diff: bench/DisplacementBench.cpp

Issue 23876006: Refactoring: get rid of the SkBenchmark void* parameter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: sync to head 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/DeferredSurfaceCopyBench.cpp ('k') | bench/FSRectBench.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDisplacementMapEffect.h" 11 #include "SkDisplacementMapEffect.h"
12 12
13 #define FILTER_WIDTH_SMALL 32 13 #define FILTER_WIDTH_SMALL 32
14 #define FILTER_HEIGHT_SMALL 32 14 #define FILTER_HEIGHT_SMALL 32
15 #define FILTER_WIDTH_LARGE 256 15 #define FILTER_WIDTH_LARGE 256
16 #define FILTER_HEIGHT_LARGE 256 16 #define FILTER_HEIGHT_LARGE 256
17 17
18 class DisplacementBaseBench : public SkBenchmark { 18 class DisplacementBaseBench : public SkBenchmark {
19 public: 19 public:
20 DisplacementBaseBench(void* param, bool small) : 20 DisplacementBaseBench(bool small) :
21 INHERITED(param), fInitialized(false), fIsSmall(small) { 21 fInitialized(false), fIsSmall(small) {
22 } 22 }
23 23
24 protected: 24 protected:
25 virtual void onPreDraw() SK_OVERRIDE { 25 virtual void onPreDraw() SK_OVERRIDE {
26 if (!fInitialized) { 26 if (!fInitialized) {
27 make_bitmap(); 27 make_bitmap();
28 make_checkerboard(); 28 make_checkerboard();
29 fInitialized = true; 29 fInitialized = true;
30 } 30 }
31 } 31 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 SkBitmap fBitmap, fCheckerboard; 84 SkBitmap fBitmap, fCheckerboard;
85 private: 85 private:
86 bool fInitialized; 86 bool fInitialized;
87 bool fIsSmall; 87 bool fIsSmall;
88 typedef SkBenchmark INHERITED; 88 typedef SkBenchmark INHERITED;
89 }; 89 };
90 90
91 class DisplacementZeroBench : public DisplacementBaseBench { 91 class DisplacementZeroBench : public DisplacementBaseBench {
92 public: 92 public:
93 DisplacementZeroBench(void* param, bool small) : INHERITED(param, small) { 93 DisplacementZeroBench(bool small) : INHERITED(small) {
94 } 94 }
95 95
96 protected: 96 protected:
97 virtual const char* onGetName() SK_OVERRIDE { 97 virtual const char* onGetName() SK_OVERRIDE {
98 return isSmall() ? "displacement_zero_small" : "displacement_zero_large" ; 98 return isSmall() ? "displacement_zero_small" : "displacement_zero_large" ;
99 } 99 }
100 100
101 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 101 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
102 SkPaint paint; 102 SkPaint paint;
103 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 103 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
104 // No displacement effect 104 // No displacement effect
105 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 105 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
106 (SkDisplacementMapEffect::kR_ChannelSelectorType, 106 (SkDisplacementMapEffect::kR_ChannelSelectorType,
107 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref(); 107 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref();
108 108
109 for (int i = 0; i < this->getLoops(); i++) { 109 for (int i = 0; i < this->getLoops(); i++) {
110 drawClippedBitmap(canvas, 0, 0, paint); 110 drawClippedBitmap(canvas, 0, 0, paint);
111 } 111 }
112 } 112 }
113 113
114 private: 114 private:
115 typedef DisplacementBaseBench INHERITED; 115 typedef DisplacementBaseBench INHERITED;
116 }; 116 };
117 117
118 class DisplacementAlphaBench : public DisplacementBaseBench { 118 class DisplacementAlphaBench : public DisplacementBaseBench {
119 public: 119 public:
120 DisplacementAlphaBench(void* param, bool small) : INHERITED(param, small) { 120 DisplacementAlphaBench(bool small) : INHERITED(small) {
121 } 121 }
122 122
123 protected: 123 protected:
124 virtual const char* onGetName() SK_OVERRIDE { 124 virtual const char* onGetName() SK_OVERRIDE {
125 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e"; 125 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e";
126 } 126 }
127 127
128 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 128 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
129 SkPaint paint; 129 SkPaint paint;
130 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 130 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
131 // Displacement, with 1 alpha component (which isn't pre-multiplied) 131 // Displacement, with 1 alpha component (which isn't pre-multiplied)
132 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 132 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
133 (SkDisplacementMapEffect::kB_ChannelSelectorType, 133 (SkDisplacementMapEffect::kB_ChannelSelectorType,
134 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->u nref(); 134 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->u nref();
135 for (int i = 0; i < this->getLoops(); i++) { 135 for (int i = 0; i < this->getLoops(); i++) {
136 drawClippedBitmap(canvas, 100, 0, paint); 136 drawClippedBitmap(canvas, 100, 0, paint);
137 } 137 }
138 } 138 }
139 139
140 private: 140 private:
141 typedef DisplacementBaseBench INHERITED; 141 typedef DisplacementBaseBench INHERITED;
142 }; 142 };
143 143
144 class DisplacementFullBench : public DisplacementBaseBench { 144 class DisplacementFullBench : public DisplacementBaseBench {
145 public: 145 public:
146 DisplacementFullBench(void* param, bool small) : INHERITED(param, small) { 146 DisplacementFullBench(bool small) : INHERITED(small) {
147 } 147 }
148 148
149 protected: 149 protected:
150 virtual const char* onGetName() SK_OVERRIDE { 150 virtual const char* onGetName() SK_OVERRIDE {
151 return isSmall() ? "displacement_full_small" : "displacement_full_large" ; 151 return isSmall() ? "displacement_full_small" : "displacement_full_large" ;
152 } 152 }
153 153
154 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 154 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
155 SkPaint paint; 155 SkPaint paint;
156 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 156 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
157 // Displacement, with 2 non-alpha components 157 // Displacement, with 2 non-alpha components
158 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 158 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
159 (SkDisplacementMapEffect::kR_ChannelSelectorType, 159 (SkDisplacementMapEffect::kR_ChannelSelectorType,
160 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->u nref(); 160 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->u nref();
161 for (int i = 0; i < this->getLoops(); i++) { 161 for (int i = 0; i < this->getLoops(); i++) {
162 drawClippedBitmap(canvas, 200, 0, paint); 162 drawClippedBitmap(canvas, 200, 0, paint);
163 } 163 }
164 } 164 }
165 165
166 private: 166 private:
167 typedef DisplacementBaseBench INHERITED; 167 typedef DisplacementBaseBench INHERITED;
168 }; 168 };
169 169
170 /////////////////////////////////////////////////////////////////////////////// 170 ///////////////////////////////////////////////////////////////////////////////
171 171
172 DEF_BENCH( return new DisplacementZeroBench(p, true); ) 172 DEF_BENCH( return new DisplacementZeroBench(true); )
173 DEF_BENCH( return new DisplacementAlphaBench(p, true); ) 173 DEF_BENCH( return new DisplacementAlphaBench(true); )
174 DEF_BENCH( return new DisplacementFullBench(p, true); ) 174 DEF_BENCH( return new DisplacementFullBench(true); )
175 DEF_BENCH( return new DisplacementZeroBench(p, false); ) 175 DEF_BENCH( return new DisplacementZeroBench(false); )
176 DEF_BENCH( return new DisplacementAlphaBench(p, false); ) 176 DEF_BENCH( return new DisplacementAlphaBench(false); )
177 DEF_BENCH( return new DisplacementFullBench(p, false); ) 177 DEF_BENCH( return new DisplacementFullBench(false); )
OLDNEW
« no previous file with comments | « bench/DeferredSurfaceCopyBench.cpp ('k') | bench/FSRectBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698