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

Commit c705e6a

Browse files
committed
round out bounds for subpass render target
1 parent 3b72291 commit c705e6a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

impeller/entity/entity_pass.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
622622
return EntityPass::EntityResult::Skip();
623623
}
624624

625+
subpass_coverage = RoundOut(subpass_coverage.value());
626+
625627
auto subpass_size = ISize(subpass_coverage->size);
626628
if (subpass_size.IsEmpty()) {
627629
capture.CreateChild("Subpass Entity (Skipped: Empty subpass coverage B)");

impeller/geometry/geometry_unittests.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,17 @@ TEST(GeometryTest, RectProject) {
21142114
}
21152115
}
21162116

2117+
TEST(GeometryTest, RectRoundOut) {
2118+
{
2119+
auto r = Rect::MakeLTRB(-100, -100, 100, 100);
2120+
ASSERT_EQ(RoundOut(r), r);
2121+
}
2122+
{
2123+
auto r = Rect::MakeLTRB(-100.1, -100.1, 100.1, 100.1);
2124+
ASSERT_EQ(RoundOut(r), Rect::MakeLTRB(-101, -101, 101, 101));
2125+
}
2126+
}
2127+
21172128
TEST(GeometryTest, CubicPathComponentPolylineDoesNotIncludePointOne) {
21182129
CubicPathComponent component({10, 10}, {20, 35}, {35, 20}, {40, 40});
21192130
auto polyline = component.CreatePolyline(1.0f);

impeller/geometry/rect.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ struct TRect {
315315
using Rect = TRect<Scalar>;
316316
using IRect = TRect<int64_t>;
317317

318+
constexpr inline Rect RoundOut(const Rect& r) {
319+
return Rect::MakeLTRB(floor(r.GetLeft()), floor(r.GetTop()),
320+
ceil(r.GetRight()), ceil(r.GetBottom()));
321+
}
322+
318323
constexpr inline std::optional<Rect> Union(const Rect& a,
319324
const std::optional<Rect> b) {
320325
return b.has_value() ? a.Union(b.value()) : a;

0 commit comments

Comments
 (0)