Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions impeller/entity/contents/clip_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ Contents::ClipCoverage ClipContents::GetClipCoverage(
FML_UNREACHABLE();
}

bool ClipContents::ShouldRender(
const Entity& entity,
const std::optional<Rect>& clip_coverage) const {
bool ClipContents::ShouldRender(const Entity& entity,
const std::optional<Rect> clip_coverage) const {
return true;
}

Expand Down Expand Up @@ -161,7 +160,7 @@ Contents::ClipCoverage ClipRestoreContents::GetClipCoverage(

bool ClipRestoreContents::ShouldRender(
const Entity& entity,
const std::optional<Rect>& clip_coverage) const {
const std::optional<Rect> clip_coverage) const {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/contents/clip_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClipContents final : public Contents {

// |Contents|
bool ShouldRender(const Entity& entity,
const std::optional<Rect>& clip_coverage) const override;
const std::optional<Rect> clip_coverage) const override;

// |Contents|
bool Render(const ContentContext& renderer,
Expand Down Expand Up @@ -78,7 +78,7 @@ class ClipRestoreContents final : public Contents {

// |Contents|
bool ShouldRender(const Entity& entity,
const std::optional<Rect>& clip_coverage) const override;
const std::optional<Rect> clip_coverage) const override;

// |Contents|
bool Render(const ContentContext& renderer,
Expand Down
9 changes: 6 additions & 3 deletions impeller/entity/contents/contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,22 @@ bool Contents::ApplyColorFilter(
}

bool Contents::ShouldRender(const Entity& entity,
const std::optional<Rect>& clip_coverage) const {
const std::optional<Rect> clip_coverage) const {
#ifdef IMPELLER_CONTENT_CULLING
if (!clip_coverage.has_value()) {
return false;
}

auto coverage = GetCoverage(entity);
if (!coverage.has_value()) {
return false;
}
if (coverage == Rect::MakeMaximum()) {
return true;
}
return clip_coverage->IntersectsWithRect(coverage.value());
return clip_coverage.IntersectsWithRect(coverage.value());
#else
return true;
#endif // IMPELLER_CONTENT_CULLING
}

void Contents::SetCoverageHint(std::optional<Rect> coverage_hint) {
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Contents {
const std::string& label = "Snapshot") const;

virtual bool ShouldRender(const Entity& entity,
const std::optional<Rect>& clip_coverage) const;
const std::optional<Rect> clip_coverage) const;

//----------------------------------------------------------------------------
/// @brief Return the color source's intrinsic size, if available.
Expand Down
14 changes: 14 additions & 0 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,20 @@ TEST_P(EntityTest, SolidFillShouldRenderIsCorrect) {
}
}

TEST_P(EntityTest, DoesNotCullEntitiesByDefault) {
auto fill = std::make_shared<SolidColorContents>();
fill->SetColor(Color::CornflowerBlue());
fill->SetGeometry(
Geometry::MakeRect(Rect::MakeLTRB(-1000, -1000, -900, -900)));

Entity entity;
entity.SetContents(fill);

// Even though the entity is offscreen, this should still render because we do
// not compute the coverage intersection by default.
EXPECT_TRUE(entity.ShouldRender(Rect::MakeLTRB(0, 0, 100, 100)));
}

TEST_P(EntityTest, ClipContentsShouldRenderIsCorrect) {
// For clip ops, `ShouldRender` should always return true.

Expand Down