diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 9ade5689524c9..09e6e188a8801 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -1146,5 +1146,40 @@ TEST_P(AiksTest, GaussianBlurMipMapSolidColor) { #endif } +TEST_P(AiksTest, MaskBlurDoesntStretchContents) { + Scalar sigma = 70; + auto callback = [&](AiksContext& renderer) -> std::optional { + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("Sigma", &sigma, 0, 500); + ImGui::End(); + } + Canvas canvas; + canvas.Scale(GetContentScale()); + canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + + std::shared_ptr boston = CreateTextureForFixture("boston.jpg"); + ColorSource image_source = ColorSource::MakeImage( + boston, Entity::TileMode::kRepeat, Entity::TileMode::kRepeat, {}, {}); + + canvas.Transform(Matrix::MakeTranslation({100, 100, 0}) * + Matrix::MakeScale({0.5, 0.5, 1.0})); + Paint paint = { + .color_source = image_source, + .mask_blur_descriptor = + Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kNormal, + .sigma = Sigma(sigma), + }, + }; + canvas.DrawRect( + Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height), + paint); + + return canvas.EndRecordingAsPicture(); + }; + ASSERT_TRUE(OpenPlaygroundHere(callback)); +} + } // namespace testing } // namespace impeller diff --git a/impeller/aiks/paint.cc b/impeller/aiks/paint.cc index dc2c3e9be2807..1efb587601e0d 100644 --- a/impeller/aiks/paint.cc +++ b/impeller/aiks/paint.cc @@ -183,7 +183,6 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( } color_source_contents->SetGeometry( Geometry::MakeRect(*expanded_local_bounds)); - std::shared_ptr color_contents = color_source_contents; /// 4. Apply the user set color filter on the GPU, if applicable. diff --git a/impeller/entity/contents/tiled_texture_contents.cc b/impeller/entity/contents/tiled_texture_contents.cc index 0862345f6e1d1..b8baa2fef8f92 100644 --- a/impeller/entity/contents/tiled_texture_contents.cc +++ b/impeller/entity/contents/tiled_texture_contents.cc @@ -228,8 +228,12 @@ std::optional TiledTextureContents::RenderToSnapshot( bool msaa_enabled, int32_t mip_count, const std::string& label) const { + std::optional geometry_coverage = GetGeometry()->GetCoverage({}); if (GetInverseEffectTransform().IsIdentity() && - GetGeometry()->IsAxisAlignedRect()) { + GetGeometry()->IsAxisAlignedRect() && + (!geometry_coverage.has_value() || + Rect::MakeSize(texture_->GetSize()) + .Contains(geometry_coverage.value()))) { auto coverage = GetCoverage(entity); if (!coverage.has_value()) { return std::nullopt; diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index f48cecd4b7be6..eff1ce0049639 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -525,6 +525,9 @@ impeller_Play_AiksTest_ImageFilteredUnboundedSaveLayerWithUnboundedContents_Vulk impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_Metal.png impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_OpenGLES.png impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_Vulkan.png +impeller_Play_AiksTest_MaskBlurDoesntStretchContents_Metal.png +impeller_Play_AiksTest_MaskBlurDoesntStretchContents_OpenGLES.png +impeller_Play_AiksTest_MaskBlurDoesntStretchContents_Vulkan.png impeller_Play_AiksTest_MaskBlurTexture_Metal.png impeller_Play_AiksTest_MaskBlurTexture_OpenGLES.png impeller_Play_AiksTest_MaskBlurTexture_Vulkan.png