5 #ifndef FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
6 #define FLUTTER_IMPELLER_TESSELLATOR_TESSELLATOR_H_
53 size_t inline size()
const {
return trigs_.size(); }
54 std::vector<Trig>::iterator
inline begin()
const {
return trigs_.begin(); }
55 std::vector<Trig>::iterator
inline end()
const {
return trigs_.end(); }
58 size_t inline GetSteps()
const {
return trigs_.size() - 1u; }
63 explicit Trigs(std::vector<Trig>& trigs,
size_t divisions) : trigs_(trigs) {
64 FML_DCHECK(divisions >= 1);
66 FML_DCHECK(trigs_.size() == divisions + 1);
69 explicit Trigs(
size_t divisions)
70 : local_storage_(
std::make_unique<
std::vector<
Trig>>()),
71 trigs_(*local_storage_) {
72 FML_DCHECK(divisions >= 1);
74 FML_DCHECK(trigs_.size() == divisions + 1);
78 std::unique_ptr<std::vector<Trig>> local_storage_;
82 std::vector<Trig>& trigs_;
86 void init(
size_t divisions);
149 return trigs_.
size() * vertices_per_trig_;
154 impl_(trigs_, data_, proc);
165 const Point reference_centers[2];
173 typedef void GeneratorProc(
const Trigs& trigs,
177 GeneratorProc& impl_;
180 const size_t vertices_per_trig_;
185 size_t vertices_per_trig,
207 const Rect oval_bounds_;
208 const bool use_center_;
211 const bool supports_triangle_fans_;
215 const Rect& oval_bounds,
217 bool supports_triangle_fans);
221 const Rect& oval_bounds,
245 bool supports_primitive_restart =
false,
246 bool supports_triangle_fan =
false);
253 std::vector<Point>& point_buffer,
254 std::vector<uint16_t>& index_buffer,
309 bool supports_triangle_fans);
388 static constexpr
size_t kCachedTrigCount = 300;
389 std::vector<Trig> precomputed_trigs_[kCachedTrigCount];
391 Trigs GetTrigsForDivisions(
size_t divisions);
393 static void GenerateFilledCircle(
const Trigs& trigs,
394 const EllipticalVertexGenerator::Data&
data,
397 static void GenerateStrokedCircle(
const Trigs& trigs,
398 const EllipticalVertexGenerator::Data&
data,
401 static void GenerateFilledArcFan(
const Trigs& trigs,
403 const Rect& oval_bounds,
407 static void GenerateFilledArcStrip(
const Trigs& trigs,
409 const Rect& oval_bounds,
413 static void GenerateStrokedArc(
const Trigs& trigs,
415 const Rect& oval_bounds,
420 static void GenerateRoundCapLine(
const Trigs& trigs,
421 const EllipticalVertexGenerator::Data&
data,
424 static void GenerateFilledEllipse(
const Trigs& trigs,
425 const EllipticalVertexGenerator::Data&
data,
428 static void GenerateFilledRoundRect(
430 const EllipticalVertexGenerator::Data&
data,
The |VertexGenerator| implementation common to all shapes that are based on a polygonal representatio...
size_t GetVertexCount() const override
|VertexGenerator|
PrimitiveType GetTriangleType() const override
|VertexGenerator|
void GenerateVertices(const TessellatedVertexProc &proc) const override
|VertexGenerator|
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|
std::vector< Trig >::iterator begin() const
std::vector< Trig >::iterator end() const
Trigs(Scalar pixel_radius)
const Trig & operator[](size_t index) const
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...
Trigs GetTrigsForDeviceRadius(Scalar pixel_radius)
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.
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 ...
VertexBuffer TessellateConvex(const PathSource &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.
static constexpr Scalar kCircleTolerance
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
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...
ArcVertexGenerator StrokedArc(const Matrix &view_transform, const Arc &arc, Cap cap, Scalar half_width)
Create a |VertexGenerator| that can produce vertices for a stroked arc inscribed within the given ova...
static void TessellateConvexInternal(const PathSource &path, std::vector< Point > &point_buffer, std::vector< uint16_t > &index_buffer, Scalar tolerance)
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.
ArcVertexGenerator FilledArc(const Matrix &view_transform, const Arc &arc, bool supports_triangle_fans)
Create a |VertexGenerator| that can produce vertices for a stroked arc inscribed within the given ova...
PrimitiveType
Decides how backend draws pixels based on input vertices.
Cap
An enum that describes ways to decorate the end of a path contour.
Tessellator::ArcVertexGenerator ArcVertexGenerator
static constexpr size_t kPointArenaSize
The size of the point arena buffer stored on the tessellator.
A 4x4 matrix using column-major storage.
A structure to store the sine and cosine of an angle.
std::shared_ptr< const fml::Mapping > data