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