5#ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
6#define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
37 explicit Trigs(std::vector<Trig>& trigs,
size_t divisions) : trigs_(trigs) {
42 explicit Trigs(
size_t divisions)
43 : local_storage_(std::make_unique<std::vector<Trig>>()),
44 trigs_(*local_storage_) {
50 auto inline size()
const {
return trigs_.size(); }
51 auto inline begin()
const {
return trigs_.begin(); }
52 auto inline end()
const {
return trigs_.end(); }
56 std::unique_ptr<std::vector<Trig>> local_storage_;
60 std::vector<Trig>& trigs_;
64 void init(
size_t divisions);
128 return trigs_.size() * vertices_per_trig_;
133 impl_(trigs_, data_, proc);
144 const Point reference_centers[2];
152 typedef void GeneratorProc(
const Trigs& trigs,
156 GeneratorProc& impl_;
159 const size_t vertices_per_trig_;
164 size_t vertices_per_trig,
277 static constexpr size_t kCachedTrigCount = 300;
278 std::vector<Trig> precomputed_trigs_[kCachedTrigCount];
280 Trigs GetTrigsForDivisions(
size_t divisions);
282 static void GenerateFilledCircle(
const Trigs& trigs,
283 const EllipticalVertexGenerator::Data& data,
286 static void GenerateStrokedCircle(
const Trigs& trigs,
287 const EllipticalVertexGenerator::Data& data,
290 static void GenerateRoundCapLine(
const Trigs& trigs,
291 const EllipticalVertexGenerator::Data& data,
294 static void GenerateFilledEllipse(
const Trigs& trigs,
295 const EllipticalVertexGenerator::Data& data,
298 static void GenerateFilledRoundRect(
300 const EllipticalVertexGenerator::Data& data,
static SkScalar center(float pos0, float pos1)
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...
PrimitiveType GetTriangleType() const override
|VertexGenerator|
size_t GetVertexCount() const override
|VertexGenerator|
void GenerateVertices(const TessellatedVertexProc &proc) const override
|VertexGenerator|
An object which produces a list of vertices as |Point|s that tessellate a previously provided shape a...
virtual size_t GetVertexCount() const =0
Returns the number of vertices that the generator plans to produce, if known.
virtual PrimitiveType GetTriangleType() const =0
Returns the |PrimitiveType| that describes the relationship among the list of vertices produced by th...
virtual void GenerateVertices(const TessellatedVertexProc &proc) const =0
Generate the vertices and deliver them in the necessary order (as required by the PrimitiveType) to t...
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
std::vector< Point > TessellateConvex(const Path &path, Scalar tolerance)
Given a convex path, create a triangle fan structure.
EllipticalVertexGenerator RoundCapLine(const Matrix &view_transform, const Point &p0, const Point &p1, Scalar radius)
Create a |VertexGenerator| that can produce vertices for a line with round end caps of the given radi...
EllipticalVertexGenerator FilledRoundRect(const Matrix &view_transform, const Rect &bounds, const Size &radii)
Create a |VertexGenerator| that can produce vertices for a filled round rect within the given bounds ...
static constexpr Scalar kCircleTolerance
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
Path::Polyline CreateTempPolyline(const Path &path, Scalar tolerance)
Create a temporary polyline. Only one per-process can exist at a time.
EllipticalVertexGenerator FilledCircle(const Matrix &view_transform, const Point ¢er, Scalar radius)
Create a |VertexGenerator| that can produce vertices for a filled circle of the given radius around t...
EllipticalVertexGenerator StrokedCircle(const Matrix &view_transform, const Point ¢er, Scalar radius, Scalar half_width)
Create a |VertexGenerator| that can produce vertices for a stroked circle of the given radius and hal...
std::unique_ptr< std::vector< Point > > point_buffer_
Used for polyline generation.
EllipticalVertexGenerator FilledEllipse(const Matrix &view_transform, const Rect &bounds)
Create a |VertexGenerator| that can produce vertices for a filled ellipse inscribed within the given ...
std::function< void(const Point &p)> TessellatedVertexProc
A callback function for a |VertexGenerator| to deliver the vertices it computes as |Point| objects.
#define FML_DCHECK(condition)
PrimitiveType
Decides how backend draws pixels based on input vertices.
A 4x4 matrix using column-major storage.