@@ -97,20 +97,28 @@ static void BM_Polyline(benchmark::State& state, Args&&... args) {
97
97
state.counters [" TotalPointCount" ] = point_count;
98
98
}
99
99
100
+ enum class UVMode {
101
+ kNoUV ,
102
+ kUVRect ,
103
+ kUVRectTx ,
104
+ };
105
+
100
106
template <class ... Args>
101
107
static void BM_StrokePolyline (benchmark::State& state, Args&&... args) {
102
108
auto args_tuple = std::make_tuple (std::move (args)...);
103
109
auto path = std::get<Path>(args_tuple);
104
110
auto cap = std::get<Cap>(args_tuple);
105
111
auto join = std::get<Join>(args_tuple);
106
- auto generate_uv = std::get<bool >(args_tuple);
112
+ auto generate_uv = std::get<UVMode >(args_tuple);
107
113
108
114
const Scalar stroke_width = 5 .0f ;
109
115
const Scalar miter_limit = 10 .0f ;
110
116
const Scalar scale = 1 .0f ;
111
117
const Point texture_origin = Point (0 , 0 );
112
118
const Size texture_size = Size (100 , 100 );
113
- const Matrix effect_transform = Matrix::MakeScale ({2 .0f , 2 .0f , 1 .0f });
119
+ const Matrix effect_transform = (generate_uv == UVMode::kUVRectTx )
120
+ ? Matrix::MakeScale ({2 .0f , 2 .0f , 1 .0f })
121
+ : Matrix ();
114
122
115
123
auto points = std::make_unique<std::vector<Point>>();
116
124
points->reserve (2048 );
@@ -123,15 +131,15 @@ static void BM_StrokePolyline(benchmark::State& state, Args&&... args) {
123
131
size_t point_count = 0u ;
124
132
size_t single_point_count = 0u ;
125
133
while (state.KeepRunning ()) {
126
- if (generate_uv) {
134
+ if (generate_uv == UVMode::kNoUV ) {
135
+ auto vertices = ImpellerBenchmarkAccessor::GenerateSolidStrokeVertices (
136
+ polyline, stroke_width, miter_limit, join, cap, scale);
137
+ single_point_count = vertices.size ();
138
+ } else {
127
139
auto vertices = ImpellerBenchmarkAccessor::GenerateSolidStrokeVerticesUV (
128
140
polyline, stroke_width, miter_limit, join, cap, scale, //
129
141
texture_origin, texture_size, effect_transform);
130
142
single_point_count = vertices.size ();
131
- } else {
132
- auto vertices = ImpellerBenchmarkAccessor::GenerateSolidStrokeVertices (
133
- polyline, stroke_width, miter_limit, join, cap, scale);
134
- single_point_count = vertices.size ();
135
143
}
136
144
point_count += single_point_count;
137
145
}
@@ -157,24 +165,21 @@ static void BM_Convex(benchmark::State& state, Args&&... args) {
157
165
state.counters [" TotalPointCount" ] = point_count;
158
166
}
159
167
160
- #define MAKE_STROKE_BENCHMARK_CAPTURE (path, cap, join, closed ) \
161
- BENCHMARK_CAPTURE (BM_StrokePolyline, stroke_##path##_##cap##_##join, \
162
- Create##path(closed), Cap::k##cap, Join::k##join, false )
163
-
164
- #define MAKE_STROKE_BENCHMARK_CAPTURE_UV (path, cap, join, closed ) \
165
- BENCHMARK_CAPTURE (BM_StrokePolyline, stroke_##path##_##cap##_##join##_uv, \
166
- Create##path(closed), Cap::k##cap, Join::k##join, true )
168
+ #define MAKE_STROKE_BENCHMARK_CAPTURE (path, cap, join, closed, uvname, uvtype ) \
169
+ BENCHMARK_CAPTURE (BM_StrokePolyline, stroke_##path##_##cap##_##join##uvname, \
170
+ Create##path(closed), Cap::k##cap, Join::k##join, uvtype)
167
171
168
- #define MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, uv ) \
169
- MAKE_STROKE_BENCHMARK_CAPTURE##uv (path, Butt, Bevel, false ); \
170
- MAKE_STROKE_BENCHMARK_CAPTURE##uv (path, Butt, Miter, false ); \
171
- MAKE_STROKE_BENCHMARK_CAPTURE##uv (path, Butt, Round, false ); \
172
- MAKE_STROKE_BENCHMARK_CAPTURE##uv (path, Square, Bevel, false ); \
173
- MAKE_STROKE_BENCHMARK_CAPTURE##uv (path, Round, Bevel, false )
172
+ #define MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, uvname, uvtype ) \
173
+ MAKE_STROKE_BENCHMARK_CAPTURE (path, Butt, Bevel, false , uvname, uvtype ); \
174
+ MAKE_STROKE_BENCHMARK_CAPTURE (path, Butt, Miter, false , uvname, uvtype ); \
175
+ MAKE_STROKE_BENCHMARK_CAPTURE (path, Butt, Round, false , uvname, uvtype ); \
176
+ MAKE_STROKE_BENCHMARK_CAPTURE (path, Square, Bevel, false , uvname, uvtype ); \
177
+ MAKE_STROKE_BENCHMARK_CAPTURE (path, Round, Bevel, false , uvname, uvtype )
174
178
175
- #define MAKE_STROKE_BENCHMARK_CAPTURE_UVS (path ) \
176
- MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, ); \
177
- MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, _UV)
179
+ #define MAKE_STROKE_BENCHMARK_CAPTURE_UVS (path ) \
180
+ MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, , UVMode::kNoUV ); \
181
+ MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, _uv, UVMode::kUVRectTx ); \
182
+ MAKE_STROKE_BENCHMARK_CAPTURE_CAPS_JOINS (path, _uvNoTx, UVMode::kUVRect )
178
183
179
184
BENCHMARK_CAPTURE (BM_Polyline, cubic_polyline, CreateCubic(true ), false );
180
185
BENCHMARK_CAPTURE (BM_Polyline, cubic_polyline_tess, CreateCubic(true ), true );
@@ -201,8 +206,9 @@ BENCHMARK_CAPTURE(BM_Polyline,
201
206
MAKE_STROKE_BENCHMARK_CAPTURE_UVS (Quadratic);
202
207
203
208
BENCHMARK_CAPTURE (BM_Convex, rrect_convex, CreateRRect(), true);
204
- MAKE_STROKE_BENCHMARK_CAPTURE (RRect, Butt, Bevel, );
205
- MAKE_STROKE_BENCHMARK_CAPTURE_UV (RRect, Butt, Bevel, );
209
+ MAKE_STROKE_BENCHMARK_CAPTURE (RRect, Butt, Bevel, , , UVMode::kNoUV );
210
+ MAKE_STROKE_BENCHMARK_CAPTURE (RRect, Butt, Bevel, , _uv, UVMode::kUVRectTx );
211
+ MAKE_STROKE_BENCHMARK_CAPTURE (RRect, Butt, Bevel, , _uvNoTx, UVMode::kUVRect );
206
212
207
213
namespace {
208
214
0 commit comments