Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::CircleGeometry Class Referencefinal

#include <circle_geometry.h>

Inheritance diagram for impeller::CircleGeometry:
impeller::Geometry

Public Member Functions

 CircleGeometry (const Point &center, Scalar radius)
 
 CircleGeometry (const Point &center, Scalar radius, Scalar stroke_width)
 
 ~CircleGeometry () override
 
bool CoversArea (const Matrix &transform, const IRect &rect) const override
 Determines if this geometry, transformed by the given transform, will completely cover all of the pixels within the given integer rect.
 
bool IsAxisAlignedRect () const override
 
Scalar ComputeAlphaCoverage (const Matrix &transform) const override
 
Scalar GetRadius () const
 
Scalar GetStrokeWidth () const
 
Point GetCenter () const
 
std::optional< RectGetCoverage (const Matrix &transform) const override
 The coverage rectangle of this geometry, transformed by the transform argument.
 
GeometryResult GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
 
void SetAntialiasPadding (Scalar extra_pixels)
 
Scalar GetAntialiasPadding () const
 
- Public Member Functions inherited from impeller::Geometry
virtual ~Geometry ()
 
virtual GeometryResult::Mode GetResultMode () const
 
virtual bool CanApplyMaskFilter () const
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::Geometry
static std::unique_ptr< GeometryMakeFillPath (const flutter::DlPath &path, std::optional< Rect > inner_rect=std::nullopt)
 
static std::unique_ptr< GeometryMakeStrokePath (const flutter::DlPath &path, const StrokeParameters &stroke={})
 
static std::unique_ptr< GeometryMakeCover ()
 
static std::unique_ptr< GeometryMakeRect (const Rect &rect)
 
static std::unique_ptr< GeometryMakeOval (const Rect &rect)
 
static std::unique_ptr< GeometryMakeLine (const Point &p0, const Point &p1, const StrokeParameters &stroke)
 
static std::unique_ptr< GeometryMakeCircle (const Point &center, Scalar radius)
 
static std::unique_ptr< GeometryMakeStrokedCircle (const Point &center, Scalar radius, Scalar stroke_width)
 
static std::unique_ptr< GeometryMakeFilledArc (const Rect &oval_bounds, Degrees start, Degrees sweep, bool include_center)
 
static std::unique_ptr< GeometryMakeStrokedArc (const Rect &oval_bounds, Degrees start, Degrees sweep, const StrokeParameters &stroke)
 
static std::unique_ptr< GeometryMakeRoundRect (const Rect &rect, const Size &radii)
 
static std::unique_ptr< GeometryMakeRoundSuperellipse (const Rect &rect, Scalar corner_radius)
 
static Scalar ComputeStrokeAlphaCoverage (const Matrix &entity, Scalar stroke_width)
 Compute an alpha value to simulate lower coverage of fractional pixel strokes.
 
static GeometryResult ComputePositionGeometry (const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
 

Detailed Description

Definition at line 14 of file circle_geometry.h.

Constructor & Destructor Documentation

◆ CircleGeometry() [1/2]

impeller::CircleGeometry::CircleGeometry ( const Point center,
Scalar  radius 
)
explicit

Definition at line 16 of file circle_geometry.cc.

17 : center_(center),
18 radius_(radius),
19 stroke_width_(-1.0f),
20 padding_pixels_(0.0f) {
21 FML_DCHECK(radius >= 0);
22}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK.

◆ CircleGeometry() [2/2]

impeller::CircleGeometry::CircleGeometry ( const Point center,
Scalar  radius,
Scalar  stroke_width 
)
explicit

Definition at line 26 of file circle_geometry.cc.

29 : center_(center),
30 radius_(radius),
31 stroke_width_(std::max(stroke_width, 0.0f)),
32 padding_pixels_(0.0) {
33 FML_DCHECK(radius >= 0);
34 FML_DCHECK(stroke_width >= 0);
35}

References FML_DCHECK.

◆ ~CircleGeometry()

impeller::CircleGeometry::~CircleGeometry ( )
overridedefault

Member Function Documentation

◆ ComputeAlphaCoverage()

Scalar impeller::CircleGeometry::ComputeAlphaCoverage ( const Matrix transform) const
overridevirtual

Reimplemented from impeller::Geometry.

Definition at line 38 of file circle_geometry.cc.

38 {
39 if (stroke_width_ < 0) {
40 return 1;
41 }
43}
static Scalar ComputeStrokeAlphaCoverage(const Matrix &entity, Scalar stroke_width)
Compute an alpha value to simulate lower coverage of fractional pixel strokes.
Definition geometry.cc:149

References impeller::Geometry::ComputeStrokeAlphaCoverage(), and transform.

◆ CoversArea()

bool impeller::CircleGeometry::CoversArea ( const Matrix transform,
const IRect rect 
) const
overridevirtual

Determines if this geometry, transformed by the given transform, will completely cover all of the pixels within the given integer rect.

The integer rect, by definition, will contain all of the area covered by any pixel within its boundary.

The return value can be a conservative estimate which will still be useful for certain optimizations. It may return false for obscure cases that might actually contain all of the pixels if it is too computationally costly to prove containment, but it should never return 'true' unless the implementation can prove that all pixels are fully covered (rendered) by the geometry.

Returns
true if the transformed geometry is guaranteed to cover the given rect. May return false in some cases where the transformed geometry does in fact cover the rect.

Reimplemented from impeller::Geometry.

Definition at line 98 of file circle_geometry.cc.

99 {
100 return false;
101}

◆ GetAntialiasPadding()

Scalar impeller::CircleGeometry::GetAntialiasPadding ( ) const

Definition at line 61 of file circle_geometry.cc.

61 {
62 return padding_pixels_;
63}

◆ GetCenter()

Point impeller::CircleGeometry::GetCenter ( ) const

Definition at line 45 of file circle_geometry.cc.

45 {
46 return center_;
47}

◆ GetCoverage()

std::optional< Rect > impeller::CircleGeometry::GetCoverage ( const Matrix transform) const
overridevirtual

The coverage rectangle of this geometry, transformed by the transform argument.

Implements impeller::Geometry.

Definition at line 88 of file circle_geometry.cc.

88 {
89 Scalar max_basis = transform.GetMaxBasisLengthXY();
90 Scalar expansion = max_basis == 0 ? 0.0 : padding_pixels_ / max_basis;
91
92 Scalar half_width = stroke_width_ < 0 ? 0.0 : stroke_width_ * 0.5f;
93 Scalar outer_radius = radius_ + half_width + expansion;
94 return Rect::MakeCircleBounds(center_, outer_radius)
96}
float Scalar
Definition scalar.h:19
static constexpr TRect MakeCircleBounds(const TPoint< Type > &center, Type radius)
Definition rect.h:156
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...
Definition rect.h:472

References impeller::TRect< Scalar >::MakeCircleBounds(), transform, and impeller::TRect< T >::TransformAndClipBounds().

◆ GetPositionBuffer()

GeometryResult impeller::CircleGeometry::GetPositionBuffer ( const ContentContext renderer,
const Entity entity,
RenderPass pass 
) const
overridevirtual

Implements impeller::Geometry.

Definition at line 65 of file circle_geometry.cc.

67 {
68 auto& transform = entity.GetTransform();
69
70 Scalar max_basis = transform.GetMaxBasisLengthXY();
71 Scalar expansion = max_basis == 0 ? 0.0 : padding_pixels_ / max_basis;
72
73 if (stroke_width_ < 0) {
74 auto generator = renderer.GetTessellator().FilledCircle(
75 transform, center_, radius_ + expansion);
76 return ComputePositionGeometry(renderer, generator, entity, pass);
77 }
78
79 Scalar half_width =
81
82 auto generator = renderer.GetTessellator().StrokedCircle(
83 transform, center_, radius_, half_width + expansion);
84
85 return ComputePositionGeometry(renderer, generator, entity, pass);
86}
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
Definition geometry.cc:26
static Scalar ComputePixelHalfWidth(const Matrix &transform, Scalar width)

References impeller::LineGeometry::ComputePixelHalfWidth(), impeller::Geometry::ComputePositionGeometry(), impeller::Tessellator::FilledCircle(), impeller::Matrix::GetMaxBasisLengthXY(), impeller::ContentContext::GetTessellator(), impeller::Entity::GetTransform(), impeller::Tessellator::StrokedCircle(), and transform.

◆ GetRadius()

Scalar impeller::CircleGeometry::GetRadius ( ) const

Definition at line 49 of file circle_geometry.cc.

49 {
50 return radius_;
51}

◆ GetStrokeWidth()

Scalar impeller::CircleGeometry::GetStrokeWidth ( ) const

Definition at line 53 of file circle_geometry.cc.

53 {
54 return stroke_width_;
55}

◆ IsAxisAlignedRect()

bool impeller::CircleGeometry::IsAxisAlignedRect ( ) const
overridevirtual

Reimplemented from impeller::Geometry.

Definition at line 103 of file circle_geometry.cc.

103 {
104 return false;
105}

◆ SetAntialiasPadding()

void impeller::CircleGeometry::SetAntialiasPadding ( Scalar  extra_pixels)

Definition at line 57 of file circle_geometry.cc.

57 {
58 padding_pixels_ = extra_padding;
59}

The documentation for this class was generated from the following files: