From 3ddcbc7940ec33717e5e80e1c31c3ce8c5777fac Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 13 Dec 2023 16:54:24 -0800 Subject: [PATCH] [Impeller] Add golden for clipped+transformed blur. (flutter/engine#48886) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a simple golden intended to smoketest potential issues when applying the coverage hint in the blur. Expected results: ![Screenshot 2023-12-11 at 12 03 50 PM](https://github.com/flutter/engine/assets/919017/251978b7-e6b4-4863-97f0-9a9a236f05ea) --- .../flutter/impeller/aiks/aiks_unittests.cc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/engine/src/flutter/impeller/aiks/aiks_unittests.cc b/engine/src/flutter/impeller/aiks/aiks_unittests.cc index c1c46ecde9..4435a8dd78 100644 --- a/engine/src/flutter/impeller/aiks/aiks_unittests.cc +++ b/engine/src/flutter/impeller/aiks/aiks_unittests.cc @@ -4555,5 +4555,34 @@ 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. +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)}; + 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.DrawImageRect(std::make_shared(boston), /*source=*/bounds, + /*dest=*/bounds.Shift(-image_center), paint); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + } // namespace testing } // namespace impeller