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[]) | 16 StrokeBench(const SkPath& path, const SkPaint& paint, const char pathType[],
SkScalar res) |
17 : fPath(path), fPaint(paint) | 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 virtual bool isSuitableFor(Backend backend) { |
| 25 return backend == kNonRendering_Backend; |
| 26 } |
| 27 |
24 const char* onGetName() override { return fName.c_str(); } | 28 const char* onGetName() override { return fName.c_str(); } |
25 | 29 |
26 void onDraw(const int loops, SkCanvas* canvas) override { | 30 void onDraw(const int loops, SkCanvas* canvas) override { |
27 SkPaint paint(fPaint); | 31 SkPaint paint(fPaint); |
28 this->setupPaint(&paint); | 32 this->setupPaint(&paint); |
29 | 33 |
30 for (int outer = 0; outer < 10; ++outer) { | 34 for (int outer = 0; outer < 10; ++outer) { |
31 for (int i = 0; i < loops; ++i) { | 35 for (int i = 0; i < loops; ++i) { |
32 SkPath result; | 36 SkPath result; |
33 paint.getFillPath(fPath, &result); | 37 paint.getFillPath(fPath, &result, NULL, fRes); |
34 } | 38 } |
35 } | 39 } |
36 } | 40 } |
37 | 41 |
38 private: | 42 private: |
39 SkPath fPath; | 43 SkPath fPath; |
40 SkPaint fPaint; | 44 SkPaint fPaint; |
41 SkString fName; | 45 SkString fName; |
42 | 46 SkScalar fRes; |
43 typedef Benchmark INHERITED; | 47 typedef Benchmark INHERITED; |
44 }; | 48 }; |
45 | 49 |
46 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
47 | 51 |
48 static const int N = 100; | 52 static const int N = 100; |
49 static const SkScalar X = 100; | 53 static const SkScalar X = 100; |
50 static const SkScalar Y = 100; | 54 static const SkScalar Y = 100; |
51 | 55 |
52 static SkPoint rand_pt(SkRandom& rand) { | 56 static SkPoint rand_pt(SkRandom& rand) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 96 |
93 static SkPaint paint_maker() { | 97 static SkPaint paint_maker() { |
94 SkPaint paint; | 98 SkPaint paint; |
95 paint.setStyle(SkPaint::kStroke_Style); | 99 paint.setStyle(SkPaint::kStroke_Style); |
96 paint.setStrokeWidth(X / 10); | 100 paint.setStrokeWidth(X / 10); |
97 paint.setStrokeJoin(SkPaint::kMiter_Join); | 101 paint.setStrokeJoin(SkPaint::kMiter_Join); |
98 paint.setStrokeCap(SkPaint::kSquare_Cap); | 102 paint.setStrokeCap(SkPaint::kSquare_Cap); |
99 return paint; | 103 return paint; |
100 } | 104 } |
101 | 105 |
102 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "li
ne")); ) | 106 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "li
ne_1", 1)); ) |
103 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "qu
ad")); ) | 107 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "qu
ad_1", 1)); ) |
104 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "c
onic")); ) | 108 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "c
onic_1", 1)); ) |
105 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "c
ubic")); ) | 109 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "c
ubic_1", 1)); ) |
| 110 |
| 111 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "li
ne_4", 4)); ) |
| 112 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "qu
ad_4", 4)); ) |
| 113 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "c
onic_4", 4)); ) |
| 114 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "c
ubic_4", 4)); ) |
| 115 |
| 116 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (line_path_maker(), paint_maker(), "li
ne_.25", .25f)); ) |
| 117 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (quad_path_maker(), paint_maker(), "qu
ad_.25", .25f)); ) |
| 118 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (conic_path_maker(), paint_maker(), "c
onic_.25", .25f)); ) |
| 119 DEF_BENCH( return SkNEW_ARGS(StrokeBench, (cubic_path_maker(), paint_maker(), "c
ubic_.25", .25f)); ) |
OLD | NEW |