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

Side by Side Diff: bench/HairlinePathBench.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/GradientBench.cpp ('k') | bench/ImageCacheBench.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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 14 matching lines...) Expand all
25 10, 10, 15, 5, 20, 20, 25 10, 10, 15, 5, 20, 20,
26 30, 5, 25, 20, 15, 12, 26 30, 5, 25, 20, 15, 12,
27 21, 21, 30, 30, 12, 4, 27 21, 21, 30, 30, 12, 4,
28 32, 28, 20, 18, 12, 10 28 32, 28, 20, 18, 12, 10
29 }; 29 };
30 30
31 static const int kMaxPathSize = 10; 31 static const int kMaxPathSize = 10;
32 32
33 class HairlinePathBench : public SkBenchmark { 33 class HairlinePathBench : public SkBenchmark {
34 public: 34 public:
35 HairlinePathBench(void* param, Flags flags) : INHERITED(param), fFlags(flags ) { 35 HairlinePathBench(Flags flags) : fFlags(flags) {
36 fPaint.setStyle(SkPaint::kStroke_Style); 36 fPaint.setStyle(SkPaint::kStroke_Style);
37 fPaint.setStrokeWidth(SkIntToScalar(0)); 37 fPaint.setStrokeWidth(SkIntToScalar(0));
38 } 38 }
39 39
40 virtual void appendName(SkString*) = 0; 40 virtual void appendName(SkString*) = 0;
41 virtual void makePath(SkPath*) = 0; 41 virtual void makePath(SkPath*) = 0;
42 42
43 protected: 43 protected:
44 virtual const char* onGetName() SK_OVERRIDE { 44 virtual const char* onGetName() SK_OVERRIDE {
45 fName.printf("path_hairline_%s_%s_", 45 fName.printf("path_hairline_%s_%s_",
(...skipping 24 matching lines...) Expand all
70 70
71 private: 71 private:
72 SkPaint fPaint; 72 SkPaint fPaint;
73 SkString fName; 73 SkString fName;
74 Flags fFlags; 74 Flags fFlags;
75 typedef SkBenchmark INHERITED; 75 typedef SkBenchmark INHERITED;
76 }; 76 };
77 77
78 class LinePathBench : public HairlinePathBench { 78 class LinePathBench : public HairlinePathBench {
79 public: 79 public:
80 LinePathBench(void* param, Flags flags) : INHERITED(param, flags) {} 80 LinePathBench(Flags flags) : INHERITED(flags) {}
81 81
82 virtual void appendName(SkString* name) SK_OVERRIDE { 82 virtual void appendName(SkString* name) SK_OVERRIDE {
83 name->append("line"); 83 name->append("line");
84 } 84 }
85 virtual void makePath(SkPath* path) SK_OVERRIDE { 85 virtual void makePath(SkPath* path) SK_OVERRIDE {
86 SkRandom rand; 86 SkRandom rand;
87 int size = SK_ARRAY_COUNT(points); 87 int size = SK_ARRAY_COUNT(points);
88 int hSize = size / 2; 88 int hSize = size / 2;
89 for (int i = 0; i < kMaxPathSize; ++i) { 89 for (int i = 0; i < kMaxPathSize; ++i) {
90 int xTrans = 10 + 40 * (i%(kMaxPathSize/2)); 90 int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
(...skipping 11 matching lines...) Expand all
102 path->lineTo(SkIntToScalar(points[base3] + xTrans), 102 path->lineTo(SkIntToScalar(points[base3] + xTrans),
103 SkIntToScalar(points[base3+1] + yTrans)); 103 SkIntToScalar(points[base3+1] + yTrans));
104 } 104 }
105 } 105 }
106 private: 106 private:
107 typedef HairlinePathBench INHERITED; 107 typedef HairlinePathBench INHERITED;
108 }; 108 };
109 109
110 class QuadPathBench : public HairlinePathBench { 110 class QuadPathBench : public HairlinePathBench {
111 public: 111 public:
112 QuadPathBench(void* param, Flags flags) : INHERITED(param, flags) {} 112 QuadPathBench(Flags flags) : INHERITED(flags) {}
113 113
114 virtual void appendName(SkString* name) SK_OVERRIDE { 114 virtual void appendName(SkString* name) SK_OVERRIDE {
115 name->append("quad"); 115 name->append("quad");
116 } 116 }
117 virtual void makePath(SkPath* path) SK_OVERRIDE { 117 virtual void makePath(SkPath* path) SK_OVERRIDE {
118 SkRandom rand; 118 SkRandom rand;
119 int size = SK_ARRAY_COUNT(points); 119 int size = SK_ARRAY_COUNT(points);
120 int hSize = size / 2; 120 int hSize = size / 2;
121 for (int i = 0; i < kMaxPathSize; ++i) { 121 for (int i = 0; i < kMaxPathSize; ++i) {
122 int xTrans = 10 + 40 * (i%(kMaxPathSize/2)); 122 int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
(...skipping 11 matching lines...) Expand all
134 SkIntToScalar(points[base3] + xTrans), 134 SkIntToScalar(points[base3] + xTrans),
135 SkIntToScalar(points[base3+1] + yTrans)); 135 SkIntToScalar(points[base3+1] + yTrans));
136 } 136 }
137 } 137 }
138 private: 138 private:
139 typedef HairlinePathBench INHERITED; 139 typedef HairlinePathBench INHERITED;
140 }; 140 };
141 141
142 class ConicPathBench : public HairlinePathBench { 142 class ConicPathBench : public HairlinePathBench {
143 public: 143 public:
144 ConicPathBench(void* param, Flags flags) : INHERITED(param, flags) {} 144 ConicPathBench(Flags flags) : INHERITED(flags) {}
145 145
146 virtual void appendName(SkString* name) SK_OVERRIDE { 146 virtual void appendName(SkString* name) SK_OVERRIDE {
147 name->append("conic"); 147 name->append("conic");
148 } 148 }
149 virtual void makePath(SkPath* path) SK_OVERRIDE { 149 virtual void makePath(SkPath* path) SK_OVERRIDE {
150 SkRandom rand; 150 SkRandom rand;
151 SkRandom randWeight; 151 SkRandom randWeight;
152 int size = SK_ARRAY_COUNT(points); 152 int size = SK_ARRAY_COUNT(points);
153 int hSize = size / 2; 153 int hSize = size / 2;
154 for (int i = 0; i < kMaxPathSize; ++i) { 154 for (int i = 0; i < kMaxPathSize; ++i) {
(...skipping 14 matching lines...) Expand all
169 SkIntToScalar(points[base3+1] + yTrans), 169 SkIntToScalar(points[base3+1] + yTrans),
170 weight); 170 weight);
171 } 171 }
172 } 172 }
173 private: 173 private:
174 typedef HairlinePathBench INHERITED; 174 typedef HairlinePathBench INHERITED;
175 }; 175 };
176 176
177 class CubicPathBench : public HairlinePathBench { 177 class CubicPathBench : public HairlinePathBench {
178 public: 178 public:
179 CubicPathBench(void* param, Flags flags) : INHERITED(param, flags) {} 179 CubicPathBench(Flags flags) : INHERITED(flags) {}
180 180
181 virtual void appendName(SkString* name) SK_OVERRIDE { 181 virtual void appendName(SkString* name) SK_OVERRIDE {
182 name->append("cubic"); 182 name->append("cubic");
183 } 183 }
184 virtual void makePath(SkPath* path) SK_OVERRIDE { 184 virtual void makePath(SkPath* path) SK_OVERRIDE {
185 SkRandom rand; 185 SkRandom rand;
186 int size = SK_ARRAY_COUNT(points); 186 int size = SK_ARRAY_COUNT(points);
187 int hSize = size / 2; 187 int hSize = size / 2;
188 for (int i = 0; i < kMaxPathSize; ++i) { 188 for (int i = 0; i < kMaxPathSize; ++i) {
189 int xTrans = 10 + 40 * (i%(kMaxPathSize/2)); 189 int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
(...skipping 17 matching lines...) Expand all
207 } 207 }
208 private: 208 private:
209 typedef HairlinePathBench INHERITED; 209 typedef HairlinePathBench INHERITED;
210 }; 210 };
211 211
212 // FLAG00 - no AA, small 212 // FLAG00 - no AA, small
213 // FLAG01 - no AA, small 213 // FLAG01 - no AA, small
214 // FLAG10 - AA, big 214 // FLAG10 - AA, big
215 // FLAG11 - AA, big 215 // FLAG11 - AA, big
216 216
217 DEF_BENCH( return new LinePathBench(p, FLAGS00); ) 217 DEF_BENCH( return new LinePathBench(FLAGS00); )
218 DEF_BENCH( return new LinePathBench(p, FLAGS01); ) 218 DEF_BENCH( return new LinePathBench(FLAGS01); )
219 DEF_BENCH( return new LinePathBench(p, FLAGS10); ) 219 DEF_BENCH( return new LinePathBench(FLAGS10); )
220 DEF_BENCH( return new LinePathBench(p, FLAGS11); ) 220 DEF_BENCH( return new LinePathBench(FLAGS11); )
221 221
222 DEF_BENCH( return new QuadPathBench(p, FLAGS00); ) 222 DEF_BENCH( return new QuadPathBench(FLAGS00); )
223 DEF_BENCH( return new QuadPathBench(p, FLAGS01); ) 223 DEF_BENCH( return new QuadPathBench(FLAGS01); )
224 DEF_BENCH( return new QuadPathBench(p, FLAGS10); ) 224 DEF_BENCH( return new QuadPathBench(FLAGS10); )
225 DEF_BENCH( return new QuadPathBench(p, FLAGS11); ) 225 DEF_BENCH( return new QuadPathBench(FLAGS11); )
226 226
227 // Don't have default path renderer for conics yet on GPU, so must use AA 227 // Don't have default path renderer for conics yet on GPU, so must use AA
228 // DEF_BENCH( return new ConicPathBench(p, FLAGS00); ) 228 // DEF_BENCH( return new ConicPathBench(FLAGS00); )
229 // DEF_BENCH( return new ConicPathBench(p, FLAGS01); ) 229 // DEF_BENCH( return new ConicPathBench(FLAGS01); )
230 DEF_BENCH( return new ConicPathBench(p, FLAGS10); ) 230 DEF_BENCH( return new ConicPathBench(FLAGS10); )
231 DEF_BENCH( return new ConicPathBench(p, FLAGS11); ) 231 DEF_BENCH( return new ConicPathBench(FLAGS11); )
232 232
233 DEF_BENCH( return new CubicPathBench(p, FLAGS00); ) 233 DEF_BENCH( return new CubicPathBench(FLAGS00); )
234 DEF_BENCH( return new CubicPathBench(p, FLAGS01); ) 234 DEF_BENCH( return new CubicPathBench(FLAGS01); )
235 DEF_BENCH( return new CubicPathBench(p, FLAGS10); ) 235 DEF_BENCH( return new CubicPathBench(FLAGS10); )
236 DEF_BENCH( return new CubicPathBench(p, FLAGS11); ) 236 DEF_BENCH( return new CubicPathBench(FLAGS11); )
OLDNEW
« no previous file with comments | « bench/GradientBench.cpp ('k') | bench/ImageCacheBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698