diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 3888f3b62c1f2..0b061b28fe38b 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -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()}); diff --git a/impeller/entity/contents/filters/matrix_filter_contents.cc b/impeller/entity/contents/filters/matrix_filter_contents.cc index 81d1b51beaec9..55bc05f28a099 100644 --- a/impeller/entity/contents/filters/matrix_filter_contents.cc +++ b/impeller/entity/contents/filters/matrix_filter_contents.cc @@ -49,8 +49,7 @@ std::optional 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() * // diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index e28ec3294a868..ee4d0c9c05198 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -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