Flutter Engine
 
Loading...
Searching...
No Matches
impeller::RoundRect Struct Reference

#include <round_rect.h>

Public Member Functions

 RoundRect ()=default
 
constexpr const RectGetBounds () const
 
constexpr const RoundingRadiiGetRadii () const
 
constexpr bool IsFinite () const
 
constexpr bool IsEmpty () const
 
constexpr bool IsRect () const
 
constexpr bool IsOval () const
 
bool Contains (const Point &p) const
 Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
 
RoundRect Shift (Scalar dx, Scalar dy) const
 Returns a new round rectangle translated by the given offset.
 
RoundRect Expand (Scalar left, Scalar top, Scalar right, Scalar bottom) const
 Returns a round rectangle with expanded edges. Negative expansion results in shrinking.
 
RoundRect Expand (Scalar horizontal, Scalar vertical) const
 Returns a round rectangle with expanded edges. Negative expansion results in shrinking.
 
RoundRect Expand (Scalar amount) const
 Returns a round rectangle with expanded edges. Negative expansion results in shrinking.
 
constexpr bool operator== (const RoundRect &rr) const
 

Static Public Member Functions

static RoundRect MakeRect (const Rect &rect)
 
static RoundRect MakeOval (const Rect &rect)
 
static RoundRect MakeRectRadius (const Rect &rect, Scalar radius)
 
static RoundRect MakeRectXY (const Rect &rect, Scalar x_radius, Scalar y_radius)
 
static RoundRect MakeRectXY (const Rect &rect, Size corner_radii)
 
static RoundRect MakeNinePatch (const Rect &rect, Scalar left, Scalar top, Scalar right, Scalar bottom)
 
static RoundRect MakeRectRadii (const Rect &rect, const RoundingRadii &radii)
 

Friends

class RoundRectPathSource
 
class DiffRoundRectPathSource
 

Detailed Description

Definition at line 16 of file round_rect.h.

Constructor & Destructor Documentation

◆ RoundRect()

impeller::RoundRect::RoundRect ( )
default

Referenced by MakeRectRadii().

Member Function Documentation

◆ Contains()

bool impeller::RoundRect::Contains ( const Point p) const

Returns true iff the provided point |p| is inside the half-open interior of this rectangle.

For purposes of containment, a rectangle contains points along the top and left edges but not points along the right and bottom edges so that a point is only ever considered inside one of two abutting rectangles.

Definition at line 73 of file round_rect.cc.

73 {
74 if (!bounds_.Contains(p)) {
75 return false;
76 }
78 radii_.top_left) ||
80 radii_.top_right) ||
82 radii_.bottom_left) ||
84 radii_.bottom_right)) {
85 return false;
86 }
87 return true;
88}
static bool CornerContains(const Point &p, const Point &corner, const Point &direction, const Size &radii)
Definition round_rect.cc:30
static constexpr Point kUpperLeftDirection(-1.0f, -1.0f)
static constexpr Point kLowerRightDirection(1.0f, 1.0f)
static constexpr Point kUpperRightDirection(1.0f, -1.0f)
static constexpr Point kLowerLeftDirection(-1.0f, 1.0f)
constexpr bool Contains(const TPoint< Type > &p) const
Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
Definition rect.h:231
constexpr TPoint< T > GetLeftTop() const
Definition rect.h:359
constexpr TPoint< T > GetRightBottom() const
Definition rect.h:371
constexpr TPoint< T > GetLeftBottom() const
Definition rect.h:367
constexpr TPoint< T > GetRightTop() const
Definition rect.h:363

References impeller::RoundingRadii::bottom_left, impeller::RoundingRadii::bottom_right, impeller::TRect< T >::Contains(), impeller::CornerContains(), impeller::TRect< T >::GetLeftBottom(), impeller::TRect< T >::GetLeftTop(), impeller::TRect< T >::GetRightBottom(), impeller::TRect< T >::GetRightTop(), impeller::kLowerLeftDirection(), impeller::kLowerRightDirection(), impeller::kUpperLeftDirection(), impeller::kUpperRightDirection(), impeller::RoundingRadii::top_left, and impeller::RoundingRadii::top_right.

◆ Expand() [1/3]

RoundRect impeller::RoundRect::Expand ( Scalar  amount) const
inline

Returns a round rectangle with expanded edges. Negative expansion results in shrinking.

Definition at line 120 of file round_rect.h.

120 {
121 // Use the factory rather than the internal constructor as the changing
122 // size of the rectangle requires that we re-validate the radii to the
123 // newly sized rectangle.
124 return MakeRectRadii(bounds_.Expand(amount), radii_);
125 }
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
Definition round_rect.cc:9
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition rect.h:618

References impeller::TRect< T >::Expand(), and MakeRectRadii().

◆ Expand() [2/3]

RoundRect impeller::RoundRect::Expand ( Scalar  horizontal,
Scalar  vertical 
) const
inline

Returns a round rectangle with expanded edges. Negative expansion results in shrinking.

Definition at line 110 of file round_rect.h.

111 {
112 // Use the factory rather than the internal constructor as the changing
113 // size of the rectangle requires that we re-validate the radii to the
114 // newly sized rectangle.
115 return MakeRectRadii(bounds_.Expand(horizontal, vertical), radii_);
116 }

References impeller::TRect< T >::Expand(), and MakeRectRadii().

◆ Expand() [3/3]

RoundRect impeller::RoundRect::Expand ( Scalar  left,
Scalar  top,
Scalar  right,
Scalar  bottom 
) const
inline

Returns a round rectangle with expanded edges. Negative expansion results in shrinking.

Definition at line 98 of file round_rect.h.

101 {
102 // Use the factory rather than the internal constructor as the changing
103 // size of the rectangle requires that we re-validate the radii to the
104 // newly sized rectangle.
105 return MakeRectRadii(bounds_.Expand(left, top, right, bottom), radii_);
106 }

References impeller::TRect< T >::Expand(), and MakeRectRadii().

Referenced by impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ GetBounds()

◆ GetRadii()

◆ IsEmpty()

◆ IsFinite()

◆ IsOval()

constexpr bool impeller::RoundRect::IsOval ( ) const
inlineconstexpr

Definition at line 71 of file round_rect.h.

71 {
72 return !bounds_.IsEmpty() && radii_.AreAllCornersSame() &&
74 bounds_.GetWidth() * 0.5f) &&
76 bounds_.GetHeight() * 0.5f);
77 }
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition scalar.h:36
constexpr bool AreAllCornersSame(Scalar tolerance=kEhCloseEnough) const
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition rect.h:347
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition rect.h:341
Type height
Definition size.h:29
Type width
Definition size.h:28

References impeller::RoundingRadii::AreAllCornersSame(), impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TSize< T >::height, impeller::TRect< T >::IsEmpty(), impeller::ScalarNearlyEqual(), impeller::RoundingRadii::top_left, and impeller::TSize< T >::width.

Referenced by flutter::DisplayListBuilder::ClipRoundRect(), impeller::DlDispatcherBase::clipRoundRect(), flutter::DisplayListMatrixClipState::clipRRect(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and flutter::DisplayListMatrixClipState::TransformedRRectCoversBounds().

◆ IsRect()

◆ MakeNinePatch()

static RoundRect impeller::RoundRect::MakeNinePatch ( const Rect rect,
Scalar  left,
Scalar  top,
Scalar  right,
Scalar  bottom 
)
inlinestatic

Definition at line 42 of file round_rect.h.

46 {
47 return MakeRectRadii(
48 rect, RoundingRadii::MakeNinePatch(left, top, right, bottom));
49 }
static constexpr RoundingRadii MakeNinePatch(Scalar left, Scalar top, Scalar right, Scalar bottom)

References impeller::RoundingRadii::MakeNinePatch(), and MakeRectRadii().

◆ MakeOval()

◆ MakeRect()

◆ MakeRectRadii()

RoundRect impeller::RoundRect::MakeRectRadii ( const Rect rect,
const RoundingRadii radii 
)
static

Definition at line 9 of file round_rect.cc.

10 {
11 if (!in_bounds.IsFinite()) {
12 return {};
13 }
14 Rect bounds = in_bounds.GetPositive();
15 // RoundingRadii::Scaled might return an empty radii if bounds or in_radii is
16 // empty, which is expected. Pass along the bounds even if the radii is empty
17 // as it would still have a valid location and/or 1-dimensional size which
18 // might appear when stroked
19 return RoundRect(bounds, in_radii.Scaled(bounds));
20}
TRect< Scalar > Rect
Definition rect.h:788
constexpr TRect GetPositive() const
Get a version of this rectangle that has a non-negative size.
Definition rect.h:398

References impeller::TRect< T >::GetPositive(), impeller::TRect< T >::IsFinite(), RoundRect(), and impeller::RoundingRadii::Scaled().

Referenced by flutter::testing::BM_DrawDRRect(), flutter::testing::BM_DrawRRect(), impeller::interop::DisplayListBuilder::ClipRoundedRect(), Skwasm::createDlRRect(), impeller::interop::DisplayListBuilder::DrawRoundedRect(), impeller::interop::DisplayListBuilder::DrawRoundedRectDifference(), Expand(), Expand(), Expand(), tonic::DartConverter< flutter::RRect >::FromDart(), MakeNinePatch(), MakeOval(), MakeRect(), MakeRectRadius(), MakeRectXY(), MakeRectXY(), Shift(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::RoundSuperellipse::ToApproximateRoundRect(), and flutter::ToDlRoundRect().

◆ MakeRectRadius()

static RoundRect impeller::RoundRect::MakeRectRadius ( const Rect rect,
Scalar  radius 
)
inlinestatic

Definition at line 27 of file round_rect.h.

27 {
28 return MakeRectRadii(rect, RoundingRadii::MakeRadius(radius));
29 }
static constexpr RoundingRadii MakeRadius(Scalar radius)

References impeller::RoundingRadii::MakeRadius(), and MakeRectRadii().

Referenced by impeller::testing::TEST(), impeller::testing::TEST_P(), flutter::testing::TEST_P(), and flutter::testing::TEST_P().

◆ MakeRectXY() [1/2]

static RoundRect impeller::RoundRect::MakeRectXY ( const Rect rect,
Scalar  x_radius,
Scalar  y_radius 
)
inlinestatic

Definition at line 31 of file round_rect.h.

33 {
34 return MakeRectRadii(rect,
35 RoundingRadii::MakeRadii(Size(x_radius, y_radius)));
36 }
TSize< Scalar > Size
Definition size.h:159

References impeller::RoundingRadii::MakeRadii(), and MakeRectRadii().

Referenced by impeller::testing::DoGradientOvalStrokeMaskBlur(), impeller::testing::MaskBlurVariantTest(), flutter::testing::CanvasCompareTester::RenderWithClips(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and flutter::testing::TEST_P().

◆ MakeRectXY() [2/2]

static RoundRect impeller::RoundRect::MakeRectXY ( const Rect rect,
Size  corner_radii 
)
inlinestatic

Definition at line 38 of file round_rect.h.

38 {
39 return MakeRectRadii(rect, RoundingRadii::MakeRadii(corner_radii));
40 }

References impeller::RoundingRadii::MakeRadii(), and MakeRectRadii().

◆ operator==()

constexpr bool impeller::RoundRect::operator== ( const RoundRect rr) const
inlineconstexpr

Definition at line 127 of file round_rect.h.

127 {
128 return bounds_ == rr.bounds_ && radii_ == rr.radii_;
129 }

◆ Shift()

RoundRect impeller::RoundRect::Shift ( Scalar  dx,
Scalar  dy 
) const
inline

Returns a new round rectangle translated by the given offset.

Definition at line 89 of file round_rect.h.

89 {
90 // Just in case, use the factory rather than the internal constructor
91 // as shifting the rectangle may increase/decrease its bit precision
92 // so we should re-validate the radii to the newly located rectangle.
93 return MakeRectRadii(bounds_.Shift(dx, dy), radii_);
94 }
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.
Definition rect.h:602

References MakeRectRadii(), and impeller::TRect< T >::Shift().

Referenced by flutter::testing::BM_DrawDRRect(), flutter::testing::BM_DrawRRect(), flutter::testing::CreateAllClipOps(), flutter::testing::CreateAllRenderingOps(), impeller::testing::TEST(), and flutter::testing::TEST_P().

Friends And Related Symbol Documentation

◆ DiffRoundRectPathSource

friend class DiffRoundRectPathSource
friend

Definition at line 142 of file round_rect.h.

◆ RoundRectPathSource

friend class RoundRectPathSource
friend

Definition at line 141 of file round_rect.h.


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