From 933be97cdebf60c88d0ac788173f0da3dc6e1274 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 12:50:54 -0800 Subject: [PATCH 01/18] [Impeller] implemented blur styles for non-solid colors --- impeller/aiks/aiks_blur_unittests.cc | 46 +++++++++++++++++++ impeller/aiks/paint.cc | 5 +- .../filters/gaussian_blur_filter_contents.cc | 16 +++++-- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index b808d4fa3366c..9ffc03b85cf06 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -17,6 +17,9 @@ // blurs. //////////////////////////////////////////////////////////////////////////////// +float fudgex = 0; +float fudgey = 0; + namespace impeller { namespace testing { @@ -755,6 +758,49 @@ TEST_P(AiksTest, GaussianBlurAnimatedBackdrop) { ASSERT_TRUE(OpenPlaygroundHere(callback)); } +TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { + auto callback = [&](AiksContext& renderer) -> std::optional { + + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("fudgex", &fudgex, -300, 300); + ImGui::SliderFloat("fudgey", &fudgey, -300, 300); + ImGui::End(); + } + Canvas canvas; + canvas.Scale(GetContentScale()); + + canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + + std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, + Color{0.7568, 0.2627, 0.2118, 1.0}}; + std::vector stops = {0.0, 1.0}; + + Paint paint; + paint.color_source = ColorSource::MakeLinearGradient( + {0, 0}, {200, 200}, std::move(colors), std::move(stops), + Entity::TileMode::kMirror, {}); + paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kInner, + .sigma = Sigma(30), + }; + canvas.DrawPath(PathBuilder() + .MoveTo({200, 200}) + .LineTo({300, 400}) + .LineTo({100, 400}) + .Close() + .TakePath(), + paint); + + // Draw another thing to make sure the clip area is reset. + Paint red; + red.color = Color::Red(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); + return canvas.EndRecordingAsPicture(); + }; + ASSERT_TRUE(OpenPlaygroundHere(callback)); +} + TEST_P(AiksTest, GaussianBlurStyleInner) { Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/impeller/aiks/paint.cc b/impeller/aiks/paint.cc index 94951236e6650..56c48d32d1439 100644 --- a/impeller/aiks/paint.cc +++ b/impeller/aiks/paint.cc @@ -141,7 +141,8 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( /// 2. Blur the mask. auto blurred_mask = FilterContents::MakeGaussianBlur( - FilterInput::Make(mask), sigma, sigma, Entity::TileMode::kDecal, style); + FilterInput::Make(mask), sigma, sigma, Entity::TileMode::kDecal, style, + color_source_contents->GetGeometry()); /// 3. Replace the geometry of the original color source with a rectangle that /// covers the full region of the blurred mask. Note that geometry is in @@ -167,7 +168,7 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( /// 5. Composite the color source with the blurred mask. return ColorFilterContents::MakeBlend( - BlendMode::kSourceIn, + BlendMode::kDestination, {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)}); } diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 46513f3b4bf85..8375c79b33d32 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -17,6 +17,9 @@ #include "impeller/renderer/texture_mipmap.h" #include "impeller/renderer/vertex_buffer_builder.h" +extern float fudgex; +extern float fudgey; + namespace impeller { using GaussianBlurVertexShader = KernelPipeline::VertexShader; @@ -217,18 +220,21 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, clipper->SetGeometry(geometry); auto restore = std::make_unique(); Entity result; - result.SetTransform(entity.GetTransform()); result.SetContents(Contents::MakeAnonymous( fml::MakeCopyable([shared_blur_entity, clipper = std::move(clipper), restore = std::move(restore)]( const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { bool result = true; - result = clipper->Render(renderer, entity, pass) && result; + // clipper->SetTransform(entity.GetTransform() * + // shared_blur_entity->GetTransform()); + // result = clipper->Render(renderer, entity, pass) && result; + shared_blur_entity->SetTransform(entity.GetTransform() * + shared_blur_entity->GetTransform()); result = shared_blur_entity->Render(renderer, pass) && result; - if constexpr (!ContentContext::kEnableStencilThenCover) { - result = restore->Render(renderer, entity, pass) && result; - } + // if constexpr (!ContentContext::kEnableStencilThenCover) { + // result = restore->Render(renderer, entity, pass) && result; + // } return result; }), [shared_blur_entity](const Entity& entity) { From d66bc181d08511fadfe9e14f959f55f53ff02b1f Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 13:23:01 -0800 Subject: [PATCH 02/18] got the clip lined up --- impeller/aiks/aiks_blur_unittests.cc | 1 - impeller/entity/contents/content_context.h | 2 +- .../filters/gaussian_blur_filter_contents.cc | 21 +++++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 9ffc03b85cf06..bc6430c4e75d3 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -760,7 +760,6 @@ TEST_P(AiksTest, GaussianBlurAnimatedBackdrop) { TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { auto callback = [&](AiksContext& renderer) -> std::optional { - if (AiksTest::ImGuiBegin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::SliderFloat("fudgex", &fudgex, -300, 300); diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index d38df9ae03b5a..6d4fc90298689 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -408,7 +408,7 @@ class ContentContext { /// // TODO(bdero): Remove this setting once StC is fully de-risked // https://github.com/flutter/flutter/issues/123671 - static constexpr bool kEnableStencilThenCover = true; + static constexpr bool kEnableStencilThenCover = false; #if IMPELLER_ENABLE_3D std::shared_ptr GetSceneContext() const; diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 8375c79b33d32..bc0efc0f81a5e 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -215,9 +215,12 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const std::shared_ptr& geometry) { auto shared_blur_entity = std::make_shared(std::move(blur_entity)); shared_blur_entity->SetNewClipDepth(entity.GetNewClipDepth()); - auto clipper = std::make_unique(); - clipper->SetClipOperation(clip_operation); - clipper->SetGeometry(geometry); + auto clip_contents = std::make_shared(); + clip_contents->SetClipOperation(clip_operation); + clip_contents->SetGeometry(geometry); + Entity clipper; + clipper.SetContents(clip_contents); + clipper.SetTransform(entity.GetTransform()); auto restore = std::make_unique(); Entity result; result.SetContents(Contents::MakeAnonymous( @@ -226,15 +229,15 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { bool result = true; - // clipper->SetTransform(entity.GetTransform() * - // shared_blur_entity->GetTransform()); - // result = clipper->Render(renderer, entity, pass) && result; + clipper.SetTransform(Matrix::MakeTranslation({fudgex, fudgey, 0}) * + entity.GetTransform() * clipper.GetTransform()); + result = clipper.Render(renderer, pass) && result; shared_blur_entity->SetTransform(entity.GetTransform() * shared_blur_entity->GetTransform()); result = shared_blur_entity->Render(renderer, pass) && result; - // if constexpr (!ContentContext::kEnableStencilThenCover) { - // result = restore->Render(renderer, entity, pass) && result; - // } + if constexpr (!ContentContext::kEnableStencilThenCover) { + result = restore->Render(renderer, entity, pass) && result; + } return result; }), [shared_blur_entity](const Entity& entity) { From 10386e7bc8fddc485b6448745d34486d4f0824c1 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 13:26:19 -0800 Subject: [PATCH 03/18] removed fudge --- impeller/aiks/aiks_blur_unittests.cc | 64 ++++++++----------- .../filters/gaussian_blur_filter_contents.cc | 6 +- 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index bc6430c4e75d3..90c76addb7810 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -17,9 +17,6 @@ // blurs. //////////////////////////////////////////////////////////////////////////////// -float fudgex = 0; -float fudgey = 0; - namespace impeller { namespace testing { @@ -759,45 +756,36 @@ TEST_P(AiksTest, GaussianBlurAnimatedBackdrop) { } TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { - auto callback = [&](AiksContext& renderer) -> std::optional { - if (AiksTest::ImGuiBegin("Controls", nullptr, - ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::SliderFloat("fudgex", &fudgex, -300, 300); - ImGui::SliderFloat("fudgey", &fudgey, -300, 300); - ImGui::End(); - } - Canvas canvas; - canvas.Scale(GetContentScale()); + Canvas canvas; + canvas.Scale(GetContentScale()); - canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); - std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, - Color{0.7568, 0.2627, 0.2118, 1.0}}; - std::vector stops = {0.0, 1.0}; + std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, + Color{0.7568, 0.2627, 0.2118, 1.0}}; + std::vector stops = {0.0, 1.0}; - Paint paint; - paint.color_source = ColorSource::MakeLinearGradient( - {0, 0}, {200, 200}, std::move(colors), std::move(stops), - Entity::TileMode::kMirror, {}); - paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ - .style = FilterContents::BlurStyle::kInner, - .sigma = Sigma(30), - }; - canvas.DrawPath(PathBuilder() - .MoveTo({200, 200}) - .LineTo({300, 400}) - .LineTo({100, 400}) - .Close() - .TakePath(), - paint); - - // Draw another thing to make sure the clip area is reset. - Paint red; - red.color = Color::Red(); - canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); - return canvas.EndRecordingAsPicture(); + Paint paint; + paint.color_source = ColorSource::MakeLinearGradient( + {0, 0}, {200, 200}, std::move(colors), std::move(stops), + Entity::TileMode::kMirror, {}); + paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kInner, + .sigma = Sigma(30), }; - ASSERT_TRUE(OpenPlaygroundHere(callback)); + canvas.DrawPath(PathBuilder() + .MoveTo({200, 200}) + .LineTo({300, 400}) + .LineTo({100, 400}) + .Close() + .TakePath(), + paint); + + // Draw another thing to make sure the clip area is reset. + Paint red; + red.color = Color::Red(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } TEST_P(AiksTest, GaussianBlurStyleInner) { diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index bc0efc0f81a5e..30e37fd6204ba 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -17,9 +17,6 @@ #include "impeller/renderer/texture_mipmap.h" #include "impeller/renderer/vertex_buffer_builder.h" -extern float fudgex; -extern float fudgey; - namespace impeller { using GaussianBlurVertexShader = KernelPipeline::VertexShader; @@ -229,8 +226,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { bool result = true; - clipper.SetTransform(Matrix::MakeTranslation({fudgex, fudgey, 0}) * - entity.GetTransform() * clipper.GetTransform()); + clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); result = clipper.Render(renderer, pass) && result; shared_blur_entity->SetTransform(entity.GetTransform() * shared_blur_entity->GetTransform()); From 974c3daffa0a1de9f0c488f3e4f7f7a65856a668 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 13:27:05 -0800 Subject: [PATCH 04/18] fixed blend --- impeller/aiks/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/aiks/paint.cc b/impeller/aiks/paint.cc index 56c48d32d1439..2b94184eaa2e8 100644 --- a/impeller/aiks/paint.cc +++ b/impeller/aiks/paint.cc @@ -168,7 +168,7 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( /// 5. Composite the color source with the blurred mask. return ColorFilterContents::MakeBlend( - BlendMode::kDestination, + BlendMode::kSourceIn, {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)}); } From 57c825189160ebb137b33493d328251b65e2bf59 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 13:37:51 -0800 Subject: [PATCH 05/18] stopped sharing the blur_entity since it is being modified --- .../filters/gaussian_blur_filter_contents.cc | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 30e37fd6204ba..eab1356af6d88 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -210,8 +210,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const Snapshot& input_snapshot, Entity blur_entity, const std::shared_ptr& geometry) { - auto shared_blur_entity = std::make_shared(std::move(blur_entity)); - shared_blur_entity->SetNewClipDepth(entity.GetNewClipDepth()); + blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); auto clip_contents = std::make_shared(); clip_contents->SetClipOperation(clip_operation); clip_contents->SetGeometry(geometry); @@ -221,24 +220,28 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, auto restore = std::make_unique(); Entity result; result.SetContents(Contents::MakeAnonymous( - fml::MakeCopyable([shared_blur_entity, clipper = std::move(clipper), + fml::MakeCopyable([blur_entity = blur_entity.Clone(), + clipper = std::move(clipper), restore = std::move(restore)]( const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { bool result = true; clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); result = clipper.Render(renderer, pass) && result; - shared_blur_entity->SetTransform(entity.GetTransform() * - shared_blur_entity->GetTransform()); - result = shared_blur_entity->Render(renderer, pass) && result; + blur_entity.SetTransform(entity.GetTransform() * + blur_entity.GetTransform()); + result = blur_entity.Render(renderer, pass) && result; if constexpr (!ContentContext::kEnableStencilThenCover) { result = restore->Render(renderer, entity, pass) && result; } return result; }), - [shared_blur_entity](const Entity& entity) { - return shared_blur_entity->GetCoverage(); - })); + fml::MakeCopyable( + [blur_entity = std::move(blur_entity)](const Entity& entity) mutable { + blur_entity.SetTransform(entity.GetTransform() * + blur_entity.GetTransform()); + return blur_entity.GetCoverage(); + }))); return result; } From f6ac48b5ed08e806e6f1456cc1ba1a306dfc891e Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 17:33:42 -0800 Subject: [PATCH 06/18] moved clipdepth and turn stc back on --- impeller/entity/contents/content_context.h | 2 +- .../entity/contents/filters/gaussian_blur_filter_contents.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 6d4fc90298689..d38df9ae03b5a 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -408,7 +408,7 @@ class ContentContext { /// // TODO(bdero): Remove this setting once StC is fully de-risked // https://github.com/flutter/flutter/issues/123671 - static constexpr bool kEnableStencilThenCover = false; + static constexpr bool kEnableStencilThenCover = true; #if IMPELLER_ENABLE_3D std::shared_ptr GetSceneContext() const; diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index eab1356af6d88..f7c05a6e14736 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -210,7 +210,6 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const Snapshot& input_snapshot, Entity blur_entity, const std::shared_ptr& geometry) { - blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); auto clip_contents = std::make_shared(); clip_contents->SetClipOperation(clip_operation); clip_contents->SetGeometry(geometry); @@ -228,6 +227,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, bool result = true; clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); result = clipper.Render(renderer, pass) && result; + blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); blur_entity.SetTransform(entity.GetTransform() * blur_entity.GetTransform()); result = blur_entity.Render(renderer, pass) && result; From a6b0394c8b29b91da10a8633b8c4bd0d3da99e48 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 17:37:35 -0800 Subject: [PATCH 07/18] added test for outer --- impeller/aiks/aiks_blur_unittests.cc | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 90c76addb7810..9afb0ae00305e 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -788,6 +788,39 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, GaussianBlurStyleOuterGradient) { + Canvas canvas; + canvas.Scale(GetContentScale()); + + canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + + std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, + Color{0.7568, 0.2627, 0.2118, 1.0}}; + std::vector stops = {0.0, 1.0}; + + Paint paint; + paint.color_source = ColorSource::MakeLinearGradient( + {0, 0}, {200, 200}, std::move(colors), std::move(stops), + Entity::TileMode::kMirror, {}); + paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kOuter, + .sigma = Sigma(30), + }; + canvas.DrawPath(PathBuilder() + .MoveTo({200, 200}) + .LineTo({300, 400}) + .LineTo({100, 400}) + .Close() + .TakePath(), + paint); + + // Draw another thing to make sure the clip area is reset. + Paint red; + red.color = Color::Red(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + TEST_P(AiksTest, GaussianBlurStyleInner) { Canvas canvas; canvas.Scale(GetContentScale()); From b0c9cc7bb162ab71929f596ea046c2e55f1cab3c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 7 Mar 2024 17:43:45 -0800 Subject: [PATCH 08/18] turned stc back off --- impeller/entity/contents/content_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index d38df9ae03b5a..6d4fc90298689 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -408,7 +408,7 @@ class ContentContext { /// // TODO(bdero): Remove this setting once StC is fully de-risked // https://github.com/flutter/flutter/issues/123671 - static constexpr bool kEnableStencilThenCover = true; + static constexpr bool kEnableStencilThenCover = false; #if IMPELLER_ENABLE_3D std::shared_ptr GetSceneContext() const; From 40a3aa482ed6f8d5327ec9f2193058bf6ad11a94 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 8 Mar 2024 10:18:44 -0800 Subject: [PATCH 09/18] got rid of use after move with explicit ordering --- .../filters/gaussian_blur_filter_contents.cc | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index f7c05a6e14736..9334f980d33fb 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -218,12 +218,11 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, clipper.SetTransform(entity.GetTransform()); auto restore = std::make_unique(); Entity result; - result.SetContents(Contents::MakeAnonymous( - fml::MakeCopyable([blur_entity = blur_entity.Clone(), - clipper = std::move(clipper), - restore = std::move(restore)]( - const ContentContext& renderer, - const Entity& entity, RenderPass& pass) mutable { + auto renderer = fml::MakeCopyable( + [blur_entity = blur_entity.Clone(), clipper = std::move(clipper), + restore = std::move(restore)](const ContentContext& renderer, + const Entity& entity, + RenderPass& pass) mutable { bool result = true; clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); result = clipper.Render(renderer, pass) && result; @@ -235,13 +234,14 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, result = restore->Render(renderer, entity, pass) && result; } return result; - }), - fml::MakeCopyable( - [blur_entity = std::move(blur_entity)](const Entity& entity) mutable { - blur_entity.SetTransform(entity.GetTransform() * - blur_entity.GetTransform()); - return blur_entity.GetCoverage(); - }))); + }); + auto coverage = fml::MakeCopyable( + [blur_entity = std::move(blur_entity)](const Entity& entity) mutable { + blur_entity.SetTransform(entity.GetTransform() * + blur_entity.GetTransform()); + return blur_entity.GetCoverage(); + }); + result.SetContents(Contents::MakeAnonymous(renderer, coverage)); return result; } From aa91d6c7f7ccd6ac4fa1c23b2d46ffdb7b9aed1d Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 8 Mar 2024 10:47:22 -0800 Subject: [PATCH 10/18] fixed inner and outer with stencil --- .../entity/contents/filters/gaussian_blur_filter_contents.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 9334f980d33fb..7aa1cdc7bccff 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -224,6 +224,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, const Entity& entity, RenderPass& pass) mutable { bool result = true; + clipper.SetNewClipDepth(entity.GetNewClipDepth()); clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); result = clipper.Render(renderer, pass) && result; blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); From 8a6078516856a00de6784762745529ae8efbd351 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 8 Mar 2024 11:54:09 -0800 Subject: [PATCH 11/18] got stencil then cover working and turned back on *sigh* --- impeller/entity/contents/content_context.h | 2 +- .../contents/filters/gaussian_blur_filter_contents.cc | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 6d4fc90298689..d38df9ae03b5a 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -408,7 +408,7 @@ class ContentContext { /// // TODO(bdero): Remove this setting once StC is fully de-risked // https://github.com/flutter/flutter/issues/123671 - static constexpr bool kEnableStencilThenCover = false; + static constexpr bool kEnableStencilThenCover = true; #if IMPELLER_ENABLE_3D std::shared_ptr GetSceneContext() const; diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 7aa1cdc7bccff..6860f8955a843 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -265,7 +265,7 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, input, input_snapshot, std::move(blur_entity), geometry); case FilterContents::BlurStyle::kSolid: { - Entity blurred = ApplyClippedBlurStyle(Entity::ClipOperation::kIntersect, + Entity blurred = ApplyClippedBlurStyle(Entity::ClipOperation::kDifference, entity, input, input_snapshot, std::move(blur_entity), geometry); Entity snapshot_entity = Entity::FromSnapshot( @@ -278,8 +278,11 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { - return blurred.Render(renderer, pass) && - snapshot_entity.Render(renderer, pass); + bool result = true; + result = result && blurred.Render(renderer, pass); + snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); + result = result && snapshot_entity.Render(renderer, pass); + return result; }), fml::MakeCopyable( [coverage](const Entity& entity) { return coverage; }))); From b4c0e22c5af65db676b04f1a6ea2396763677310 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 8 Mar 2024 15:43:03 -0800 Subject: [PATCH 12/18] made the closures idempotent --- .../filters/gaussian_blur_filter_contents.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 6860f8955a843..9c26cef6d0d9c 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -215,33 +215,33 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, clip_contents->SetGeometry(geometry); Entity clipper; clipper.SetContents(clip_contents); - clipper.SetTransform(entity.GetTransform()); auto restore = std::make_unique(); - Entity result; + Matrix entity_transform = entity.GetTransform(); + Matrix blur_transform = blur_entity.GetTransform(); auto renderer = fml::MakeCopyable( [blur_entity = blur_entity.Clone(), clipper = std::move(clipper), - restore = std::move(restore)](const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) mutable { + restore = std::move(restore), entity_transform, + blur_transform](const ContentContext& renderer, const Entity& entity, + RenderPass& pass) mutable { bool result = true; clipper.SetNewClipDepth(entity.GetNewClipDepth()); - clipper.SetTransform(entity.GetTransform() * clipper.GetTransform()); + clipper.SetTransform(entity.GetTransform() * entity_transform); result = clipper.Render(renderer, pass) && result; blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); - blur_entity.SetTransform(entity.GetTransform() * - blur_entity.GetTransform()); + blur_entity.SetTransform(entity.GetTransform() * blur_transform); result = blur_entity.Render(renderer, pass) && result; if constexpr (!ContentContext::kEnableStencilThenCover) { result = restore->Render(renderer, entity, pass) && result; } return result; }); - auto coverage = fml::MakeCopyable( - [blur_entity = std::move(blur_entity)](const Entity& entity) mutable { - blur_entity.SetTransform(entity.GetTransform() * - blur_entity.GetTransform()); + auto coverage = + fml::MakeCopyable([blur_entity = std::move(blur_entity), + blur_transform](const Entity& entity) mutable { + blur_entity.SetTransform(entity.GetTransform() * blur_transform); return blur_entity.GetCoverage(); }); + Entity result; result.SetContents(Contents::MakeAnonymous(renderer, coverage)); return result; } From 740cf64c06774cf985b08d0ea81bbd516dab9abf Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 8 Mar 2024 16:09:52 -0800 Subject: [PATCH 13/18] added a solid case for a gradient, doesn't work with stc --- impeller/aiks/aiks_blur_unittests.cc | 34 +++++++++++++++++++ .../filters/gaussian_blur_filter_contents.cc | 33 +++++++++++------- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 9afb0ae00305e..af621c8947ba3 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -788,6 +788,40 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +/// TODO(gaaclarke): This still doesn't work with stencil and cover. +// TEST_P(AiksTest, GaussianBlurStyleSolidGradient) { +// Canvas canvas; +// canvas.Scale(GetContentScale()); + +// canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + +// std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, +// Color{0.7568, 0.2627, 0.2118, 1.0}}; +// std::vector stops = {0.0, 1.0}; + +// Paint paint; +// paint.color_source = ColorSource::MakeLinearGradient( +// {0, 0}, {200, 200}, std::move(colors), std::move(stops), +// Entity::TileMode::kMirror, {}); +// paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ +// .style = FilterContents::BlurStyle::kSolid, +// .sigma = Sigma(30), +// }; +// canvas.DrawPath(PathBuilder() +// .MoveTo({200, 200}) +// .LineTo({300, 400}) +// .LineTo({100, 400}) +// .Close() +// .TakePath(), +// paint); + +// // Draw another thing to make sure the clip area is reset. +// Paint red; +// red.color = Color::Red(); +// canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); +// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +// } + TEST_P(AiksTest, GaussianBlurStyleOuterGradient) { Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 9c26cef6d0d9c..976ac8dff5fcd 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -271,21 +271,28 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, Entity snapshot_entity = Entity::FromSnapshot( input_snapshot, entity.GetBlendMode(), entity.GetClipDepth()); Entity result; - std::optional coverage = blurred.GetCoverage(); + Matrix blurred_transform = blurred.GetTransform(); + Matrix snapshot_transform = snapshot_entity.GetTransform(); result.SetContents(Contents::MakeAnonymous( - fml::MakeCopyable([blurred = std::move(blurred), - snapshot_entity = std::move(snapshot_entity)]( - const ContentContext& renderer, - const Entity& entity, - RenderPass& pass) mutable { - bool result = true; - result = result && blurred.Render(renderer, pass); - snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); - result = result && snapshot_entity.Render(renderer, pass); - return result; - }), fml::MakeCopyable( - [coverage](const Entity& entity) { return coverage; }))); + [blurred = blurred.Clone(), blurred_transform, snapshot_transform, + snapshot_entity = std::move(snapshot_entity)]( + const ContentContext& renderer, const Entity& entity, + RenderPass& pass) mutable { + bool result = true; + blurred.SetTransform(entity.GetTransform() * blurred_transform); + result = result && blurred.Render(renderer, pass); + snapshot_entity.SetTransform(entity.GetTransform() * + snapshot_transform); + snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); + result = result && snapshot_entity.Render(renderer, pass); + return result; + }), + fml::MakeCopyable([blurred = blurred.Clone(), + blurred_transform](const Entity& entity) mutable { + blurred.SetTransform(entity.GetTransform() * blurred_transform); + return blurred.GetCoverage(); + }))); return result; } } From 288e944f4d1da90a87de3550fe8d7df95149d244 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 11 Mar 2024 09:41:44 -0700 Subject: [PATCH 14/18] got solid working for gradients --- impeller/aiks/aiks_blur_unittests.cc | 64 +++++++++---------- .../filters/gaussian_blur_filter_contents.cc | 4 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index af621c8947ba3..f4bd341c0fb10 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -789,38 +789,38 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { } /// TODO(gaaclarke): This still doesn't work with stencil and cover. -// TEST_P(AiksTest, GaussianBlurStyleSolidGradient) { -// Canvas canvas; -// canvas.Scale(GetContentScale()); - -// canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); - -// std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, -// Color{0.7568, 0.2627, 0.2118, 1.0}}; -// std::vector stops = {0.0, 1.0}; - -// Paint paint; -// paint.color_source = ColorSource::MakeLinearGradient( -// {0, 0}, {200, 200}, std::move(colors), std::move(stops), -// Entity::TileMode::kMirror, {}); -// paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ -// .style = FilterContents::BlurStyle::kSolid, -// .sigma = Sigma(30), -// }; -// canvas.DrawPath(PathBuilder() -// .MoveTo({200, 200}) -// .LineTo({300, 400}) -// .LineTo({100, 400}) -// .Close() -// .TakePath(), -// paint); - -// // Draw another thing to make sure the clip area is reset. -// Paint red; -// red.color = Color::Red(); -// canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); -// ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); -// } +TEST_P(AiksTest, GaussianBlurStyleSolidGradient) { + Canvas canvas; + canvas.Scale(GetContentScale()); + + canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)}); + + std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, + Color{0.7568, 0.2627, 0.2118, 1.0}}; + std::vector stops = {0.0, 1.0}; + + Paint paint; + paint.color_source = ColorSource::MakeLinearGradient( + {0, 0}, {200, 200}, std::move(colors), std::move(stops), + Entity::TileMode::kMirror, {}); + paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kSolid, + .sigma = Sigma(30), + }; + canvas.DrawPath(PathBuilder() + .MoveTo({200, 200}) + .LineTo({300, 400}) + .LineTo({100, 400}) + .Close() + .TakePath(), + paint); + + // Draw another thing to make sure the clip area is reset. + Paint red; + red.color = Color::Red(); + canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red); + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} TEST_P(AiksTest, GaussianBlurStyleOuterGradient) { Canvas canvas; diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 976ac8dff5fcd..b6a742397225f 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -280,12 +280,12 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, const ContentContext& renderer, const Entity& entity, RenderPass& pass) mutable { bool result = true; - blurred.SetTransform(entity.GetTransform() * blurred_transform); - result = result && blurred.Render(renderer, pass); snapshot_entity.SetTransform(entity.GetTransform() * snapshot_transform); snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); result = result && snapshot_entity.Render(renderer, pass); + blurred.SetTransform(entity.GetTransform() * blurred_transform); + result = result && blurred.Render(renderer, pass); return result; }), fml::MakeCopyable([blurred = blurred.Clone(), From 8921f0d78eaa5e3b825a2ac93281d040e1c4debc Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 11 Mar 2024 09:44:24 -0700 Subject: [PATCH 15/18] cleaned up clip depth a bit --- .../entity/contents/filters/gaussian_blur_filter_contents.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index b6a742397225f..2c177141c75b3 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -227,7 +227,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, clipper.SetNewClipDepth(entity.GetNewClipDepth()); clipper.SetTransform(entity.GetTransform() * entity_transform); result = clipper.Render(renderer, pass) && result; - blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); + blur_entity.SetClipDepth(clipper.GetClipDepth()); blur_entity.SetTransform(entity.GetTransform() * blur_transform); result = blur_entity.Render(renderer, pass) && result; if constexpr (!ContentContext::kEnableStencilThenCover) { @@ -284,6 +284,7 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, snapshot_transform); snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); result = result && snapshot_entity.Render(renderer, pass); + blurred.SetClipDepth(snapshot_entity.GetClipDepth()); blurred.SetTransform(entity.GetTransform() * blurred_transform); result = result && blurred.Render(renderer, pass); return result; From 391d9673c5386e55e7d085a587512880c817888c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 11 Mar 2024 09:57:15 -0700 Subject: [PATCH 16/18] updated golden --- testing/impeller_golden_tests_output.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/testing/impeller_golden_tests_output.txt b/testing/impeller_golden_tests_output.txt index 0a6c28e5bb62d..436aabb89f9bc 100644 --- a/testing/impeller_golden_tests_output.txt +++ b/testing/impeller_golden_tests_output.txt @@ -488,12 +488,21 @@ impeller_Play_AiksTest_GaussianBlurRotatedAndClipped_Vulkan.png impeller_Play_AiksTest_GaussianBlurScaledAndClipped_Metal.png impeller_Play_AiksTest_GaussianBlurScaledAndClipped_OpenGLES.png impeller_Play_AiksTest_GaussianBlurScaledAndClipped_Vulkan.png +impeller_Play_AiksTest_GaussianBlurStyleInnerGradient_Metal.png +impeller_Play_AiksTest_GaussianBlurStyleInnerGradient_OpenGLES.png +impeller_Play_AiksTest_GaussianBlurStyleInnerGradient_Vulkan.png impeller_Play_AiksTest_GaussianBlurStyleInner_Metal.png impeller_Play_AiksTest_GaussianBlurStyleInner_OpenGLES.png impeller_Play_AiksTest_GaussianBlurStyleInner_Vulkan.png +impeller_Play_AiksTest_GaussianBlurStyleOuterGradient_Metal.png +impeller_Play_AiksTest_GaussianBlurStyleOuterGradient_OpenGLES.png +impeller_Play_AiksTest_GaussianBlurStyleOuterGradient_Vulkan.png impeller_Play_AiksTest_GaussianBlurStyleOuter_Metal.png impeller_Play_AiksTest_GaussianBlurStyleOuter_OpenGLES.png impeller_Play_AiksTest_GaussianBlurStyleOuter_Vulkan.png +impeller_Play_AiksTest_GaussianBlurStyleSolidGradient_Metal.png +impeller_Play_AiksTest_GaussianBlurStyleSolidGradient_OpenGLES.png +impeller_Play_AiksTest_GaussianBlurStyleSolidGradient_Vulkan.png impeller_Play_AiksTest_GaussianBlurStyleSolid_Metal.png impeller_Play_AiksTest_GaussianBlurStyleSolid_OpenGLES.png impeller_Play_AiksTest_GaussianBlurStyleSolid_Vulkan.png From 25b61b996f910bc35a7a78cac604df228f5267ff Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 11 Mar 2024 10:32:33 -0700 Subject: [PATCH 17/18] removed old todo --- impeller/aiks/aiks_blur_unittests.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 7fa3ac6c22160..9ade5689524c9 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -788,7 +788,6 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -/// TODO(gaaclarke): This still doesn't work with stencil and cover. TEST_P(AiksTest, GaussianBlurStyleSolidGradient) { Canvas canvas; canvas.Scale(GetContentScale()); From eccb6529af0dab1f05a94d0829e14c4465d539ad Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Mon, 11 Mar 2024 15:24:16 -0700 Subject: [PATCH 18/18] started just drawing the original over the blur for solid --- .../filters/gaussian_blur_filter_contents.cc | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 2c177141c75b3..c116b3d517cdc 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -227,7 +227,7 @@ Entity ApplyClippedBlurStyle(Entity::ClipOperation clip_operation, clipper.SetNewClipDepth(entity.GetNewClipDepth()); clipper.SetTransform(entity.GetTransform() * entity_transform); result = clipper.Render(renderer, pass) && result; - blur_entity.SetClipDepth(clipper.GetClipDepth()); + blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); blur_entity.SetTransform(entity.GetTransform() * blur_transform); result = blur_entity.Render(renderer, pass) && result; if constexpr (!ContentContext::kEnableStencilThenCover) { @@ -265,34 +265,32 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style, input, input_snapshot, std::move(blur_entity), geometry); case FilterContents::BlurStyle::kSolid: { - Entity blurred = ApplyClippedBlurStyle(Entity::ClipOperation::kDifference, - entity, input, input_snapshot, - std::move(blur_entity), geometry); Entity snapshot_entity = Entity::FromSnapshot( input_snapshot, entity.GetBlendMode(), entity.GetClipDepth()); Entity result; - Matrix blurred_transform = blurred.GetTransform(); + Matrix blurred_transform = blur_entity.GetTransform(); Matrix snapshot_transform = snapshot_entity.GetTransform(); result.SetContents(Contents::MakeAnonymous( - fml::MakeCopyable( - [blurred = blurred.Clone(), blurred_transform, snapshot_transform, - snapshot_entity = std::move(snapshot_entity)]( - const ContentContext& renderer, const Entity& entity, - RenderPass& pass) mutable { - bool result = true; - snapshot_entity.SetTransform(entity.GetTransform() * - snapshot_transform); - snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); - result = result && snapshot_entity.Render(renderer, pass); - blurred.SetClipDepth(snapshot_entity.GetClipDepth()); - blurred.SetTransform(entity.GetTransform() * blurred_transform); - result = result && blurred.Render(renderer, pass); - return result; - }), - fml::MakeCopyable([blurred = blurred.Clone(), + fml::MakeCopyable([blur_entity = blur_entity.Clone(), + blurred_transform, snapshot_transform, + snapshot_entity = std::move(snapshot_entity)]( + const ContentContext& renderer, + const Entity& entity, + RenderPass& pass) mutable { + bool result = true; + blur_entity.SetNewClipDepth(entity.GetNewClipDepth()); + blur_entity.SetTransform(entity.GetTransform() * blurred_transform); + result = result && blur_entity.Render(renderer, pass); + snapshot_entity.SetTransform(entity.GetTransform() * + snapshot_transform); + snapshot_entity.SetNewClipDepth(entity.GetNewClipDepth()); + result = result && snapshot_entity.Render(renderer, pass); + return result; + }), + fml::MakeCopyable([blur_entity = blur_entity.Clone(), blurred_transform](const Entity& entity) mutable { - blurred.SetTransform(entity.GetTransform() * blurred_transform); - return blurred.GetCoverage(); + blur_entity.SetTransform(entity.GetTransform() * blurred_transform); + return blur_entity.GetCoverage(); }))); return result; }