99#include " impeller/entity/geometry/stroke_path_geometry.h"
1010#include " impeller/geometry/path.h"
1111#include " impeller/geometry/path_builder.h"
12- #include " impeller/tessellator/tessellator.h"
1312#include " impeller/tessellator/tessellator_libtess.h"
1413
1514namespace impeller {
@@ -44,39 +43,22 @@ template <class... Args>
4443static void BM_Polyline (benchmark::State& state, Args&&... args) {
4544 auto args_tuple = std::make_tuple (std::move (args)...);
4645 auto path = std::get<Path>(args_tuple);
47- bool tessellate = std::get<bool >(args_tuple);
4846
4947 size_t point_count = 0u ;
5048 size_t single_point_count = 0u ;
5149 auto points = std::make_unique<std::vector<Point>>();
5250 points->reserve (2048 );
5351 while (state.KeepRunning ()) {
54- if (tessellate) {
55- tess.Tessellate (path, 1 .0f ,
56- [&point_count, &single_point_count](
57- const float * vertices, size_t vertices_count,
58- const uint16_t * indices, size_t indices_count) {
59- if (indices_count > 0 ) {
60- single_point_count = indices_count;
61- point_count += indices_count;
62- } else {
63- single_point_count = vertices_count;
64- point_count += vertices_count;
65- }
66- return true ;
67- });
68- } else {
69- auto polyline = path.CreatePolyline (
70- // Clang-tidy doesn't know that the points get moved back before
71- // getting moved again in this loop.
72- // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
73- 1 .0f , std::move (points),
74- [&points](Path::Polyline::PointBufferPtr reclaimed) {
75- points = std::move (reclaimed);
76- });
77- single_point_count = polyline.points ->size ();
78- point_count += single_point_count;
79- }
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;
8062 }
8163 state.counters [" SinglePointCount" ] = single_point_count;
8264 state.counters [" TotalPointCount" ] = point_count;
@@ -121,11 +103,14 @@ static void BM_Convex(benchmark::State& state, Args&&... args) {
121103 size_t point_count = 0u ;
122104 size_t single_point_count = 0u ;
123105 auto points = std::make_unique<std::vector<Point>>();
106+ auto indices = std::make_unique<std::vector<uint16_t >>();
124107 points->reserve (2048 );
125108 while (state.KeepRunning ()) {
126- auto points = tess.TessellateConvex (path, 1 .0f );
127- single_point_count = points.size ();
128- point_count += points.size ();
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 ();
129114 }
130115 state.counters [" SinglePointCount" ] = single_point_count;
131116 state.counters [" TotalPointCount" ] = point_count;
@@ -143,14 +128,12 @@ static void BM_Convex(benchmark::State& state, Args&&... args) {
143128 MAKE_STROKE_BENCHMARK_CAPTURE (path, Round, Bevel, false , uvname, uvtype)
144129
145130BENCHMARK_CAPTURE (BM_Polyline, cubic_polyline, CreateCubic(true ), false );
146- BENCHMARK_CAPTURE (BM_Polyline, cubic_polyline_tess, CreateCubic(true ), true );
147131BENCHMARK_CAPTURE (BM_Polyline,
148132 unclosed_cubic_polyline,
149133 CreateCubic (false ),
150134 false);
151135
152136BENCHMARK_CAPTURE (BM_Polyline, quad_polyline, CreateQuadratic(true ), false);
153- BENCHMARK_CAPTURE (BM_Polyline, quad_polyline_tess, CreateQuadratic(true ), true);
154137BENCHMARK_CAPTURE (BM_Polyline,
155138 unclosed_quad_polyline,
156139 CreateQuadratic (false ),
0 commit comments