-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Fallback to no index buffer when tesselation count is large, split up nonZero contours. #46282
[Impeller] Fallback to no index buffer when tesselation count is large, split up nonZero contours. #46282
Changes from 3 commits
2666377
42d5fef
30682b5
da27136
8f60191
d5bc00a
2ea9c22
2158807
364acc4
8804000
f65c055
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -78,51 +78,132 @@ Tessellator::Result Tessellator::Tessellate( | |||||
| constexpr int kVertexSize = 2; | ||||||
| constexpr int kPolygonSize = 3; | ||||||
|
|
||||||
| //---------------------------------------------------------------------------- | ||||||
| /// Feed contour information to the tessellator. | ||||||
| /// | ||||||
| static_assert(sizeof(Point) == 2 * sizeof(float)); | ||||||
| for (size_t contour_i = 0; contour_i < polyline.contours.size(); | ||||||
| contour_i++) { | ||||||
| size_t start_point_index, end_point_index; | ||||||
| std::tie(start_point_index, end_point_index) = | ||||||
| polyline.GetContourPointBounds(contour_i); | ||||||
|
|
||||||
| ::tessAddContour(tessellator, // the C tessellator | ||||||
| kVertexSize, // | ||||||
| polyline.points.data() + start_point_index, // | ||||||
| sizeof(Point), // | ||||||
| end_point_index - start_point_index // | ||||||
| if (polyline.contours.size() > 30 && fill_type == FillType::kNonZero) { | ||||||
|
||||||
| std::vector<Point> points; | ||||||
| std::vector<float> data; | ||||||
|
|
||||||
| //---------------------------------------------------------------------------- | ||||||
| /// Feed contour information to the tessellator. | ||||||
| /// | ||||||
| size_t total = 0u; | ||||||
| static_assert(sizeof(Point) == 2 * sizeof(float)); | ||||||
| for (size_t contour_i = 0; contour_i < polyline.contours.size(); | ||||||
| contour_i++) { | ||||||
| size_t start_point_index, end_point_index; | ||||||
| std::tie(start_point_index, end_point_index) = | ||||||
| polyline.GetContourPointBounds(contour_i); | ||||||
|
|
||||||
| ::tessAddContour(tessellator, // the C tessellator | ||||||
| kVertexSize, // | ||||||
| polyline.points.data() + start_point_index, // | ||||||
| sizeof(Point), // | ||||||
| end_point_index - start_point_index // | ||||||
| ); | ||||||
|
|
||||||
| //---------------------------------------------------------------------------- | ||||||
| /// Let's tessellate. | ||||||
| /// | ||||||
| auto result = ::tessTesselate(tessellator, // tessellator | ||||||
| ToTessWindingRule(fill_type), // winding | ||||||
| TESS_POLYGONS, // element type | ||||||
| kPolygonSize, // polygon size | ||||||
| kVertexSize, // vertex size | ||||||
| nullptr // normal (null is automatic) | ||||||
| ); | ||||||
|
|
||||||
| if (result != 1) { | ||||||
| return Result::kTessellationError; | ||||||
| } | ||||||
|
|
||||||
| int vertexItemCount = tessGetVertexCount(tessellator) * kVertexSize; | ||||||
|
||||||
| int vertexItemCount = tessGetVertexCount(tessellator) * kVertexSize; | |
| int vertex_item_count = tessGetVertexCount(tessellator) * kVertexSize; |
These variable names don't conform to the c++ style guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
jonahwilliams marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
jonahwilliams marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is generated, but never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name here belies the fact that it actually can represent 2 different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed