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

Commit 6df4d89

Browse files
bderoharryterkelsen
authored andcommitted
[Impeller] Add Entity::RenderingMode enum. (#45845)
Resolves flutter/flutter#134681. For the various places where we track if a rendered entity is a subpass or not. After landing this, I think the next winning move is to make this an Entity field and remove the `SetRenderingMode` junk from the filter graph. That refactor is a bit more risky, so I plan to do that separately.
1 parent 494f98e commit 6df4d89

16 files changed

+53
-34
lines changed

impeller/aiks/canvas.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ void Canvas::Save(bool create_subpass,
6464
entry.cull_rect = xformation_stack_.back().cull_rect;
6565
entry.stencil_depth = xformation_stack_.back().stencil_depth;
6666
if (create_subpass) {
67-
entry.is_subpass = true;
67+
entry.rendering_mode = Entity::RenderingMode::kSubpass;
6868
auto subpass = std::make_unique<EntityPass>();
6969
subpass->SetEnableOffscreenCheckerboard(
7070
debug_options.offscreen_texture_checkerboard);
7171
if (backdrop_filter) {
7272
EntityPass::BackdropFilterProc backdrop_filter_proc =
7373
[backdrop_filter = backdrop_filter->Clone()](
7474
const FilterInput::Ref& input, const Matrix& effect_transform,
75-
bool is_subpass) {
75+
Entity::RenderingMode rendering_mode) {
7676
auto filter = backdrop_filter->WrapInput(input);
7777
filter->SetEffectTransform(effect_transform);
78-
filter->SetIsForSubpass(is_subpass);
78+
filter->SetRenderingMode(rendering_mode);
7979
return filter;
8080
};
8181
subpass->SetBackdropFilter(backdrop_filter_proc);
@@ -93,7 +93,8 @@ bool Canvas::Restore() {
9393
if (xformation_stack_.size() == 1) {
9494
return false;
9595
}
96-
if (xformation_stack_.back().is_subpass) {
96+
if (xformation_stack_.back().rendering_mode ==
97+
Entity::RenderingMode::kSubpass) {
9798
current_pass_ = GetCurrentPass().GetSuperpass();
9899
FML_DCHECK(current_pass_);
99100
}

impeller/aiks/canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct CanvasStackEntry {
3535
// |cull_rect| is conservative screen-space bounds of the clipped output area
3636
std::optional<Rect> cull_rect;
3737
size_t stencil_depth = 0u;
38-
bool is_subpass = false;
38+
Entity::RenderingMode rendering_mode = Entity::RenderingMode::kDirect;
3939
bool contains_clips = false;
4040
};
4141

impeller/aiks/paint.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ std::shared_ptr<Contents> Paint::WithFilters(
6060
std::shared_ptr<Contents> input) const {
6161
input = WithColorFilter(input, ColorFilterContents::AbsorbOpacity::kYes);
6262
input = WithInvertFilter(input);
63-
auto image_filter = WithImageFilter(input, Matrix(), /*is_subpass=*/false);
63+
auto image_filter =
64+
WithImageFilter(input, Matrix(), Entity::RenderingMode::kDirect);
6465
if (image_filter) {
6566
input = image_filter;
6667
}
@@ -71,7 +72,7 @@ std::shared_ptr<Contents> Paint::WithFiltersForSubpassTarget(
7172
std::shared_ptr<Contents> input,
7273
const Matrix& effect_transform) const {
7374
auto image_filter =
74-
WithImageFilter(input, effect_transform, /*is_subpass=*/true);
75+
WithImageFilter(input, effect_transform, Entity::RenderingMode::kSubpass);
7576
if (image_filter) {
7677
input = image_filter;
7778
}
@@ -91,12 +92,12 @@ std::shared_ptr<Contents> Paint::WithMaskBlur(std::shared_ptr<Contents> input,
9192
std::shared_ptr<FilterContents> Paint::WithImageFilter(
9293
const FilterInput::Variant& input,
9394
const Matrix& effect_transform,
94-
bool is_subpass) const {
95+
Entity::RenderingMode rendering_mode) const {
9596
if (!image_filter) {
9697
return nullptr;
9798
}
9899
auto filter = image_filter->WrapInput(FilterInput::Make(input));
99-
filter->SetIsForSubpass(is_subpass);
100+
filter->SetRenderingMode(rendering_mode);
100101
filter->SetEffectTransform(effect_transform);
101102
return filter;
102103
}

impeller/aiks/paint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct Paint {
2626
using ImageFilterProc = std::function<std::shared_ptr<FilterContents>(
2727
FilterInput::Ref,
2828
const Matrix& effect_transform,
29-
bool is_subpass)>;
29+
Entity::RenderingMode rendering_mode)>;
3030
using MaskFilterProc = std::function<std::shared_ptr<FilterContents>(
3131
FilterInput::Ref,
3232
bool is_solid_color,
@@ -101,7 +101,7 @@ struct Paint {
101101
std::shared_ptr<FilterContents> WithImageFilter(
102102
const FilterInput::Variant& input,
103103
const Matrix& effect_transform,
104-
bool is_subpass) const;
104+
Entity::RenderingMode rendering_mode) const;
105105

106106
private:
107107
std::shared_ptr<Contents> WithColorFilter(

impeller/aiks/paint_pass_delegate.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ std::shared_ptr<Contents> PaintPassDelegate::CreateContentsForSubpassTarget(
5151
std::shared_ptr<FilterContents> PaintPassDelegate::WithImageFilter(
5252
const FilterInput::Variant& input,
5353
const Matrix& effect_transform) const {
54-
return paint_.WithImageFilter(input, effect_transform, true);
54+
return paint_.WithImageFilter(input, effect_transform,
55+
Entity::RenderingMode::kSubpass);
5556
}
5657

5758
/// OpacityPeepholePassDelegate
@@ -151,7 +152,8 @@ OpacityPeepholePassDelegate::CreateContentsForSubpassTarget(
151152
std::shared_ptr<FilterContents> OpacityPeepholePassDelegate::WithImageFilter(
152153
const FilterInput::Variant& input,
153154
const Matrix& effect_transform) const {
154-
return paint_.WithImageFilter(input, effect_transform, true);
155+
return paint_.WithImageFilter(input, effect_transform,
156+
Entity::RenderingMode::kSubpass);
155157
}
156158

157159
} // namespace impeller

impeller/entity/contents/filters/filter_contents.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ void FilterContents::SetLeafInputs(const FilterInput::Vector& inputs) {
298298
}
299299
}
300300

301-
void FilterContents::SetIsForSubpass(bool is_subpass) {
301+
void FilterContents::SetRenderingMode(Entity::RenderingMode rendering_mode) {
302302
for (auto& input : inputs_) {
303-
input->SetIsForSubpass(is_subpass);
303+
input->SetRenderingMode(rendering_mode);
304304
}
305305
}
306306

impeller/entity/contents/filters/filter_contents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class FilterContents : public Contents {
157157
/// that the current transformation matrix of the entity is not stored
158158
/// in the Entity transformation matrix. Instead, the effect transform
159159
/// is used in this case.
160-
virtual void SetIsForSubpass(bool is_subpass);
160+
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode);
161161

162162
private:
163163
virtual std::optional<Rect> GetFilterCoverage(

impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ void FilterContentsFilterInput::SetEffectTransform(const Matrix& matrix) {
7575
filter_->SetEffectTransform(matrix);
7676
}
7777

78-
void FilterContentsFilterInput::SetIsForSubpass(bool is_for_subpass) {
79-
filter_->SetIsForSubpass(is_for_subpass);
78+
void FilterContentsFilterInput::SetRenderingMode(
79+
Entity::RenderingMode rendering_mode) {
80+
filter_->SetRenderingMode(rendering_mode);
8081
}
8182

8283
} // namespace impeller

impeller/entity/contents/filters/inputs/filter_contents_filter_input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class FilterContentsFilterInput final : public FilterInput {
4949
virtual void SetEffectTransform(const Matrix& matrix) override;
5050

5151
// |FilterInput|
52-
virtual void SetIsForSubpass(bool is_for_subpass) override;
52+
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode) override;
5353

5454
private:
5555
explicit FilterContentsFilterInput(std::shared_ptr<FilterContents> filter);

impeller/entity/contents/filters/inputs/filter_input.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ void FilterInput::SetLeafInputs(const FilterInput::Vector& inputs) {}
8888

8989
void FilterInput::SetEffectTransform(const Matrix& matrix) {}
9090

91-
void FilterInput::SetIsForSubpass(bool is_for_subpass) {}
91+
void FilterInput::SetRenderingMode(Entity::RenderingMode rendering_mode) {}
9292

9393
} // namespace impeller

0 commit comments

Comments
 (0)