71 auto fill_type = path.GetFillType();
77 auto tessellator = c_tessellator_.get();
82 constexpr int kVertexSize = 2;
83 constexpr int kPolygonSize = 3;
88 static_assert(
sizeof(
Point) == 2 *
sizeof(
float));
89 for (
size_t contour_i = 0; contour_i <
polyline.contours.size();
91 size_t start_point_index, end_point_index;
92 std::tie(start_point_index, end_point_index) =
93 polyline.GetContourPointBounds(contour_i);
95 ::tessAddContour(tessellator,
97 polyline.points->data() + start_point_index,
99 end_point_index - start_point_index
106 auto result = ::tessTesselate(tessellator,
118 int element_item_count = tessGetElementCount(tessellator) * kPolygonSize;
125 if (element_item_count < USHRT_MAX) {
126 int vertex_item_count = tessGetVertexCount(tessellator);
127 auto vertices = tessGetVertices(tessellator);
128 auto elements = tessGetElements(tessellator);
132 std::vector<uint16_t> indices(element_item_count);
133 for (
int i = 0; i < element_item_count; i++) {
134 indices[i] =
static_cast<uint16_t
>(elements[i]);
136 if (!
callback(vertices, vertex_item_count, indices.data(),
137 element_item_count)) {
141 std::vector<Point>
points;
142 std::vector<float> data;
144 int vertex_item_count = tessGetVertexCount(tessellator) * kVertexSize;
145 auto vertices = tessGetVertices(tessellator);
146 points.reserve(vertex_item_count);
147 for (
int i = 0; i < vertex_item_count; i += 2) {
148 points.emplace_back(vertices[i], vertices[i + 1]);
151 int element_item_count = tessGetElementCount(tessellator) * kPolygonSize;
152 auto elements = tessGetElements(tessellator);
153 data.reserve(element_item_count);
154 for (
int i = 0; i < element_item_count; i++) {
155 data.emplace_back(
points[elements[i]].
x);
156 data.emplace_back(
points[elements[i]].
y);
158 if (!
callback(data.data(), element_item_count,
nullptr, 0u)) {
std::function< bool(const float *vertices, size_t vertices_count, const uint16_t *indices, size_t indices_count)> BuilderCallback
A callback that returns the results of the tessellation.