Flutter Impeller
geometry_benchmarks.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/benchmarking/benchmarking.h"
6 
11 
12 namespace impeller {
13 
15  public:
16  static std::vector<Point> GenerateSolidStrokeVertices(
17  const Path::Polyline& polyline,
19  Scalar miter_limit,
20  Join stroke_join,
21  Cap stroke_cap,
22  Scalar scale) {
23  return StrokePathGeometry::GenerateSolidStrokeVertices(
24  polyline, stroke_width, miter_limit, stroke_join, stroke_cap, scale);
25  }
26 };
27 
28 namespace {
29 /// A path with many connected cubic components, including
30 /// overlaps/self-intersections/multi-contour.
31 Path CreateCubic(bool closed);
32 /// Similar to the path above, but with all cubics replaced by quadratics.
33 Path CreateQuadratic(bool closed);
34 /// Create a rounded rect.
35 Path CreateRRect();
36 } // namespace
37 
39 
40 template <class... Args>
41 static void BM_Polyline(benchmark::State& state, Args&&... args) {
42  auto args_tuple = std::make_tuple(std::move(args)...);
43  auto path = std::get<Path>(args_tuple);
44 
45  size_t point_count = 0u;
46  size_t single_point_count = 0u;
47  auto points = std::make_unique<std::vector<Point>>();
48  points->reserve(2048);
49  while (state.KeepRunning()) {
50  auto polyline = path.CreatePolyline(
51  // Clang-tidy doesn't know that the points get moved back before
52  // getting moved again in this loop.
53  // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
54  1.0f, std::move(points),
55  [&points](Path::Polyline::PointBufferPtr reclaimed) {
56  points = std::move(reclaimed);
57  });
58  single_point_count = polyline.points->size();
59  point_count += single_point_count;
60  }
61  state.counters["SinglePointCount"] = single_point_count;
62  state.counters["TotalPointCount"] = point_count;
63 }
64 
65 template <class... Args>
66 static void BM_StrokePolyline(benchmark::State& state, Args&&... args) {
67  auto args_tuple = std::make_tuple(std::move(args)...);
68  auto path = std::get<Path>(args_tuple);
69  auto cap = std::get<Cap>(args_tuple);
70  auto join = std::get<Join>(args_tuple);
71 
72  const Scalar stroke_width = 5.0f;
73  const Scalar miter_limit = 10.0f;
74  const Scalar scale = 1.0f;
75 
76  auto points = std::make_unique<std::vector<Point>>();
77  points->reserve(2048);
78  auto polyline =
79  path.CreatePolyline(1.0f, std::move(points),
80  [&points](Path::Polyline::PointBufferPtr reclaimed) {
81  points = std::move(reclaimed);
82  });
83 
84  size_t point_count = 0u;
85  size_t single_point_count = 0u;
86  while (state.KeepRunning()) {
88  polyline, stroke_width, miter_limit, join, cap, scale);
89  single_point_count = vertices.size();
90  point_count += single_point_count;
91  }
92  state.counters["SinglePointCount"] = single_point_count;
93  state.counters["TotalPointCount"] = point_count;
94 }
95 
96 template <class... Args>
97 static void BM_Convex(benchmark::State& state, Args&&... args) {
98  auto args_tuple = std::make_tuple(std::move(args)...);
99  auto path = std::get<Path>(args_tuple);
100 
101  size_t point_count = 0u;
102  size_t single_point_count = 0u;
103  auto points = std::make_unique<std::vector<Point>>();
104  auto indices = std::make_unique<std::vector<uint16_t>>();
105  points->reserve(2048);
106  while (state.KeepRunning()) {
107  points->clear();
108  indices->clear();
109  Tessellator::TessellateConvexInternal(path, *points, *indices, 1.0f);
110  single_point_count = indices->size();
111  point_count += indices->size();
112  }
113  state.counters["SinglePointCount"] = single_point_count;
114  state.counters["TotalPointCount"] = point_count;
115 }
116 
117 #define MAKE_STROKE_BENCHMARK_CAPTURE(path, cap, join, closed) \
118  BENCHMARK_CAPTURE(BM_StrokePolyline, stroke_##path##_##cap##_##join, \
119  Create##path(closed), Cap::k##cap, Join::k##join)
120 
121 #define MAKE_STROKE_BENCHMARK_CAPTURE_ALL_CAPS_JOINS(path, closed) \
122  MAKE_STROKE_BENCHMARK_CAPTURE(path, Butt, Bevel, closed); \
123  MAKE_STROKE_BENCHMARK_CAPTURE(path, Butt, Miter, closed); \
124  MAKE_STROKE_BENCHMARK_CAPTURE(path, Butt, Round, closed); \
125  MAKE_STROKE_BENCHMARK_CAPTURE(path, Square, Bevel, closed); \
126  MAKE_STROKE_BENCHMARK_CAPTURE(path, Round, Bevel, closed)
127 
128 BENCHMARK_CAPTURE(BM_Polyline, cubic_polyline, CreateCubic(true));
129 BENCHMARK_CAPTURE(BM_Polyline, unclosed_cubic_polyline, CreateCubic(false));
131 
132 BENCHMARK_CAPTURE(BM_Polyline, quad_polyline, CreateQuadratic(true));
133 BENCHMARK_CAPTURE(BM_Polyline, unclosed_quad_polyline, CreateQuadratic(false));
135 
136 BENCHMARK_CAPTURE(BM_Convex, rrect_convex, CreateRRect(), true);
137 // A round rect has no ends so we don't need to try it with all cap values
138 // but it does have joins and even though they should all be almost
139 // colinear, we run the benchmark against all 3 join values.
140 MAKE_STROKE_BENCHMARK_CAPTURE(RRect, Butt, Bevel, );
141 MAKE_STROKE_BENCHMARK_CAPTURE(RRect, Butt, Miter, );
142 MAKE_STROKE_BENCHMARK_CAPTURE(RRect, Butt, Round, );
143 
144 namespace {
145 
146 Path CreateRRect() {
147  return PathBuilder{}
148  .AddRoundRect(
149  RoundRect::MakeRectXY(Rect::MakeLTRB(0, 0, 400, 400), 16, 16))
150  .TakePath();
151 }
152 
153 Path CreateCubic(bool closed) {
154  auto builder = PathBuilder{};
155  builder //
156  .MoveTo({359.934, 96.6335})
157  .CubicCurveTo({358.189, 96.7055}, {356.436, 96.7908}, {354.673, 96.8895})
158  .CubicCurveTo({354.571, 96.8953}, {354.469, 96.9016}, {354.367, 96.9075})
159  .CubicCurveTo({352.672, 97.0038}, {350.969, 97.113}, {349.259, 97.2355})
160  .CubicCurveTo({349.048, 97.2506}, {348.836, 97.2678}, {348.625, 97.2834})
161  .CubicCurveTo({347.019, 97.4014}, {345.407, 97.5299}, {343.789, 97.6722})
162  .CubicCurveTo({343.428, 97.704}, {343.065, 97.7402}, {342.703, 97.7734})
163  .CubicCurveTo({341.221, 97.9086}, {339.736, 98.0505}, {338.246, 98.207})
164  .CubicCurveTo({337.702, 98.2642}, {337.156, 98.3292}, {336.612, 98.3894})
165  .CubicCurveTo({335.284, 98.5356}, {333.956, 98.6837}, {332.623, 98.8476})
166  .CubicCurveTo({332.495, 98.8635}, {332.366, 98.8818}, {332.237, 98.8982})
167  .LineTo({332.237, 102.601})
168  .LineTo({321.778, 102.601})
169  .LineTo({321.778, 100.382})
170  .CubicCurveTo({321.572, 100.413}, {321.367, 100.442}, {321.161, 100.476})
171  .CubicCurveTo({319.22, 100.79}, {317.277, 101.123}, {315.332, 101.479})
172  .CubicCurveTo({315.322, 101.481}, {315.311, 101.482}, {315.301, 101.484})
173  .LineTo({310.017, 105.94})
174  .LineTo({309.779, 105.427})
175  .LineTo({314.403, 101.651})
176  .CubicCurveTo({314.391, 101.653}, {314.379, 101.656}, {314.368, 101.658})
177  .CubicCurveTo({312.528, 102.001}, {310.687, 102.366}, {308.846, 102.748})
178  .CubicCurveTo({307.85, 102.955}, {306.855, 103.182}, {305.859, 103.4})
179  .CubicCurveTo({305.048, 103.579}, {304.236, 103.75}, {303.425, 103.936})
180  .LineTo({299.105, 107.578})
181  .LineTo({298.867, 107.065})
182  .LineTo({302.394, 104.185})
183  .LineTo({302.412, 104.171})
184  .CubicCurveTo({301.388, 104.409}, {300.366, 104.67}, {299.344, 104.921})
185  .CubicCurveTo({298.618, 105.1}, {297.89, 105.269}, {297.165, 105.455})
186  .CubicCurveTo({295.262, 105.94}, {293.36, 106.445}, {291.462, 106.979})
187  .CubicCurveTo({291.132, 107.072}, {290.802, 107.163}, {290.471, 107.257})
188  .CubicCurveTo({289.463, 107.544}, {288.455, 107.839}, {287.449, 108.139})
189  .CubicCurveTo({286.476, 108.431}, {285.506, 108.73}, {284.536, 109.035})
190  .CubicCurveTo({283.674, 109.304}, {282.812, 109.579}, {281.952, 109.859})
191  .CubicCurveTo({281.177, 110.112}, {280.406, 110.377}, {279.633, 110.638})
192  .CubicCurveTo({278.458, 111.037}, {277.256, 111.449}, {276.803, 111.607})
193  .CubicCurveTo({276.76, 111.622}, {276.716, 111.637}, {276.672, 111.653})
194  .CubicCurveTo({275.017, 112.239}, {273.365, 112.836}, {271.721, 113.463})
195  .LineTo({271.717, 113.449})
196  .CubicCurveTo({271.496, 113.496}, {271.238, 113.559}, {270.963, 113.628})
197  .CubicCurveTo({270.893, 113.645}, {270.822, 113.663}, {270.748, 113.682})
198  .CubicCurveTo({270.468, 113.755}, {270.169, 113.834}, {269.839, 113.926})
199  .CubicCurveTo({269.789, 113.94}, {269.732, 113.957}, {269.681, 113.972})
200  .CubicCurveTo({269.391, 114.053}, {269.081, 114.143}, {268.756, 114.239})
201  .CubicCurveTo({268.628, 114.276}, {268.5, 114.314}, {268.367, 114.354})
202  .CubicCurveTo({268.172, 114.412}, {267.959, 114.478}, {267.752, 114.54})
203  .CubicCurveTo({263.349, 115.964}, {258.058, 117.695}, {253.564, 119.252})
204  .CubicCurveTo({253.556, 119.255}, {253.547, 119.258}, {253.538, 119.261})
205  .CubicCurveTo({251.844, 119.849}, {250.056, 120.474}, {248.189, 121.131})
206  .CubicCurveTo({248, 121.197}, {247.812, 121.264}, {247.621, 121.331})
207  .CubicCurveTo({247.079, 121.522}, {246.531, 121.715}, {245.975, 121.912})
208  .CubicCurveTo({245.554, 122.06}, {245.126, 122.212}, {244.698, 122.364})
209  .CubicCurveTo({244.071, 122.586}, {243.437, 122.811}, {242.794, 123.04})
210  .CubicCurveTo({242.189, 123.255}, {241.58, 123.472}, {240.961, 123.693})
211  .CubicCurveTo({240.659, 123.801}, {240.357, 123.909}, {240.052, 124.018})
212  .CubicCurveTo({239.12, 124.351}, {238.18, 124.687}, {237.22, 125.032})
213  .LineTo({237.164, 125.003})
214  .CubicCurveTo({236.709, 125.184}, {236.262, 125.358}, {235.81, 125.538})
215  .CubicCurveTo({235.413, 125.68}, {234.994, 125.832}, {234.592, 125.977})
216  .CubicCurveTo({234.592, 125.977}, {234.591, 125.977}, {234.59, 125.977})
217  .CubicCurveTo({222.206, 130.435}, {207.708, 135.753}, {192.381, 141.429})
218  .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
219  .LineTo({360, 160})
220  .LineTo({360, 119.256})
221  .LineTo({360, 106.332})
222  .LineTo({360, 96.6307})
223  .CubicCurveTo({359.978, 96.6317}, {359.956, 96.6326}, {359.934, 96.6335});
224  if (closed) {
225  builder.Close();
226  }
227  builder //
228  .MoveTo({337.336, 124.143})
229  .CubicCurveTo({337.274, 122.359}, {338.903, 121.511}, {338.903, 121.511})
230  .CubicCurveTo({338.903, 121.511}, {338.96, 123.303}, {337.336, 124.143});
231  if (closed) {
232  builder.Close();
233  }
234  builder //
235  .MoveTo({340.082, 121.849})
236  .CubicCurveTo({340.074, 121.917}, {340.062, 121.992}, {340.046, 122.075})
237  .CubicCurveTo({340.039, 122.109}, {340.031, 122.142}, {340.023, 122.177})
238  .CubicCurveTo({340.005, 122.26}, {339.98, 122.346}, {339.952, 122.437})
239  .CubicCurveTo({339.941, 122.473}, {339.931, 122.507}, {339.918, 122.544})
240  .CubicCurveTo({339.873, 122.672}, {339.819, 122.804}, {339.75, 122.938})
241  .CubicCurveTo({339.747, 122.944}, {339.743, 122.949}, {339.74, 122.955})
242  .CubicCurveTo({339.674, 123.08}, {339.593, 123.205}, {339.501, 123.328})
243  .CubicCurveTo({339.473, 123.366}, {339.441, 123.401}, {339.41, 123.438})
244  .CubicCurveTo({339.332, 123.534}, {339.243, 123.625}, {339.145, 123.714})
245  .CubicCurveTo({339.105, 123.75}, {339.068, 123.786}, {339.025, 123.821})
246  .CubicCurveTo({338.881, 123.937}, {338.724, 124.048}, {338.539, 124.143})
247  .CubicCurveTo({338.532, 123.959}, {338.554, 123.79}, {338.58, 123.626})
248  .CubicCurveTo({338.58, 123.625}, {338.58, 123.625}, {338.58, 123.625})
249  .CubicCurveTo({338.607, 123.455}, {338.65, 123.299}, {338.704, 123.151})
250  .CubicCurveTo({338.708, 123.14}, {338.71, 123.127}, {338.714, 123.117})
251  .CubicCurveTo({338.769, 122.971}, {338.833, 122.838}, {338.905, 122.712})
252  .CubicCurveTo({338.911, 122.702}, {338.916, 122.69200000000001},
253  {338.922, 122.682})
254  .CubicCurveTo({338.996, 122.557}, {339.072, 122.444}, {339.155, 122.34})
255  .CubicCurveTo({339.161, 122.333}, {339.166, 122.326}, {339.172, 122.319})
256  .CubicCurveTo({339.256, 122.215}, {339.339, 122.12}, {339.425, 122.037})
257  .CubicCurveTo({339.428, 122.033}, {339.431, 122.03}, {339.435, 122.027})
258  .CubicCurveTo({339.785, 121.687}, {340.106, 121.511}, {340.106, 121.511})
259  .CubicCurveTo({340.106, 121.511}, {340.107, 121.645}, {340.082, 121.849});
260  if (closed) {
261  builder.Close();
262  }
263  builder //
264  .MoveTo({340.678, 113.245})
265  .CubicCurveTo({340.594, 113.488}, {340.356, 113.655}, {340.135, 113.775})
266  .CubicCurveTo({339.817, 113.948}, {339.465, 114.059}, {339.115, 114.151})
267  .CubicCurveTo({338.251, 114.379}, {337.34, 114.516}, {336.448, 114.516})
268  .CubicCurveTo({335.761, 114.516}, {335.072, 114.527}, {334.384, 114.513})
269  .CubicCurveTo({334.125, 114.508}, {333.862, 114.462}, {333.605, 114.424})
270  .CubicCurveTo({332.865, 114.318}, {332.096, 114.184}, {331.41, 113.883})
271  .CubicCurveTo({330.979, 113.695}, {330.442, 113.34}, {330.672, 112.813})
272  .CubicCurveTo({331.135, 111.755}, {333.219, 112.946}, {334.526, 113.833})
273  .CubicCurveTo({334.54, 113.816}, {334.554, 113.8}, {334.569, 113.784})
274  .CubicCurveTo({333.38, 112.708}, {331.749, 110.985}, {332.76, 110.402})
275  .CubicCurveTo({333.769, 109.82}, {334.713, 111.93}, {335.228, 113.395})
276  .CubicCurveTo({334.915, 111.889}, {334.59, 109.636}, {335.661, 109.592})
277  .CubicCurveTo({336.733, 109.636}, {336.408, 111.889}, {336.07, 113.389})
278  .CubicCurveTo({336.609, 111.93}, {337.553, 109.82}, {338.563, 110.402})
279  .CubicCurveTo({339.574, 110.984}, {337.942, 112.708}, {336.753, 113.784})
280  .CubicCurveTo({336.768, 113.8}, {336.782, 113.816}, {336.796, 113.833})
281  .CubicCurveTo({338.104, 112.946}, {340.187, 111.755}, {340.65, 112.813})
282  .CubicCurveTo({340.71, 112.95}, {340.728, 113.102}, {340.678, 113.245});
283  if (closed) {
284  builder.Close();
285  }
286  builder //
287  .MoveTo({346.357, 106.771})
288  .CubicCurveTo({346.295, 104.987}, {347.924, 104.139}, {347.924, 104.139})
289  .CubicCurveTo({347.924, 104.139}, {347.982, 105.931}, {346.357, 106.771});
290  if (closed) {
291  builder.Close();
292  }
293  builder //
294  .MoveTo({347.56, 106.771})
295  .CubicCurveTo({347.498, 104.987}, {349.127, 104.139}, {349.127, 104.139})
296  .CubicCurveTo({349.127, 104.139}, {349.185, 105.931}, {347.56, 106.771});
297  if (closed) {
298  builder.Close();
299  }
300  return builder.TakePath();
301 }
302 
303 Path CreateQuadratic(bool closed) {
304  auto builder = PathBuilder{};
305  builder //
306  .MoveTo({359.934, 96.6335})
307  .QuadraticCurveTo({358.189, 96.7055}, {354.673, 96.8895})
308  .QuadraticCurveTo({354.571, 96.8953}, {354.367, 96.9075})
309  .QuadraticCurveTo({352.672, 97.0038}, {349.259, 97.2355})
310  .QuadraticCurveTo({349.048, 97.2506}, {348.625, 97.2834})
311  .QuadraticCurveTo({347.019, 97.4014}, {343.789, 97.6722})
312  .QuadraticCurveTo({343.428, 97.704}, {342.703, 97.7734})
313  .QuadraticCurveTo({341.221, 97.9086}, {338.246, 98.207})
314  .QuadraticCurveTo({337.702, 98.2642}, {336.612, 98.3894})
315  .QuadraticCurveTo({335.284, 98.5356}, {332.623, 98.8476})
316  .QuadraticCurveTo({332.495, 98.8635}, {332.237, 98.8982})
317  .LineTo({332.237, 102.601})
318  .LineTo({321.778, 102.601})
319  .LineTo({321.778, 100.382})
320  .QuadraticCurveTo({321.572, 100.413}, {321.161, 100.476})
321  .QuadraticCurveTo({319.22, 100.79}, {315.332, 101.479})
322  .QuadraticCurveTo({315.322, 101.481}, {315.301, 101.484})
323  .LineTo({310.017, 105.94})
324  .LineTo({309.779, 105.427})
325  .LineTo({314.403, 101.651})
326  .QuadraticCurveTo({314.391, 101.653}, {314.368, 101.658})
327  .QuadraticCurveTo({312.528, 102.001}, {308.846, 102.748})
328  .QuadraticCurveTo({307.85, 102.955}, {305.859, 103.4})
329  .QuadraticCurveTo({305.048, 103.579}, {303.425, 103.936})
330  .LineTo({299.105, 107.578})
331  .LineTo({298.867, 107.065})
332  .LineTo({302.394, 104.185})
333  .LineTo({302.412, 104.171})
334  .QuadraticCurveTo({301.388, 104.409}, {299.344, 104.921})
335  .QuadraticCurveTo({298.618, 105.1}, {297.165, 105.455})
336  .QuadraticCurveTo({295.262, 105.94}, {291.462, 106.979})
337  .QuadraticCurveTo({291.132, 107.072}, {290.471, 107.257})
338  .QuadraticCurveTo({289.463, 107.544}, {287.449, 108.139})
339  .QuadraticCurveTo({286.476, 108.431}, {284.536, 109.035})
340  .QuadraticCurveTo({283.674, 109.304}, {281.952, 109.859})
341  .QuadraticCurveTo({281.177, 110.112}, {279.633, 110.638})
342  .QuadraticCurveTo({278.458, 111.037}, {276.803, 111.607})
343  .QuadraticCurveTo({276.76, 111.622}, {276.672, 111.653})
344  .QuadraticCurveTo({275.017, 112.239}, {271.721, 113.463})
345  .LineTo({271.717, 113.449})
346  .QuadraticCurveTo({271.496, 113.496}, {270.963, 113.628})
347  .QuadraticCurveTo({270.893, 113.645}, {270.748, 113.682})
348  .QuadraticCurveTo({270.468, 113.755}, {269.839, 113.926})
349  .QuadraticCurveTo({269.789, 113.94}, {269.681, 113.972})
350  .QuadraticCurveTo({269.391, 114.053}, {268.756, 114.239})
351  .QuadraticCurveTo({268.628, 114.276}, {268.367, 114.354})
352  .QuadraticCurveTo({268.172, 114.412}, {267.752, 114.54})
353  .QuadraticCurveTo({263.349, 115.964}, {253.564, 119.252})
354  .QuadraticCurveTo({253.556, 119.255}, {253.538, 119.261})
355  .QuadraticCurveTo({251.844, 119.849}, {248.189, 121.131})
356  .QuadraticCurveTo({248, 121.197}, {247.621, 121.331})
357  .QuadraticCurveTo({247.079, 121.522}, {245.975, 121.912})
358  .QuadraticCurveTo({245.554, 122.06}, {244.698, 122.364})
359  .QuadraticCurveTo({244.071, 122.586}, {242.794, 123.04})
360  .QuadraticCurveTo({242.189, 123.255}, {240.961, 123.693})
361  .QuadraticCurveTo({240.659, 123.801}, {240.052, 124.018})
362  .QuadraticCurveTo({239.12, 124.351}, {237.22, 125.032})
363  .LineTo({237.164, 125.003})
364  .QuadraticCurveTo({236.709, 125.184}, {235.81, 125.538})
365  .QuadraticCurveTo({235.413, 125.68}, {234.592, 125.977})
366  .QuadraticCurveTo({234.592, 125.977}, {234.59, 125.977})
367  .QuadraticCurveTo({222.206, 130.435}, {192.381, 141.429})
368  .QuadraticCurveTo({162.77, 151.336}, {84.1123, 160})
369  .LineTo({360, 160})
370  .LineTo({360, 119.256})
371  .LineTo({360, 106.332})
372  .LineTo({360, 96.6307})
373  .QuadraticCurveTo({359.978, 96.6317}, {359.934, 96.6335});
374  if (closed) {
375  builder.Close();
376  }
377  builder //
378  .MoveTo({337.336, 124.143})
379  .QuadraticCurveTo({337.274, 122.359}, {338.903, 121.511})
380  .QuadraticCurveTo({338.903, 121.511}, {337.336, 124.143});
381  if (closed) {
382  builder.Close();
383  }
384  builder //
385  .MoveTo({340.082, 121.849})
386  .QuadraticCurveTo({340.074, 121.917}, {340.046, 122.075})
387  .QuadraticCurveTo({340.039, 122.109}, {340.023, 122.177})
388  .QuadraticCurveTo({340.005, 122.26}, {339.952, 122.437})
389  .QuadraticCurveTo({339.941, 122.473}, {339.918, 122.544})
390  .QuadraticCurveTo({339.873, 122.672}, {339.75, 122.938})
391  .QuadraticCurveTo({339.747, 122.944}, {339.74, 122.955})
392  .QuadraticCurveTo({339.674, 123.08}, {339.501, 123.328})
393  .QuadraticCurveTo({339.473, 123.366}, {339.41, 123.438})
394  .QuadraticCurveTo({339.332, 123.534}, {339.145, 123.714})
395  .QuadraticCurveTo({339.105, 123.75}, {339.025, 123.821})
396  .QuadraticCurveTo({338.881, 123.937}, {338.539, 124.143})
397  .QuadraticCurveTo({338.532, 123.959}, {338.58, 123.626})
398  .QuadraticCurveTo({338.58, 123.625}, {338.58, 123.625})
399  .QuadraticCurveTo({338.607, 123.455}, {338.704, 123.151})
400  .QuadraticCurveTo({338.708, 123.14}, {338.714, 123.117})
401  .QuadraticCurveTo({338.769, 122.971}, {338.905, 122.712})
402  .QuadraticCurveTo({338.911, 122.702}, {338.922, 122.682})
403  .QuadraticCurveTo({338.996, 122.557}, {339.155, 122.34})
404  .QuadraticCurveTo({339.161, 122.333}, {339.172, 122.319})
405  .QuadraticCurveTo({339.256, 122.215}, {339.425, 122.037})
406  .QuadraticCurveTo({339.428, 122.033}, {339.435, 122.027})
407  .QuadraticCurveTo({339.785, 121.687}, {340.106, 121.511})
408  .QuadraticCurveTo({340.106, 121.511}, {340.082, 121.849});
409  if (closed) {
410  builder.Close();
411  }
412  builder //
413  .MoveTo({340.678, 113.245})
414  .QuadraticCurveTo({340.594, 113.488}, {340.135, 113.775})
415  .QuadraticCurveTo({339.817, 113.948}, {339.115, 114.151})
416  .QuadraticCurveTo({338.251, 114.379}, {336.448, 114.516})
417  .QuadraticCurveTo({335.761, 114.516}, {334.384, 114.513})
418  .QuadraticCurveTo({334.125, 114.508}, {333.605, 114.424})
419  .QuadraticCurveTo({332.865, 114.318}, {331.41, 113.883})
420  .QuadraticCurveTo({330.979, 113.695}, {330.672, 112.813})
421  .QuadraticCurveTo({331.135, 111.755}, {334.526, 113.833})
422  .QuadraticCurveTo({334.54, 113.816}, {334.569, 113.784})
423  .QuadraticCurveTo({333.38, 112.708}, {332.76, 110.402})
424  .QuadraticCurveTo({333.769, 109.82}, {335.228, 113.395})
425  .QuadraticCurveTo({334.915, 111.889}, {335.661, 109.592})
426  .QuadraticCurveTo({336.733, 109.636}, {336.07, 113.389})
427  .QuadraticCurveTo({336.609, 111.93}, {338.563, 110.402})
428  .QuadraticCurveTo({339.574, 110.984}, {336.753, 113.784})
429  .QuadraticCurveTo({336.768, 113.8}, {336.796, 113.833})
430  .QuadraticCurveTo({338.104, 112.946}, {340.65, 112.813})
431  .QuadraticCurveTo({340.71, 112.95}, {340.678, 113.245});
432  if (closed) {
433  builder.Close();
434  }
435  builder //
436  .MoveTo({346.357, 106.771})
437  .QuadraticCurveTo({346.295, 104.987}, {347.924, 104.139})
438  .QuadraticCurveTo({347.924, 104.139}, {346.357, 106.771});
439  if (closed) {
440  builder.Close();
441  }
442  builder //
443  .MoveTo({347.56, 106.771})
444  .QuadraticCurveTo({347.498, 104.987}, {349.127, 104.139})
445  .QuadraticCurveTo({349.127, 104.139}, {347.56, 106.771});
446  if (closed) {
447  builder.Close();
448  }
449  return builder.TakePath();
450 }
451 
452 } // namespace
453 } // namespace impeller
static std::vector< Point > GenerateSolidStrokeVertices(const Path::Polyline &polyline, Scalar stroke_width, Scalar miter_limit, Join stroke_join, Cap stroke_cap, Scalar scale)
Path TakePath(FillType fill=FillType::kNonZero)
Definition: path_builder.cc:28
PathBuilder & AddRoundRect(RoundRect rect)
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition: path.h:53
static void TessellateConvexInternal(const Path &path, std::vector< Point > &point_buffer, std::vector< uint16_t > &index_buffer, Scalar tolerance)
Definition: tessellator.cc:164
An extended tessellator that offers arbitrary/concave tessellation via the libtess2 library.
Join
Definition: path.h:25
float Scalar
Definition: scalar.h:18
static TessellatorLibtess tess
BENCHMARK_CAPTURE(BM_Polyline, cubic_polyline, CreateCubic(true))
Cap
Definition: path.h:19
MAKE_STROKE_BENCHMARK_CAPTURE_ALL_CAPS_JOINS(Cubic, false)
static void BM_Convex(benchmark::State &state, Args &&... args)
MAKE_STROKE_BENCHMARK_CAPTURE(RRect, Butt, Bevel,)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
Definition: tessellator.cc:24
static void BM_Polyline(benchmark::State &state, Args &&... args)
static void BM_StrokePolyline(benchmark::State &state, Args &&... args)
const Scalar stroke_width
const Scalar scale
const Path::Polyline & polyline
std::unique_ptr< std::vector< Point > > PointBufferPtr
Definition: path.h:114
PointBufferPtr points
Definition: path.h:126
constexpr static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
Definition: round_rect.h:30
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129