Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] elide extra save layer in BDF. #55305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all 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
19 changes: 19 additions & 0 deletions impeller/aiks/experimental_canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,25 @@ void ExperimentalCanvas::SaveLayer(
: Entity::RenderingMode::kSubpassAppendSnapshotTransform);
}

// If the BDF save layer has no other properties, we can elide the
// subpass and apply the filter output directly to the flipped backdrop.
if (Paint::CanApplyOpacityPeephole(paint) &&
transform_stack_.back().distributed_opacity >= 1.0) {
Entity backdrop_entity;
backdrop_filter_contents->SetCoverageHint(subpass_coverage);
backdrop_entity.SetContents(std::move(backdrop_filter_contents));
backdrop_entity.SetTransform(
Matrix::MakeTranslation(-GetGlobalPassPosition()));
backdrop_entity.SetClipDepth(std::numeric_limits<uint32_t>::max());

backdrop_entity.Render(
renderer_,
*render_passes_.back().inline_pass_context->GetRenderPass(0).pass);

Save(0);
return;
}

// When applying a save layer, absorb any pending distributed opacity.
Paint paint_copy = paint;
paint_copy.color.alpha *= transform_stack_.back().distributed_opacity;
Expand Down