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/display_list/geometry/dl_path.h"
8 #include "flutter/display_list/geometry/dl_path_builder.h"
12 
13 namespace impeller {
14 
16  public:
17  static std::vector<Point> GenerateSolidStrokeVertices(
18  Tessellator& tessellator,
19  const PathSource& path,
20  const StrokeParameters& stroke,
21  Scalar scale) {
22  return StrokePathGeometry::GenerateSolidStrokeVertices( //
23  tessellator, path, stroke, scale);
24  }
25 };
26 
27 namespace {
28 /// A path with many connected cubic components, including
29 /// overlaps/self-intersections/multi-contour.
30 flutter::DlPath CreateCubic(bool closed);
31 /// Similar to the path above, but with all cubics replaced by quadratics.
32 flutter::DlPath CreateQuadratic(bool closed);
33 /// Create a rounded rect.
34 flutter::DlPath CreateRRect();
35 /// Create a rounded superellipse.
36 flutter::DlPath CreateRSuperellipse();
37 /// Create a clockwise triangle path.
38 flutter::DlPath CreateClockwiseTriangle();
39 /// Create a counter-clockwise triangle path.
40 flutter::DlPath CreateCounterClockwiseTriangle();
41 /// Create a clockwise rect path.
42 flutter::DlPath CreateClockwiseRect();
43 /// Create a counter-clockwise rect path.
44 flutter::DlPath CreateCounterClockwiseRect();
45 /// Create a clockwise multi-radii round rect path.
46 flutter::DlPath CreateClockwiseMultiRadiiRoundRect();
47 /// Create a counter-clockwise multi-radii round rect path.
48 flutter::DlPath CreateCounterClockwiseMultiRadiiRoundRect();
49 /// Create a clockwise polygonal path.
50 flutter::DlPath CreateClockwisePolygon();
51 /// Create a counter-clockwise polygonal path.
52 flutter::DlPath CreateCounterClockwisePolygon();
53 } // namespace
54 
56 
57 template <class... Args>
58 static void BM_StrokePath(benchmark::State& state, Args&&... args) {
59  auto args_tuple = std::make_tuple(std::move(args)...);
60  auto path = std::get<flutter::DlPath>(args_tuple);
61 
62  Tessellator tessellator;
63  StrokeParameters stroke{
64  .width = 5.0f,
65  .cap = std::get<Cap>(args_tuple),
66  .join = std::get<Join>(args_tuple),
67  .miter_limit = 10.0f,
68  };
69 
70  const Scalar scale = 1.0f;
71 
72  size_t point_count = 0u;
73  size_t single_point_count = 0u;
74  while (state.KeepRunning()) {
76  tessellator, path, stroke, scale);
77  single_point_count = vertices.size();
78  point_count += single_point_count;
79  }
80  state.counters["SinglePointCount"] = single_point_count;
81  state.counters["TotalPointCount"] = point_count;
82 }
83 
84 template <class... Args>
85 static void BM_Convex(benchmark::State& state, Args&&... args) {
86  auto args_tuple = std::make_tuple(std::move(args)...);
87  auto path = flutter::DlPath(std::get<flutter::DlPath>(args_tuple));
88 
89  size_t point_count = 0u;
90  size_t single_point_count = 0u;
91  auto points = std::make_unique<std::vector<Point>>();
92  auto indices = std::make_unique<std::vector<uint16_t>>();
93  points->reserve(2048);
94  while (state.KeepRunning()) {
95  points->clear();
96  indices->clear();
97  Tessellator::TessellateConvexInternal(path, *points, *indices, 1.0f);
98  single_point_count = indices->size();
99  point_count += indices->size();
100  }
101  state.counters["SinglePointCount"] = single_point_count;
102  state.counters["TotalPointCount"] = point_count;
103 }
104 
105 template <class... Args>
106 static void BM_ShadowPathVerticesImpeller(benchmark::State& state,
107  Args&&... args) {
108  auto args_tuple = std::make_tuple(std::move(args)...);
109  auto path = std::get<flutter::DlPath>(args_tuple);
110  auto height = std::get<Scalar>(args_tuple);
111  auto matrix = std::get<Matrix>(args_tuple);
112 
113  Tessellator tessellator;
114 
115  while (state.KeepRunning()) {
117  tessellator, path, height, matrix);
118  FML_CHECK(result != nullptr);
119  }
120 }
121 
122 #define MAKE_SHADOW_BENCHMARK_CAPTURE(clockwise, shape, backend) \
123  BENCHMARK_CAPTURE(BM_ShadowPathVertices##backend, \
124  shadow_##clockwise##_##shape##_##backend, \
125  Create##clockwise##shape(), 20.0f, Matrix{})
126 
127 #define MAKE_SHADOW_BENCHMARK_SHAPE_CAPTURE(shape, backend) \
128  MAKE_SHADOW_BENCHMARK_CAPTURE(Clockwise, shape, backend); \
129  MAKE_SHADOW_BENCHMARK_CAPTURE(CounterClockwise, shape, backend)
130 
131 #define MAKE_SHADOW_BENCHMARK_CAPTURE_ALL_SHAPES(backend) \
132  MAKE_SHADOW_BENCHMARK_SHAPE_CAPTURE(Triangle, backend); \
133  MAKE_SHADOW_BENCHMARK_SHAPE_CAPTURE(Rect, backend); \
134  MAKE_SHADOW_BENCHMARK_SHAPE_CAPTURE(MultiRadiiRoundRect, backend); \
135  MAKE_SHADOW_BENCHMARK_SHAPE_CAPTURE(Polygon, backend)
136 
138 
139 #define MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, cap, join, closed) \
140  BENCHMARK_CAPTURE(BM_StrokePath, stroke_##path##_##cap##_##join, \
141  Create##path(closed), Cap::k##cap, Join::k##join)
142 
143 #define MAKE_STROKE_BENCHMARK_CAPTURE_ALL_CAPS_JOINS(path, closed) \
144  MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, Butt, Bevel, closed); \
145  MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, Butt, Miter, closed); \
146  MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, Butt, Round, closed); \
147  MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, Square, Bevel, closed); \
148  MAKE_STROKE_PATH_BENCHMARK_CAPTURE(path, Round, Bevel, closed)
149 
151 
153 
154 BENCHMARK_CAPTURE(BM_Convex, rrect_convex, CreateRRect(), true);
155 // A round rect has no ends so we don't need to try it with all cap values
156 // but it does have joins and even though they should all be almost
157 // colinear, we run the benchmark against all 3 join values.
161 
162 // Same as RRect
163 BENCHMARK_CAPTURE(BM_Convex, rse_convex, CreateRSuperellipse(), true);
164 MAKE_STROKE_PATH_BENCHMARK_CAPTURE(RSuperellipse, Butt, Bevel, );
165 MAKE_STROKE_PATH_BENCHMARK_CAPTURE(RSuperellipse, Butt, Miter, );
166 MAKE_STROKE_PATH_BENCHMARK_CAPTURE(RSuperellipse, Butt, Round, );
167 
168 namespace {
169 
170 flutter::DlPath CreateClockwiseTriangle() {
171  flutter::DlPathBuilder builder;
172  builder.MoveTo(flutter::DlPoint(100, 100));
173  builder.LineTo(flutter::DlPoint(300, 100));
174  builder.LineTo(flutter::DlPoint(200, 300));
175  builder.Close();
176  return builder.TakePath();
177 }
178 
179 flutter::DlPath CreateCounterClockwiseTriangle() {
180  flutter::DlPathBuilder builder;
181  builder.MoveTo(flutter::DlPoint(100, 100));
182  builder.LineTo(flutter::DlPoint(200, 300));
183  builder.LineTo(flutter::DlPoint(300, 100));
184  builder.Close();
185  return builder.TakePath();
186 }
187 
188 flutter::DlPath CreateClockwiseRect() {
189  flutter::DlPathBuilder builder;
190  builder.MoveTo(flutter::DlPoint(100, 100));
191  builder.LineTo(flutter::DlPoint(300, 100));
192  builder.LineTo(flutter::DlPoint(300, 300));
193  builder.LineTo(flutter::DlPoint(100, 300));
194  builder.Close();
195  return builder.TakePath();
196 }
197 
198 flutter::DlPath CreateCounterClockwiseRect() {
199  flutter::DlPathBuilder builder;
200  builder.MoveTo(flutter::DlPoint(100, 100));
201  builder.LineTo(flutter::DlPoint(100, 300));
202  builder.LineTo(flutter::DlPoint(300, 300));
203  builder.LineTo(flutter::DlPoint(300, 100));
204  builder.Close();
205  return builder.TakePath();
206 }
207 
208 class HorizontalPathFlipper : private flutter::DlPathReceiver {
209  public:
210  HorizontalPathFlipper(const flutter::DlPath& path, Scalar flip_coordinate)
211  : flip_coordinate_(flip_coordinate) {
212  path.Dispatch(*this);
213  }
214 
215  flutter::DlPath TakePath() { return builder_.TakePath(); }
216 
217  private:
218  const Scalar flip_coordinate_;
219  flutter::DlPathBuilder builder_;
220 
222  return flutter::DlPoint(flip_coordinate_ * 2 - p.x, p.y);
223  }
224 
225  // |flutter::DlPathReceiver|
226  void MoveTo(const Point& p2, bool will_be_closed) override {
227  builder_.MoveTo(flip(p2));
228  }
229 
230  // |flutter::DlPathReceiver|
231  void LineTo(const Point& p2) override { //
232  builder_.LineTo(flip(p2));
233  }
234 
235  // |flutter::DlPathReceiver|
236  void QuadTo(const Point& cp, const Point& p2) override {
237  builder_.QuadraticCurveTo(flip(cp), flip(p2));
238  }
239 
240  // |flutter::DlPathReceiver|
241  bool ConicTo(const Point& cp, const Point& p2, Scalar weight) override {
242  builder_.ConicCurveTo(flip(cp), flip(p2), weight);
243  return true;
244  }
245 
246  // |flutter::DlPathReceiver|
247  void CubicTo(const Point& cp1, const Point& cp2, const Point& p2) override {
248  builder_.CubicCurveTo(flip(cp1), flip(cp2), flip(p2));
249  }
250 
251  // |flutter::DlPathReceiver|
252  void Close() override {}
253 };
254 
255 flutter::DlPath CreateClockwiseMultiRadiiRoundRect() {
256  // Upper left corner: 10 x 15
257  // Upper right corner: 15 x 10
258  // Bottom right corner: 16 x 20
259  // Bottom left corner: 20 x 16
260  flutter::DlPathBuilder builder;
261  builder.MoveTo(flutter::DlPoint(110, 100));
262  builder.LineTo(flutter::DlPoint(285, 100));
263  builder.ConicCurveTo(flutter::DlPoint(300, 100), flutter::DlPoint(300, 110),
264  kSqrt2);
265  builder.LineTo(flutter::DlPoint(300, 280));
266  builder.ConicCurveTo(flutter::DlPoint(300, 300), flutter::DlPoint(284, 300),
267  kSqrt2);
268  builder.LineTo(flutter::DlPoint(120, 300));
269  builder.ConicCurveTo(flutter::DlPoint(100, 300), flutter::DlPoint(100, 284),
270  kSqrt2);
271  builder.LineTo(flutter::DlPoint(100, 115));
272  builder.ConicCurveTo(flutter::DlPoint(100, 100), flutter::DlPoint(110, 100),
273  kSqrt2);
274  builder.Close();
275  return builder.TakePath();
276 }
277 
278 flutter::DlPath CreateCounterClockwiseMultiRadiiRoundRect() {
279  flutter::DlPath clockwise_path = CreateClockwiseMultiRadiiRoundRect();
280  return HorizontalPathFlipper(clockwise_path, 200.0f).TakePath();
281 }
282 
283 flutter::DlPath CreatePolygon(bool clockwise) {
284  int vertex_count = 40;
285  Scalar direction = clockwise ? 1.0f : -1.0f;
286 
287  auto make_point = [](Scalar angle) {
288  return flutter::DlPoint(200 + 100 * std::cos(angle),
289  200 + 100 * std::sin(angle));
290  };
291 
292  flutter::DlPathBuilder builder;
293  builder.MoveTo(make_point(0.0f));
294  for (int i = 1; i < vertex_count; i++) {
295  Scalar angle = (static_cast<Scalar>(i) / vertex_count) * k2Pi;
296  builder.LineTo(make_point(angle * direction));
297  }
298  builder.Close();
299  return builder.TakePath();
300 }
301 
302 flutter::DlPath CreateClockwisePolygon() {
303  return CreatePolygon(true);
304 }
305 
306 flutter::DlPath CreateCounterClockwisePolygon() {
307  return CreatePolygon(false);
308 }
309 
310 flutter::DlPath CreateRRect() {
311  return flutter::DlPathBuilder{}
312  .AddRoundRect(
313  RoundRect::MakeRectXY(Rect::MakeLTRB(0, 0, 400, 400), 16, 16))
314  .TakePath();
315 }
316 
317 flutter::DlPath CreateRSuperellipse() {
318  return flutter::DlPathBuilder{}
319  .AddRoundSuperellipse(
320  RoundSuperellipse::MakeRectXY(Rect::MakeLTRB(0, 0, 400, 400), 16, 16))
321  .TakePath();
322 }
323 
324 flutter::DlPath CreateCubic(bool closed) {
325  auto builder = flutter::DlPathBuilder{};
326  builder //
327  .MoveTo({359.934, 96.6335})
328  .CubicCurveTo({358.189, 96.7055}, {356.436, 96.7908}, {354.673, 96.8895})
329  .CubicCurveTo({354.571, 96.8953}, {354.469, 96.9016}, {354.367, 96.9075})
330  .CubicCurveTo({352.672, 97.0038}, {350.969, 97.113}, {349.259, 97.2355})
331  .CubicCurveTo({349.048, 97.2506}, {348.836, 97.2678}, {348.625, 97.2834})
332  .CubicCurveTo({347.019, 97.4014}, {345.407, 97.5299}, {343.789, 97.6722})
333  .CubicCurveTo({343.428, 97.704}, {343.065, 97.7402}, {342.703, 97.7734})
334  .CubicCurveTo({341.221, 97.9086}, {339.736, 98.0505}, {338.246, 98.207})
335  .CubicCurveTo({337.702, 98.2642}, {337.156, 98.3292}, {336.612, 98.3894})
336  .CubicCurveTo({335.284, 98.5356}, {333.956, 98.6837}, {332.623, 98.8476})
337  .CubicCurveTo({332.495, 98.8635}, {332.366, 98.8818}, {332.237, 98.8982})
338  .LineTo({332.237, 102.601})
339  .LineTo({321.778, 102.601})
340  .LineTo({321.778, 100.382})
341  .CubicCurveTo({321.572, 100.413}, {321.367, 100.442}, {321.161, 100.476})
342  .CubicCurveTo({319.22, 100.79}, {317.277, 101.123}, {315.332, 101.479})
343  .CubicCurveTo({315.322, 101.481}, {315.311, 101.482}, {315.301, 101.484})
344  .LineTo({310.017, 105.94})
345  .LineTo({309.779, 105.427})
346  .LineTo({314.403, 101.651})
347  .CubicCurveTo({314.391, 101.653}, {314.379, 101.656}, {314.368, 101.658})
348  .CubicCurveTo({312.528, 102.001}, {310.687, 102.366}, {308.846, 102.748})
349  .CubicCurveTo({307.85, 102.955}, {306.855, 103.182}, {305.859, 103.4})
350  .CubicCurveTo({305.048, 103.579}, {304.236, 103.75}, {303.425, 103.936})
351  .LineTo({299.105, 107.578})
352  .LineTo({298.867, 107.065})
353  .LineTo({302.394, 104.185})
354  .LineTo({302.412, 104.171})
355  .CubicCurveTo({301.388, 104.409}, {300.366, 104.67}, {299.344, 104.921})
356  .CubicCurveTo({298.618, 105.1}, {297.89, 105.269}, {297.165, 105.455})
357  .CubicCurveTo({295.262, 105.94}, {293.36, 106.445}, {291.462, 106.979})
358  .CubicCurveTo({291.132, 107.072}, {290.802, 107.163}, {290.471, 107.257})
359  .CubicCurveTo({289.463, 107.544}, {288.455, 107.839}, {287.449, 108.139})
360  .CubicCurveTo({286.476, 108.431}, {285.506, 108.73}, {284.536, 109.035})
361  .CubicCurveTo({283.674, 109.304}, {282.812, 109.579}, {281.952, 109.859})
362  .CubicCurveTo({281.177, 110.112}, {280.406, 110.377}, {279.633, 110.638})
363  .CubicCurveTo({278.458, 111.037}, {277.256, 111.449}, {276.803, 111.607})
364  .CubicCurveTo({276.76, 111.622}, {276.716, 111.637}, {276.672, 111.653})
365  .CubicCurveTo({275.017, 112.239}, {273.365, 112.836}, {271.721, 113.463})
366  .LineTo({271.717, 113.449})
367  .CubicCurveTo({271.496, 113.496}, {271.238, 113.559}, {270.963, 113.628})
368  .CubicCurveTo({270.893, 113.645}, {270.822, 113.663}, {270.748, 113.682})
369  .CubicCurveTo({270.468, 113.755}, {270.169, 113.834}, {269.839, 113.926})
370  .CubicCurveTo({269.789, 113.94}, {269.732, 113.957}, {269.681, 113.972})
371  .CubicCurveTo({269.391, 114.053}, {269.081, 114.143}, {268.756, 114.239})
372  .CubicCurveTo({268.628, 114.276}, {268.5, 114.314}, {268.367, 114.354})
373  .CubicCurveTo({268.172, 114.412}, {267.959, 114.478}, {267.752, 114.54})
374  .CubicCurveTo({263.349, 115.964}, {258.058, 117.695}, {253.564, 119.252})
375  .CubicCurveTo({253.556, 119.255}, {253.547, 119.258}, {253.538, 119.261})
376  .CubicCurveTo({251.844, 119.849}, {250.056, 120.474}, {248.189, 121.131})
377  .CubicCurveTo({248, 121.197}, {247.812, 121.264}, {247.621, 121.331})
378  .CubicCurveTo({247.079, 121.522}, {246.531, 121.715}, {245.975, 121.912})
379  .CubicCurveTo({245.554, 122.06}, {245.126, 122.212}, {244.698, 122.364})
380  .CubicCurveTo({244.071, 122.586}, {243.437, 122.811}, {242.794, 123.04})
381  .CubicCurveTo({242.189, 123.255}, {241.58, 123.472}, {240.961, 123.693})
382  .CubicCurveTo({240.659, 123.801}, {240.357, 123.909}, {240.052, 124.018})
383  .CubicCurveTo({239.12, 124.351}, {238.18, 124.687}, {237.22, 125.032})
384  .LineTo({237.164, 125.003})
385  .CubicCurveTo({236.709, 125.184}, {236.262, 125.358}, {235.81, 125.538})
386  .CubicCurveTo({235.413, 125.68}, {234.994, 125.832}, {234.592, 125.977})
387  .CubicCurveTo({234.592, 125.977}, {234.591, 125.977}, {234.59, 125.977})
388  .CubicCurveTo({222.206, 130.435}, {207.708, 135.753}, {192.381, 141.429})
389  .CubicCurveTo({162.77, 151.336}, {122.17, 156.894}, {84.1123, 160})
390  .LineTo({360, 160})
391  .LineTo({360, 119.256})
392  .LineTo({360, 106.332})
393  .LineTo({360, 96.6307})
394  .CubicCurveTo({359.978, 96.6317}, {359.956, 96.6326}, {359.934, 96.6335});
395  if (closed) {
396  builder.Close();
397  }
398  builder //
399  .MoveTo({337.336, 124.143})
400  .CubicCurveTo({337.274, 122.359}, {338.903, 121.511}, {338.903, 121.511})
401  .CubicCurveTo({338.903, 121.511}, {338.96, 123.303}, {337.336, 124.143});
402  if (closed) {
403  builder.Close();
404  }
405  builder //
406  .MoveTo({340.082, 121.849})
407  .CubicCurveTo({340.074, 121.917}, {340.062, 121.992}, {340.046, 122.075})
408  .CubicCurveTo({340.039, 122.109}, {340.031, 122.142}, {340.023, 122.177})
409  .CubicCurveTo({340.005, 122.26}, {339.98, 122.346}, {339.952, 122.437})
410  .CubicCurveTo({339.941, 122.473}, {339.931, 122.507}, {339.918, 122.544})
411  .CubicCurveTo({339.873, 122.672}, {339.819, 122.804}, {339.75, 122.938})
412  .CubicCurveTo({339.747, 122.944}, {339.743, 122.949}, {339.74, 122.955})
413  .CubicCurveTo({339.674, 123.08}, {339.593, 123.205}, {339.501, 123.328})
414  .CubicCurveTo({339.473, 123.366}, {339.441, 123.401}, {339.41, 123.438})
415  .CubicCurveTo({339.332, 123.534}, {339.243, 123.625}, {339.145, 123.714})
416  .CubicCurveTo({339.105, 123.75}, {339.068, 123.786}, {339.025, 123.821})
417  .CubicCurveTo({338.881, 123.937}, {338.724, 124.048}, {338.539, 124.143})
418  .CubicCurveTo({338.532, 123.959}, {338.554, 123.79}, {338.58, 123.626})
419  .CubicCurveTo({338.58, 123.625}, {338.58, 123.625}, {338.58, 123.625})
420  .CubicCurveTo({338.607, 123.455}, {338.65, 123.299}, {338.704, 123.151})
421  .CubicCurveTo({338.708, 123.14}, {338.71, 123.127}, {338.714, 123.117})
422  .CubicCurveTo({338.769, 122.971}, {338.833, 122.838}, {338.905, 122.712})
423  .CubicCurveTo({338.911, 122.702}, {338.916, 122.69200000000001},
424  {338.922, 122.682})
425  .CubicCurveTo({338.996, 122.557}, {339.072, 122.444}, {339.155, 122.34})
426  .CubicCurveTo({339.161, 122.333}, {339.166, 122.326}, {339.172, 122.319})
427  .CubicCurveTo({339.256, 122.215}, {339.339, 122.12}, {339.425, 122.037})
428  .CubicCurveTo({339.428, 122.033}, {339.431, 122.03}, {339.435, 122.027})
429  .CubicCurveTo({339.785, 121.687}, {340.106, 121.511}, {340.106, 121.511})
430  .CubicCurveTo({340.106, 121.511}, {340.107, 121.645}, {340.082, 121.849});
431  if (closed) {
432  builder.Close();
433  }
434  builder //
435  .MoveTo({340.678, 113.245})
436  .CubicCurveTo({340.594, 113.488}, {340.356, 113.655}, {340.135, 113.775})
437  .CubicCurveTo({339.817, 113.948}, {339.465, 114.059}, {339.115, 114.151})
438  .CubicCurveTo({338.251, 114.379}, {337.34, 114.516}, {336.448, 114.516})
439  .CubicCurveTo({335.761, 114.516}, {335.072, 114.527}, {334.384, 114.513})
440  .CubicCurveTo({334.125, 114.508}, {333.862, 114.462}, {333.605, 114.424})
441  .CubicCurveTo({332.865, 114.318}, {332.096, 114.184}, {331.41, 113.883})
442  .CubicCurveTo({330.979, 113.695}, {330.442, 113.34}, {330.672, 112.813})
443  .CubicCurveTo({331.135, 111.755}, {333.219, 112.946}, {334.526, 113.833})
444  .CubicCurveTo({334.54, 113.816}, {334.554, 113.8}, {334.569, 113.784})
445  .CubicCurveTo({333.38, 112.708}, {331.749, 110.985}, {332.76, 110.402})
446  .CubicCurveTo({333.769, 109.82}, {334.713, 111.93}, {335.228, 113.395})
447  .CubicCurveTo({334.915, 111.889}, {334.59, 109.636}, {335.661, 109.592})
448  .CubicCurveTo({336.733, 109.636}, {336.408, 111.889}, {336.07, 113.389})
449  .CubicCurveTo({336.609, 111.93}, {337.553, 109.82}, {338.563, 110.402})
450  .CubicCurveTo({339.574, 110.984}, {337.942, 112.708}, {336.753, 113.784})
451  .CubicCurveTo({336.768, 113.8}, {336.782, 113.816}, {336.796, 113.833})
452  .CubicCurveTo({338.104, 112.946}, {340.187, 111.755}, {340.65, 112.813})
453  .CubicCurveTo({340.71, 112.95}, {340.728, 113.102}, {340.678, 113.245});
454  if (closed) {
455  builder.Close();
456  }
457  builder //
458  .MoveTo({346.357, 106.771})
459  .CubicCurveTo({346.295, 104.987}, {347.924, 104.139}, {347.924, 104.139})
460  .CubicCurveTo({347.924, 104.139}, {347.982, 105.931}, {346.357, 106.771});
461  if (closed) {
462  builder.Close();
463  }
464  builder //
465  .MoveTo({347.56, 106.771})
466  .CubicCurveTo({347.498, 104.987}, {349.127, 104.139}, {349.127, 104.139})
467  .CubicCurveTo({349.127, 104.139}, {349.185, 105.931}, {347.56, 106.771});
468  if (closed) {
469  builder.Close();
470  }
471  return builder.TakePath();
472 }
473 
474 flutter::DlPath CreateQuadratic(bool closed) {
475  auto builder = flutter::DlPathBuilder{};
476  builder //
477  .MoveTo({359.934, 96.6335})
478  .QuadraticCurveTo({358.189, 96.7055}, {354.673, 96.8895})
479  .QuadraticCurveTo({354.571, 96.8953}, {354.367, 96.9075})
480  .QuadraticCurveTo({352.672, 97.0038}, {349.259, 97.2355})
481  .QuadraticCurveTo({349.048, 97.2506}, {348.625, 97.2834})
482  .QuadraticCurveTo({347.019, 97.4014}, {343.789, 97.6722})
483  .QuadraticCurveTo({343.428, 97.704}, {342.703, 97.7734})
484  .QuadraticCurveTo({341.221, 97.9086}, {338.246, 98.207})
485  .QuadraticCurveTo({337.702, 98.2642}, {336.612, 98.3894})
486  .QuadraticCurveTo({335.284, 98.5356}, {332.623, 98.8476})
487  .QuadraticCurveTo({332.495, 98.8635}, {332.237, 98.8982})
488  .LineTo({332.237, 102.601})
489  .LineTo({321.778, 102.601})
490  .LineTo({321.778, 100.382})
491  .QuadraticCurveTo({321.572, 100.413}, {321.161, 100.476})
492  .QuadraticCurveTo({319.22, 100.79}, {315.332, 101.479})
493  .QuadraticCurveTo({315.322, 101.481}, {315.301, 101.484})
494  .LineTo({310.017, 105.94})
495  .LineTo({309.779, 105.427})
496  .LineTo({314.403, 101.651})
497  .QuadraticCurveTo({314.391, 101.653}, {314.368, 101.658})
498  .QuadraticCurveTo({312.528, 102.001}, {308.846, 102.748})
499  .QuadraticCurveTo({307.85, 102.955}, {305.859, 103.4})
500  .QuadraticCurveTo({305.048, 103.579}, {303.425, 103.936})
501  .LineTo({299.105, 107.578})
502  .LineTo({298.867, 107.065})
503  .LineTo({302.394, 104.185})
504  .LineTo({302.412, 104.171})
505  .QuadraticCurveTo({301.388, 104.409}, {299.344, 104.921})
506  .QuadraticCurveTo({298.618, 105.1}, {297.165, 105.455})
507  .QuadraticCurveTo({295.262, 105.94}, {291.462, 106.979})
508  .QuadraticCurveTo({291.132, 107.072}, {290.471, 107.257})
509  .QuadraticCurveTo({289.463, 107.544}, {287.449, 108.139})
510  .QuadraticCurveTo({286.476, 108.431}, {284.536, 109.035})
511  .QuadraticCurveTo({283.674, 109.304}, {281.952, 109.859})
512  .QuadraticCurveTo({281.177, 110.112}, {279.633, 110.638})
513  .QuadraticCurveTo({278.458, 111.037}, {276.803, 111.607})
514  .QuadraticCurveTo({276.76, 111.622}, {276.672, 111.653})
515  .QuadraticCurveTo({275.017, 112.239}, {271.721, 113.463})
516  .LineTo({271.717, 113.449})
517  .QuadraticCurveTo({271.496, 113.496}, {270.963, 113.628})
518  .QuadraticCurveTo({270.893, 113.645}, {270.748, 113.682})
519  .QuadraticCurveTo({270.468, 113.755}, {269.839, 113.926})
520  .QuadraticCurveTo({269.789, 113.94}, {269.681, 113.972})
521  .QuadraticCurveTo({269.391, 114.053}, {268.756, 114.239})
522  .QuadraticCurveTo({268.628, 114.276}, {268.367, 114.354})
523  .QuadraticCurveTo({268.172, 114.412}, {267.752, 114.54})
524  .QuadraticCurveTo({263.349, 115.964}, {253.564, 119.252})
525  .QuadraticCurveTo({253.556, 119.255}, {253.538, 119.261})
526  .QuadraticCurveTo({251.844, 119.849}, {248.189, 121.131})
527  .QuadraticCurveTo({248, 121.197}, {247.621, 121.331})
528  .QuadraticCurveTo({247.079, 121.522}, {245.975, 121.912})
529  .QuadraticCurveTo({245.554, 122.06}, {244.698, 122.364})
530  .QuadraticCurveTo({244.071, 122.586}, {242.794, 123.04})
531  .QuadraticCurveTo({242.189, 123.255}, {240.961, 123.693})
532  .QuadraticCurveTo({240.659, 123.801}, {240.052, 124.018})
533  .QuadraticCurveTo({239.12, 124.351}, {237.22, 125.032})
534  .LineTo({237.164, 125.003})
535  .QuadraticCurveTo({236.709, 125.184}, {235.81, 125.538})
536  .QuadraticCurveTo({235.413, 125.68}, {234.592, 125.977})
537  .QuadraticCurveTo({234.592, 125.977}, {234.59, 125.977})
538  .QuadraticCurveTo({222.206, 130.435}, {192.381, 141.429})
539  .QuadraticCurveTo({162.77, 151.336}, {84.1123, 160})
540  .LineTo({360, 160})
541  .LineTo({360, 119.256})
542  .LineTo({360, 106.332})
543  .LineTo({360, 96.6307})
544  .QuadraticCurveTo({359.978, 96.6317}, {359.934, 96.6335});
545  if (closed) {
546  builder.Close();
547  }
548  builder //
549  .MoveTo({337.336, 124.143})
550  .QuadraticCurveTo({337.274, 122.359}, {338.903, 121.511})
551  .QuadraticCurveTo({338.903, 121.511}, {337.336, 124.143});
552  if (closed) {
553  builder.Close();
554  }
555  builder //
556  .MoveTo({340.082, 121.849})
557  .QuadraticCurveTo({340.074, 121.917}, {340.046, 122.075})
558  .QuadraticCurveTo({340.039, 122.109}, {340.023, 122.177})
559  .QuadraticCurveTo({340.005, 122.26}, {339.952, 122.437})
560  .QuadraticCurveTo({339.941, 122.473}, {339.918, 122.544})
561  .QuadraticCurveTo({339.873, 122.672}, {339.75, 122.938})
562  .QuadraticCurveTo({339.747, 122.944}, {339.74, 122.955})
563  .QuadraticCurveTo({339.674, 123.08}, {339.501, 123.328})
564  .QuadraticCurveTo({339.473, 123.366}, {339.41, 123.438})
565  .QuadraticCurveTo({339.332, 123.534}, {339.145, 123.714})
566  .QuadraticCurveTo({339.105, 123.75}, {339.025, 123.821})
567  .QuadraticCurveTo({338.881, 123.937}, {338.539, 124.143})
568  .QuadraticCurveTo({338.532, 123.959}, {338.58, 123.626})
569  .QuadraticCurveTo({338.58, 123.625}, {338.58, 123.625})
570  .QuadraticCurveTo({338.607, 123.455}, {338.704, 123.151})
571  .QuadraticCurveTo({338.708, 123.14}, {338.714, 123.117})
572  .QuadraticCurveTo({338.769, 122.971}, {338.905, 122.712})
573  .QuadraticCurveTo({338.911, 122.702}, {338.922, 122.682})
574  .QuadraticCurveTo({338.996, 122.557}, {339.155, 122.34})
575  .QuadraticCurveTo({339.161, 122.333}, {339.172, 122.319})
576  .QuadraticCurveTo({339.256, 122.215}, {339.425, 122.037})
577  .QuadraticCurveTo({339.428, 122.033}, {339.435, 122.027})
578  .QuadraticCurveTo({339.785, 121.687}, {340.106, 121.511})
579  .QuadraticCurveTo({340.106, 121.511}, {340.082, 121.849});
580  if (closed) {
581  builder.Close();
582  }
583  builder //
584  .MoveTo({340.678, 113.245})
585  .QuadraticCurveTo({340.594, 113.488}, {340.135, 113.775})
586  .QuadraticCurveTo({339.817, 113.948}, {339.115, 114.151})
587  .QuadraticCurveTo({338.251, 114.379}, {336.448, 114.516})
588  .QuadraticCurveTo({335.761, 114.516}, {334.384, 114.513})
589  .QuadraticCurveTo({334.125, 114.508}, {333.605, 114.424})
590  .QuadraticCurveTo({332.865, 114.318}, {331.41, 113.883})
591  .QuadraticCurveTo({330.979, 113.695}, {330.672, 112.813})
592  .QuadraticCurveTo({331.135, 111.755}, {334.526, 113.833})
593  .QuadraticCurveTo({334.54, 113.816}, {334.569, 113.784})
594  .QuadraticCurveTo({333.38, 112.708}, {332.76, 110.402})
595  .QuadraticCurveTo({333.769, 109.82}, {335.228, 113.395})
596  .QuadraticCurveTo({334.915, 111.889}, {335.661, 109.592})
597  .QuadraticCurveTo({336.733, 109.636}, {336.07, 113.389})
598  .QuadraticCurveTo({336.609, 111.93}, {338.563, 110.402})
599  .QuadraticCurveTo({339.574, 110.984}, {336.753, 113.784})
600  .QuadraticCurveTo({336.768, 113.8}, {336.796, 113.833})
601  .QuadraticCurveTo({338.104, 112.946}, {340.65, 112.813})
602  .QuadraticCurveTo({340.71, 112.95}, {340.678, 113.245});
603  if (closed) {
604  builder.Close();
605  }
606  builder //
607  .MoveTo({346.357, 106.771})
608  .QuadraticCurveTo({346.295, 104.987}, {347.924, 104.139})
609  .QuadraticCurveTo({347.924, 104.139}, {346.357, 106.771});
610  if (closed) {
611  builder.Close();
612  }
613  builder //
614  .MoveTo({347.56, 106.771})
615  .QuadraticCurveTo({347.498, 104.987}, {349.127, 104.139})
616  .QuadraticCurveTo({349.127, 104.139}, {347.56, 106.771});
617  if (closed) {
618  builder.Close();
619  }
620  return builder.TakePath();
621 }
622 
623 } // namespace
624 } // namespace impeller
static std::vector< Point > GenerateSolidStrokeVertices(Tessellator &tessellator, const PathSource &path, const StrokeParameters &stroke, Scalar scale)
static std::shared_ptr< ShadowVertices > MakeAmbientShadowVertices(Tessellator &tessellator, const PathSource &source, Scalar occluder_height, const Matrix &matrix)
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
Definition: tessellator.h:37
static void TessellateConvexInternal(const PathSource &path, std::vector< Point > &point_buffer, std::vector< uint16_t > &index_buffer, Scalar tolerance)
Definition: tessellator.cc:440
An extended tessellator that offers arbitrary/concave tessellation via the libtess2 library.
constexpr float k2Pi
Definition: constants.h:29
float Scalar
Definition: scalar.h:19
static TessellatorLibtess tess
MAKE_STROKE_PATH_BENCHMARK_CAPTURE(RRect, Butt, Bevel,)
TPoint< Scalar > Point
Definition: point.h:425
static void BM_StrokePath(benchmark::State &state, Args &&... args)
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:24
MAKE_STROKE_BENCHMARK_CAPTURE_ALL_CAPS_JOINS(Cubic, false)
static void BM_ShadowPathVerticesImpeller(benchmark::State &state, Args &&... args)
static void BM_Convex(benchmark::State &state, Args &&... args)
flutter::DlPath DlPath
Definition: dl_dispatcher.h:29
MAKE_SHADOW_BENCHMARK_CAPTURE_ALL_SHAPES(Impeller)
BENCHMARK_CAPTURE(BM_Convex, rrect_convex, CreateRRect(), true)
constexpr float kSqrt2
Definition: constants.h:47
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
Definition: tessellator.cc:20
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
Definition: tessellator.cc:24
void CubicTo(PathBuilder *builder, Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar x3, Scalar y3)
Definition: tessellator.cc:28
void Close(PathBuilder *builder)
Definition: tessellator.cc:38
static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
Definition: round_rect.h:31
static RoundSuperellipse MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129
std::vector< Point > points