A utility that generates triangles of the specified fill type given a polyline. This happens on the CPU. More...
#include <tessellator.h>
Classes | |
class | EllipticalVertexGenerator |
The |VertexGenerator| implementation common to all shapes that are based on a polygonal representation of an ellipse. More... | |
class | VertexGenerator |
An object which produces a list of vertices as |Point|s that tessellate a previously provided shape and delivers the vertices through a |TessellatedVertexProc| callback. More... | |
Public Types | |
enum | Result { Result::kSuccess, Result::kInputError, Result::kTessellationError } |
using | TessellatedVertexProc = std::function< void(const Point &p)> |
A callback function for a |VertexGenerator| to deliver the vertices it computes as |Point| objects. More... | |
using | BuilderCallback = std::function< bool(const float *vertices, size_t vertices_count, const uint16_t *indices, size_t indices_count)> |
A callback that returns the results of the tessellation. More... | |
Public Member Functions | |
Tessellator () | |
~Tessellator () | |
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. More... | |
std::vector< Point > | TessellateConvex (const Path &path, Scalar tolerance) |
Given a convex path, create a triangle fan structure. More... | |
Path::Polyline | CreateTempPolyline (const Path &path, Scalar tolerance) |
Create a temporary polyline. Only one per-process can exist at a time. More... | |
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 the given center with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. More... | |
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 half_width around the given shared center with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. The outer edge of the stroked circle is generated at (radius + half_width) and the inner edge is generated at (radius - half_width). More... | |
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 radius with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. More... | |
EllipticalVertexGenerator | FilledEllipse (const Matrix &view_transform, const Rect &bounds) |
Create a |VertexGenerator| that can produce vertices for a filled ellipse inscribed within the given bounds with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. More... | |
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 and corner radii with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. More... | |
Static Public Attributes | |
static constexpr Scalar | kCircleTolerance = 0.1f |
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle. More... | |
A utility that generates triangles of the specified fill type given a polyline. This happens on the CPU.
This object is not thread safe, and its methods must not be called from multiple threads.
Definition at line 33 of file tessellator.h.
using impeller::Tessellator::BuilderCallback = std::function<bool(const float* vertices, size_t vertices_count, const uint16_t* indices, size_t indices_count)> |
A callback that returns the results of the tessellation.
The index buffer may not be populated, in which case [indices] will be nullptr and indices_count will be 0.
Definition at line 183 of file tessellator.h.
using impeller::Tessellator::TessellatedVertexProc = std::function<void(const Point& p)> |
A callback function for a |VertexGenerator| to deliver the vertices it computes as |Point| objects.
Definition at line 80 of file tessellator.h.
|
strong |
Enumerator | |
---|---|
kSuccess | |
kInputError | |
kTessellationError |
Definition at line 72 of file tessellator.h.
impeller::Tessellator::Tessellator | ( | ) |
Definition at line 34 of file tessellator.cc.
References impeller::DestroyTessellator(), and impeller::kAlloc.
|
default |
Path::Polyline impeller::Tessellator::CreateTempPolyline | ( | const Path & | path, |
Scalar | tolerance | ||
) |
Create a temporary polyline. Only one per-process can exist at a time.
The tessellator itself is not a thread safe class and should only be used from the raster thread.
Definition at line 167 of file tessellator.cc.
References impeller::Path::CreatePolyline(), and polyline.
EllipticalVertexGenerator impeller::Tessellator::FilledCircle | ( | const Matrix & | view_transform, |
const Point & | center, | ||
Scalar | radius | ||
) |
Create a |VertexGenerator| that can produce vertices for a filled circle of the given radius around the given center with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform.
Note that the view transform is only used to choose the number of sample points to use per quarter circle and the returned points are not transformed by it, instead they are relative to the coordinate space of the center point.
Definition at line 411 of file tessellator.cc.
References impeller::ComputeQuadrantDivisions(), and impeller::Matrix::GetMaxBasisLength().
EllipticalVertexGenerator impeller::Tessellator::FilledEllipse | ( | const Matrix & | view_transform, |
const Rect & | bounds | ||
) |
Create a |VertexGenerator| that can produce vertices for a filled ellipse inscribed within the given bounds with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform.
Note that the view transform is only used to choose the number of sample points to use per quarter circle and the returned points are not transformed by it, instead they are relative to the coordinate space of the bounds.
Definition at line 471 of file tessellator.cc.
References impeller::ComputeQuadrantDivisions(), impeller::TRect< T >::GetCenter(), impeller::Matrix::GetMaxBasisLength(), impeller::TRect< T >::GetSize(), impeller::TRect< T >::GetWidth(), and impeller::TRect< T >::IsSquare().
EllipticalVertexGenerator impeller::Tessellator::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 and corner radii with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform.
Note that the view transform is only used to choose the number of sample points to use per quarter circle and the returned points are not transformed by it, instead they are relative to the coordinate space of the bounds.
Definition at line 492 of file tessellator.cc.
References impeller::ComputeQuadrantDivisions(), impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetLeftTop(), impeller::Matrix::GetMaxBasisLength(), impeller::TRect< T >::GetRightBottom(), impeller::TRect< T >::GetWidth(), impeller::TSize< T >::height, impeller::TSize< T >::MaxDimension(), and impeller::TSize< T >::width.
EllipticalVertexGenerator impeller::Tessellator::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 radius with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform.
Note that the view transform is only used to choose the number of sample points to use per quarter circle and the returned points are not transformed by it, instead they are relative to the coordinate space of the two points.
Definition at line 448 of file tessellator.cc.
References impeller::ComputeQuadrantDivisions(), impeller::TPoint< T >::GetLength(), impeller::Matrix::GetMaxBasisLength(), and impeller::kEhCloseEnough.
EllipticalVertexGenerator impeller::Tessellator::StrokedCircle | ( | const Matrix & | view_transform, |
const Point & | center, | ||
Scalar | radius, | ||
Scalar | half_width | ||
) |
Create a |VertexGenerator| that can produce vertices for a stroked circle of the given radius and half_width around the given shared center with enough polygon sub-divisions to provide reasonable fidelity when viewed under the given view transform. The outer edge of the stroked circle is generated at (radius + half_width) and the inner edge is generated at (radius - half_width).
Note that the view transform is only used to choose the number of sample points to use per quarter circle and the returned points are not transformed by it, instead they are relative to the coordinate space of the center point.
Definition at line 427 of file tessellator.cc.
References impeller::ComputeQuadrantDivisions(), and impeller::Matrix::GetMaxBasisLength().
Tessellator::Result impeller::Tessellator::Tessellate | ( | const Path & | path, |
Scalar | tolerance, | ||
const BuilderCallback & | callback | ||
) |
Generates filled triangles from the path. A callback is invoked once for the entire tessellation.
[in] | path | The path to tessellate. |
[in] | tolerance | The tolerance value for conversion of the path to a polyline. This value is often derived from the Matrix::GetMaxBasisLength of the CTM applied to the path for rendering. |
[in] | callback | The callback, return false to indicate failure. |
Feed contour information to the tessellator.
Let's tessellate.
Definition at line 58 of file tessellator.cc.
References impeller::Path::CreatePolyline(), impeller::Path::GetFillType(), kInputError, kSuccess, kTessellationError, polyline, and impeller::ToTessWindingRule().
Referenced by impeller::BM_Polyline(), impeller::Tessellate(), impeller::testing::TEST(), and impeller::testing::TEST_P().
std::vector< Point > impeller::Tessellator::TessellateConvex | ( | const Path & | path, |
Scalar | tolerance | ||
) |
Given a convex path, create a triangle fan structure.
[in] | path | The path to tessellate. |
[in] | tolerance | The tolerance value for conversion of the path to a polyline. This value is often derived from the Matrix::GetMaxBasisLength of the CTM applied to the path for rendering. |
Definition at line 179 of file tessellator.cc.
References impeller::saturated::b, impeller::Path::CreatePolyline(), and polyline.
Referenced by impeller::BM_Convex(), and impeller::testing::TEST().
|
staticconstexpr |
The pixel tolerance used by the algorighm to determine how many divisions to create for a circle.
No point on the polygon of vertices should deviate from the true circle by more than this tolerance.
Definition at line 228 of file tessellator.h.
Referenced by impeller::ComputeQuadrantDivisions(), and impeller::testing::TEST().