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 | enum Flags { |
| 19 | kStroke_Flag = 1 << 0, |
| 20 | kBig_Flag = 1 << 1 |
| 21 | }; |
| 22 | |
| 23 | #define FLAGS00 Flags(0) |
| 24 | #define FLAGS01 Flags(kStroke_Flag) |
| 25 | #define FLAGS10 Flags(kBig_Flag) |
| 26 | #define FLAGS11 Flags(kStroke_Flag | kBig_Flag) |
| 27 | |
| 28 | class PathBench : public SkBenchmark { |
| 29 | SkPaint fPaint; |
| 30 | SkString fName; |
| 31 | Flags fFlags; |
tomhudson@google.com | ca529d3 | 2011-10-28 15:34:49 +0000 | [diff] [blame] | 32 | enum { N = SkBENCHLOOP(1000) }; |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 33 | public: |
| 34 | PathBench(void* param, Flags flags) : INHERITED(param), fFlags(flags) { |
| 35 | fPaint.setStyle(flags & kStroke_Flag ? SkPaint::kStroke_Style : |
| 36 | SkPaint::kFill_Style); |
| 37 | fPaint.setStrokeWidth(SkIntToScalar(5)); |
| 38 | fPaint.setStrokeJoin(SkPaint::kBevel_Join); |
| 39 | } |
| 40 | |
| 41 | virtual void appendName(SkString*) = 0; |
| 42 | virtual void makePath(SkPath*) = 0; |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 43 | virtual int complexity() { return 0; } |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 44 | |
| 45 | protected: |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 46 | virtual const char* onGetName() SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 47 | fName.printf("path_%s_%s_", |
| 48 | fFlags & kStroke_Flag ? "stroke" : "fill", |
| 49 | fFlags & kBig_Flag ? "big" : "small"); |
| 50 | this->appendName(&fName); |
| 51 | return fName.c_str(); |
| 52 | } |
| 53 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 54 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 55 | SkPaint paint(fPaint); |
| 56 | this->setupPaint(&paint); |
| 57 | |
| 58 | SkPath path; |
| 59 | this->makePath(&path); |
| 60 | if (fFlags & kBig_Flag) { |
| 61 | SkMatrix m; |
| 62 | m.setScale(SkIntToScalar(10), SkIntToScalar(10)); |
| 63 | path.transform(m); |
| 64 | } |
| 65 | |
| 66 | int count = N; |
| 67 | if (fFlags & kBig_Flag) { |
| 68 | count >>= 2; |
| 69 | } |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 70 | count >>= (3 * complexity()); |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 71 | |
| 72 | for (int i = 0; i < count; i++) { |
| 73 | canvas->drawPath(path, paint); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | private: |
| 78 | typedef SkBenchmark INHERITED; |
| 79 | }; |
| 80 | |
| 81 | class TrianglePathBench : public PathBench { |
| 82 | public: |
| 83 | TrianglePathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 84 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 85 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 86 | name->append("triangle"); |
| 87 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 88 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 89 | static const int gCoord[] = { |
| 90 | 10, 10, 15, 5, 20, 20 |
| 91 | }; |
| 92 | path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1])); |
| 93 | path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3])); |
| 94 | path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5])); |
| 95 | path->close(); |
| 96 | } |
| 97 | private: |
| 98 | typedef PathBench INHERITED; |
| 99 | }; |
| 100 | |
| 101 | class RectPathBench : public PathBench { |
| 102 | public: |
| 103 | RectPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 104 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 105 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 106 | name->append("rect"); |
| 107 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 108 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 109 | SkRect r = { 10, 10, 20, 20 }; |
| 110 | path->addRect(r); |
| 111 | } |
| 112 | private: |
| 113 | typedef PathBench INHERITED; |
| 114 | }; |
| 115 | |
| 116 | class OvalPathBench : public PathBench { |
| 117 | public: |
| 118 | OvalPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 119 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 120 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 121 | name->append("oval"); |
| 122 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 123 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
jvanverth@google.com | e2bfd8b | 2013-01-24 15:45:35 +0000 | [diff] [blame] | 124 | SkRect r = { 10, 10, 23, 20 }; |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 125 | path->addOval(r); |
| 126 | } |
| 127 | private: |
| 128 | typedef PathBench INHERITED; |
| 129 | }; |
| 130 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 131 | class CirclePathBench: public PathBench { |
| 132 | public: |
| 133 | CirclePathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
| 134 | |
| 135 | virtual void appendName(SkString* name) SK_OVERRIDE { |
| 136 | name->append("circle"); |
| 137 | } |
| 138 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
| 139 | path->addCircle(SkIntToScalar(20), SkIntToScalar(20), |
| 140 | SkIntToScalar(10)); |
| 141 | } |
| 142 | private: |
| 143 | typedef PathBench INHERITED; |
| 144 | }; |
| 145 | |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 146 | class SawToothPathBench : public PathBench { |
| 147 | public: |
| 148 | SawToothPathBench(void* param, Flags flags) : INHERITED(param, flags) {} |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 149 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 150 | virtual void appendName(SkString* name) SK_OVERRIDE { |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 151 | name->append("sawtooth"); |
| 152 | } |
| 153 | virtual void makePath(SkPath* path) { |
| 154 | SkScalar x = SkIntToScalar(20); |
| 155 | SkScalar y = SkIntToScalar(20); |
| 156 | const SkScalar x0 = x; |
| 157 | const SkScalar dx = SK_Scalar1 * 5; |
| 158 | const SkScalar dy = SK_Scalar1 * 10; |
| 159 | |
| 160 | path->moveTo(x, y); |
| 161 | for (int i = 0; i < 32; i++) { |
| 162 | x += dx; |
| 163 | path->lineTo(x, y - dy); |
| 164 | x += dx; |
| 165 | path->lineTo(x, y + dy); |
| 166 | } |
| 167 | path->lineTo(x, y + 2 * dy); |
| 168 | path->lineTo(x0, y + 2 * dy); |
| 169 | path->close(); |
| 170 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 171 | virtual int complexity() SK_OVERRIDE { return 1; } |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 172 | private: |
| 173 | typedef PathBench INHERITED; |
| 174 | }; |
| 175 | |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 176 | class LongCurvedPathBench : public PathBench { |
| 177 | public: |
| 178 | LongCurvedPathBench(void * param, Flags flags) |
| 179 | : INHERITED(param, flags) { |
| 180 | } |
| 181 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 182 | virtual void appendName(SkString* name) SK_OVERRIDE { |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 183 | name->append("long_curved"); |
| 184 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 185 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 186 | SkRandom rand (12); |
| 187 | int i; |
| 188 | for (i = 0; i < 100; i++) { |
| 189 | path->quadTo(SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)), |
| 190 | SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)), |
| 191 | SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)), |
| 192 | SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480))); |
| 193 | } |
| 194 | path->close(); |
| 195 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 196 | virtual int complexity() SK_OVERRIDE { return 2; } |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 197 | private: |
| 198 | typedef PathBench INHERITED; |
| 199 | }; |
| 200 | |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 201 | class LongLinePathBench : public PathBench { |
| 202 | public: |
| 203 | LongLinePathBench(void * param, Flags flags) |
| 204 | : INHERITED(param, flags) { |
| 205 | } |
| 206 | |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 207 | virtual void appendName(SkString* name) SK_OVERRIDE { |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 208 | name->append("long_line"); |
| 209 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 210 | virtual void makePath(SkPath* path) SK_OVERRIDE { |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 211 | SkRandom rand; |
| 212 | path->moveTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); |
| 213 | for (size_t i = 1; i < 100; i++) { |
| 214 | path->lineTo(rand.nextUScalar1() * 640, rand.nextUScalar1() * 480); |
| 215 | } |
| 216 | } |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 217 | virtual int complexity() SK_OVERRIDE { return 2; } |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 218 | private: |
| 219 | typedef PathBench INHERITED; |
| 220 | }; |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 221 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 222 | class RandomPathBench : public SkBenchmark { |
| 223 | public: |
| 224 | RandomPathBench(void* param) : INHERITED(param) { |
robertphillips@google.com | 83187a2 | 2012-09-13 16:39:08 +0000 | [diff] [blame] | 225 | fIsRendering = false; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 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 | 373ebc6 | 2012-09-26 13:08:56 +0000 | [diff] [blame] | 274 | path->quadTo(fPoints[(fCurrPoint + 0) & (kNumPoints - 1)], |
| 275 | fPoints[(fCurrPoint + 1) & (kNumPoints - 1)]); |
| 276 | fCurrPoint += 2; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 277 | break; |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 278 | case SkPath::kConic_Verb: |
| 279 | path->conicTo(fPoints[(fCurrPoint + 0) & (kNumPoints - 1)], |
| 280 | fPoints[(fCurrPoint + 1) & (kNumPoints - 1)], |
| 281 | SK_ScalarHalf); |
| 282 | fCurrPoint += 2; |
| 283 | break; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 284 | case SkPath::kCubic_Verb: |
bsalomon@google.com | 373ebc6 | 2012-09-26 13:08:56 +0000 | [diff] [blame] | 285 | path->cubicTo(fPoints[(fCurrPoint + 0) & (kNumPoints - 1)], |
| 286 | fPoints[(fCurrPoint + 1) & (kNumPoints - 1)], |
| 287 | fPoints[(fCurrPoint + 2) & (kNumPoints - 1)]); |
| 288 | fCurrPoint += 3; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 289 | break; |
| 290 | case SkPath::kClose_Verb: |
| 291 | path->close(); |
| 292 | break; |
| 293 | default: |
| 294 | SkDEBUGFAIL("Unexpected path verb"); |
| 295 | break; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | void finishedMakingPaths() { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 301 | fVerbCnts.reset(0); |
| 302 | fVerbs.reset(0); |
| 303 | fPoints.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | private: |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 307 | enum { |
| 308 | // these should all be pow 2 |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 309 | kNumVerbCnts = 1 << 5, |
| 310 | kNumVerbs = 1 << 5, |
| 311 | kNumPoints = 1 << 5, |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 312 | }; |
| 313 | SkAutoTArray<int> fVerbCnts; |
| 314 | SkAutoTArray<SkPath::Verb> fVerbs; |
| 315 | SkAutoTArray<SkPoint> fPoints; |
| 316 | int fCurrPath; |
| 317 | int fCurrVerb; |
| 318 | int fCurrPoint; |
| 319 | SkRandom fRandom; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 320 | typedef SkBenchmark INHERITED; |
| 321 | }; |
| 322 | |
| 323 | class PathCreateBench : public RandomPathBench { |
| 324 | public: |
| 325 | PathCreateBench(void* param) : INHERITED(param) { |
| 326 | } |
| 327 | |
| 328 | protected: |
| 329 | enum { N = SkBENCHLOOP(5000) }; |
| 330 | |
| 331 | virtual const char* onGetName() SK_OVERRIDE { |
| 332 | return "path_create"; |
| 333 | } |
| 334 | |
| 335 | virtual void onPreDraw() SK_OVERRIDE { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 336 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 337 | fPaths.reset(kPathCnt); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 341 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 342 | this->makePath(&fPaths[i & (kPathCnt - 1)]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 343 | } |
| 344 | this->restartMakingPaths(); |
| 345 | } |
| 346 | |
| 347 | virtual void onPostDraw() SK_OVERRIDE { |
| 348 | this->finishedMakingPaths(); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 349 | fPaths.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 353 | enum { |
| 354 | // must be a pow 2 |
| 355 | kPathCnt = 1 << 5, |
| 356 | }; |
| 357 | SkAutoTArray<SkPath> fPaths; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 358 | |
| 359 | typedef RandomPathBench INHERITED; |
| 360 | }; |
| 361 | |
| 362 | class PathCopyBench : public RandomPathBench { |
| 363 | public: |
| 364 | PathCopyBench(void* param) : INHERITED(param) { |
| 365 | } |
| 366 | |
| 367 | protected: |
bsalomon@google.com | 62e4190 | 2012-08-13 16:59:21 +0000 | [diff] [blame] | 368 | enum { N = SkBENCHLOOP(30000) }; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 369 | |
| 370 | virtual const char* onGetName() SK_OVERRIDE { |
| 371 | return "path_copy"; |
| 372 | } |
| 373 | virtual void onPreDraw() SK_OVERRIDE { |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 374 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 375 | fPaths.reset(kPathCnt); |
| 376 | fCopies.reset(kPathCnt); |
| 377 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 378 | this->makePath(&fPaths[i]); |
| 379 | } |
| 380 | this->finishedMakingPaths(); |
| 381 | } |
| 382 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 383 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 384 | int idx = i & (kPathCnt - 1); |
| 385 | fCopies[idx] = fPaths[idx]; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 389 | fPaths.reset(0); |
| 390 | fCopies.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 394 | enum { |
| 395 | // must be a pow 2 |
| 396 | kPathCnt = 1 << 5, |
| 397 | }; |
| 398 | SkAutoTArray<SkPath> fPaths; |
| 399 | SkAutoTArray<SkPath> fCopies; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 400 | |
| 401 | typedef RandomPathBench INHERITED; |
| 402 | }; |
| 403 | |
| 404 | class PathTransformBench : public RandomPathBench { |
| 405 | public: |
| 406 | PathTransformBench(bool inPlace, void* param) |
| 407 | : INHERITED(param) |
| 408 | , fInPlace(inPlace) { |
| 409 | } |
| 410 | |
| 411 | protected: |
| 412 | enum { N = SkBENCHLOOP(30000) }; |
| 413 | |
| 414 | virtual const char* onGetName() SK_OVERRIDE { |
| 415 | return fInPlace ? "path_transform_in_place" : "path_transform_copy"; |
| 416 | } |
| 417 | |
| 418 | virtual void onPreDraw() SK_OVERRIDE { |
| 419 | fMatrix.setScale(5 * SK_Scalar1, 6 * SK_Scalar1); |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 420 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 421 | fPaths.reset(kPathCnt); |
| 422 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 423 | this->makePath(&fPaths[i]); |
| 424 | } |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 425 | this->finishedMakingPaths(); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 426 | if (!fInPlace) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 427 | fTransformed.reset(kPathCnt); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 432 | if (fInPlace) { |
| 433 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 434 | fPaths[i & (kPathCnt - 1)].transform(fMatrix); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 435 | } |
| 436 | } else { |
| 437 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 438 | int idx = i & (kPathCnt - 1); |
| 439 | fPaths[idx].transform(fMatrix, &fTransformed[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 445 | fPaths.reset(0); |
| 446 | fTransformed.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | private: |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 450 | enum { |
| 451 | // must be a pow 2 |
| 452 | kPathCnt = 1 << 5, |
| 453 | }; |
| 454 | SkAutoTArray<SkPath> fPaths; |
| 455 | SkAutoTArray<SkPath> fTransformed; |
| 456 | |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 457 | SkMatrix fMatrix; |
| 458 | bool fInPlace; |
| 459 | typedef RandomPathBench INHERITED; |
| 460 | }; |
| 461 | |
| 462 | class PathEqualityBench : public RandomPathBench { |
| 463 | public: |
| 464 | PathEqualityBench(void* param) |
| 465 | : INHERITED(param) { |
| 466 | } |
| 467 | |
| 468 | protected: |
| 469 | enum { N = SkBENCHLOOP(40000) }; |
| 470 | |
| 471 | virtual const char* onGetName() SK_OVERRIDE { |
| 472 | return "path_equality_50%"; |
| 473 | } |
| 474 | |
| 475 | virtual void onPreDraw() SK_OVERRIDE { |
| 476 | fParity = 0; |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 477 | this->createData(10, 100); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 478 | fPaths.reset(kPathCnt); |
| 479 | fCopies.reset(kPathCnt); |
| 480 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 481 | this->makePath(&fPaths[i]); |
| 482 | fCopies[i] = fPaths[i]; |
| 483 | } |
| 484 | this->finishedMakingPaths(); |
| 485 | } |
| 486 | |
| 487 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 488 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 489 | int idx = i & (kPathCnt - 1); |
| 490 | fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
| 494 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 495 | fPaths.reset(0); |
| 496 | fCopies.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | private: |
| 500 | bool fParity; // attempt to keep compiler from optimizing out the == |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 501 | enum { |
| 502 | // must be a pow 2 |
| 503 | kPathCnt = 1 << 5, |
| 504 | }; |
| 505 | SkAutoTArray<SkPath> fPaths; |
| 506 | SkAutoTArray<SkPath> fCopies; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 507 | typedef RandomPathBench INHERITED; |
| 508 | }; |
| 509 | |
| 510 | class SkBench_AddPathTest : public RandomPathBench { |
| 511 | public: |
| 512 | enum AddType { |
| 513 | kAdd_AddType, |
| 514 | kAddTrans_AddType, |
| 515 | kAddMatrix_AddType, |
| 516 | kPathTo_AddType, |
| 517 | kReverseAdd_AddType, |
| 518 | kReversePathTo_AddType, |
| 519 | }; |
| 520 | |
| 521 | SkBench_AddPathTest(AddType type, void* param) |
| 522 | : INHERITED(param) |
| 523 | , fType(type) { |
| 524 | fMatrix.setRotate(60 * SK_Scalar1); |
| 525 | } |
| 526 | |
| 527 | protected: |
| 528 | enum { N = SkBENCHLOOP(15000) }; |
| 529 | |
| 530 | virtual const char* onGetName() SK_OVERRIDE { |
| 531 | switch (fType) { |
| 532 | case kAdd_AddType: |
| 533 | return "path_add_path"; |
| 534 | case kAddTrans_AddType: |
| 535 | return "path_add_path_trans"; |
| 536 | case kAddMatrix_AddType: |
| 537 | return "path_add_path_matrix"; |
| 538 | case kPathTo_AddType: |
| 539 | return "path_path_to"; |
| 540 | case kReverseAdd_AddType: |
| 541 | return "path_reverse_add_path"; |
| 542 | case kReversePathTo_AddType: |
| 543 | return "path_reverse_path_to"; |
| 544 | default: |
| 545 | SkDEBUGFAIL("Bad add type"); |
| 546 | return ""; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | virtual void onPreDraw() SK_OVERRIDE { |
| 551 | // pathTo and reversePathTo assume a single contour path. |
| 552 | bool allowMoves = kPathTo_AddType != fType && |
| 553 | kReversePathTo_AddType != fType; |
bsalomon@google.com | 6d552ee | 2012-08-14 15:10:09 +0000 | [diff] [blame] | 554 | this->createData(10, 100, allowMoves); |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 555 | fPaths0.reset(kPathCnt); |
| 556 | fPaths1.reset(kPathCnt); |
| 557 | for (int i = 0; i < kPathCnt; ++i) { |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 558 | this->makePath(&fPaths0[i]); |
| 559 | this->makePath(&fPaths1[i]); |
| 560 | } |
| 561 | this->finishedMakingPaths(); |
| 562 | } |
| 563 | |
| 564 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 565 | switch (fType) { |
| 566 | case kAdd_AddType: |
| 567 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 568 | int idx = i & (kPathCnt - 1); |
| 569 | SkPath result = fPaths0[idx]; |
| 570 | result.addPath(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 571 | } |
| 572 | break; |
| 573 | case kAddTrans_AddType: |
| 574 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 575 | int idx = i & (kPathCnt - 1); |
| 576 | SkPath result = fPaths0[idx]; |
| 577 | result.addPath(fPaths1[idx], 2 * SK_Scalar1, 5 * SK_Scalar1); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 578 | } |
| 579 | break; |
| 580 | case kAddMatrix_AddType: |
| 581 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 582 | int idx = i & (kPathCnt - 1); |
| 583 | SkPath result = fPaths0[idx]; |
| 584 | result.addPath(fPaths1[idx], fMatrix); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 585 | } |
| 586 | break; |
| 587 | case kPathTo_AddType: |
| 588 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 589 | int idx = i & (kPathCnt - 1); |
| 590 | SkPath result = fPaths0[idx]; |
| 591 | result.pathTo(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 592 | } |
| 593 | break; |
| 594 | case kReverseAdd_AddType: |
| 595 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 596 | int idx = i & (kPathCnt - 1); |
| 597 | SkPath result = fPaths0[idx]; |
| 598 | result.reverseAddPath(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 599 | } |
| 600 | break; |
| 601 | case kReversePathTo_AddType: |
| 602 | for (int i = 0; i < N; ++i) { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 603 | int idx = i & (kPathCnt - 1); |
| 604 | SkPath result = fPaths0[idx]; |
| 605 | result.reversePathTo(fPaths1[idx]); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 606 | } |
| 607 | break; |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | virtual void onPostDraw() SK_OVERRIDE { |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 612 | fPaths0.reset(0); |
| 613 | fPaths1.reset(0); |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | private: |
| 617 | AddType fType; // or reverseAddPath |
bsalomon@google.com | b5e4703 | 2012-08-14 17:49:46 +0000 | [diff] [blame] | 618 | enum { |
| 619 | // must be a pow 2 |
| 620 | kPathCnt = 1 << 5, |
| 621 | }; |
| 622 | SkAutoTArray<SkPath> fPaths0; |
| 623 | SkAutoTArray<SkPath> fPaths1; |
bsalomon@google.com | 30e6d2c | 2012-08-13 14:03:31 +0000 | [diff] [blame] | 624 | SkMatrix fMatrix; |
| 625 | typedef RandomPathBench INHERITED; |
| 626 | }; |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 627 | |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 628 | |
| 629 | class CirclesBench : public SkBenchmark { |
| 630 | protected: |
| 631 | SkString fName; |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 632 | Flags fFlags; |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 633 | |
| 634 | enum { |
| 635 | N = SkBENCHLOOP(100) |
| 636 | }; |
| 637 | public: |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 638 | CirclesBench(void* param, Flags flags) : INHERITED(param), fFlags(flags) { |
| 639 | fName.printf("circles_%s", fFlags & kStroke_Flag ? "stroke" : "fill"); |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | protected: |
| 643 | virtual const char* onGetName() SK_OVERRIDE { |
| 644 | return fName.c_str(); |
| 645 | } |
| 646 | |
| 647 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 648 | SkPaint paint; |
| 649 | |
| 650 | paint.setColor(SK_ColorBLACK); |
| 651 | paint.setAntiAlias(true); |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 652 | if (fFlags & kStroke_Flag) { |
| 653 | paint.setStyle(SkPaint::kStroke_Style); |
| 654 | } |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 655 | |
| 656 | SkRandom rand; |
| 657 | |
| 658 | SkRect r; |
| 659 | |
| 660 | for (int i = 0; i < 5000; ++i) { |
| 661 | SkScalar radius = rand.nextUScalar1() * 3; |
| 662 | r.fLeft = rand.nextUScalar1() * 300; |
| 663 | r.fTop = rand.nextUScalar1() * 300; |
| 664 | r.fRight = r.fLeft + 2 * radius; |
| 665 | r.fBottom = r.fTop + 2 * radius; |
| 666 | |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 667 | if (fFlags & kStroke_Flag) { |
| 668 | paint.setStrokeWidth(rand.nextUScalar1() * 5.0f); |
| 669 | } |
| 670 | |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 671 | SkPath temp; |
| 672 | |
| 673 | // mimic how Chrome does circles |
| 674 | temp.arcTo(r, 0, 0, false); |
| 675 | temp.addOval(r, SkPath::kCCW_Direction); |
| 676 | temp.arcTo(r, 360, 0, true); |
| 677 | temp.close(); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 678 | |
robertphillips@google.com | 17bb458 | 2012-08-20 17:24:16 +0000 | [diff] [blame] | 679 | canvas->drawPath(temp, paint); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | private: |
| 684 | typedef SkBenchmark INHERITED; |
| 685 | }; |
| 686 | |
jvanverth@google.com | 46d3d39 | 2013-01-22 13:34:01 +0000 | [diff] [blame] | 687 | |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 688 | // Chrome creates its own round rects with each corner possibly being different. |
| 689 | // In its "zero radius" incarnation it creates degenerate round rects. |
skia.committer@gmail.com | 1e34ff7 | 2012-10-24 02:01:24 +0000 | [diff] [blame] | 690 | // Note: PathTest::test_arb_round_rect_is_convex and |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 691 | // test_arb_zero_rad_round_rect_is_rect perform almost exactly |
robertphillips@google.com | b95eaa8 | 2012-10-18 15:26:12 +0000 | [diff] [blame] | 692 | // the same test (but with no drawing) |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 693 | class ArbRoundRectBench : public SkBenchmark { |
| 694 | protected: |
| 695 | SkString fName; |
| 696 | |
| 697 | enum { |
| 698 | N = SkBENCHLOOP(100) |
| 699 | }; |
| 700 | public: |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 701 | ArbRoundRectBench(void* param, bool zeroRad) : INHERITED(param), fZeroRad(zeroRad) { |
| 702 | if (zeroRad) { |
| 703 | fName.printf("zeroradroundrect"); |
| 704 | } else { |
| 705 | fName.printf("arbroundrect"); |
| 706 | } |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | protected: |
| 710 | virtual const char* onGetName() SK_OVERRIDE { |
| 711 | return fName.c_str(); |
| 712 | } |
| 713 | |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 714 | static void add_corner_arc(SkPath* path, const SkRect& rect, |
| 715 | SkScalar xIn, SkScalar yIn, |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 716 | int startAngle) |
| 717 | { |
| 718 | |
| 719 | SkScalar rx = SkMinScalar(rect.width(), xIn); |
| 720 | SkScalar ry = SkMinScalar(rect.height(), yIn); |
| 721 | |
| 722 | SkRect arcRect; |
| 723 | arcRect.set(-rx, -ry, rx, ry); |
| 724 | switch (startAngle) { |
| 725 | case 0: |
| 726 | arcRect.offset(rect.fRight - arcRect.fRight, rect.fBottom - arcRect.fBottom); |
| 727 | break; |
| 728 | case 90: |
| 729 | arcRect.offset(rect.fLeft - arcRect.fLeft, rect.fBottom - arcRect.fBottom); |
| 730 | break; |
| 731 | case 180: |
| 732 | arcRect.offset(rect.fLeft - arcRect.fLeft, rect.fTop - arcRect.fTop); |
| 733 | break; |
| 734 | case 270: |
| 735 | arcRect.offset(rect.fRight - arcRect.fRight, rect.fTop - arcRect.fTop); |
| 736 | break; |
| 737 | default: |
| 738 | break; |
| 739 | } |
| 740 | |
| 741 | path->arcTo(arcRect, SkIntToScalar(startAngle), SkIntToScalar(90), false); |
| 742 | } |
| 743 | |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 744 | static void make_arb_round_rect(SkPath* path, const SkRect& r, |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 745 | SkScalar xCorner, SkScalar yCorner) { |
| 746 | // we are lazy here and use the same x & y for each corner |
| 747 | add_corner_arc(path, r, xCorner, yCorner, 270); |
| 748 | add_corner_arc(path, r, xCorner, yCorner, 0); |
| 749 | add_corner_arc(path, r, xCorner, yCorner, 90); |
| 750 | add_corner_arc(path, r, xCorner, yCorner, 180); |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 751 | path->close(); |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 752 | |
robertphillips@google.com | b95eaa8 | 2012-10-18 15:26:12 +0000 | [diff] [blame] | 753 | SkASSERT(path->isConvex()); |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 757 | SkRandom rand; |
| 758 | SkRect r; |
| 759 | |
| 760 | for (int i = 0; i < 5000; ++i) { |
| 761 | SkPaint paint; |
| 762 | paint.setColor(0xff000000 | rand.nextU()); |
| 763 | paint.setAntiAlias(true); |
| 764 | |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 765 | SkScalar size = rand.nextUScalar1() * 30; |
| 766 | if (size < SK_Scalar1) { |
robertphillips@google.com | b95eaa8 | 2012-10-18 15:26:12 +0000 | [diff] [blame] | 767 | continue; |
| 768 | } |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 769 | r.fLeft = rand.nextUScalar1() * 300; |
| 770 | r.fTop = rand.nextUScalar1() * 300; |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 771 | r.fRight = r.fLeft + 2 * size; |
| 772 | r.fBottom = r.fTop + 2 * size; |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 773 | |
| 774 | SkPath temp; |
| 775 | |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 776 | if (fZeroRad) { |
| 777 | make_arb_round_rect(&temp, r, 0, 0); |
| 778 | |
| 779 | SkASSERT(temp.isRect(NULL)); |
| 780 | } else { |
| 781 | make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15); |
| 782 | } |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 783 | |
| 784 | canvas->drawPath(temp, paint); |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | private: |
robertphillips@google.com | 158618e | 2012-10-23 16:56:56 +0000 | [diff] [blame] | 789 | bool fZeroRad; // should 0 radius rounds rects be tested? |
| 790 | |
robertphillips@google.com | f6fc3fc | 2012-10-17 15:23:21 +0000 | [diff] [blame] | 791 | typedef SkBenchmark INHERITED; |
| 792 | }; |
| 793 | |
bsalomon@google.com | 9bee33a | 2012-11-13 21:51:38 +0000 | [diff] [blame] | 794 | class ConservativelyContainsBench : public SkBenchmark { |
| 795 | public: |
| 796 | enum Type { |
| 797 | kRect_Type, |
| 798 | kRoundRect_Type, |
| 799 | kOval_Type, |
| 800 | }; |
| 801 | |
| 802 | ConservativelyContainsBench(void* param, Type type) : INHERITED(param) { |
| 803 | fIsRendering = false; |
| 804 | fParity = false; |
| 805 | fName = "conservatively_contains_"; |
| 806 | switch (type) { |
| 807 | case kRect_Type: |
| 808 | fName.append("rect"); |
| 809 | fPath.addRect(kBaseRect); |
| 810 | break; |
| 811 | case kRoundRect_Type: |
| 812 | fName.append("round_rect"); |
| 813 | fPath.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1]); |
| 814 | break; |
| 815 | case kOval_Type: |
| 816 | fName.append("oval"); |
| 817 | fPath.addOval(kBaseRect); |
| 818 | break; |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | private: |
| 823 | virtual const char* onGetName() SK_OVERRIDE { |
| 824 | return fName.c_str(); |
| 825 | } |
| 826 | |
sugoi@google.com | 77472f0 | 2013-03-05 18:50:01 +0000 | [diff] [blame] | 827 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
bsalomon@google.com | 9bee33a | 2012-11-13 21:51:38 +0000 | [diff] [blame] | 828 | for (int i = 0; i < N; ++i) { |
| 829 | const SkRect& rect = fQueryRects[i % kQueryRectCnt]; |
| 830 | fParity = fParity != fPath.conservativelyContainsRect(rect); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | virtual void onPreDraw() SK_OVERRIDE { |
| 835 | fQueryRects.setCount(kQueryRectCnt); |
| 836 | |
| 837 | SkRandom rand; |
| 838 | for (int i = 0; i < kQueryRectCnt; ++i) { |
| 839 | SkSize size; |
| 840 | SkPoint xy; |
| 841 | size.fWidth = rand.nextRangeScalar(kQueryMin.fWidth, kQueryMax.fWidth); |
| 842 | size.fHeight = rand.nextRangeScalar(kQueryMin.fHeight, kQueryMax.fHeight); |
| 843 | xy.fX = rand.nextRangeScalar(kBounds.fLeft, kBounds.fRight - size.fWidth); |
| 844 | xy.fY = rand.nextRangeScalar(kBounds.fTop, kBounds.fBottom - size.fHeight); |
| 845 | |
| 846 | fQueryRects[i] = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeight); |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | virtual void onPostDraw() SK_OVERRIDE { |
| 851 | fQueryRects.setCount(0); |
| 852 | } |
| 853 | |
| 854 | enum { |
| 855 | N = SkBENCHLOOP(100000), |
| 856 | kQueryRectCnt = 400, |
| 857 | }; |
| 858 | static const SkRect kBounds; // bounds for all random query rects |
| 859 | static const SkSize kQueryMin; // minimum query rect size, should be <= kQueryMax |
| 860 | static const SkSize kQueryMax; // max query rect size, should < kBounds |
| 861 | static const SkRect kBaseRect; // rect that is used to construct the path |
| 862 | static const SkScalar kRRRadii[2]; // x and y radii for round rect |
| 863 | |
| 864 | SkString fName; |
| 865 | SkPath fPath; |
| 866 | bool fParity; |
| 867 | SkTDArray<SkRect> fQueryRects; |
| 868 | |
| 869 | typedef SkBenchmark INHERITED; |
| 870 | }; |
| 871 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 872 | /////////////////////////////////////////////////////////////////////////////// |
| 873 | |
| 874 | #include "SkGeometry.h" |
| 875 | |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 876 | class ConicBench_Chop5 : public SkBenchmark { |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 877 | enum { |
| 878 | N = 100000 |
| 879 | }; |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 880 | SkConic fRQ; |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 881 | public: |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 882 | ConicBench_Chop5(void* param) : INHERITED(param) { |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 883 | fRQ.fPts[0].set(0, 0); |
| 884 | fRQ.fPts[1].set(100, 0); |
| 885 | fRQ.fPts[2].set(100, 100); |
| 886 | fRQ.fW = SkScalarCos(SK_ScalarPI/4); |
| 887 | } |
skia.committer@gmail.com | ab38e56 | 2013-04-14 07:01:08 +0000 | [diff] [blame] | 888 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 889 | private: |
| 890 | virtual const char* onGetName() SK_OVERRIDE { |
| 891 | return "ratquad-chop-0.5"; |
| 892 | } |
skia.committer@gmail.com | ab38e56 | 2013-04-14 07:01:08 +0000 | [diff] [blame] | 893 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 894 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 895 | SkConic dst[2]; |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 896 | for (int i = 0; i < N; ++i) { |
| 897 | fRQ.chopAt(0.5f, dst); |
| 898 | } |
| 899 | } |
skia.committer@gmail.com | ab38e56 | 2013-04-14 07:01:08 +0000 | [diff] [blame] | 900 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 901 | typedef SkBenchmark INHERITED; |
| 902 | }; |
| 903 | |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 904 | class ConicBench_ChopHalf : public SkBenchmark { |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 905 | enum { |
| 906 | N = 100000 |
| 907 | }; |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 908 | SkConic fRQ; |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 909 | public: |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 910 | ConicBench_ChopHalf(void* param) : INHERITED(param) { |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 911 | fRQ.fPts[0].set(0, 0); |
| 912 | fRQ.fPts[1].set(100, 0); |
| 913 | fRQ.fPts[2].set(100, 100); |
| 914 | fRQ.fW = SkScalarCos(SK_ScalarPI/4); |
| 915 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 916 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 917 | private: |
| 918 | virtual const char* onGetName() SK_OVERRIDE { |
| 919 | return "ratquad-chop-half"; |
| 920 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 921 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 922 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 923 | SkConic dst[2]; |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 924 | for (int i = 0; i < N; ++i) { |
| 925 | fRQ.chop(dst); |
| 926 | } |
| 927 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 928 | |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 929 | typedef SkBenchmark INHERITED; |
| 930 | }; |
| 931 | |
| 932 | /////////////////////////////////////////////////////////////////////////////// |
| 933 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 934 | static void rand_conic(SkConic* conic, SkRandom& rand) { |
| 935 | for (int i = 0; i < 3; ++i) { |
| 936 | conic->fPts[i].set(rand.nextUScalar1() * 100, rand.nextUScalar1() * 100); |
| 937 | } |
| 938 | if (rand.nextUScalar1() > 0.5f) { |
| 939 | conic->fW = rand.nextUScalar1(); |
| 940 | } else { |
| 941 | conic->fW = 1 + rand.nextUScalar1() * 4; |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | class ConicBench : public SkBenchmark { |
| 946 | public: |
| 947 | ConicBench(void* param) : INHERITED(param) { |
| 948 | SkRandom rand; |
| 949 | for (int i = 0; i < CONICS; ++i) { |
| 950 | rand_conic(&fConics[i], rand); |
| 951 | } |
| 952 | fIsRendering = false; |
| 953 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 954 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 955 | protected: |
| 956 | enum { |
| 957 | N = 20000, |
| 958 | CONICS = 100 |
| 959 | }; |
| 960 | SkConic fConics[CONICS]; |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 961 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 962 | private: |
| 963 | typedef SkBenchmark INHERITED; |
| 964 | }; |
| 965 | |
| 966 | class ConicBench_ComputeError : public ConicBench { |
| 967 | public: |
| 968 | ConicBench_ComputeError(void* param) : INHERITED(param) {} |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 969 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 970 | protected: |
| 971 | virtual const char* onGetName() SK_OVERRIDE { |
| 972 | return "conic-compute-error"; |
| 973 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 974 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 975 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 976 | SkVector err; |
| 977 | for (int i = 0; i < N; ++i) { |
| 978 | for (int j = 0; j < CONICS; ++j) { |
| 979 | fConics[j].computeAsQuadError(&err); |
| 980 | } |
| 981 | } |
| 982 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 983 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 984 | private: |
| 985 | typedef ConicBench INHERITED; |
| 986 | }; |
| 987 | |
| 988 | class ConicBench_asQuadTol : public ConicBench { |
| 989 | public: |
| 990 | ConicBench_asQuadTol(void* param) : INHERITED(param) {} |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 991 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 992 | protected: |
| 993 | virtual const char* onGetName() SK_OVERRIDE { |
| 994 | return "conic-asQuadTol"; |
| 995 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 996 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 997 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 998 | for (int i = 0; i < N; ++i) { |
| 999 | for (int j = 0; j < CONICS; ++j) { |
| 1000 | fConics[j].asQuadTol(SK_ScalarHalf); |
| 1001 | } |
| 1002 | } |
| 1003 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 1004 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 1005 | private: |
| 1006 | typedef ConicBench INHERITED; |
| 1007 | }; |
| 1008 | |
| 1009 | class ConicBench_quadPow2 : public ConicBench { |
| 1010 | public: |
| 1011 | ConicBench_quadPow2(void* param) : INHERITED(param) {} |
| 1012 | |
| 1013 | protected: |
| 1014 | virtual const char* onGetName() SK_OVERRIDE { |
| 1015 | return "conic-quadPow2"; |
| 1016 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 1017 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 1018 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 1019 | for (int i = 0; i < N; ++i) { |
| 1020 | for (int j = 0; j < CONICS; ++j) { |
| 1021 | fConics[j].computeQuadPOW2(SK_ScalarHalf); |
| 1022 | } |
| 1023 | } |
| 1024 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 1025 | |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 1026 | private: |
| 1027 | typedef ConicBench INHERITED; |
| 1028 | }; |
| 1029 | |
| 1030 | /////////////////////////////////////////////////////////////////////////////// |
| 1031 | |
bsalomon@google.com | 9bee33a | 2012-11-13 21:51:38 +0000 | [diff] [blame] | 1032 | const SkRect ConservativelyContainsBench::kBounds = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
| 1033 | const SkSize ConservativelyContainsBench::kQueryMin = SkSize::Make(SkIntToScalar(1), SkIntToScalar(1)); |
| 1034 | const SkSize ConservativelyContainsBench::kQueryMax = SkSize::Make(SkIntToScalar(40), SkIntToScalar(40)); |
| 1035 | const SkRect ConservativelyContainsBench::kBaseRect = SkRect::MakeXYWH(SkIntToScalar(25), SkIntToScalar(25), SkIntToScalar(50), SkIntToScalar(50)); |
| 1036 | const SkScalar ConservativelyContainsBench::kRRRadii[2] = {SkIntToScalar(5), SkIntToScalar(10)}; |
| 1037 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1038 | DEF_BENCH( return new TrianglePathBench(p, FLAGS00); ) |
| 1039 | DEF_BENCH( return new TrianglePathBench(p, FLAGS01); ) |
| 1040 | DEF_BENCH( return new TrianglePathBench(p, FLAGS10); ) |
| 1041 | DEF_BENCH( return new TrianglePathBench(p, FLAGS11); ) |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 1042 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1043 | DEF_BENCH( return new RectPathBench(p, FLAGS00); ) |
| 1044 | DEF_BENCH( return new RectPathBench(p, FLAGS01); ) |
| 1045 | DEF_BENCH( return new RectPathBench(p, FLAGS10); ) |
| 1046 | DEF_BENCH( return new RectPathBench(p, FLAGS11); ) |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 1047 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1048 | DEF_BENCH( return new OvalPathBench(p, FLAGS00); ) |
| 1049 | DEF_BENCH( return new OvalPathBench(p, FLAGS01); ) |
| 1050 | DEF_BENCH( return new OvalPathBench(p, FLAGS10); ) |
| 1051 | DEF_BENCH( return new OvalPathBench(p, FLAGS11); ) |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 1052 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1053 | DEF_BENCH( return new CirclePathBench(p, FLAGS00); ) |
| 1054 | DEF_BENCH( return new CirclePathBench(p, FLAGS01); ) |
| 1055 | DEF_BENCH( return new CirclePathBench(p, FLAGS10); ) |
| 1056 | DEF_BENCH( return new CirclePathBench(p, FLAGS11); ) |
bsalomon@google.com | 1647a19 | 2012-04-11 15:34:46 +0000 | [diff] [blame] | 1057 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1058 | DEF_BENCH( return new SawToothPathBench(p, FLAGS00); ) |
| 1059 | DEF_BENCH( return new SawToothPathBench(p, FLAGS01); ) |
reed@google.com | d34658a | 2011-04-11 13:12:51 +0000 | [diff] [blame] | 1060 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1061 | DEF_BENCH( return new LongCurvedPathBench(p, FLAGS00); ) |
| 1062 | DEF_BENCH( return new LongCurvedPathBench(p, FLAGS01); ) |
| 1063 | DEF_BENCH( return new LongLinePathBench(p, FLAGS00); ) |
| 1064 | DEF_BENCH( return new LongLinePathBench(p, FLAGS01); ) |
tomhudson@google.com | 6e8d335 | 2011-06-22 17:16:35 +0000 | [diff] [blame] | 1065 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1066 | DEF_BENCH( return new PathCreateBench(p); ) |
| 1067 | DEF_BENCH( return new PathCopyBench(p); ) |
| 1068 | DEF_BENCH( return new PathTransformBench(true, p); ) |
| 1069 | DEF_BENCH( return new PathTransformBench(false, p); ) |
| 1070 | DEF_BENCH( return new PathEqualityBench(p); ) |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 1071 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1072 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAdd_AddType, p); ) |
| 1073 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddTrans_AddType, p); ) |
| 1074 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kAddMatrix_AddType, p); ) |
| 1075 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kPathTo_AddType, p); ) |
| 1076 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReverseAdd_AddType, p); ) |
| 1077 | DEF_BENCH( return new SkBench_AddPathTest(SkBench_AddPathTest::kReversePathTo_AddType, p); ) |
senorblanco@chromium.org | e50f736 | 2012-01-12 19:10:35 +0000 | [diff] [blame] | 1078 | |
mike@reedtribe.org | 0cf7b82 | 2013-02-04 05:05:36 +0000 | [diff] [blame] | 1079 | DEF_BENCH( return new CirclesBench(p, FLAGS00); ) |
| 1080 | DEF_BENCH( return new CirclesBench(p, FLAGS01); ) |
| 1081 | DEF_BENCH( return new ArbRoundRectBench(p, false); ) |
| 1082 | DEF_BENCH( return new ArbRoundRectBench(p, true); ) |
| 1083 | DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kRect_Type); ) |
| 1084 | DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kRoundRect_Type); ) |
| 1085 | DEF_BENCH( return new ConservativelyContainsBench(p, ConservativelyContainsBench::kOval_Type); ) |
mike@reedtribe.org | 8d55101 | 2013-04-14 02:40:50 +0000 | [diff] [blame] | 1086 | |
mike@reedtribe.org | 28552e1 | 2013-04-26 00:58:29 +0000 | [diff] [blame] | 1087 | DEF_BENCH( return new ConicBench_Chop5(p) ) |
| 1088 | DEF_BENCH( return new ConicBench_ChopHalf(p) ) |
mike@reedtribe.org | af5c506 | 2013-04-30 02:14:58 +0000 | [diff] [blame] | 1089 | DEF_BENCH( return new ConicBench_ComputeError(p) ) |
| 1090 | DEF_BENCH( return new ConicBench_asQuadTol(p) ) |
| 1091 | DEF_BENCH( return new ConicBench_quadPow2(p) ) |