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