Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7cbf4ca

Browse files
committed
more unit tests
1 parent e18fdf0 commit 7cbf4ca

File tree

3 files changed

+635
-23
lines changed

3 files changed

+635
-23
lines changed

impeller/geometry/round_rect.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ RoundRect RoundRect::MakeRectRadii(const Rect& bounds,
6060
scale);
6161
// clang-format on
6262
if (scale < 1.0f) {
63-
radii.Scale(scale);
63+
radii = radii * scale;
6464
}
6565

6666
return RoundRect(bounds, radii);
@@ -117,7 +117,7 @@ static constexpr Point kUpperRightDirection(1.0f, -1.0f);
117117
static constexpr Point kLowerLeftDirection(-1.0f, 1.0f);
118118
static constexpr Point kLowerRightDirection(1.0f, 1.0f);
119119

120-
[[nodiscard]] constexpr bool RoundRect::Contains(const Point& p) const {
120+
[[nodiscard]] bool RoundRect::Contains(const Point& p) const {
121121
if (!bounds_.Contains(p)) {
122122
return false;
123123
}

impeller/geometry/round_rect.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@ struct RoundingRadii {
4545
top_left == bottom_right;
4646
}
4747

48-
constexpr bool AreNearlyAllSame() const {
49-
return top_left == top_right && //
50-
top_left == bottom_left && //
51-
top_left == bottom_right;
52-
}
53-
54-
constexpr void Scale(Scalar scale) {
55-
top_left *= scale;
56-
top_right *= scale;
57-
bottom_left *= scale;
58-
bottom_right *= scale;
48+
constexpr inline RoundingRadii operator*(Scalar scale) {
49+
return {
50+
.top_left = top_left * scale,
51+
.top_right = top_right * scale,
52+
.bottom_left = bottom_left * scale,
53+
.bottom_right = bottom_right * scale,
54+
};
5955
}
6056

6157
[[nodiscard]] constexpr bool operator==(const RoundingRadii& rr) const {
@@ -65,8 +61,8 @@ struct RoundingRadii {
6561
bottom_right == rr.bottom_right;
6662
}
6763

68-
[[nodiscard]] constexpr bool operator!=(const RoundingRadii& r) const {
69-
return !(*this == r);
64+
[[nodiscard]] constexpr bool operator!=(const RoundingRadii& rr) const {
65+
return !(*this == rr);
7066
}
7167
};
7268

@@ -130,7 +126,7 @@ struct RoundRect {
130126
/// along the top and left edges but not points along the
131127
/// right and bottom edges so that a point is only ever
132128
/// considered inside one of two abutting rectangles.
133-
[[nodiscard]] constexpr bool Contains(const Point& p) const;
129+
[[nodiscard]] bool Contains(const Point& p) const;
134130

135131
/// @brief Returns a new round rectangle translated by the given offset.
136132
[[nodiscard]] constexpr RoundRect Shift(Scalar dx, Scalar dy) const {

0 commit comments

Comments
 (0)