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 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
32 changes: 32 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,38 @@ TEST_P(AiksTest, DrawPictureWithText) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, MatrixSaveLayerFilter) {
Canvas canvas;
canvas.DrawPaint({.color = Color::Black()});
canvas.SaveLayer({}, std::nullopt);
{
canvas.DrawCircle(Point(200, 200), 100,
{.color = Color::Green().WithAlpha(0.5),
.blend_mode = BlendMode::kPlus});
// Should render a second circle, centered on the bottom-right-most edge of
// the circle.
canvas.SaveLayer({.image_filter =
[](const FilterInput::Ref& input,
const Matrix& effect_transform, bool is_subpass) {
Matrix matrix =
Matrix::MakeTranslation(
Vector2(1, 1) * (100 + 100 * k1OverSqrt2)) *
Matrix::MakeScale(Vector2(1, 1) * 0.2) *
Matrix::MakeTranslation(Vector2(-100, -100));
return FilterContents::MakeMatrixFilter(
input, matrix, {}, Matrix(), true);
}},
std::nullopt);
canvas.DrawCircle(Point(200, 200), 100,
{.color = Color::Green().WithAlpha(0.5),
.blend_mode = BlendMode::kPlus});
canvas.Restore();
}
canvas.Restore();

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, MatrixBackdropFilter) {
Canvas canvas;
canvas.DrawPaint({.color = Color::Black()});
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/filters/matrix_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ std::optional<Entity> MatrixFilterContents::RenderFilter(
// mentioned above). And so we sneak the subpass's captured CTM in through the
// effect transform.

auto transform = is_subpass_ ? effect_transform.Basis()
: entity.GetTransformation().Basis();
auto transform = is_subpass_ ? effect_transform : entity.GetTransformation();
snapshot->transform = transform * //
matrix_ * //
transform.Invert() * //
Expand Down
6 changes: 3 additions & 3 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
auto texture = pass_context.GetTexture();
// Render the backdrop texture before any of the pass elements.
const auto& proc = subpass->backdrop_filter_proc_;
subpass_backdrop_filter_contents =
proc(FilterInput::Make(std::move(texture)), subpass->xformation_,
/*is_subpass*/ true);
subpass_backdrop_filter_contents = proc(
FilterInput::Make(std::move(texture)), subpass->xformation_.Basis(),
/*is_subpass*/ true);

// The subpass will need to read from the current pass texture when
// rendering the backdrop, so if there's an active pass, end it prior to
Expand Down