Skip to content

Commit ed8b78a

Browse files
chinmaygardednfield
authored andcommitted
Allow entity passes to be elided based on their contents.
1 parent ead8058 commit ed8b78a

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

impeller/aiks/paint_pass_delegate.cc

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ PaintPassDelegate::PaintPassDelegate(Paint paint) : paint_(std::move(paint)) {}
1414
PaintPassDelegate::~PaintPassDelegate() = default;
1515

1616
// |EntityPassDelgate|
17-
bool PaintPassDelegate::CanCollapseIntoParentPass() {
18-
if (paint_.color.IsOpaque()) {
19-
return true;
20-
}
17+
bool PaintPassDelegate::CanElide() {
18+
return paint_.color.IsTransparent();
19+
}
2120

22-
return false;
21+
// |EntityPassDelgate|
22+
bool PaintPassDelegate::CanCollapseIntoParentPass() {
23+
return paint_.color.IsOpaque();
2324
}
2425

2526
// |EntityPassDelgate|

impeller/aiks/paint_pass_delegate.h

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class PaintPassDelegate final : public EntityPassDelegate {
1717
// |EntityPassDelgate|
1818
~PaintPassDelegate() override;
1919

20+
// |EntityPassDelgate|
21+
bool CanElide() override;
22+
2023
// |EntityPassDelgate|
2124
bool CanCollapseIntoParentPass() override;
2225

impeller/entity/entity_pass.cc

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ bool EntityPass::Render(ContentRenderer& renderer,
9191
}
9292
}
9393
for (const auto& subpass : subpasses_) {
94+
if (delegate_->CanElide()) {
95+
continue;
96+
}
97+
9498
if (delegate_->CanCollapseIntoParentPass()) {
9599
// Directly render into the parent pass and move on.
96100
if (!subpass->Render(renderer, parent_pass)) {

impeller/entity/entity_pass_delegate.cc

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class DefaultEntityPassDelegate final : public EntityPassDelegate {
1616

1717
~DefaultEntityPassDelegate() override = default;
1818

19+
bool CanElide() override { return false; }
20+
1921
bool CanCollapseIntoParentPass() override { return true; }
2022

2123
std::shared_ptr<Contents> CreateContentsForSubpassTarget(

impeller/entity/entity_pass_delegate.h

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class EntityPassDelegate {
2020

2121
virtual ~EntityPassDelegate();
2222

23+
virtual bool CanElide() = 0;
24+
2325
virtual bool CanCollapseIntoParentPass() = 0;
2426

2527
virtual std::shared_ptr<Contents> CreateContentsForSubpassTarget(

0 commit comments

Comments
 (0)