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