| Flutter Impeller |

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
impeller::RoundingRadii Struct Reference

`#include <rounding_radii.h>`

## Public Member Functions
constexpr bool | IsFinite () const
constexpr bool | AreAllCornersEmpty () const
constexpr bool | AreAllCornersSame (Scalar tolerance=kEhCloseEnough) const
RoundingRadii | Scaled (const Rect &bounds) const
| Returns a scaled copy of this object, ensuring that the sum of the corner radii on each side does not exceed the width or height of the given bounds. More...
constexpr RoundingRadii | operator* (Scalar scale)
constexpr bool | operator== (const RoundingRadii &rr) const
constexpr bool | operator!= (const RoundingRadii &rr) const

## Static Public Member Functions
constexpr static RoundingRadii | MakeRadius (Scalar radius)
constexpr static RoundingRadii | MakeRadii (Size radii)
constexpr static RoundingRadii | MakeNinePatch (Scalar left, Scalar top, Scalar right, Scalar bottom)

## Public Attributes
Size | top_left
Size | top_right
Size | bottom_left
Size | bottom_right

## Detailed Description

Definition at line 14 of file rounding_radii.h.

## Member Function Documentation

## ◆ AreAllCornersEmpty()

constexpr bool impeller::RoundingRadii::AreAllCornersEmpty | ( |  | ) | const
| inline constexpr

Definition at line 47 of file rounding_radii.h.

47 {
48 return top_left.IsEmpty() && //
49 top_right.IsEmpty() && //
50 bottom_left.IsEmpty() && //
51 bottom_right.IsEmpty();
52 }
impeller::RoundingRadii::top_right
Size top_right
Definition: rounding_radii.h:16
impeller::RoundingRadii::bottom_left
Size bottom_left
Definition: rounding_radii.h:17
impeller::RoundingRadii::bottom_right
Size bottom_right
Definition: rounding_radii.h:18
impeller::RoundingRadii::top_left
Size top_left
Definition: rounding_radii.h:15
impeller::TSize::IsEmpty
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123

References bottom_left, bottom_right, impeller::TSize< T >::IsEmpty(), top_left, and top_right.

Referenced by impeller::RoundRect::IsRect(), impeller::RoundSuperellipse::IsRect(), Scaled(), and impeller::testing::TEST().

## ◆ AreAllCornersSame()

constexpr bool impeller::RoundingRadii::AreAllCornersSame | ( | Scalar | tolerance = `kEhCloseEnough` | ) | const
| inline constexpr

Definition at line 54 of file rounding_radii.h.

54 {
55 return ScalarNearlyEqual(top_left.width, top_right.width, tolerance) &&
56 ScalarNearlyEqual(top_left.width, bottom_right.width, tolerance) &&
57 ScalarNearlyEqual(top_left.width, bottom_left.width, tolerance) &&
58 ScalarNearlyEqual(top_left.height, top_right.height, tolerance) &&
59 ScalarNearlyEqual(top_left.height, bottom_right.height, tolerance) &&
60 ScalarNearlyEqual(top_left.height, bottom_left.height, tolerance);
61 }
impeller::ScalarNearlyEqual
constexpr bool ScalarNearlyEqual(Scalar x, Scalar y, Scalar tolerance=kEhCloseEnough)
Definition: scalar.h:35
impeller::TSize::height
Type height
Definition: size.h:29
impeller::TSize::width
Type width
Definition: size.h:28

References bottom_left, bottom_right, impeller::TSize< T >::height, impeller::ScalarNearlyEqual(), top_left, top_right, and impeller::TSize< T >::width.

Referenced by impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), and impeller::testing::TEST().

## ◆ IsFinite()

constexpr bool impeller::RoundingRadii::IsFinite | ( |  | ) | const
| inline constexpr

Definition at line 40 of file rounding_radii.h.

40 {
41 return top_left.IsFinite() && //
42 top_right.IsFinite() && //
43 bottom_left.IsFinite() && //
44 bottom_right.IsFinite();
45 }
impeller::TSize::IsFinite
IsFinite() const
Definition: size.h:126

References bottom_left, bottom_right, impeller::TSize< T >::IsFinite(), top_left, and top_right.

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

## ◆ MakeNinePatch()

constexpr static RoundingRadii impeller::RoundingRadii::MakeNinePatch | ( | Scalar | left,
|  | Scalar | top,
|  | Scalar | right,
|  | Scalar | bottom
| ) |  |
| inline static constexpr

Definition at line 28 of file rounding_radii.h.

31 {
32 return {
33 .top_left = Size{left, top},
34 .top_right = Size{right, top},
35 .bottom_left = Size(left, bottom),
36 .bottom_right = Size(right, bottom),
37 };
38 }
impeller::Size
TSize< Scalar > Size
Definition: size.h:159

References top_left.

Referenced by impeller::RoundRect::MakeNinePatch().

## ◆ MakeRadii()

constexpr static RoundingRadii impeller::RoundingRadii::MakeRadii | ( | Size | radii | ) |
| inline static constexpr

Definition at line 24 of file rounding_radii.h.

24 {
25 return {radii, radii, radii, radii};
26 }

Referenced by impeller::RoundRect::MakeOval(), impeller::RoundSuperellipse::MakeOval(), impeller::RoundRect::MakeRectXY(), impeller::RoundSuperellipse::MakeRectXY(), and impeller::testing::TEST().

## ◆ MakeRadius()

constexpr static RoundingRadii impeller::RoundingRadii::MakeRadius | ( | Scalar | radius | ) |
| inline static constexpr

Definition at line 20 of file rounding_radii.h.

20 {
21 return {Size(radius), Size(radius), Size(radius), Size(radius)};
22 }

Referenced by impeller::RoundRect::MakeRectRadius(), impeller::RoundSuperellipse::MakeRectRadius(), and impeller::testing::TEST().

## ◆ operator!=()

constexpr bool impeller::RoundingRadii::operator!= | ( | const RoundingRadii & | rr | ) | const
| inline constexpr

Definition at line 88 of file rounding_radii.h.

88 {
89 return !(*this == rr);
90 }

## ◆ operator*()

constexpr RoundingRadii impeller::RoundingRadii::operator* | ( | Scalar | scale | ) |
| inline constexpr

Definition at line 72 of file rounding_radii.h.

72 {
73 return {
74 .top_left = top_left * scale,
75 .top_right = top_right * scale,
76 .bottom_left = bottom_left * scale,
77 .bottom_right = bottom_right * scale,
78 };
79 }
scale
const Scalar scale
Definition: stroke_path_geometry.cc:319

References bottom_left, bottom_right, scale, top_left, and top_right.

## ◆ operator==()

constexpr bool impeller::RoundingRadii::operator== | ( | const RoundingRadii & | rr | ) | const
| inline constexpr

Definition at line 81 of file rounding_radii.h.

81 {
82 return top_left == rr.top_left && //
83 top_right == rr.top_right && //
84 bottom_left == rr.bottom_left && //
85 bottom_right == rr.bottom_right;
86 }

References bottom_left, bottom_right, top_left, and top_right.

## ◆ Scaled()

RoundingRadii impeller::RoundingRadii::Scaled | ( | const Rect & | bounds | ) | const

Returns a scaled copy of this object, ensuring that the sum of the corner radii on each side does not exceed the width or height of the given bounds.

See the Skia scaling implementation for more details.

Definition at line 26 of file rounding_radii.cc.

26 {
27 Rect bounds = in_bounds.GetPositive();
28 if (bounds.IsEmpty() || //
29 AreAllCornersEmpty() || !IsFinite()) {
30 // Normalize empty radii.
31 return RoundingRadii();
32 }
33
34 // Copy the incoming radii so that we can work on normalizing them to the
35 // particular rectangle they are paired with without disturbing the caller.
36 RoundingRadii radii = *this;
37
38 // If any corner is flat or has a negative value, normalize it to zeros
39 // We do this first so that the unnecessary non-flat part of that radius
40 // does not contribute to the global scaling below.
41 NormalizeEmptyToZero(radii.top_left);
42 NormalizeEmptyToZero(radii.top_right);
43 NormalizeEmptyToZero(radii.bottom_left);
44 NormalizeEmptyToZero(radii.bottom_right);
45
46 // Now determine a global scale to apply to all of the radii to ensure
47 // that none of the adjacent pairs of radius values sum to larger than
48 // the corresponding dimension of the rectangle.
49 Size size = bounds.GetSize();
50 Scalar scale = 1.0f;
51 // clang-format off
52 AdjustScale(radii.top_left.width, radii.top_right.width, size.width,
53 scale);
54 AdjustScale(radii.bottom_left.width, radii.bottom_right.width, size.width,
55 scale);
56 AdjustScale(radii.top_left.height, radii.bottom_left.height, size.height,
57 scale);
58 AdjustScale(radii.top_right.height, radii.bottom_right.height, size.height,
59 scale);
60 // clang-format on
61 if (scale < 1.0f) {
62 radii = radii * scale;
63 }
64
65 return radii;
66 }
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:792
impeller::AdjustScale
static void AdjustScale(Scalar &radius1, Scalar &radius2, Scalar dimension, Scalar &scale)
Definition: rounding_radii.cc:15
impeller::NormalizeEmptyToZero
static void NormalizeEmptyToZero(Size &radii)
Definition: rounding_radii.cc:9
impeller::RoundingRadii::AreAllCornersEmpty
constexpr bool AreAllCornersEmpty() const
Definition: rounding_radii.h:47
impeller::RoundingRadii::IsFinite
constexpr bool IsFinite() const
Definition: rounding_radii.h:40
impeller::TRect::GetPositive
constexpr TRect GetPositive() const
Get a version of this rectangle that has a non-negative size.
Definition: rect.h:402

References impeller::AdjustScale(), AreAllCornersEmpty(), bottom_left, bottom_right, impeller::TRect< T >::GetPositive(), impeller::TRect< T >::GetSize(), impeller::TSize< T >::height, impeller::TRect< T >::IsEmpty(), IsFinite(), impeller::NormalizeEmptyToZero(), scale, top_left, top_right, and impeller::TSize< T >::width.

Referenced by impeller::RoundRect::MakeRectRadii(), and impeller::RoundSuperellipse::MakeRectRadii().

## Member Data Documentation

## ◆ bottom_left

Size impeller::RoundingRadii::bottom_left

Definition at line 17 of file rounding_radii.h.

Referenced by AreAllCornersEmpty(), AreAllCornersSame(), impeller::RoundRect::Contains(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), IsFinite(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), operator*(), std::operator<<(), operator==(), Scaled(), impeller::testing::TEST(), and impeller::interop::ToSkiaType().

## ◆ bottom_right

Size impeller::RoundingRadii::bottom_right

Definition at line 18 of file rounding_radii.h.

Referenced by AreAllCornersEmpty(), AreAllCornersSame(), impeller::RoundRect::Contains(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), IsFinite(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), operator*(), std::operator<<(), operator==(), Scaled(), impeller::testing::TEST(), and impeller::interop::ToSkiaType().

## ◆ top_left

Size impeller::RoundingRadii::top_left

Definition at line 15 of file rounding_radii.h.

Referenced by AreAllCornersEmpty(), AreAllCornersSame(), impeller::RoundRect::Contains(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), IsFinite(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), MakeNinePatch(), operator*(), std::operator<<(), operator==(), Scaled(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::interop::ToImpellerType(), and impeller::interop::ToSkiaType().

## ◆ top_right

Size impeller::RoundingRadii::top_right

Definition at line 16 of file rounding_radii.h.

Referenced by AreAllCornersEmpty(), AreAllCornersSame(), impeller::RoundRect::Contains(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), IsFinite(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), operator*(), std::operator<<(), operator==(), Scaled(), impeller::testing::TEST(), and impeller::interop::ToSkiaType().

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

- impeller/geometry/rounding_radii.h
- impeller/geometry/rounding_radii.cc