From 106116d6ebb7a64701675cd0ce0990c8bae9512b Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 11 Dec 2023 12:05:51 -0800 Subject: [PATCH 1/4] [Impeller] Add golden for clipped+transformed blur. --- impeller/aiks/aiks_unittests.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index c1c46ecde95f4..084648710707b 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -4555,5 +4555,28 @@ TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, GaussianBlurRotatedAndClipped) { + // Smoketest to catch issues with the coverage hint. + Paint paint = {.image_filter = + ImageFilter::MakeBlur(Sigma(20.0), Sigma(20.0), + FilterContents::BlurStyle::kNormal, + Entity::TileMode::kDecal)}; + Canvas canvas; + canvas.Scale(GetContentScale()); + + canvas.ClipRect(Rect::MakeLTRB(100, 200, 450, 350)); + + canvas.Scale(Vector2(0.5, 0.5)); + canvas.Translate(Vector2(300, 100)); + canvas.Rotate(Degrees(25)); + + std::shared_ptr boston = CreateTextureForFixture("boston.jpg"); + auto bounds = + Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height); + canvas.DrawImageRect(std::make_shared(boston), bounds, bounds, paint); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller From 485c5cf214f874bc7c3b52b34dae7f9edb1b8412 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 12 Dec 2023 01:13:45 -0800 Subject: [PATCH 2/4] Center the clip over the blurred image --- impeller/aiks/aiks_unittests.cc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 084648710707b..135b42232c995 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -4505,6 +4505,7 @@ TEST_P(AiksTest, GaussianBlurAtPeripheryHorizontal) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +<<<<<<< HEAD #define FLT_FORWARD(mock, real, method) \ EXPECT_CALL(*mock, method()) \ .WillRepeatedly(::testing::Return(real->method())); @@ -4555,25 +4556,37 @@ TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +======= +// Smoketest to catch issues with the coverage hint. +// Draws a rotated blurred image within a rectangle clip. The center of the clip +// rectangle is the center of the rotated image. The entire area of the clip +// rectangle should be filled with opaque colors output by the blur. +>>>>>>> a178d2a245 (Center the clip over the blurred image) TEST_P(AiksTest, GaussianBlurRotatedAndClipped) { - // Smoketest to catch issues with the coverage hint. Paint paint = {.image_filter = ImageFilter::MakeBlur(Sigma(20.0), Sigma(20.0), FilterContents::BlurStyle::kNormal, Entity::TileMode::kDecal)}; - Canvas canvas; - canvas.Scale(GetContentScale()); - - canvas.ClipRect(Rect::MakeLTRB(100, 200, 450, 350)); - - canvas.Scale(Vector2(0.5, 0.5)); - canvas.Translate(Vector2(300, 100)); - canvas.Rotate(Degrees(25)); std::shared_ptr boston = CreateTextureForFixture("boston.jpg"); auto bounds = Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height); - canvas.DrawImageRect(std::make_shared(boston), bounds, bounds, paint); + + Vector2 scale = GetContentScale() * 0.5; + Vector2 pivot(450, 300); + Vector2 image_center = Vector2(bounds.GetSize() / 2); + + Canvas canvas; + canvas.Scale(scale); + + canvas.Translate(pivot); + canvas.ClipRect(Rect::MakeLTRB(-350, -150, 350, 150)); + + canvas.Translate(-pivot); + canvas.Rotate(Degrees(25)); + canvas.PreConcat(Matrix::MakeTranslation(pivot * scale)); + canvas.DrawImageRect(std::make_shared(boston), bounds, + bounds.Shift(-image_center), paint); ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } From 3467a9fff224aa9ebb73257360048bbb66fb3ec1 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 13 Dec 2023 15:16:27 -0800 Subject: [PATCH 3/4] Aaron review --- impeller/aiks/aiks_unittests.cc | 34 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 135b42232c995..f7ea9d77dd90b 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -4563,30 +4563,26 @@ TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) { // rectangle should be filled with opaque colors output by the blur. >>>>>>> a178d2a245 (Center the clip over the blurred image) TEST_P(AiksTest, GaussianBlurRotatedAndClipped) { + Canvas canvas; + std::shared_ptr boston = CreateTextureForFixture("boston.jpg"); + Rect bounds = + Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height); + Vector2 image_center = Vector2(bounds.GetSize() / 2); Paint paint = {.image_filter = ImageFilter::MakeBlur(Sigma(20.0), Sigma(20.0), FilterContents::BlurStyle::kNormal, Entity::TileMode::kDecal)}; - - std::shared_ptr boston = CreateTextureForFixture("boston.jpg"); - auto bounds = - Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height); - - Vector2 scale = GetContentScale() * 0.5; - Vector2 pivot(450, 300); - Vector2 image_center = Vector2(bounds.GetSize() / 2); - - Canvas canvas; - canvas.Scale(scale); - - canvas.Translate(pivot); - canvas.ClipRect(Rect::MakeLTRB(-350, -150, 350, 150)); - - canvas.Translate(-pivot); + Vector2 clip_size = {150, 75}; + Vector2 center = Vector2(1024, 768) / 2; + canvas.Scale(GetContentScale()); + canvas.ClipRect( + Rect::MakeLTRB(center.x, center.y, center.x, center.y).Expand(clip_size)); + canvas.Translate({center.x, center.y, 0}); + canvas.Scale({0.6, 0.6, 1}); canvas.Rotate(Degrees(25)); - canvas.PreConcat(Matrix::MakeTranslation(pivot * scale)); - canvas.DrawImageRect(std::make_shared(boston), bounds, - bounds.Shift(-image_center), paint); + + canvas.DrawImageRect(std::make_shared(boston), /*source=*/bounds, + /*dest=*/bounds.Shift(-image_center), paint); ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } From 7f4738d2b076f451ef3f14ca0db362dfdbd331b5 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 13 Dec 2023 15:39:36 -0800 Subject: [PATCH 4/4] merge... --- impeller/aiks/aiks_unittests.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index f7ea9d77dd90b..4435a8dd789ac 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -4505,7 +4505,6 @@ TEST_P(AiksTest, GaussianBlurAtPeripheryHorizontal) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -<<<<<<< HEAD #define FLT_FORWARD(mock, real, method) \ EXPECT_CALL(*mock, method()) \ .WillRepeatedly(::testing::Return(real->method())); @@ -4556,12 +4555,10 @@ TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } -======= // Smoketest to catch issues with the coverage hint. // Draws a rotated blurred image within a rectangle clip. The center of the clip // rectangle is the center of the rotated image. The entire area of the clip // rectangle should be filled with opaque colors output by the blur. ->>>>>>> a178d2a245 (Center the clip over the blurred image) TEST_P(AiksTest, GaussianBlurRotatedAndClipped) { Canvas canvas; std::shared_ptr boston = CreateTextureForFixture("boston.jpg");