10 : point_buffer_(
std::make_unique<
std::vector<
Point>>()),
11 index_buffer_(
std::make_unique<
std::vector<uint16_t>>()) {
56 .index_buffer = std::move(index_buffer),
63 std::vector<Point>& point_buffer,
64 std::vector<uint16_t>& index_buffer,
71 path.WritePolyline(tolerance, writer);
77 1, 2, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7,
78 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
79 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13,
80 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
81 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16,
82 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18,
83 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19,
84 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
85 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
86 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23,
87 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
88 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25,
89 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26,
90 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27,
91 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28,
92 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29,
93 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
94 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
95 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
96 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
97 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33,
98 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
99 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
100 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35,
101 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36,
102 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
103 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
104 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38,
105 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
106 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
107 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40,
108 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
109 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41,
110 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
111 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
112 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43,
113 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
114 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44,
115 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
116 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
117 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
118 45, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
119 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47,
120 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
121 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48,
122 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
123 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49,
124 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
125 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50,
126 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
127 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51,
128 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
129 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52,
130 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
131 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53,
132 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
133 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54,
134 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
135 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
136 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
137 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
138 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
139 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
140 56, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 57,
145 if (pixel_radius <= 0.0) {
148 int radius_index =
ceil(pixel_radius);
201 if (!trigs_.empty()) {
206 trigs_.reserve(divisions + 1);
208 double angle_scale =
kPiOver2 / divisions;
210 trigs_.emplace_back(1.0, 0.0);
211 for (
size_t i = 1;
i < divisions;
i++) {
212 trigs_.emplace_back(Radians(
i * angle_scale));
214 trigs_.emplace_back(0.0, 1.0);
217Tessellator::Trigs Tessellator::GetTrigsForDivisions(
size_t divisions) {
218 return divisions < Tessellator::kCachedTrigCount
219 ? Trigs(precomputed_trigs_[divisions], divisions)
226EllipticalVertexGenerator::EllipticalVertexGenerator(
227 EllipticalVertexGenerator::GeneratorProc& generator,
230 size_t vertices_per_trig,
233 trigs_(
std::move(trigs)),
235 vertices_per_trig_(vertices_per_trig) {}
238 const Matrix& view_transform,
244 GetTrigsForDivisions(divisions),
245 PrimitiveType::kTriangleStrip, 4,
248 .radii = {radius, radius},
254 const Matrix& view_transform,
258 if (half_width > 0) {
262 GetTrigsForDivisions(divisions),
263 PrimitiveType::kTriangleStrip, 8,
266 .radii = {radius, radius},
267 .half_width = half_width,
270 return FilledCircle(view_transform,
center, radius);
275 const Matrix& view_transform,
279 auto along = p1 - p0;
280 auto length = along.GetLength();
285 GetTrigsForDivisions(divisions),
286 PrimitiveType::kTriangleStrip, 4,
288 .reference_centers = {p0, p1},
289 .radii = {radius, radius},
293 return FilledCircle(view_transform, p0, radius);
298 const Matrix& view_transform,
301 return FilledCircle(view_transform,
bounds.GetCenter(),
302 bounds.GetWidth() * 0.5f);
304 auto max_radius =
bounds.GetSize().MaxDimension();
309 GetTrigsForDivisions(divisions),
310 PrimitiveType::kTriangleStrip, 4,
313 .radii =
bounds.GetSize() * 0.5f,
319 const Matrix& view_transform,
327 auto upper_left =
bounds.GetLeftTop() + radii;
328 auto lower_right =
bounds.GetRightBottom() - radii;
330 GetTrigsForDivisions(divisions),
331 PrimitiveType::kTriangleStrip, 4,
342 return FilledEllipse(view_transform,
bounds);
346void Tessellator::GenerateFilledCircle(
351 auto radius =
data.radii.width;
358 for (
auto& trig : trigs) {
359 auto offset = trig * radius;
369 for (
auto& trig : trigs) {
370 auto offset = trig * radius;
376void Tessellator::GenerateStrokedCircle(
386 auto outer_radius =
data.radii.width +
data.half_width;
387 auto inner_radius =
data.radii.width -
data.half_width;
395 for (
auto& trig : trigs) {
396 auto outer = trig * outer_radius;
397 auto inner = trig * inner_radius;
407 for (
auto& trig : trigs) {
408 auto outer = trig * outer_radius;
409 auto inner = trig * inner_radius;
415 for (
auto& trig : trigs) {
416 auto outer = trig * outer_radius;
417 auto inner = trig * inner_radius;
423 for (
auto& trig : trigs) {
424 auto outer = trig * outer_radius;
425 auto inner = trig * inner_radius;
431void Tessellator::GenerateRoundCapLine(
435 auto p0 =
data.reference_centers[0];
436 auto p1 =
data.reference_centers[1];
437 auto radius =
data.radii.width;
442 auto along = p1 - p0;
443 along *= radius / along.GetLength();
444 auto across =
Point(-along.y, along.x);
446 for (
auto& trig : trigs) {
447 auto relative_along = along * trig.cos;
448 auto relative_across = across * trig.sin;
449 proc(p0 - relative_along + relative_across);
450 proc(p0 - relative_along - relative_across);
456 for (
auto& trig : trigs) {
457 auto relative_along = along * trig.sin;
458 auto relative_across = across * trig.cos;
459 proc(p1 + relative_along + relative_across);
460 proc(p1 + relative_along - relative_across);
464void Tessellator::GenerateFilledEllipse(
469 auto radii =
data.radii;
475 for (
auto& trig : trigs) {
476 auto offset = trig * radii;
486 for (
auto& trig : trigs) {
487 auto offset =
Point(trig.sin * radii.width, trig.cos * radii.height);
493void Tessellator::GenerateFilledRoundRect(
501 auto radii =
data.radii;
506 for (
auto& trig : trigs) {
507 auto offset = trig * radii;
517 for (
auto& trig : trigs) {
518 auto offset =
Point(trig.sin * radii.width, trig.cos * radii.height);
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
static SkScalar center(float pos0, float pos1)
BufferView Emplace(const BufferType &buffer, size_t alignment=0)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
The |VertexGenerator| implementation common to all shapes that are based on a polygonal representatio...
VertexBuffer TessellateConvex(const Path &path, HostBuffer &host_buffer, Scalar tolerance)
Given a convex path, create a triangle fan structure.
static constexpr Scalar kCircleTolerance
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
static void TessellateConvexInternal(const Path &path, std::vector< Point > &point_buffer, std::vector< uint16_t > &index_buffer, Scalar tolerance)
Path::Polyline CreateTempPolyline(const Path &path, Scalar tolerance)
Create a temporary polyline. Only one per-process can exist at a time.
std::unique_ptr< std::vector< Point > > point_buffer_
Used for polyline generation.
std::unique_ptr< std::vector< uint16_t > > index_buffer_
std::function< void(const Point &p)> TessellatedVertexProc
A callback function for a |VertexGenerator| to deliver the vertices it computes as |Point| objects.
An interface for generating a multi contour polyline as a triangle strip.
#define FML_DCHECK(condition)
Optional< SkRect > bounds
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
struct PathData * Data(SkPath *path)
static size_t ComputeQuadrantDivisions(Scalar pixel_radius)
Tessellator::TessellatedVertexProc TessellatedVertexProc
PrimitiveType
Decides how backend draws pixels based on input vertices.
constexpr float kEhCloseEnough
static constexpr int kPrecomputedDivisionCount
Tessellator::EllipticalVertexGenerator EllipticalVertexGenerator
static int kPrecomputedDivisions[kPrecomputedDivisionCount]
SIN Vec< N, float > ceil(const Vec< N, float > &x)
const Path::Polyline & polyline
A 4x4 matrix using column-major storage.
Scalar GetMaxBasisLength() const
std::unique_ptr< std::vector< Point > > PointBufferPtr
constexpr Type MaxDimension() const
std::shared_ptr< const fml::Mapping > data