From 702c6cec660fd5bd6e9ccf1b1edd965613676c05 Mon Sep 17 00:00:00 2001 From: Jim Graham Date: Tue, 2 Jul 2024 13:44:16 -0700 Subject: [PATCH] [Impeller] fix typo in setup for fast elliptical rrect blurs (flutter/engine#53673) This typo was discovered while converting the AIKS tests to DisplayList - the new test executes correctly, but the old test generated bad goldens due to this typo. Fixing the typo to fix the golden prior to landing the test conversion. The fix should be covered by existing tests - in fact the change is correcting an already bad golden test to correct behavior. --- .../flutter/impeller/aiks/aiks_unittests.cc | 26 +++++++++++++++++++ .../contents/solid_rrect_blur_contents.cc | 2 +- .../testing/impeller_golden_tests_output.txt | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/impeller/aiks/aiks_unittests.cc b/engine/src/flutter/impeller/aiks/aiks_unittests.cc index 1525d9f908..cdf59f42a5 100644 --- a/engine/src/flutter/impeller/aiks/aiks_unittests.cc +++ b/engine/src/flutter/impeller/aiks/aiks_unittests.cc @@ -1246,6 +1246,32 @@ TEST_P(AiksTest, SolidColorCirclesOvalsRRectsMaskBlurCorrectly) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, FastEllipticalRRectMaskBlursRenderCorrectly) { + Canvas canvas; + canvas.Scale(GetContentScale()); + Paint paint; + paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{ + .style = FilterContents::BlurStyle::kNormal, + .sigma = Sigma{1}, + }; + + canvas.DrawPaint({.color = Color::White()}); + + paint.color = Color::Blue(); + for (int i = 0; i < 5; i++) { + Scalar y = i * 125; + Scalar y_radius = i * 15; + for (int j = 0; j < 5; j++) { + Scalar x = j * 125; + Scalar x_radius = j * 15; + canvas.DrawRRect(Rect::MakeXYWH(x + 50, y + 50, 100.0f, 100.0f), + {x_radius, y_radius}, paint); + } + } + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + TEST_P(AiksTest, FilledRoundRectPathsRenderCorrectly) { Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/engine/src/flutter/impeller/entity/contents/solid_rrect_blur_contents.cc b/engine/src/flutter/impeller/entity/contents/solid_rrect_blur_contents.cc index b6bdffd2b7..4f62435a02 100644 --- a/engine/src/flutter/impeller/entity/contents/solid_rrect_blur_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/solid_rrect_blur_contents.cc @@ -113,7 +113,7 @@ bool SolidRRectBlurContents::Render(const ContentContext& renderer, frag_info.rect_size = Point(positive_rect.GetSize()); frag_info.corner_radii = {std::clamp(corner_radii_.width, kEhCloseEnough, positive_rect.GetWidth() * 0.5f), - std::clamp(corner_radii_.width, kEhCloseEnough, + std::clamp(corner_radii_.height, kEhCloseEnough, positive_rect.GetHeight() * 0.5f)}; pass.SetCommandLabel("RRect Shadow"); diff --git a/engine/src/flutter/testing/impeller_golden_tests_output.txt b/engine/src/flutter/testing/impeller_golden_tests_output.txt index affa64d1f9..6a25f99892 100644 --- a/engine/src/flutter/testing/impeller_golden_tests_output.txt +++ b/engine/src/flutter/testing/impeller_golden_tests_output.txt @@ -596,6 +596,9 @@ impeller_Play_AiksTest_EmptySaveLayerIgnoresPaint_Vulkan.png impeller_Play_AiksTest_EmptySaveLayerRendersWithClear_Metal.png impeller_Play_AiksTest_EmptySaveLayerRendersWithClear_OpenGLES.png impeller_Play_AiksTest_EmptySaveLayerRendersWithClear_Vulkan.png +impeller_Play_AiksTest_FastEllipticalRRectMaskBlursRenderCorrectly_Metal.png +impeller_Play_AiksTest_FastEllipticalRRectMaskBlursRenderCorrectly_OpenGLES.png +impeller_Play_AiksTest_FastEllipticalRRectMaskBlursRenderCorrectly_Vulkan.png impeller_Play_AiksTest_FastGradientTestHorizontalReversed_Metal.png impeller_Play_AiksTest_FastGradientTestHorizontalReversed_OpenGLES.png impeller_Play_AiksTest_FastGradientTestHorizontalReversed_Vulkan.png