OLD | NEW |
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 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkAAClip.h" | 9 #include "SkAAClip.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 50.5f, 50.5f); | 36 50.5f, 50.5f); |
37 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10)); | 37 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10)); |
38 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0), | 38 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0), |
39 SkIntToScalar(100), SkIntToScalar(100)); | 39 SkIntToScalar(100), SkIntToScalar(100)); |
40 | 40 |
41 SkASSERT(fClipPath.isConvex()); | 41 SkASSERT(fClipPath.isConvex()); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 virtual const char* onGetName() { return fName.c_str(); } | 45 virtual const char* onGetName() { return fName.c_str(); } |
46 virtual void onDraw(const int loops, SkCanvas* canvas) { | 46 virtual void onDraw(int loops, SkCanvas* canvas) { |
47 | 47 |
48 SkPaint paint; | 48 SkPaint paint; |
49 this->setupPaint(&paint); | 49 this->setupPaint(&paint); |
50 | 50 |
51 for (int i = 0; i < loops; ++i) { | 51 for (int i = 0; i < loops; ++i) { |
52 // jostle the clip regions each time to prevent caching | 52 // jostle the clip regions each time to prevent caching |
53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1
0), 0); | 53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1
0), 0); |
54 fClipPath.reset(); | 54 fClipPath.reset(); |
55 fClipPath.addRoundRect(fClipRect, | 55 fClipPath.addRoundRect(fClipRect, |
56 SkIntToScalar(5), SkIntToScalar(5)); | 56 SkIntToScalar(5), SkIntToScalar(5)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 this->recurse(canvas, depth+1, childOffset); | 151 this->recurse(canvas, depth+1, childOffset); |
152 | 152 |
153 childOffset.fX = offset.fX; | 153 childOffset.fX = offset.fX; |
154 childOffset.fY = offset.fY + fSizes[depth+1].fY; | 154 childOffset.fY = offset.fY + fSizes[depth+1].fY; |
155 this->recurse(canvas, depth+1, childOffset); | 155 this->recurse(canvas, depth+1, childOffset); |
156 } | 156 } |
157 | 157 |
158 canvas->restore(); | 158 canvas->restore(); |
159 } | 159 } |
160 | 160 |
161 virtual void onDraw(const int loops, SkCanvas* canvas) { | 161 virtual void onDraw(int loops, SkCanvas* canvas) { |
162 | 162 |
163 for (int i = 0; i < loops; ++i) { | 163 for (int i = 0; i < loops; ++i) { |
164 SkPoint offset = SkPoint::Make(0, 0); | 164 SkPoint offset = SkPoint::Make(0, 0); |
165 this->recurse(canvas, 0, offset); | 165 this->recurse(canvas, 0, offset); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 private: | 169 private: |
170 typedef Benchmark INHERITED; | 170 typedef Benchmark INHERITED; |
171 }; | 171 }; |
(...skipping 16 matching lines...) Expand all Loading... |
188 doAA ? "AA" : "BW"); | 188 doAA ? "AA" : "BW"); |
189 | 189 |
190 fRegion.setRect(0, 0, 640, 480); | 190 fRegion.setRect(0, 0, 640, 480); |
191 fRect.set(fRegion.getBounds()); | 191 fRect.set(fRegion.getBounds()); |
192 fRect.inset(SK_Scalar1/4, SK_Scalar1/4); | 192 fRect.inset(SK_Scalar1/4, SK_Scalar1/4); |
193 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20)); | 193 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20)); |
194 } | 194 } |
195 | 195 |
196 protected: | 196 protected: |
197 virtual const char* onGetName() { return fName.c_str(); } | 197 virtual const char* onGetName() { return fName.c_str(); } |
198 virtual void onDraw(const int loops, SkCanvas*) { | 198 virtual void onDraw(int loops, SkCanvas*) { |
199 SkPaint paint; | 199 SkPaint paint; |
200 this->setupPaint(&paint); | 200 this->setupPaint(&paint); |
201 | 201 |
202 for (int i = 0; i < loops; ++i) { | 202 for (int i = 0; i < loops; ++i) { |
203 SkAAClip clip; | 203 SkAAClip clip; |
204 if (fDoPath) { | 204 if (fDoPath) { |
205 clip.setPath(fPath, &fRegion, fDoAA); | 205 clip.setPath(fPath, &fRegion, fDoAA); |
206 } else { | 206 } else { |
207 clip.setRect(fRect, fDoAA); | 207 clip.setRect(fRect, fDoAA); |
208 } | 208 } |
(...skipping 14 matching lines...) Expand all Loading... |
223 // evenodd means we've constructed basically a stroked circle | 223 // evenodd means we've constructed basically a stroked circle |
224 path.setFillType(SkPath::kEvenOdd_FillType); | 224 path.setFillType(SkPath::kEvenOdd_FillType); |
225 | 225 |
226 SkIRect bounds; | 226 SkIRect bounds; |
227 path.getBounds().roundOut(&bounds); | 227 path.getBounds().roundOut(&bounds); |
228 fRegion.setPath(path, SkRegion(bounds)); | 228 fRegion.setPath(path, SkRegion(bounds)); |
229 } | 229 } |
230 | 230 |
231 protected: | 231 protected: |
232 virtual const char* onGetName() { return "aaclip_setregion"; } | 232 virtual const char* onGetName() { return "aaclip_setregion"; } |
233 virtual void onDraw(const int loops, SkCanvas*) { | 233 virtual void onDraw(int loops, SkCanvas*) { |
234 for (int i = 0; i < loops; ++i) { | 234 for (int i = 0; i < loops; ++i) { |
235 SkAAClip clip; | 235 SkAAClip clip; |
236 clip.setRegion(fRegion); | 236 clip.setRegion(fRegion); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 private: | 240 private: |
241 SkRegion fRegion; | 241 SkRegion fRegion; |
242 typedef Benchmark INHERITED; | 242 typedef Benchmark INHERITED; |
243 }; | 243 }; |
244 | 244 |
245 //////////////////////////////////////////////////////////////////////////////// | 245 //////////////////////////////////////////////////////////////////////////////// |
246 | 246 |
247 DEF_BENCH(return new AAClipBuilderBench(false, false);) | 247 DEF_BENCH(return new AAClipBuilderBench(false, false);) |
248 DEF_BENCH(return new AAClipBuilderBench(false, true);) | 248 DEF_BENCH(return new AAClipBuilderBench(false, true);) |
249 DEF_BENCH(return new AAClipBuilderBench(true, false);) | 249 DEF_BENCH(return new AAClipBuilderBench(true, false);) |
250 DEF_BENCH(return new AAClipBuilderBench(true, true);) | 250 DEF_BENCH(return new AAClipBuilderBench(true, true);) |
251 DEF_BENCH(return new AAClipRegionBench();) | 251 DEF_BENCH(return new AAClipRegionBench();) |
252 DEF_BENCH(return new AAClipBench(false, false);) | 252 DEF_BENCH(return new AAClipBench(false, false);) |
253 DEF_BENCH(return new AAClipBench(false, true);) | 253 DEF_BENCH(return new AAClipBench(false, true);) |
254 DEF_BENCH(return new AAClipBench(true, false);) | 254 DEF_BENCH(return new AAClipBench(true, false);) |
255 DEF_BENCH(return new AAClipBench(true, true);) | 255 DEF_BENCH(return new AAClipBench(true, true);) |
256 DEF_BENCH(return new NestedAAClipBench(false);) | 256 DEF_BENCH(return new NestedAAClipBench(false);) |
257 DEF_BENCH(return new NestedAAClipBench(true);) | 257 DEF_BENCH(return new NestedAAClipBench(true);) |
OLD | NEW |