 |
Flutter Impeller
|
|
Go to the documentation of this file.
5 #ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
6 #define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
39 explicit Trigs(std::vector<Trig>& trigs,
size_t divisions) : trigs_(trigs) {
41 FML_DCHECK(trigs_.size() == divisions + 1);
44 explicit Trigs(
size_t divisions)
45 : local_storage_(std::make_unique<std::vector<Trig>>()),
46 trigs_(*local_storage_) {
48 FML_DCHECK(trigs_.size() == divisions + 1);
52 auto inline size()
const {
return trigs_.size(); }
53 auto inline begin()
const {
return trigs_.begin(); }
54 auto inline end()
const {
return trigs_.end(); }
58 std::unique_ptr<std::vector<Trig>> local_storage_;
62 std::vector<Trig>& trigs_;
66 void init(
size_t divisions);
130 return trigs_.size() * vertices_per_trig_;
135 impl_(trigs_, data_, proc);
146 const Point reference_centers[2];
154 typedef void GeneratorProc(
const Trigs& trigs,
158 GeneratorProc& impl_;
161 const size_t vertices_per_trig_;
166 size_t vertices_per_trig,
197 std::vector<Point>& point_buffer,
198 std::vector<uint16_t>& index_buffer,
294 static constexpr
size_t kCachedTrigCount = 300;
295 std::vector<Trig> precomputed_trigs_[kCachedTrigCount];
297 Trigs GetTrigsForDivisions(
size_t divisions);
299 static void GenerateFilledCircle(
const Trigs& trigs,
300 const EllipticalVertexGenerator::Data&
data,
303 static void GenerateStrokedCircle(
const Trigs& trigs,
304 const EllipticalVertexGenerator::Data&
data,
307 static void GenerateRoundCapLine(
const Trigs& trigs,
308 const EllipticalVertexGenerator::Data&
data,
311 static void GenerateFilledEllipse(
const Trigs& trigs,
312 const EllipticalVertexGenerator::Data&
data,
315 static void GenerateFilledRoundRect(
317 const EllipticalVertexGenerator::Data&
data,
327 #endif // FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
std::shared_ptr< const fml::Mapping > data
std::function< void(const Point &p)> TessellatedVertexProc
A callback function for a |VertexGenerator| to deliver the vertices it computes as |Point| objects.
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...
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...
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...
PrimitiveType
Decides how backend draws pixels based on input vertices.
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 ...
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
std::unique_ptr< std::vector< Point > > point_buffer_
Used for polyline generation.
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...
The |VertexGenerator| implementation common to all shapes that are based on a polygonal representatio...
EllipticalVertexGenerator FilledEllipse(const Matrix &view_transform, const Rect &bounds)
Create a |VertexGenerator| that can produce vertices for a filled ellipse inscribed within the given ...
static void TessellateConvexInternal(const Path &path, std::vector< Point > &point_buffer, std::vector< uint16_t > &index_buffer, Scalar tolerance)
std::unique_ptr< std::vector< uint16_t > > index_buffer_
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...
size_t GetVertexCount() const override
|VertexGenerator|
virtual PrimitiveType GetTriangleType() const =0
Returns the |PrimitiveType| that describes the relationship among the list of vertices produced by th...
static constexpr Scalar kCircleTolerance
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
VertexBuffer TessellateConvex(const Path &path, HostBuffer &host_buffer, Scalar tolerance)
Given a convex path, create a triangle fan structure.
virtual size_t GetVertexCount() const =0
Returns the number of vertices that the generator plans to produce, if known.
PrimitiveType GetTriangleType() const override
|VertexGenerator|
Path::Polyline CreateTempPolyline(const Path &path, Scalar tolerance)
Create a temporary polyline. Only one per-process can exist at a time.
A 4x4 matrix using column-major storage.