7#include "third_party/libtess2/Include/tesselator.h"
19static void HeapFree(
void* userData,
void* ptr) {
40 c_tessellator_ = std::move(tessellator);
49 return TESS_WINDING_ODD;
51 return TESS_WINDING_NONZERO;
53 return TESS_WINDING_ODD;
64 std::unique_ptr<std::vector<Point>> point_buffer =
65 std::make_unique<std::vector<Point>>();
66 auto polyline =
path.CreatePolyline(tolerance, std::move(point_buffer));
68 auto fill_type =
path.GetFillType();
74 auto tessellator = c_tessellator_.get();
79 constexpr int kVertexSize = 2;
80 constexpr int kPolygonSize = 3;
85 static_assert(
sizeof(
Point) == 2 *
sizeof(
float));
86 for (
size_t contour_i = 0; contour_i <
polyline.contours.size();
88 size_t start_point_index, end_point_index;
89 std::tie(start_point_index, end_point_index) =
90 polyline.GetContourPointBounds(contour_i);
92 ::tessAddContour(tessellator,
94 polyline.points->data() + start_point_index,
96 end_point_index - start_point_index
103 auto result = ::tessTesselate(tessellator,
115 int element_item_count = tessGetElementCount(tessellator) * kPolygonSize;
122 if (element_item_count < USHRT_MAX) {
123 int vertex_item_count = tessGetVertexCount(tessellator);
124 auto vertices = tessGetVertices(tessellator);
125 auto elements = tessGetElements(tessellator);
129 std::vector<uint16_t> indices(element_item_count);
130 for (
int i = 0;
i < element_item_count;
i++) {
131 indices[
i] =
static_cast<uint16_t
>(elements[
i]);
133 if (!
callback(vertices, vertex_item_count, indices.data(),
134 element_item_count)) {
138 std::vector<Point>
points;
139 std::vector<float>
data;
141 int vertex_item_count = tessGetVertexCount(tessellator) * kVertexSize;
142 auto vertices = tessGetVertices(tessellator);
143 points.reserve(vertex_item_count);
144 for (
int i = 0;
i < vertex_item_count;
i += 2) {
145 points.emplace_back(vertices[
i], vertices[
i + 1]);
148 int element_item_count = tessGetElementCount(tessellator) * kPolygonSize;
149 auto elements = tessGetElements(tessellator);
150 data.reserve(element_item_count);
151 for (
int i = 0;
i < element_item_count;
i++) {
155 if (!
callback(
data.data(), element_item_count,
nullptr, 0u)) {
164 if (tessellator !=
nullptr) {
165 ::tessDeleteTess(tessellator);
static const int points[]
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
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.
TessellatorLibtess::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.
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
void * malloc(size_t size)
void * realloc(void *ptr, size_t size)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
void DestroyTessellator(TESStesselator *tessellator)
static void * HeapRealloc(void *userData, void *ptr, unsigned int size)
static void * HeapAlloc(void *userData, unsigned int size)
std::unique_ptr< TESStesselator, decltype(&DestroyTessellator)> CTessellator
static int ToTessWindingRule(FillType fill_type)
static void HeapFree(void *userData, void *ptr)
static const TESSalloc kAlloc
const Path::Polyline & polyline
std::shared_ptr< const fml::Mapping > data