| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkString.h" | 12 #include "SkString.h" |
| 13 | 13 |
| 14 class StrokeBench : public Benchmark { | 14 class StrokeBench : public Benchmark { |
| 15 public: | 15 public: |
| 16 StrokeBench(const SkPath& path, const SkPaint& paint, const char pathType[],
SkScalar res) | 16 StrokeBench(const SkPath& path, const SkPaint& paint, const char pathType[],
SkScalar res) |
| 17 : fPath(path), fPaint(paint), fRes(res) | 17 : fPath(path), fPaint(paint), fRes(res) |
| 18 { | 18 { |
| 19 fName.printf("build_stroke_%s_%g_%d_%d", | 19 fName.printf("build_stroke_%s_%g_%d_%d", |
| 20 pathType, paint.getStrokeWidth(), paint.getStrokeJoin(), pa
int.getStrokeCap()); | 20 pathType, paint.getStrokeWidth(), paint.getStrokeJoin(), pa
int.getStrokeCap()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 bool isSuitableFor(Backend backend) override { | 24 bool isSuitableFor(Backend backend) override { |
| 25 return backend == kNonRendering_Backend; | 25 return backend == kNonRendering_Backend; |
| 26 } | 26 } |
| 27 | 27 |
| 28 const char* onGetName() override { return fName.c_str(); } | 28 const char* onGetName() override { return fName.c_str(); } |
| 29 | 29 |
| 30 void onDraw(const int loops, SkCanvas* canvas) override { | 30 void onDraw(int loops, SkCanvas* canvas) override { |
| 31 SkPaint paint(fPaint); | 31 SkPaint paint(fPaint); |
| 32 this->setupPaint(&paint); | 32 this->setupPaint(&paint); |
| 33 | 33 |
| 34 for (int outer = 0; outer < 10; ++outer) { | 34 for (int outer = 0; outer < 10; ++outer) { |
| 35 for (int i = 0; i < loops; ++i) { | 35 for (int i = 0; i < loops; ++i) { |
| 36 SkPath result; | 36 SkPath result; |
| 37 paint.getFillPath(fPath, &result, nullptr, fRes); | 37 paint.getFillPath(fPath, &result, nullptr, fRes); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 } | 40 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_4", 4);
) | 111 DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_4", 4);
) |
| 112 DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_4", 4);
) | 112 DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_4", 4);
) |
| 113 DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_4", 4
);) | 113 DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_4", 4
);) |
| 114 DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_4", 4
);) | 114 DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_4", 4
);) |
| 115 | 115 |
| 116 DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_.25", .
25f);) | 116 DEF_BENCH(return new StrokeBench(line_path_maker(), paint_maker(), "line_.25", .
25f);) |
| 117 DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_.25", .
25f);) | 117 DEF_BENCH(return new StrokeBench(quad_path_maker(), paint_maker(), "quad_.25", .
25f);) |
| 118 DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_.25",
.25f);) | 118 DEF_BENCH(return new StrokeBench(conic_path_maker(), paint_maker(), "conic_.25",
.25f);) |
| 119 DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_.25",
.25f);) | 119 DEF_BENCH(return new StrokeBench(cubic_path_maker(), paint_maker(), "cubic_.25",
.25f);) |
| OLD | NEW |