epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 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.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 8 | #include "SkBenchmark.h" |
| 9 | #include "SkBitmap.h" |
| 10 | #include "SkCanvas.h" |
| 11 | #include "SkColorPriv.h" |
| 12 | #include "SkPaint.h" |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 13 | #include "SkRandom.h" |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 14 | #include "SkShader.h" |
| 15 | #include "SkString.h" |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 16 | #include "SkTArray.h" |
| 17 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 18 | |
| 19 | enum 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 | |
| 29 | class PathBench : public SkBenchmark { |
| 30 | SkPaint fPaint; |
| 31 | SkString fName; |
| 32 | Flags fFlags; |
tomhudson@google.com | ca529d3 | 2011-10-28 15:34:49 +0000 | [diff] [blame] | 33 | enum { N = SkBENCHLOOP(1000) }; |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 34 | public: |
| 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.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 44 | virtual int complexity() { return 0; } |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 45 | |
| 46 | protected: |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 47 | virtual const char* onGetName() SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 48 | 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.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 55 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 56 | 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.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 71 | count >>= (3 * complexity()); |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 72 | |
| 73 | for (int i = 0; i < count; i++) { |
| 74 | canvas->drawPath(path, paint); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | private: |
| 79 | typedef SkBenchmark INHERITED; |
| 80 | }; |
| 81 | |
| 82 | class TrianglePathBench : public PathBench { |
| 83 | public: |
| 84 | TrianglePathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 85 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 86 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 87 | name->append("triangle"); |
| 88 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 89 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 90 | 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 | } |
| 98 | private: |
| 99 | typedef PathBench INHERITED; |
| 100 | }; |
| 101 | |
| 102 | class RectPathBench : public PathBench { |
| 103 | public: |
| 104 | RectPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 105 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 106 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 107 | name->append("rect"); |
| 108 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 109 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 110 | SkRect r = { 10, 10, 20, 20 }; |
| 111 | path->addRect(r); |
| 112 | } |
| 113 | private: |
| 114 | typedef PathBench INHERITED; |
| 115 | }; |
| 116 | |
| 117 | class OvalPathBench : public PathBench { |
| 118 | public: |
| 119 | OvalPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 120 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 121 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 122 | name->append("oval"); |
| 123 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 124 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 125 | SkRect r = { 10, 10, 20, 20 }; |
| 126 | path->addOval(r); |
| 127 | } |
| 128 | private: |
| 129 | typedef PathBench INHERITED; |
| 130 | }; |
| 131 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 132 | class CirclePathBench: public PathBench { |
| 133 | public: |
| 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 | } |
| 143 | private: |
| 144 | typedef PathBench INHERITED; |
| 145 | }; |
| 146 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 147 | class SawToothPathBench : public PathBench { |
| 148 | public: |
| 149 | SawToothPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 150 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 151 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 152 | 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.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 172 | virtual int complexity() SK_OVERRIDE { return 1; } |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 173 | private: |
| 174 | typedef PathBench INHERITED; |
| 175 | }; |
| 176 | |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 177 | class LongCurvedPathBench : public PathBench { |
| 178 | public: |
| 179 | LongCurvedPathBench(void * param, Flags flags) |
| 180 | : INHERITED(param, flags) { |
| 181 | } |
| 182 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 183 | virtual void appendName(SkString* name) SK_OVERRIDE { |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 184 | name->append("long_curved"); |
| 185 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 186 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 187 | 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.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 197 | virtual int complexity() SK_OVERRIDE { return 2; } |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 198 | private: |
| 199 | typedef PathBench INHERITED; |
| 200 | }; |
| 201 | |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 202 | class LongLinePathBench : public PathBench { |
| 203 | public: |
| 204 | LongLinePathBench(void * param, Flags flags) |
| 205 | : INHERITED(param, flags) { |
| 206 | } |
| 207 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 208 | virtual void appendName(SkString* name) SK_OVERRIDE { |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 209 | name->append("long_line"); |
| 210 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 211 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 212 | 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.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 218 | virtual int complexity() SK_OVERRIDE { return 2; } |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 219 | private: |
| 220 | typedef PathBench INHERITED; |
| 221 | }; |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 222 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 223 | class RandomPathBench : public SkBenchmark { |
| 224 | public: |
| 225 | RandomPathBench(void* param) : INHERITED(param) { |
| 226 | } |
| 227 | |
| 228 | protected: |
| 229 | void createData(int minVerbs, |
| 230 | int maxVerbs, |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 231 | bool allowMoves = true, |
| 232 | SkRect* bounds = NULL) { |
| 233 | SkRect tempBounds; |
| 234 | if (NULL == bounds) { |
| 235 | tempBounds.setXYWH(0, 0, SK_Scalar1, SK_Scalar1); |
| 236 | bounds = &tempBounds; |
| 237 | } |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 238 | fVerbCnts.reset(kNumVerbCnts); |
| 239 | for (int i = 0; i < kNumVerbCnts; ++i) { |
| 240 | fVerbCnts[i] = fRandom.nextRangeU(minVerbs, maxVerbs + 1); |
| 241 | } |
| 242 | fVerbs.reset(kNumVerbs); |
| 243 | for (int i = 0; i < kNumVerbs; ++i) { |
| 244 | do { |
| 245 | fVerbs[i] = static_cast<SkPath::Verb>(fRandom.nextULessThan(SkPath::kDone_Verb)); |
| 246 | } while (!allowMoves && SkPath::kMove_Verb == fVerbs[i]); |
| 247 | } |
| 248 | fPoints.reset(kNumPoints); |
| 249 | for (int i = 0; i < kNumPoints; ++i) { |
| 250 | fPoints[i].set(fRandom.nextRangeScalar(bounds->fLeft, bounds->fRight), |
| 251 | fRandom.nextRangeScalar(bounds->fTop, bounds->fBottom)); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 252 | } |
| 253 | this->restartMakingPaths(); |
| 254 | } |
| 255 | |
| 256 | void restartMakingPaths() { |
| 257 | fCurrPath = 0; |
| 258 | fCurrVerb = 0; |
| 259 | fCurrPoint = 0; |
| 260 | } |
| 261 | |
| 262 | void makePath(SkPath* path) { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 263 | int vCount = fVerbCnts[(fCurrPath++) & (kNumVerbCnts - 1)]; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 264 | for (int v = 0; v < vCount; ++v) { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 265 | int verb = fVerbs[(fCurrVerb++) & (kNumVerbs - 1)]; |
| 266 | switch (verb) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 267 | case SkPath::kMove_Verb: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 268 | path->moveTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 269 | break; |
| 270 | case SkPath::kLine_Verb: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 271 | path->lineTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 272 | break; |
| 273 | case SkPath::kQuad_Verb: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 274 | path->quadTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)], |
| 275 | fPoints[(fCurrPoint++) & (kNumPoints - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 276 | break; |
| 277 | case SkPath::kCubic_Verb: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 278 | path->cubicTo(fPoints[(fCurrPoint++) & (kNumPoints - 1)], |
| 279 | fPoints[(fCurrPoint++) & (kNumPoints - 1)], |
| 280 | fPoints[(fCurrPoint++) & (kNumPoints - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 281 | break; |
| 282 | case SkPath::kClose_Verb: |
| 283 | path->close(); |
| 284 | break; |
| 285 | default: |
| 286 | SkDEBUGFAIL("Unexpected path verb"); |
| 287 | break; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | void finishedMakingPaths() { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 293 | fVerbCnts.reset(0); |
| 294 | fVerbs.reset(0); |
| 295 | fPoints.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | private: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 299 | enum { |
| 300 | // these should all be pow 2 |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 301 | kNumVerbCnts = 1 << 5, |
| 302 | kNumVerbs = 1 << 5, |
| 303 | kNumPoints = 1 << 5, |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 304 | }; |
| 305 | SkAutoTArray<int> fVerbCnts; |
| 306 | SkAutoTArray<SkPath::Verb> fVerbs; |
| 307 | SkAutoTArray<SkPoint> fPoints; |
| 308 | int fCurrPath; |
| 309 | int fCurrVerb; |
| 310 | int fCurrPoint; |
| 311 | SkRandom fRandom; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 312 | typedef SkBenchmark INHERITED; |
| 313 | }; |
| 314 | |
| 315 | class PathCreateBench : public RandomPathBench { |
| 316 | public: |
| 317 | PathCreateBench(void* param) : INHERITED(param) { |
| 318 | } |
| 319 | |
| 320 | protected: |
| 321 | enum { N = SkBENCHLOOP(5000) }; |
| 322 | |
| 323 | virtual const char* onGetName() SK_OVERRIDE { |
| 324 | return "path_create"; |
| 325 | } |
| 326 | |
| 327 | virtual void onPreDraw() SK_OVERRIDE { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 328 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 329 | fPaths.reset(kPathCnt); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 333 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 334 | this->makePath(&fPaths[i & (kPathCnt - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 335 | } |
| 336 | this->restartMakingPaths(); |
| 337 | } |
| 338 | |
| 339 | virtual void onPostDraw() SK_OVERRIDE { |
| 340 | this->finishedMakingPaths(); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 341 | fPaths.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 345 | enum { |
| 346 | // must be a pow 2 |
| 347 | kPathCnt = 1 << 5, |
| 348 | }; |
| 349 | SkAutoTArray<SkPath> fPaths; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 350 | |
| 351 | typedef RandomPathBench INHERITED; |
| 352 | }; |
| 353 | |
| 354 | class PathCopyBench : public RandomPathBench { |
| 355 | public: |
| 356 | PathCopyBench(void* param) : INHERITED(param) { |
| 357 | } |
| 358 | |
| 359 | protected: |
bsalomon@google.com | 62e4190 | 2012-08-13 16:59:21 +0000 | [diff] [blame] | 360 | enum { N = SkBENCHLOOP(30000) }; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 361 | |
| 362 | virtual const char* onGetName() SK_OVERRIDE { |
| 363 | return "path_copy"; |
| 364 | } |
| 365 | virtual void onPreDraw() SK_OVERRIDE { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 366 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 367 | fPaths.reset(kPathCnt); |
| 368 | fCopies.reset(kPathCnt); |
| 369 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 370 | this->makePath(&fPaths[i]); |
| 371 | } |
| 372 | this->finishedMakingPaths(); |
| 373 | } |
| 374 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 375 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 376 | int idx = i & (kPathCnt - 1); |
| 377 | fCopies[idx] = fPaths[idx]; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 381 | fPaths.reset(0); |
| 382 | fCopies.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 386 | enum { |
| 387 | // must be a pow 2 |
| 388 | kPathCnt = 1 << 5, |
| 389 | }; |
| 390 | SkAutoTArray<SkPath> fPaths; |
| 391 | SkAutoTArray<SkPath> fCopies; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 392 | |
| 393 | typedef RandomPathBench INHERITED; |
| 394 | }; |
| 395 | |
| 396 | class PathTransformBench : public RandomPathBench { |
| 397 | public: |
| 398 | PathTransformBench(bool inPlace, void* param) |
| 399 | : INHERITED(param) |
| 400 | , fInPlace(inPlace) { |
| 401 | } |
| 402 | |
| 403 | protected: |
| 404 | enum { N = SkBENCHLOOP(30000) }; |
| 405 | |
| 406 | virtual const char* onGetName() SK_OVERRIDE { |
| 407 | return fInPlace ? "path_transform_in_place" : "path_transform_copy"; |
| 408 | } |
| 409 | |
| 410 | virtual void onPreDraw() SK_OVERRIDE { |
| 411 | fMatrix.setScale(5 * SK_Scalar1, 6 * SK_Scalar1); |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 412 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 413 | fPaths.reset(kPathCnt); |
| 414 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 415 | this->makePath(&fPaths[i]); |
| 416 | } |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 417 | this->finishedMakingPaths(); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 418 | if (!fInPlace) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 419 | fTransformed.reset(kPathCnt); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
| 423 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 424 | if (fInPlace) { |
| 425 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 426 | fPaths[i & (kPathCnt - 1)].transform(fMatrix); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 427 | } |
| 428 | } else { |
| 429 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 430 | int idx = i & (kPathCnt - 1); |
| 431 | fPaths[idx].transform(fMatrix, &fTransformed[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 437 | fPaths.reset(0); |
| 438 | fTransformed.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 442 | enum { |
| 443 | // must be a pow 2 |
| 444 | kPathCnt = 1 << 5, |
| 445 | }; |
| 446 | SkAutoTArray<SkPath> fPaths; |
| 447 | SkAutoTArray<SkPath> fTransformed; |
| 448 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 449 | SkMatrix fMatrix; |
| 450 | bool fInPlace; |
| 451 | typedef RandomPathBench INHERITED; |
| 452 | }; |
| 453 | |
| 454 | class PathEqualityBench : public RandomPathBench { |
| 455 | public: |
| 456 | PathEqualityBench(void* param) |
| 457 | : INHERITED(param) { |
| 458 | } |
| 459 | |
| 460 | protected: |
| 461 | enum { N = SkBENCHLOOP(40000) }; |
| 462 | |
| 463 | virtual const char* onGetName() SK_OVERRIDE { |
| 464 | return "path_equality_50%"; |
| 465 | } |
| 466 | |
| 467 | virtual void onPreDraw() SK_OVERRIDE { |
| 468 | fParity = 0; |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 469 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 470 | fPaths.reset(kPathCnt); |
| 471 | fCopies.reset(kPathCnt); |
| 472 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 473 | this->makePath(&fPaths[i]); |
| 474 | fCopies[i] = fPaths[i]; |
| 475 | } |
| 476 | this->finishedMakingPaths(); |
| 477 | } |
| 478 | |
| 479 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 480 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 481 | int idx = i & (kPathCnt - 1); |
| 482 | fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | |
| 486 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 487 | fPaths.reset(0); |
| 488 | fCopies.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | private: |
| 492 | bool fParity; // attempt to keep compiler from optimizing out the == |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 493 | enum { |
| 494 | // must be a pow 2 |
| 495 | kPathCnt = 1 << 5, |
| 496 | }; |
| 497 | SkAutoTArray<SkPath> fPaths; |
| 498 | SkAutoTArray<SkPath> fCopies; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 499 | typedef RandomPathBench INHERITED; |
| 500 | }; |
| 501 | |
| 502 | class SkBench_AddPathTest : public RandomPathBench { |
| 503 | public: |
| 504 | enum AddType { |
| 505 | kAdd_AddType, |
| 506 | kAddTrans_AddType, |
| 507 | kAddMatrix_AddType, |
| 508 | kPathTo_AddType, |
| 509 | kReverseAdd_AddType, |
| 510 | kReversePathTo_AddType, |
| 511 | }; |
| 512 | |
| 513 | SkBench_AddPathTest(AddType type, void* param) |
| 514 | : INHERITED(param) |
| 515 | , fType(type) { |
| 516 | fMatrix.setRotate(60 * SK_Scalar1); |
| 517 | } |
| 518 | |
| 519 | protected: |
| 520 | enum { N = SkBENCHLOOP(15000) }; |
| 521 | |
| 522 | virtual const char* onGetName() SK_OVERRIDE { |
| 523 | switch (fType) { |
| 524 | case kAdd_AddType: |
| 525 | return "path_add_path"; |
| 526 | case kAddTrans_AddType: |
| 527 | return "path_add_path_trans"; |
| 528 | case kAddMatrix_AddType: |
| 529 | return "path_add_path_matrix"; |
| 530 | case kPathTo_AddType: |
| 531 | return "path_path_to"; |
| 532 | case kReverseAdd_AddType: |
| 533 | return "path_reverse_add_path"; |
| 534 | case kReversePathTo_AddType: |
| 535 | return "path_reverse_path_to"; |
| 536 | default: |
| 537 | SkDEBUGFAIL("Bad add type"); |
| 538 | return ""; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | virtual void onPreDraw() SK_OVERRIDE { |
| 543 | // pathTo and reversePathTo assume a single contour path. |
| 544 | bool allowMoves = kPathTo_AddType != fType && |
| 545 | kReversePathTo_AddType != fType; |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 546 | this->createData(10, 100, allowMoves); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 547 | fPaths0.reset(kPathCnt); |
| 548 | fPaths1.reset(kPathCnt); |
| 549 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 550 | this->makePath(&fPaths0[i]); |
| 551 | this->makePath(&fPaths1[i]); |
| 552 | } |
| 553 | this->finishedMakingPaths(); |
| 554 | } |
| 555 | |
| 556 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 557 | switch (fType) { |
| 558 | case kAdd_AddType: |
| 559 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 560 | int idx = i & (kPathCnt - 1); |
| 561 | SkPath result = fPaths0[idx]; |
| 562 | result.addPath(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 563 | } |
| 564 | break; |
| 565 | case kAddTrans_AddType: |
| 566 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 567 | int idx = i & (kPathCnt - 1); |
| 568 | SkPath result = fPaths0[idx]; |
| 569 | result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 570 | } |
| 571 | break; |
| 572 | case kAddMatrix_AddType: |
| 573 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 574 | int idx = i & (kPathCnt - 1); |
| 575 | SkPath result = fPaths0[idx]; |
| 576 | result.addPath(fPaths1[idx], fMatrix); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 577 | } |
| 578 | break; |
| 579 | case kPathTo_AddType: |
| 580 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 581 | int idx = i & (kPathCnt - 1); |
| 582 | SkPath result = fPaths0[idx]; |
| 583 | result.pathTo(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 584 | } |
| 585 | break; |
| 586 | case kReverseAdd_AddType: |
| 587 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 588 | int idx = i & (kPathCnt - 1); |
| 589 | SkPath result = fPaths0[idx]; |
| 590 | result.reverseAddPath(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 591 | } |
| 592 | break; |
| 593 | case kReversePathTo_AddType: |
| 594 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 595 | int idx = i & (kPathCnt - 1); |
| 596 | SkPath result = fPaths0[idx]; |
| 597 | result.reversePathTo(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 598 | } |
| 599 | break; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 604 | fPaths0.reset(0); |
| 605 | fPaths1.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | private: |
| 609 | AddType fType; // or reverseAddPath |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 610 | enum { |
| 611 | // must be a pow 2 |
| 612 | kPathCnt = 1 << 5, |
| 613 | }; |
| 614 | SkAutoTArray<SkPath> fPaths0; |
| 615 | SkAutoTArray<SkPath> fPaths1; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 616 | SkMatrix fMatrix; |
| 617 | typedef RandomPathBench INHERITED; |
| 618 | }; |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 619 | |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 620 | |
| 621 | class CirclesBench : public SkBenchmark { |
| 622 | protected: |
| 623 | SkString fName; |
| 624 | |
| 625 | enum { |
| 626 | N = SkBENCHLOOP(100) |
| 627 | }; |
| 628 | public: |
| 629 | CirclesBench(void* param) : INHERITED(param) { |
| 630 | fName.printf("circles"); |
| 631 | } |
| 632 | |
| 633 | protected: |
| 634 | virtual const char* onGetName() SK_OVERRIDE { |
| 635 | return fName.c_str(); |
| 636 | } |
| 637 | |
| 638 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 639 | SkPaint paint; |
| 640 | |
| 641 | paint.setColor(SK_ColorBLACK); |
| 642 | paint.setAntiAlias(true); |
| 643 | |
| 644 | SkRandom rand; |
| 645 | |
| 646 | SkRect r; |
| 647 | |
| 648 | for (int i = 0; i < 5000; ++i) { |
| 649 | SkScalar radius = rand.nextUScalar1() * 3; |
| 650 | r.fLeft = rand.nextUScalar1() * 300; |
| 651 | r.fTop = rand.nextUScalar1() * 300; |
| 652 | r.fRight = r.fLeft + 2 * radius; |
| 653 | r.fBottom = r.fTop + 2 * radius; |
| 654 | |
| 655 | SkPath temp; |
| 656 | |
| 657 | // mimic how Chrome does circles |
| 658 | temp.arcTo(r, 0, 0, false); |
| 659 | temp.addOval(r, SkPath::kCCW_Direction); |
| 660 | temp.arcTo(r, 360, 0, true); |
| 661 | temp.close(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 662 | |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 663 | canvas->drawPath(temp, paint); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | private: |
| 668 | typedef SkBenchmark INHERITED; |
| 669 | }; |
| 670 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 671 | static SkBenchmark* FactT00(void* p) { return new TrianglePathBench(p, FLAGS00); } |
| 672 | static SkBenchmark* FactT01(void* p) { return new TrianglePathBench(p, FLAGS01); } |
| 673 | static SkBenchmark* FactT10(void* p) { return new TrianglePathBench(p, FLAGS10); } |
| 674 | static SkBenchmark* FactT11(void* p) { return new TrianglePathBench(p, FLAGS11); } |
| 675 | |
| 676 | static SkBenchmark* FactR00(void* p) { return new RectPathBench(p, FLAGS00); } |
| 677 | static SkBenchmark* FactR01(void* p) { return new RectPathBench(p, FLAGS01); } |
| 678 | static SkBenchmark* FactR10(void* p) { return new RectPathBench(p, FLAGS10); } |
| 679 | static SkBenchmark* FactR11(void* p) { return new RectPathBench(p, FLAGS11); } |
| 680 | |
| 681 | static SkBenchmark* FactO00(void* p) { return new OvalPathBench(p, FLAGS00); } |
| 682 | static SkBenchmark* FactO01(void* p) { return new OvalPathBench(p, FLAGS01); } |
| 683 | static SkBenchmark* FactO10(void* p) { return new OvalPathBench(p, FLAGS10); } |
| 684 | static SkBenchmark* FactO11(void* p) { return new OvalPathBench(p, FLAGS11); } |
| 685 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 686 | static SkBenchmark* FactC00(void* p) { return new CirclePathBench(p, FLAGS00); } |
| 687 | static SkBenchmark* FactC01(void* p) { return new CirclePathBench(p, FLAGS01); } |
| 688 | static SkBenchmark* FactC10(void* p) { return new CirclePathBench(p, FLAGS10); } |
| 689 | static SkBenchmark* FactC11(void* p) { return new CirclePathBench(p, FLAGS11); } |
| 690 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 691 | static SkBenchmark* FactS00(void* p) { return new SawToothPathBench(p, FLAGS00); } |
| 692 | static SkBenchmark* FactS01(void* p) { return new SawToothPathBench(p, FLAGS01); } |
| 693 | |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 694 | static SkBenchmark* FactLC00(void* p) { |
| 695 | return new LongCurvedPathBench(p, FLAGS00); |
| 696 | } |
| 697 | static SkBenchmark* FactLC01(void* p) { |
| 698 | return new LongCurvedPathBench(p, FLAGS01); |
| 699 | } |
| 700 | |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 701 | static SkBenchmark* FactLL00(void* p) { |
| 702 | return new LongLinePathBench(p, FLAGS00); |
| 703 | } |
| 704 | |
| 705 | static SkBenchmark* FactLL01(void* p) { |
| 706 | return new LongLinePathBench(p, FLAGS01); |
| 707 | } |
| 708 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 709 | static BenchRegistry gRegT00(FactT00); |
| 710 | static BenchRegistry gRegT01(FactT01); |
| 711 | static BenchRegistry gRegT10(FactT10); |
| 712 | static BenchRegistry gRegT11(FactT11); |
| 713 | |
| 714 | static BenchRegistry gRegR00(FactR00); |
| 715 | static BenchRegistry gRegR01(FactR01); |
| 716 | static BenchRegistry gRegR10(FactR10); |
| 717 | static BenchRegistry gRegR11(FactR11); |
| 718 | |
| 719 | static BenchRegistry gRegO00(FactO00); |
| 720 | static BenchRegistry gRegO01(FactO01); |
| 721 | static BenchRegistry gRegO10(FactO10); |
| 722 | static BenchRegistry gRegO11(FactO11); |
| 723 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 724 | static BenchRegistry gRegC00(FactC00); |
| 725 | static BenchRegistry gRegC01(FactC01); |
| 726 | static BenchRegistry gRegC10(FactC10); |
| 727 | static BenchRegistry gRegC11(FactC11); |
| 728 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 729 | static BenchRegistry gRegS00(FactS00); |
| 730 | static BenchRegistry gRegS01(FactS01); |
| 731 | |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 732 | static BenchRegistry gRegLC00(FactLC00); |
| 733 | static BenchRegistry gRegLC01(FactLC01); |
| 734 | |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 735 | static BenchRegistry gRegLL00(FactLL00); |
| 736 | static BenchRegistry gRegLL01(FactLL01); |
| 737 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 738 | static SkBenchmark* FactCreate(void* p) { return new PathCreateBench(p); } |
| 739 | static BenchRegistry gRegCreate(FactCreate); |
| 740 | |
| 741 | static SkBenchmark* FactCopy(void* p) { return new PathCopyBench(p); } |
| 742 | static BenchRegistry gRegCopy(FactCopy); |
| 743 | |
| 744 | static SkBenchmark* FactPathTransformInPlace(void* p) { return new PathTransformBench(true, p); } |
| 745 | static BenchRegistry gRegPathTransformInPlace(FactPathTransformInPlace); |
| 746 | |
| 747 | static SkBenchmark* FactPathTransformCopy(void* p) { return new PathTransformBench(false, p); } |
| 748 | static BenchRegistry gRegPathTransformCopy(FactPathTransformCopy); |
| 749 | |
| 750 | static SkBenchmark* FactEquality(void* p) { return new PathEqualityBench(p); } |
| 751 | static BenchRegistry gRegEquality(FactEquality); |
| 752 | |
| 753 | static SkBenchmark* FactAdd(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kAdd_AddType, p); } |
| 754 | static SkBenchmark* FactAddTrans(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kAddTrans_AddType, p); } |
| 755 | static SkBenchmark* FactAddMatrix(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kAddMatrix_AddType, p); } |
| 756 | static SkBenchmark* FactPathTo(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kPathTo_AddType, p); } |
| 757 | static SkBenchmark* FactReverseAdd(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kReverseAdd_AddType, p); } |
| 758 | static SkBenchmark* FactReverseTo(void* p) { return new SkBench_AddPathTest(SkBench_AddPathTest::kReversePathTo_AddType, p); } |
| 759 | |
| 760 | static BenchRegistry gRegAdd(FactAdd); |
| 761 | static BenchRegistry gRegAddTrans(FactAddTrans); |
| 762 | static BenchRegistry gRegAddMatrix(FactAddMatrix); |
| 763 | static BenchRegistry gRegPathTo(FactPathTo); |
| 764 | static BenchRegistry gRegReverseAdd(FactReverseAdd); |
| 765 | static BenchRegistry gRegReverseTo(FactReverseTo); |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 766 | |
| 767 | static SkBenchmark* CirclesTest(void* p) { return new CirclesBench(p); } |
| 768 | static BenchRegistry gRegCirclesTest(CirclesTest); |
| 769 | |