5 #ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
6 #define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
42 explicit Trigs(std::vector<Trig>& trigs,
size_t divisions) : trigs_(trigs) {
44 FML_DCHECK(trigs_.size() == divisions + 1);
47 explicit Trigs(
size_t divisions)
48 : local_storage_(std::make_unique<std::vector<Trig>>()),
49 trigs_(*local_storage_) {
51 FML_DCHECK(trigs_.size() == divisions + 1);
55 auto inline size()
const {
return trigs_.size(); }
56 auto inline begin()
const {
return trigs_.begin(); }
57 auto inline end()
const {
return trigs_.end(); }
61 std::unique_ptr<std::vector<Trig>> local_storage_;
65 std::vector<Trig>& trigs_;
69 void init(
size_t divisions);
133 return trigs_.size() * vertices_per_trig_;
138 impl_(trigs_, data_, proc);
149 const Point reference_centers[2];
157 typedef void GeneratorProc(
const Trigs& trigs,
161 GeneratorProc& impl_;
164 const size_t vertices_per_trig_;
169 size_t vertices_per_trig,
192 bool supports_primitive_restart =
false,
193 bool supports_triangle_fan =
false);
221 std::vector<Point>& point_buffer,
222 std::vector<uint16_t>& index_buffer,
323 static constexpr
size_t kCachedTrigCount = 300;
324 std::vector<Trig> precomputed_trigs_[kCachedTrigCount];
326 Trigs GetTrigsForDivisions(
size_t divisions);
328 static void GenerateFilledCircle(
const Trigs& trigs,
329 const EllipticalVertexGenerator::Data&
data,
332 static void GenerateStrokedCircle(
const Trigs& trigs,
333 const EllipticalVertexGenerator::Data&
data,
336 static void GenerateRoundCapLine(
const Trigs& trigs,
337 const EllipticalVertexGenerator::Data&
data,
340 static void GenerateFilledEllipse(
const Trigs& trigs,
341 const EllipticalVertexGenerator::Data&
data,
344 static void GenerateFilledRoundRect(
346 const EllipticalVertexGenerator::Data&
data,
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 > stroke_points_
Used for stroke path generation.
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...
std::vector< Point > & GetStrokePointCache()
Retrieve a pre-allocated arena of kPointArenaSize points.
VertexBuffer GenerateLineStrip(const Path &path, HostBuffer &host_buffer, Scalar tolerance)
Given a path, create a line strip primitive structure.
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.
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.
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.
std::unique_ptr< std::vector< uint16_t > > index_buffer_
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.
VertexBuffer TessellateConvex(const Path &path, HostBuffer &host_buffer, Scalar tolerance, bool supports_primitive_restart=false, bool supports_triangle_fan=false)
Given a convex path, create a triangle fan structure.
PrimitiveType
Decides how backend draws pixels based on input vertices.
static constexpr size_t kPointArenaSize
The size of the point arena buffer stored on the tessellator.
A 4x4 matrix using column-major storage.
std::shared_ptr< const fml::Mapping > data