blob: 3292ce028f725a8fc8611cf6ed49220eccf90d3d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@google.comd34658a2011-04-11 13:12:51 +00008#include "SkBenchmark.h"
9#include "SkBitmap.h"
10#include "SkCanvas.h"
11#include "SkColorPriv.h"
12#include "SkPaint.h"
tomhudson@google.com6e8d3352011-06-22 17:16:35 +000013#include "SkRandom.h"
reed@google.comd34658a2011-04-11 13:12:51 +000014#include "SkShader.h"
15#include "SkString.h"
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +000016#include "SkTArray.h"
17
reed@google.comd34658a2011-04-11 13:12:51 +000018
19enum Flags {
20 kStroke_Flag = 1 << 0,
21 kBig_Flag = 1 << 1
22};
23
24#define FLAGS00 Flags(0)
25#define FLAGS01 Flags(kStroke_Flag)
26#define FLAGS10 Flags(kBig_Flag)
27#define FLAGS11 Flags(kStroke_Flag | kBig_Flag)
28
29class PathBench : public SkBenchmark {
30 SkPaint fPaint;
31 SkString fName;
32 Flags fFlags;
tomhudson@google.comca529d32011-10-28 15:34:49 +000033 enum { N = SkBENCHLOOP(1000) };
reed@google.comd34658a2011-04-11 13:12:51 +000034public:
35 PathBench(void* param, Flags flags) : INHERITED(param), fFlags(flags) {
36 fPaint.setStyle(flags & kStroke_Flag ? SkPaint::kStroke_Style :
37 SkPaint::kFill_Style);
38 fPaint.setStrokeWidth(SkIntToScalar(5));
39 fPaint.setStrokeJoin(SkPaint::kBevel_Join);
40 }
41
42 virtual void appendName(SkString*) = 0;
43 virtual void makePath(SkPath*) = 0;
tomhudson@google.com6e8d3352011-06-22 17:16:35 +000044 virtual int complexity() { return 0; }
reed@google.comd34658a2011-04-11 13:12:51 +000045
46protected:
bsalomon@google.com1647a192012-04-11 15:34:46 +000047 virtual const char* onGetName() SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +000048 fName.printf("path_%s_%s_",
49 fFlags & kStroke_Flag ? "stroke" : "fill",
50 fFlags & kBig_Flag ? "big" : "small");
51 this->appendName(&fName);
52 return fName.c_str();
53 }
54
bsalomon@google.com1647a192012-04-11 15:34:46 +000055 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +000056 SkPaint paint(fPaint);
57 this->setupPaint(&paint);
58
59 SkPath path;
60 this->makePath(&path);
61 if (fFlags & kBig_Flag) {
62 SkMatrix m;
63 m.setScale(SkIntToScalar(10), SkIntToScalar(10));
64 path.transform(m);
65 }
66
67 int count = N;
68 if (fFlags & kBig_Flag) {
69 count >>= 2;
70 }
tomhudson@google.com6e8d3352011-06-22 17:16:35 +000071 count >>= (3 * complexity());
reed@google.comd34658a2011-04-11 13:12:51 +000072
73 for (int i = 0; i < count; i++) {
74 canvas->drawPath(path, paint);
75 }
76 }
77
78private:
79 typedef SkBenchmark INHERITED;
80};
81
82class TrianglePathBench : public PathBench {
83public:
84 TrianglePathBench(void* param, Flags flags) : INHERITED(param, flags) {}
rmistry@google.comfbfcd562012-08-23 18:09:54 +000085
bsalomon@google.com1647a192012-04-11 15:34:46 +000086 virtual void appendName(SkString* name) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +000087 name->append("triangle");
88 }
bsalomon@google.com1647a192012-04-11 15:34:46 +000089 virtual void makePath(SkPath* path) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +000090 static const int gCoord[] = {
91 10, 10, 15, 5, 20, 20
92 };
93 path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1]));
94 path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3]));
95 path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]));
96 path->close();
97 }
98private:
99 typedef PathBench INHERITED;
100};
101
102class RectPathBench : public PathBench {
103public:
104 RectPathBench(void* param, Flags flags) : INHERITED(param, flags) {}
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000105
bsalomon@google.com1647a192012-04-11 15:34:46 +0000106 virtual void appendName(SkString* name) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +0000107 name->append("rect");
108 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000109 virtual void makePath(SkPath* path) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +0000110 SkRect r = { 10, 10, 20, 20 };
111 path->addRect(r);
112 }
113private:
114 typedef PathBench INHERITED;
115};
116
117class OvalPathBench : public PathBench {
118public:
119 OvalPathBench(void* param, Flags flags) : INHERITED(param, flags) {}
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000120
bsalomon@google.com1647a192012-04-11 15:34:46 +0000121 virtual void appendName(SkString* name) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +0000122 name->append("oval");
123 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000124 virtual void makePath(SkPath* path) SK_OVERRIDE {
jvanverth@google.come2bfd8b2013-01-24 15:45:35 +0000125 SkRect r = { 10, 10, 23, 20 };
reed@google.comd34658a2011-04-11 13:12:51 +0000126 path->addOval(r);
127 }
128private:
129 typedef PathBench INHERITED;
130};
131
bsalomon@google.com1647a192012-04-11 15:34:46 +0000132class CirclePathBench: public PathBench {
133public:
134 CirclePathBench(void* param, Flags flags) : INHERITED(param, flags) {}
135
136 virtual void appendName(SkString* name) SK_OVERRIDE {
137 name->append("circle");
138 }
139 virtual void makePath(SkPath* path) SK_OVERRIDE {
140 path->addCircle(SkIntToScalar(20), SkIntToScalar(20),
141 SkIntToScalar(10));
142 }
143private:
144 typedef PathBench INHERITED;
145};
146
reed@google.comd34658a2011-04-11 13:12:51 +0000147class SawToothPathBench : public PathBench {
148public:
149 SawToothPathBench(void* param, Flags flags) : INHERITED(param, flags) {}
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000150
bsalomon@google.com1647a192012-04-11 15:34:46 +0000151 virtual void appendName(SkString* name) SK_OVERRIDE {
reed@google.comd34658a2011-04-11 13:12:51 +0000152 name->append("sawtooth");
153 }
154 virtual void makePath(SkPath* path) {
155 SkScalar x = SkIntToScalar(20);
156 SkScalar y = SkIntToScalar(20);
157 const SkScalar x0 = x;
158 const SkScalar dx = SK_Scalar1 * 5;
159 const SkScalar dy = SK_Scalar1 * 10;
160
161 path->moveTo(x, y);
162 for (int i = 0; i < 32; i++) {
163 x += dx;
164 path->lineTo(x, y - dy);
165 x += dx;
166 path->lineTo(x, y + dy);
167 }
168 path->lineTo(x, y + 2 * dy);
169 path->lineTo(x0, y + 2 * dy);
170 path->close();
171 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000172 virtual int complexity() SK_OVERRIDE { return 1; }
reed@google.comd34658a2011-04-11 13:12:51 +0000173private:
174 typedef PathBench INHERITED;
175};
176
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000177class LongCurvedPathBench : public PathBench {
178public:
179 LongCurvedPathBench(void * param, Flags flags)
180 : INHERITED(param, flags) {
181 }
182
bsalomon@google.com1647a192012-04-11 15:34:46 +0000183 virtual void appendName(SkString* name) SK_OVERRIDE {
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000184 name->append("long_curved");
185 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000186 virtual void makePath(SkPath* path) SK_OVERRIDE {
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000187 SkRandom rand (12);
188 int i;
189 for (i = 0; i < 100; i++) {
190 path->quadTo(SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
191 SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)),
192 SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
193 SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)));
194 }
195 path->close();
196 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000197 virtual int complexity() SK_OVERRIDE { return 2; }
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000198private:
199 typedef PathBench INHERITED;
200};
201
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000202class LongLinePathBench : public PathBench {
203public:
204 LongLinePathBench(void * param, Flags flags)
205 : INHERITED(param, flags) {
206 }
207
bsalomon@google.com1647a192012-04-11 15:34:46 +0000208 virtual void appendName(SkString* name) SK_OVERRIDE {
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000209 name->append("long_line");
210 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000211 virtual void makePath(SkPath* path) SK_OVERRIDE {
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000212 SkRandom rand;
213 path->moveTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
214 for (size_t i = 1; i < 100; i++) {
215 path->lineTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480);
216 }
217 }
bsalomon@google.com1647a192012-04-11 15:34:46 +0000218 virtual int complexity() SK_OVERRIDE { return 2; }
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000219private:
220 typedef PathBench INHERITED;
221};
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000222
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000223class RandomPathBench : public SkBenchmark {
224public:
225 RandomPathBench(void* param) : INHERITED(param) {
robertphillips@google.com83187a22012-09-13 16:39:08 +0000226 fIsRendering = false;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000227 }
228
229protected:
230 void createData(int minVerbs,
231 int maxVerbs,
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000232 bool allowMoves = true,
233 SkRect* bounds = NULL) {
234 SkRect tempBounds;
235 if (NULL == bounds) {
236 tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1);
237 bounds = &tempBounds;
238 }
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000239 fVerbCnts.reset(kNumVerbCnts);
240 for (int i = 0; i < kNumVerbCnts; ++i) {
241 fVerbCnts[i] = fRandom.nextRangeU(minVerbs, maxVerbs + 1);
242 }
243 fVerbs.reset(kNumVerbs);
244 for (int i = 0; i < kNumVerbs; ++i) {
245 do {
246 fVerbs[i] = static_cast<SkPath::Verb>(fRandom.nextULessThan(SkPath::kDone_Verb));
247 } while (!allowMoves && SkPath::kMove_Verb == fVerbs[i]);
248 }
249 fPoints.reset(kNumPoints);
250 for (int i = 0; i < kNumPoints; ++i) {
251 fPoints[i].set(fRandom.nextRangeScalar(bounds->fLeft, bounds->fRight),
252 fRandom.nextRangeScalar(bounds->fTop, bounds->fBottom));
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000253 }
254 this->restartMakingPaths();
255 }
256
257 void restartMakingPaths() {
258 fCurrPath = 0;
259 fCurrVerb = 0;
260 fCurrPoint = 0;
261 }
262
263 void makePath(SkPath* path) {
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000264 int vCount = fVerbCnts[(fCurrPath++) & (kNumVerbCnts - 1)];
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000265 for (int v = 0; v < vCount; ++v) {
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000266 int verb = fVerbs[(fCurrVerb++) & (kNumVerbs - 1)];
267 switch (verb) {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000268 case SkPath::kMove_Verb:
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000269 path->moveTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000270 break;
271 case SkPath::kLine_Verb:
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000272 path->lineTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000273 break;
274 case SkPath::kQuad_Verb:
bsalomon@google.com373ebc62012-09-26 13:08:56 +0000275 path->quadTo(fPoints[(fCurrPoint + 0) & (kNumPoints - 1)],
276 fPoints[(fCurrPoint + 1) & (kNumPoints - 1)]);
277 fCurrPoint += 2;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000278 break;
279 case SkPath::kCubic_Verb:
bsalomon@google.com373ebc62012-09-26 13:08:56 +0000280 path->cubicTo(fPoints[(fCurrPoint + 0) & (kNumPoints - 1)],
281 fPoints[(fCurrPoint + 1) & (kNumPoints - 1)],
282 fPoints[(fCurrPoint + 2) & (kNumPoints - 1)]);
283 fCurrPoint += 3;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000284 break;
285 case SkPath::kClose_Verb:
286 path->close();
287 break;
288 default:
289 SkDEBUGFAIL("Unexpected path verb");
290 break;
291 }
292 }
293 }
294
295 void finishedMakingPaths() {
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000296 fVerbCnts.reset(0);
297 fVerbs.reset(0);
298 fPoints.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000299 }
300
301private:
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000302 enum {
303 // these should all be pow 2
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000304 kNumVerbCnts = 1 << 5,
305 kNumVerbs = 1 << 5,
306 kNumPoints = 1 << 5,
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000307 };
308 SkAutoTArray<int> fVerbCnts;
309 SkAutoTArray<SkPath::Verb> fVerbs;
310 SkAutoTArray<SkPoint> fPoints;
311 int fCurrPath;
312 int fCurrVerb;
313 int fCurrPoint;
314 SkRandom fRandom;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000315 typedef SkBenchmark INHERITED;
316};
317
318class PathCreateBench : public RandomPathBench {
319public:
320 PathCreateBench(void* param) : INHERITED(param) {
321 }
322
323protected:
324 enum { N = SkBENCHLOOP(5000) };
325
326 virtual const char* onGetName() SK_OVERRIDE {
327 return "path_create";
328 }
329
330 virtual void onPreDraw() SK_OVERRIDE {
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000331 this->createData(10, 100);
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000332 fPaths.reset(kPathCnt);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000333 }
334
335 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
336 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000337 this->makePath(&fPaths[i & (kPathCnt - 1)]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000338 }
339 this->restartMakingPaths();
340 }
341
342 virtual void onPostDraw() SK_OVERRIDE {
343 this->finishedMakingPaths();
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000344 fPaths.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000345 }
346
347private:
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000348 enum {
349 // must be a pow 2
350 kPathCnt = 1 << 5,
351 };
352 SkAutoTArray<SkPath> fPaths;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000353
354 typedef RandomPathBench INHERITED;
355};
356
357class PathCopyBench : public RandomPathBench {
358public:
359 PathCopyBench(void* param) : INHERITED(param) {
360 }
361
362protected:
bsalomon@google.com62e41902012-08-13 16:59:21 +0000363 enum { N = SkBENCHLOOP(30000) };
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000364
365 virtual const char* onGetName() SK_OVERRIDE {
366 return "path_copy";
367 }
368 virtual void onPreDraw() SK_OVERRIDE {
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000369 this->createData(10, 100);
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000370 fPaths.reset(kPathCnt);
371 fCopies.reset(kPathCnt);
372 for (int i = 0; i < kPathCnt; ++i) {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000373 this->makePath(&fPaths[i]);
374 }
375 this->finishedMakingPaths();
376 }
377 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
378 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000379 int idx = i & (kPathCnt - 1);
380 fCopies[idx] = fPaths[idx];
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000381 }
382 }
383 virtual void onPostDraw() SK_OVERRIDE {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000384 fPaths.reset(0);
385 fCopies.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000386 }
387
388private:
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000389 enum {
390 // must be a pow 2
391 kPathCnt = 1 << 5,
392 };
393 SkAutoTArray<SkPath> fPaths;
394 SkAutoTArray<SkPath> fCopies;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000395
396 typedef RandomPathBench INHERITED;
397};
398
399class PathTransformBench : public RandomPathBench {
400public:
401 PathTransformBench(bool inPlace, void* param)
402 : INHERITED(param)
403 , fInPlace(inPlace) {
404 }
405
406protected:
407 enum { N = SkBENCHLOOP(30000) };
408
409 virtual const char* onGetName() SK_OVERRIDE {
410 return fInPlace ? "path_transform_in_place" : "path_transform_copy";
411 }
412
413 virtual void onPreDraw() SK_OVERRIDE {
414 fMatrix.setScale(5 * SK_Scalar1, 6 * SK_Scalar1);
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000415 this->createData(10, 100);
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000416 fPaths.reset(kPathCnt);
417 for (int i = 0; i < kPathCnt; ++i) {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000418 this->makePath(&fPaths[i]);
419 }
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000420 this->finishedMakingPaths();
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000421 if (!fInPlace) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000422 fTransformed.reset(kPathCnt);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000423 }
424 }
425
426 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
427 if (fInPlace) {
428 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000429 fPaths[i & (kPathCnt - 1)].transform(fMatrix);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000430 }
431 } else {
432 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000433 int idx = i & (kPathCnt - 1);
434 fPaths[idx].transform(fMatrix, &fTransformed[idx]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000435 }
436 }
437 }
438
439 virtual void onPostDraw() SK_OVERRIDE {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000440 fPaths.reset(0);
441 fTransformed.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000442 }
443
444private:
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000445 enum {
446 // must be a pow 2
447 kPathCnt = 1 << 5,
448 };
449 SkAutoTArray<SkPath> fPaths;
450 SkAutoTArray<SkPath> fTransformed;
451
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000452 SkMatrix fMatrix;
453 bool fInPlace;
454 typedef RandomPathBench INHERITED;
455};
456
457class PathEqualityBench : public RandomPathBench {
458public:
459 PathEqualityBench(void* param)
460 : INHERITED(param) {
461 }
462
463protected:
464 enum { N = SkBENCHLOOP(40000) };
465
466 virtual const char* onGetName() SK_OVERRIDE {
467 return "path_equality_50%";
468 }
469
470 virtual void onPreDraw() SK_OVERRIDE {
471 fParity = 0;
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000472 this->createData(10, 100);
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000473 fPaths.reset(kPathCnt);
474 fCopies.reset(kPathCnt);
475 for (int i = 0; i < kPathCnt; ++i) {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000476 this->makePath(&fPaths[i]);
477 fCopies[i] = fPaths[i];
478 }
479 this->finishedMakingPaths();
480 }
481
482 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
483 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000484 int idx = i & (kPathCnt - 1);
485 fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000486 }
487 }
488
489 virtual void onPostDraw() SK_OVERRIDE {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000490 fPaths.reset(0);
491 fCopies.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000492 }
493
494private:
495 bool fParity; // attempt to keep compiler from optimizing out the ==
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000496 enum {
497 // must be a pow 2
498 kPathCnt = 1 << 5,
499 };
500 SkAutoTArray<SkPath> fPaths;
501 SkAutoTArray<SkPath> fCopies;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000502 typedef RandomPathBench INHERITED;
503};
504
505class SkBench_AddPathTest : public RandomPathBench {
506public:
507 enum AddType {
508 kAdd_AddType,
509 kAddTrans_AddType,
510 kAddMatrix_AddType,
511 kPathTo_AddType,
512 kReverseAdd_AddType,
513 kReversePathTo_AddType,
514 };
515
516 SkBench_AddPathTest(AddType type, void* param)
517 : INHERITED(param)
518 , fType(type) {
519 fMatrix.setRotate(60 * SK_Scalar1);
520 }
521
522protected:
523 enum { N = SkBENCHLOOP(15000) };
524
525 virtual const char* onGetName() SK_OVERRIDE {
526 switch (fType) {
527 case kAdd_AddType:
528 return "path_add_path";
529 case kAddTrans_AddType:
530 return "path_add_path_trans";
531 case kAddMatrix_AddType:
532 return "path_add_path_matrix";
533 case kPathTo_AddType:
534 return "path_path_to";
535 case kReverseAdd_AddType:
536 return "path_reverse_add_path";
537 case kReversePathTo_AddType:
538 return "path_reverse_path_to";
539 default:
540 SkDEBUGFAIL("Bad add type");
541 return "";
542 }
543 }
544
545 virtual void onPreDraw() SK_OVERRIDE {
546 // pathTo and reversePathTo assume a single contour path.
547 bool allowMoves = kPathTo_AddType != fType &&
548 kReversePathTo_AddType != fType;
bsalomon@google.com6d552ee2012-08-14 15:10:09 +0000549 this->createData(10, 100, allowMoves);
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000550 fPaths0.reset(kPathCnt);
551 fPaths1.reset(kPathCnt);
552 for (int i = 0; i < kPathCnt; ++i) {
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000553 this->makePath(&fPaths0[i]);
554 this->makePath(&fPaths1[i]);
555 }
556 this->finishedMakingPaths();
557 }
558
559 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
560 switch (fType) {
561 case kAdd_AddType:
562 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000563 int idx = i & (kPathCnt - 1);
564 SkPath result = fPaths0[idx];
565 result.addPath(fPaths1[idx]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000566 }
567 break;
568 case kAddTrans_AddType:
569 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000570 int idx = i & (kPathCnt - 1);
571 SkPath result = fPaths0[idx];
572 result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000573 }
574 break;
575 case kAddMatrix_AddType:
576 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000577 int idx = i & (kPathCnt - 1);
578 SkPath result = fPaths0[idx];
579 result.addPath(fPaths1[idx], fMatrix);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000580 }
581 break;
582 case kPathTo_AddType:
583 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000584 int idx = i & (kPathCnt - 1);
585 SkPath result = fPaths0[idx];
586 result.pathTo(fPaths1[idx]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000587 }
588 break;
589 case kReverseAdd_AddType:
590 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000591 int idx = i & (kPathCnt - 1);
592 SkPath result = fPaths0[idx];
593 result.reverseAddPath(fPaths1[idx]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000594 }
595 break;
596 case kReversePathTo_AddType:
597 for (int i = 0; i < N; ++i) {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000598 int idx = i & (kPathCnt - 1);
599 SkPath result = fPaths0[idx];
600 result.reversePathTo(fPaths1[idx]);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000601 }
602 break;
603 }
604 }
605
606 virtual void onPostDraw() SK_OVERRIDE {
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000607 fPaths0.reset(0);
608 fPaths1.reset(0);
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000609 }
610
611private:
612 AddType fType; // or reverseAddPath
bsalomon@google.comb5e47032012-08-14 17:49:46 +0000613 enum {
614 // must be a pow 2
615 kPathCnt = 1 << 5,
616 };
617 SkAutoTArray<SkPath> fPaths0;
618 SkAutoTArray<SkPath> fPaths1;
bsalomon@google.com30e6d2c2012-08-13 14:03:31 +0000619 SkMatrix fMatrix;
620 typedef RandomPathBench INHERITED;
621};
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000622
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000623
624class CirclesBench : public SkBenchmark {
625protected:
626 SkString fName;
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000627 Flags fFlags;
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000628
629 enum {
630 N = SkBENCHLOOP(100)
631 };
632public:
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000633 CirclesBench(void* param, Flags flags) : INHERITED(param), fFlags(flags) {
634 fName.printf("circles_%s", fFlags & kStroke_Flag ? "stroke" : "fill");
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000635 }
636
637protected:
638 virtual const char* onGetName() SK_OVERRIDE {
639 return fName.c_str();
640 }
641
642 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
643 SkPaint paint;
644
645 paint.setColor(SK_ColorBLACK);
646 paint.setAntiAlias(true);
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000647 if (fFlags & kStroke_Flag) {
648 paint.setStyle(SkPaint::kStroke_Style);
649 }
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000650
651 SkRandom rand;
652
653 SkRect r;
654
655 for (int i = 0; i < 5000; ++i) {
656 SkScalar radius = rand.nextUScalar1() * 3;
657 r.fLeft = rand.nextUScalar1() * 300;
658 r.fTop = rand.nextUScalar1() * 300;
659 r.fRight = r.fLeft + 2 * radius;
660 r.fBottom = r.fTop + 2 * radius;
661
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000662 if (fFlags & kStroke_Flag) {
663 paint.setStrokeWidth(rand.nextUScalar1() * 5.0f);
664 }
665
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000666 SkPath temp;
667
668 // mimic how Chrome does circles
669 temp.arcTo(r, 0, 0, false);
670 temp.addOval(r, SkPath::kCCW_Direction);
671 temp.arcTo(r, 360, 0, true);
672 temp.close();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000673
robertphillips@google.com17bb4582012-08-20 17:24:16 +0000674 canvas->drawPath(temp, paint);
675 }
676 }
677
678private:
679 typedef SkBenchmark INHERITED;
680};
681
jvanverth@google.com46d3d392013-01-22 13:34:01 +0000682
robertphillips@google.com158618e2012-10-23 16:56:56 +0000683// Chrome creates its own round rects with each corner possibly being different.
684// In its "zero radius" incarnation it creates degenerate round rects.
skia.committer@gmail.com1e34ff72012-10-24 02:01:24 +0000685// Note: PathTest::test_arb_round_rect_is_convex and
robertphillips@google.com158618e2012-10-23 16:56:56 +0000686// test_arb_zero_rad_round_rect_is_rect perform almost exactly
robertphillips@google.comb95eaa82012-10-18 15:26:12 +0000687// the same test (but with no drawing)
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000688class ArbRoundRectBench : public SkBenchmark {
689protected:
690 SkString fName;
691
692 enum {
693 N = SkBENCHLOOP(100)
694 };
695public:
robertphillips@google.com158618e2012-10-23 16:56:56 +0000696 ArbRoundRectBench(void* param, bool zeroRad) : INHERITED(param), fZeroRad(zeroRad) {
697 if (zeroRad) {
698 fName.printf("zeroradroundrect");
699 } else {
700 fName.printf("arbroundrect");
701 }
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000702 }
703
704protected:
705 virtual const char* onGetName() SK_OVERRIDE {
706 return fName.c_str();
707 }
708
skia.committer@gmail.com989a95e2012-10-18 02:01:23 +0000709 static void add_corner_arc(SkPath* path, const SkRect& rect,
710 SkScalar xIn, SkScalar yIn,
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000711 int startAngle)
712 {
713
714 SkScalar rx = SkMinScalar(rect.width(), xIn);
715 SkScalar ry = SkMinScalar(rect.height(), yIn);
716
717 SkRect arcRect;
718 arcRect.set(-rx, -ry, rx, ry);
719 switch (startAngle) {
720 case 0:
721 arcRect.offset(rect.fRight - arcRect.fRight, rect.fBottom - arcRect.fBottom);
722 break;
723 case 90:
724 arcRect.offset(rect.fLeft - arcRect.fLeft, rect.fBottom - arcRect.fBottom);
725 break;
726 case 180:
727 arcRect.offset(rect.fLeft - arcRect.fLeft, rect.fTop - arcRect.fTop);
728 break;
729 case 270:
730 arcRect.offset(rect.fRight - arcRect.fRight, rect.fTop - arcRect.fTop);
731 break;
732 default:
733 break;
734 }
735
736 path->arcTo(arcRect, SkIntToScalar(startAngle), SkIntToScalar(90), false);
737 }
738
skia.committer@gmail.com989a95e2012-10-18 02:01:23 +0000739 static void make_arb_round_rect(SkPath* path, const SkRect& r,
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000740 SkScalar xCorner, SkScalar yCorner) {
741 // we are lazy here and use the same x & y for each corner
742 add_corner_arc(path, r, xCorner, yCorner, 270);
743 add_corner_arc(path, r, xCorner, yCorner, 0);
744 add_corner_arc(path, r, xCorner, yCorner, 90);
745 add_corner_arc(path, r, xCorner, yCorner, 180);
robertphillips@google.com158618e2012-10-23 16:56:56 +0000746 path->close();
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000747
robertphillips@google.comb95eaa82012-10-18 15:26:12 +0000748 SkASSERT(path->isConvex());
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000749 }
750
751 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
752 SkRandom rand;
753 SkRect r;
754
755 for (int i = 0; i < 5000; ++i) {
756 SkPaint paint;
757 paint.setColor(0xff000000 | rand.nextU());
758 paint.setAntiAlias(true);
759
robertphillips@google.com158618e2012-10-23 16:56:56 +0000760 SkScalar size = rand.nextUScalar1() * 30;
761 if (size < SK_Scalar1) {
robertphillips@google.comb95eaa82012-10-18 15:26:12 +0000762 continue;
763 }
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000764 r.fLeft = rand.nextUScalar1() * 300;
765 r.fTop = rand.nextUScalar1() * 300;
robertphillips@google.com158618e2012-10-23 16:56:56 +0000766 r.fRight = r.fLeft + 2 * size;
767 r.fBottom = r.fTop + 2 * size;
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000768
769 SkPath temp;
770
robertphillips@google.com158618e2012-10-23 16:56:56 +0000771 if (fZeroRad) {
772 make_arb_round_rect(&temp, r, 0, 0);
773
774 SkASSERT(temp.isRect(NULL));
775 } else {
776 make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15);
777 }
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000778
779 canvas->drawPath(temp, paint);
780 }
781 }
782
783private:
robertphillips@google.com158618e2012-10-23 16:56:56 +0000784 bool fZeroRad; // should 0 radius rounds rects be tested?
785
robertphillips@google.comf6fc3fc2012-10-17 15:23:21 +0000786 typedef SkBenchmark INHERITED;
787};
788
bsalomon@google.com9bee33a2012-11-13 21:51:38 +0000789class ConservativelyContainsBench : public SkBenchmark {
790public:
791 enum Type {
792 kRect_Type,
793 kRoundRect_Type,
794 kOval_Type,
795 };
796
797 ConservativelyContainsBench(void* param, Type type) : INHERITED(param) {
798 fIsRendering = false;
799 fParity = false;
800 fName = "conservatively_contains_";
801 switch (type) {
802 case kRect_Type:
803 fName.append("rect");
804 fPath.addRect(kBaseRect);
805 break;
806 case kRoundRect_Type:
807 fName.append("round_rect");
808 fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]);
809 break;
810 case kOval_Type:
811 fName.append("oval");
812 fPath.addOval(kBaseRect);
813 break;
814 }
815 }
816
817private:
818 virtual const char* onGetName() SK_OVERRIDE {
819 return fName.c_str();
820 }
821
sugoi@google.com77472f02013-03-05 18:50:01 +0000822 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
bsalomon@google.com9bee33a2012-11-13 21:51:38 +0000823 for (int i = 0; i < N; ++i) {
824 const SkRect& rect = fQueryRects[i % kQueryRectCnt];
825 fParity = fParity != fPath.conservativelyContainsRect(rect);
826 }
827 }
828
829 virtual void onPreDraw() SK_OVERRIDE {
830 fQueryRects.setCount(kQueryRectCnt);
831
832 SkRandom rand;
833 for (int i = 0; i < kQueryRectCnt; ++i) {
834 SkSize size;
835 SkPoint xy;
836 size.fWidth = rand.nextRangeScalar(kQueryMin.fWidth, kQueryMax.fWidth);
837 size.fHeight = rand.nextRangeScalar(kQueryMin.fHeight, kQueryMax.fHeight);
838 xy.fX = rand.nextRangeScalar(kBounds.fLeft, kBounds.fRight - size.fWidth);
839 xy.fY = rand.nextRangeScalar(kBounds.fTop, kBounds.fBottom - size.fHeight);
840
841 fQueryRects[i] = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeight);
842 }
843 }
844
845 virtual void onPostDraw() SK_OVERRIDE {
846 fQueryRects.setCount(0);
847 }
848
849 enum {
850 N = SkBENCHLOOP(100000),
851 kQueryRectCnt = 400,
852 };
853 static const SkRect kBounds; // bounds for all random query rects
854 static const SkSize kQueryMin; // minimum query rect size, should be <= kQueryMax
855 static const SkSize kQueryMax; // max query rect size, should < kBounds
856 static const SkRect kBaseRect; // rect that is used to construct the path
857 static const SkScalar kRRRadii[2]; // x and y radii for round rect
858
859 SkString fName;
860 SkPath fPath;
861 bool fParity;
862 SkTDArray<SkRect> fQueryRects;
863
864 typedef SkBenchmark INHERITED;
865};
866
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000867///////////////////////////////////////////////////////////////////////////////
868
869#include "SkGeometry.h"
870
871class RationalQuadBench_Chop5 : public SkBenchmark {
872 enum {
873 N = 100000
874 };
875 SkRationalQuad fRQ;
876public:
877 RationalQuadBench_Chop5(void* param) : INHERITED(param) {
878 fRQ.fPts[0].set(0, 0);
879 fRQ.fPts[1].set(100, 0);
880 fRQ.fPts[2].set(100, 100);
881 fRQ.fW = SkScalarCos(SK_ScalarPI/4);
882 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000883
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000884private:
885 virtual const char* onGetName() SK_OVERRIDE {
886 return "ratquad-chop-0.5";
887 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000888
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000889 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
890 SkRationalQuad dst[2];
891 for (int i = 0; i < N; ++i) {
892 fRQ.chopAt(0.5f, dst);
893 }
894 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000895
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000896 typedef SkBenchmark INHERITED;
897};
898
899class RationalQuadBench_ChopHalf : public SkBenchmark {
900 enum {
901 N = 100000
902 };
903 SkRationalQuad fRQ;
904public:
905 RationalQuadBench_ChopHalf(void* param) : INHERITED(param) {
906 fRQ.fPts[0].set(0, 0);
907 fRQ.fPts[1].set(100, 0);
908 fRQ.fPts[2].set(100, 100);
909 fRQ.fW = SkScalarCos(SK_ScalarPI/4);
910 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000911
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000912private:
913 virtual const char* onGetName() SK_OVERRIDE {
914 return "ratquad-chop-half";
915 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000916
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000917 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
918 SkRationalQuad dst[2];
919 for (int i = 0; i < N; ++i) {
920 fRQ.chop(dst);
921 }
922 }
skia.committer@gmail.comab38e562013-04-14 07:01:08 +0000923
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000924 typedef SkBenchmark INHERITED;
925};
926
927///////////////////////////////////////////////////////////////////////////////
928
bsalomon@google.com9bee33a2012-11-13 21:51:38 +0000929const SkRect ConservativelyContainsBench::kBounds = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
930const SkSize ConservativelyContainsBench::kQueryMin = SkSize::Make(SkIntToScalar(1), SkIntToScalar(1));
931const SkSize ConservativelyContainsBench::kQueryMax = SkSize::Make(SkIntToScalar(40), SkIntToScalar(40));
932const SkRect ConservativelyContainsBench::kBaseRect = SkRect::MakeXYWH(SkIntToScalar(25), SkIntToScalar(25), SkIntToScalar(50), SkIntToScalar(50));
933const SkScalar ConservativelyContainsBench::kRRRadii[2] = {SkIntToScalar(5), SkIntToScalar(10)};
934
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000935DEF_BENCH( return new TrianglePathBench(p, FLAGS00); )
936DEF_BENCH( return new TrianglePathBench(p, FLAGS01); )
937DEF_BENCH( return new TrianglePathBench(p, FLAGS10); )
938DEF_BENCH( return new TrianglePathBench(p, FLAGS11); )
reed@google.comd34658a2011-04-11 13:12:51 +0000939
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000940DEF_BENCH( return new RectPathBench(p, FLAGS00); )
941DEF_BENCH( return new RectPathBench(p, FLAGS01); )
942DEF_BENCH( return new RectPathBench(p, FLAGS10); )
943DEF_BENCH( return new RectPathBench(p, FLAGS11); )
reed@google.comd34658a2011-04-11 13:12:51 +0000944
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000945DEF_BENCH( return new OvalPathBench(p, FLAGS00); )
946DEF_BENCH( return new OvalPathBench(p, FLAGS01); )
947DEF_BENCH( return new OvalPathBench(p, FLAGS10); )
948DEF_BENCH( return new OvalPathBench(p, FLAGS11); )
reed@google.comd34658a2011-04-11 13:12:51 +0000949
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000950DEF_BENCH( return new CirclePathBench(p, FLAGS00); )
951DEF_BENCH( return new CirclePathBench(p, FLAGS01); )
952DEF_BENCH( return new CirclePathBench(p, FLAGS10); )
953DEF_BENCH( return new CirclePathBench(p, FLAGS11); )
bsalomon@google.com1647a192012-04-11 15:34:46 +0000954
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000955DEF_BENCH( return new SawToothPathBench(p, FLAGS00); )
956DEF_BENCH( return new SawToothPathBench(p, FLAGS01); )
reed@google.comd34658a2011-04-11 13:12:51 +0000957
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000958DEF_BENCH( return new LongCurvedPathBench(p, FLAGS00); )
959DEF_BENCH( return new LongCurvedPathBench(p, FLAGS01); )
960DEF_BENCH( return new LongLinePathBench(p, FLAGS00); )
961DEF_BENCH( return new LongLinePathBench(p, FLAGS01); )
tomhudson@google.com6e8d3352011-06-22 17:16:35 +0000962
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000963DEF_BENCH( return new PathCreateBench(p); )
964DEF_BENCH( return new PathCopyBench(p); )
965DEF_BENCH( return new PathTransformBench(true, p); )
966DEF_BENCH( return new PathTransformBench(false, p); )
967DEF_BENCH( return new PathEqualityBench(p); )
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000968
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000969DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAdd_AddType, p); )
970DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddTrans_AddType, p); )
971DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddMatrix_AddType, p); )
972DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kPathTo_AddType, p); )
973DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReverseAdd_AddType, p); )
974DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReversePathTo_AddType, p); )
senorblanco@chromium.orge50f7362012-01-12 19:10:35 +0000975
mike@reedtribe.org0cf7b822013-02-04 05:05:36 +0000976DEF_BENCH( return new CirclesBench(p, FLAGS00); )
977DEF_BENCH( return new CirclesBench(p, FLAGS01); )
978DEF_BENCH( return new ArbRoundRectBench(p, false); )
979DEF_BENCH( return new ArbRoundRectBench(p, true); )
980DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kRect_Type); )
981DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kRoundRect_Type); )
982DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kOval_Type); )
mike@reedtribe.org8d551012013-04-14 02:40:50 +0000983
984DEF_BENCH( return new RationalQuadBench_Chop5(p) )
985DEF_BENCH( return new RationalQuadBench_ChopHalf(p) )