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 1 commit
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
Prev Previous commit
Next Next commit
switched to explicit rendermode names, deduced when they were needed
  • Loading branch information
gaaclarke committed May 21, 2024
commit 373cf526918135d385f649af914d0d038eea14a2
7 changes: 4 additions & 3 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ void Canvas::Save(bool create_subpass,
entry.cull_rect = transform_stack_.back().cull_rect;
entry.clip_height = transform_stack_.back().clip_height;
if (create_subpass) {
entry.rendering_mode = Entity::RenderingMode::kClippedSubpass;
entry.rendering_mode =
Entity::RenderingMode::kSubpassAppendSnapshotTransform;
auto subpass = std::make_unique<EntityPass>();
if (backdrop_filter) {
EntityPass::BackdropFilterProc backdrop_filter_proc =
Expand Down Expand Up @@ -261,9 +262,9 @@ bool Canvas::Restore() {
current_pass_->PopClips(num_clips, current_depth_);

if (transform_stack_.back().rendering_mode ==
Entity::RenderingMode::kClippedSubpass ||
Entity::RenderingMode::kSubpassAppendSnapshotTransform ||
transform_stack_.back().rendering_mode ==
Entity::RenderingMode::kSubpass) {
Entity::RenderingMode::kSubpassPrependSnapshotTransform) {
current_pass_->SetClipDepth(++current_depth_);
current_pass_ = GetCurrentPass().GetSuperpass();
FML_DCHECK(current_pass_);
Expand Down
6 changes: 3 additions & 3 deletions impeller/aiks/experimental_canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void ExperimentalCanvas::SaveLayer(
<< entry.clip_depth << " <=? " << transform_stack_.back().clip_depth
<< " after allocating " << total_content_depth;
entry.clip_height = transform_stack_.back().clip_height;
entry.rendering_mode = Entity::RenderingMode::kClippedSubpass;
entry.rendering_mode = Entity::RenderingMode::kSubpassAppendSnapshotTransform;
transform_stack_.emplace_back(entry);

auto inline_pass = std::make_unique<InlinePassContext>(
Expand Down Expand Up @@ -272,9 +272,9 @@ bool ExperimentalCanvas::Restore() {
current_depth_ = transform_stack_.back().clip_depth;

if (transform_stack_.back().rendering_mode ==
Entity::RenderingMode::kClippedSubpass ||
Entity::RenderingMode::kSubpassAppendSnapshotTransform ||
transform_stack_.back().rendering_mode ==
Entity::RenderingMode::kSubpass) {
Entity::RenderingMode::kSubpassPrependSnapshotTransform) {
auto inline_pass = std::move(inline_pass_contexts_.back());

SaveLayerState save_layer_state = save_layer_state_.back();
Expand Down
3 changes: 2 additions & 1 deletion impeller/aiks/paint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ std::shared_ptr<Contents> Paint::WithFiltersForSubpassTarget(
std::shared_ptr<Contents> input,
const Matrix& effect_transform) const {
auto image_filter =
WithImageFilter(input, effect_transform, Entity::RenderingMode::kSubpass);
WithImageFilter(input, effect_transform,
Entity::RenderingMode::kSubpassPrependSnapshotTransform);
if (image_filter) {
input = image_filter;
}
Expand Down
10 changes: 6 additions & 4 deletions impeller/aiks/paint_pass_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ std::shared_ptr<Contents> PaintPassDelegate::CreateContentsForSubpassTarget(
std::shared_ptr<FilterContents> PaintPassDelegate::WithImageFilter(
const FilterInput::Variant& input,
const Matrix& effect_transform) const {
return paint_.WithImageFilter(input, effect_transform,
Entity::RenderingMode::kSubpass);
return paint_.WithImageFilter(
input, effect_transform,
Entity::RenderingMode::kSubpassPrependSnapshotTransform);
}

/// OpacityPeepholePassDelegate
Expand Down Expand Up @@ -152,8 +153,9 @@ OpacityPeepholePassDelegate::CreateContentsForSubpassTarget(
std::shared_ptr<FilterContents> OpacityPeepholePassDelegate::WithImageFilter(
const FilterInput::Variant& input,
const Matrix& effect_transform) const {
return paint_.WithImageFilter(input, effect_transform,
Entity::RenderingMode::kSubpass);
return paint_.WithImageFilter(
input, effect_transform,
Entity::RenderingMode::kSubpassPrependSnapshotTransform);
}

} // namespace impeller
18 changes: 12 additions & 6 deletions impeller/entity/contents/filters/matrix_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ Matrix CalculateSubpassTransform(const Matrix& snapshot_transform,
const Matrix& effect_transform,
const Matrix& matrix,
Entity::RenderingMode rendering_mode) {
if (rendering_mode == Entity::RenderingMode::kClippedSubpass) {
if (rendering_mode ==
Entity::RenderingMode::kSubpassAppendSnapshotTransform) {
return snapshot_transform * //
effect_transform * //
matrix * //
effect_transform.Invert();
} else {
FML_DCHECK(rendering_mode == Entity::RenderingMode::kSubpass);
FML_DCHECK(rendering_mode ==
Entity::RenderingMode::kSubpassPrependSnapshotTransform);
return effect_transform * //
matrix * //
effect_transform.Invert() * //
Expand All @@ -60,8 +62,10 @@ std::optional<Entity> MatrixFilterContents::RenderFilter(
return std::nullopt;
}

if (rendering_mode_ == Entity::RenderingMode::kSubpass ||
rendering_mode_ == Entity::RenderingMode::kClippedSubpass) {
if (rendering_mode_ ==
Entity::RenderingMode::kSubpassPrependSnapshotTransform ||
rendering_mode_ ==
Entity::RenderingMode::kSubpassAppendSnapshotTransform) {
// There are two special quirks with how Matrix filters behave when used as
// subpass backdrop filters:
//
Expand Down Expand Up @@ -131,8 +135,10 @@ std::optional<Rect> MatrixFilterContents::GetFilterCoverage(
}

Matrix input_transform = inputs[0]->GetTransform(entity);
if (rendering_mode_ == Entity::RenderingMode::kSubpass ||
rendering_mode_ == Entity::RenderingMode::kClippedSubpass) {
if (rendering_mode_ ==
Entity::RenderingMode::kSubpassPrependSnapshotTransform ||
rendering_mode_ ==
Entity::RenderingMode::kSubpassAppendSnapshotTransform) {
Rect coverage_bounds = coverage->TransformBounds(input_transform.Invert());
Matrix transform = CalculateSubpassTransform(
input_transform, effect_transform, matrix_, rendering_mode_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ TEST_P(MatrixFilterContentsTest,
contents.SetInputs({FilterInput::Make(texture)});
contents.SetMatrix(Matrix::MakeTranslation({50, 100, 0}));
contents.SetEffectTransform(Matrix::MakeScale({2, 2, 1}));
contents.SetRenderingMode(Entity::RenderingMode::kClippedSubpass);
contents.SetRenderingMode(
Entity::RenderingMode::kSubpassAppendSnapshotTransform);

Entity entity;
entity.SetTransform(Matrix::MakeTranslation({100, 200, 0}));
Expand Down Expand Up @@ -183,7 +184,8 @@ TEST_P(MatrixFilterContentsTest,
contents.SetInputs({FilterInput::Make(texture)});
contents.SetMatrix(Matrix::MakeScale({3, 3, 1}));
contents.SetEffectTransform(Matrix::MakeScale({2, 2, 1}));
contents.SetRenderingMode(Entity::RenderingMode::kClippedSubpass);
contents.SetRenderingMode(
Entity::RenderingMode::kSubpassAppendSnapshotTransform);

Entity entity;
entity.SetTransform(Matrix::MakeTranslation({100, 200, 0}));
Expand All @@ -201,7 +203,8 @@ TEST_P(MatrixFilterContentsTest, RenderCoverageMatchesGetCoverageSubpassScale) {
contents.SetInputs({FilterInput::Make(texture)});
contents.SetMatrix(Matrix::MakeScale({3, 3, 1}));
contents.SetEffectTransform(Matrix::MakeScale({2, 2, 1}));
contents.SetRenderingMode(Entity::RenderingMode::kSubpass);
contents.SetRenderingMode(
Entity::RenderingMode::kSubpassPrependSnapshotTransform);

Entity entity;
entity.SetTransform(Matrix::MakeTranslation({100, 200, 0}));
Expand Down
9 changes: 2 additions & 7 deletions impeller/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ class Entity {
/// rather than local space, and so some filters (namely,
/// MatrixFilterContents) need to interpret the given EffectTransform as the
/// current transform matrix.
///
/// With kClippedSubpass the filters's transform is prepended to the
/// snapshot's transform. With kSubpass the filters's transform is
/// appended
/// to the snapshot's transform.
kClippedSubpass,
kSubpass,
kSubpassAppendSnapshotTransform,
kSubpassPrependSnapshotTransform,
};

/// An enum to define how to repeat, fold, or omit colors outside of the
Expand Down
9 changes: 6 additions & 3 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ std::optional<Rect> EntityPass::GetElementsCoverage(
std::shared_ptr<FilterContents> backdrop_filter =
subpass.backdrop_filter_proc_(
FilterInput::Make(accumulated_coverage.value()),
subpass.transform_, Entity::RenderingMode::kClippedSubpass);
subpass.transform_,
Entity::RenderingMode::kSubpassAppendSnapshotTransform);
if (backdrop_filter) {
auto backdrop_coverage = backdrop_filter->GetCoverage({});
unfiltered_coverage =
Expand Down Expand Up @@ -589,9 +590,11 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
Matrix subpass_transform_basis = subpass->transform_.Basis();
subpass_backdrop_filter_contents =
proc(FilterInput::Make(std::move(texture)), subpass_transform_basis,
// When the subpass has a translation that means the math with
// the snapshot has to be different.
subpass_transform_basis == subpass->transform_
? Entity::RenderingMode::kClippedSubpass
: Entity::RenderingMode::kSubpass);
? Entity::RenderingMode::kSubpassAppendSnapshotTransform
: Entity::RenderingMode::kSubpassPrependSnapshotTransform);

// If the very first thing we render in this EntityPass is a subpass that
// happens to have a backdrop filter, than that backdrop filter will end
Expand Down