 |
Flutter Impeller
|
|
Go to the documentation of this file.
5 #ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
6 #define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
17 struct TESStesselator;
41 explicit Trigs(std::vector<Trig>& trigs,
size_t divisions) : trigs_(trigs) {
43 FML_DCHECK(trigs_.size() == divisions + 1);
46 explicit Trigs(
size_t divisions)
47 : local_storage_(std::make_unique<std::vector<Trig>>()),
48 trigs_(*local_storage_) {
50 FML_DCHECK(trigs_.size() == divisions + 1);
54 auto inline size()
const {
return trigs_.size(); }
55 auto inline begin()
const {
return trigs_.begin(); }
56 auto inline end()
const {
return trigs_.end(); }
60 std::unique_ptr<std::vector<Trig>> local_storage_;
64 std::vector<Trig>& trigs_;
68 void init(
size_t divisions);
132 return trigs_.size() * vertices_per_trig_;
137 impl_(trigs_, data_, proc);
148 const Point reference_centers[2];
156 typedef void GeneratorProc(
const Trigs& trigs,
160 GeneratorProc& impl_;
163 const size_t vertices_per_trig_;
168 size_t vertices_per_trig,
181 size_t vertices_count,
182 const uint16_t* indices,
183 size_t indices_count)>;
301 std::unique_ptr<std::vector<Point>> point_buffer_;
307 static constexpr
size_t kCachedTrigCount = 300;
308 std::vector<Trig> precomputed_trigs_[kCachedTrigCount];
310 Trigs GetTrigsForDivisions(
size_t divisions);
312 static void GenerateFilledCircle(
const Trigs& trigs,
313 const EllipticalVertexGenerator::Data& data,
316 static void GenerateStrokedCircle(
const Trigs& trigs,
317 const EllipticalVertexGenerator::Data& data,
320 static void GenerateRoundCapLine(
const Trigs& trigs,
321 const EllipticalVertexGenerator::Data& data,
324 static void GenerateFilledEllipse(
const Trigs& trigs,
325 const EllipticalVertexGenerator::Data& data,
328 static void GenerateFilledRoundRect(
330 const EllipticalVertexGenerator::Data& data,
340 #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::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.
std::vector< Point > TessellateConvex(const Path &path, Scalar tolerance)
Given a convex path, create a triangle fan 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 ...
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
void DestroyTessellator(TESStesselator *tessellator)
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 ...
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...
Tessellator::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.
static constexpr Scalar kCircleTolerance
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
virtual size_t GetVertexCount() const =0
Returns the number of vertices that the generator plans to produce, if known.
PrimitiveType GetTriangleType() const override
|VertexGenerator|
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.
Path::Polyline CreateTempPolyline(const Path &path, Scalar tolerance)
Create a temporary polyline. Only one per-process can exist at a time.
std::unique_ptr< TESStesselator, decltype(&DestroyTessellator)> CTessellator
A 4x4 matrix using column-major storage.