From 76873af763a186c73a98d9d14ddd41258444fd8d Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 13 Mar 2024 15:09:44 -0700 Subject: [PATCH 1/3] [Impeller] make sure to render TiledTextureContents if the geometry doesn't fit in the texture's bounds. --- impeller/aiks/aiks_blur_unittests.cc | 35 +++++++++++++++++++ impeller/aiks/paint.cc | 1 - .../entity/contents/tiled_texture_contents.cc | 6 +++- 3 files changed, 40 insertions(+), 2 deletions(-) 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; From ae032116d2d27cfd3a2d627d3e2dfbe027286436 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 13 Mar 2024 15:36:01 -0700 Subject: [PATCH 2/3] updated golden --- testing/impeller_golden_tests_output.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index f48cecd4b7be6..363140c66cbb1 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 From 47f185f0b37a92a3a29716447e21e60511e2b100 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 15 Mar 2024 17:20:49 -0700 Subject: [PATCH 3/3] golden typo --- testing/impeller_golden_tests_output.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index 363140c66cbb1..eff1ce0049639 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -525,9 +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_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