Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4c75338

Browse files
committed
okay a bit closer, this seems to mimic skia's behavior
1 parent 3c71b94 commit 4c75338

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

impeller/aiks/aiks_blur_unittests.cc

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// blurs.
1717
////////////////////////////////////////////////////////////////////////////////
1818

19+
float fudge = 100;
20+
1921
namespace impeller {
2022
namespace testing {
2123

@@ -645,20 +647,30 @@ TEST_P(AiksTest, GaussianBlurStyleOuter) {
645647
}
646648

647649
TEST_P(AiksTest, GaussianBlurStyleInnerTexture) {
648-
Canvas canvas;
649-
canvas.Scale(GetContentScale());
650-
Paint paint;
651-
paint.color = Color::Green();
652-
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
653-
.style = FilterContents::BlurStyle::kNormal,
654-
.sigma = Sigma(30),
650+
auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
651+
static Scalar sigma = 30;
652+
if (AiksTest::ImGuiBegin("Controls", nullptr,
653+
ImGuiWindowFlags_AlwaysAutoResize)) {
654+
ImGui::SliderFloat("Sigma", &sigma, 0, 500);
655+
ImGui::SliderFloat("Fudge", &fudge, 0, 100);
656+
ImGui::End();
657+
}
658+
Canvas canvas;
659+
canvas.Scale(GetContentScale());
660+
Paint paint;
661+
paint.color = Color::Green();
662+
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
663+
.style = FilterContents::BlurStyle::kNormal,
664+
.sigma = Sigma(sigma),
665+
};
666+
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
667+
canvas.DrawImage(std::make_shared<Image>(boston), {200, 200}, paint);
668+
Paint red;
669+
red.color = Color::Red();
670+
canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red);
671+
return canvas.EndRecordingAsPicture();
655672
};
656-
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
657-
canvas.DrawImage(std::make_shared<Image>(boston), {200, 200}, paint);
658-
Paint red;
659-
red.color = Color::Red();
660-
canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red);
661-
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
673+
ASSERT_TRUE(OpenPlaygroundHere(callback));
662674
}
663675

664676
} // namespace testing

impeller/aiks/paint.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "impeller/entity/contents/solid_color_contents.h"
1313
#include "impeller/entity/geometry/geometry.h"
1414

15+
extern float fudge;
16+
1517
namespace impeller {
1618

1719
/// A color matrix which inverts colors.
@@ -124,9 +126,14 @@ std::shared_ptr<Contents> Paint::WithColorFilter(
124126
std::shared_ptr<FilterContents> Paint::MaskBlurDescriptor::CreateMaskBlur(
125127
std::shared_ptr<TextureContents> texture_contents,
126128
const std::shared_ptr<ColorFilter>& color_filter) const {
129+
texture_contents->SetSourceRect(
130+
texture_contents->GetSourceRect().Expand(fudge, fudge));
127131
auto mask = std::make_shared<SolidColorContents>();
128132
mask->SetColor(Color::White());
129133
std::optional<Rect> coverage = texture_contents->GetCoverage({});
134+
texture_contents->SetDestinationRect(coverage.value().Expand(fudge, fudge));
135+
auto descriptor = texture_contents->GetSamplerDescriptor();
136+
texture_contents->SetSamplerDescriptor(descriptor);
130137
std::shared_ptr<Geometry> geometry = Geometry::MakeRect(coverage.value());
131138
mask->SetGeometry(geometry);
132139
std::shared_ptr<FilterContents> blurred_mask =

0 commit comments

Comments
 (0)