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

Commit e55e686

Browse files
committed
Fix offset, add tests
1 parent d7f2f9e commit e55e686

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,5 +2174,52 @@ TEST_P(AiksTest, CanRenderDestructiveSaveLayer) {
21742174
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
21752175
}
21762176

2177+
TEST_P(AiksTest, CanRenderBackdropBlurInteractive) {
2178+
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
2179+
auto [a, b] = IMPELLER_PLAYGROUND_LINE(Point(50, 50), Point(300, 200), 30,
2180+
Color::White(), Color::White());
2181+
2182+
Canvas canvas;
2183+
canvas.DrawCircle({100, 100}, 50, {.color = Color::CornflowerBlue()});
2184+
canvas.DrawCircle({300, 200}, 100, {.color = Color::GreenYellow()});
2185+
canvas.DrawCircle({140, 170}, 75, {.color = Color::DarkMagenta()});
2186+
canvas.DrawCircle({180, 120}, 100, {.color = Color::OrangeRed()});
2187+
canvas.ClipRRect(Rect::MakeLTRB(a.x, a.y, b.x, b.y), 20);
2188+
canvas.SaveLayer({.blend_mode = BlendMode::kSource}, std::nullopt,
2189+
[](const FilterInput::Ref& input,
2190+
const Matrix& effect_transform, bool is_subpass) {
2191+
return FilterContents::MakeGaussianBlur(
2192+
input, Sigma(20.0), Sigma(20.0),
2193+
FilterContents::BlurStyle::kNormal,
2194+
Entity::TileMode::kClamp, effect_transform);
2195+
});
2196+
canvas.Restore();
2197+
2198+
return renderer.Render(canvas.EndRecordingAsPicture(), render_target);
2199+
};
2200+
2201+
ASSERT_TRUE(OpenPlaygroundHere(callback));
2202+
}
2203+
2204+
TEST_P(AiksTest, CanRenderBackdropBlur) {
2205+
Canvas canvas;
2206+
canvas.DrawCircle({100, 100}, 50, {.color = Color::CornflowerBlue()});
2207+
canvas.DrawCircle({300, 200}, 100, {.color = Color::GreenYellow()});
2208+
canvas.DrawCircle({140, 170}, 75, {.color = Color::DarkMagenta()});
2209+
canvas.DrawCircle({180, 120}, 100, {.color = Color::OrangeRed()});
2210+
canvas.ClipRRect(Rect::MakeLTRB(75, 50, 375, 275), 20);
2211+
canvas.SaveLayer({.blend_mode = BlendMode::kSource}, std::nullopt,
2212+
[](const FilterInput::Ref& input,
2213+
const Matrix& effect_transform, bool is_subpass) {
2214+
return FilterContents::MakeGaussianBlur(
2215+
input, Sigma(30.0), Sigma(30.0),
2216+
FilterContents::BlurStyle::kNormal,
2217+
Entity::TileMode::kClamp, effect_transform);
2218+
});
2219+
canvas.Restore();
2220+
2221+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2222+
}
2223+
21772224
} // namespace testing
21782225
} // namespace impeller

impeller/entity/entity_pass.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
481481
return EntityPass::EntityResult::Failure();
482482
}
483483

484+
FML_LOG(ERROR) << "Origin: " << subpass_coverage->origin
485+
<< " Size: " << subpass_coverage->size;
486+
484487
// Stencil textures aren't shared between EntityPasses (as much of the
485488
// time they are transient).
486489
if (!subpass->OnRender(renderer, // renderer
@@ -688,13 +691,18 @@ bool EntityPass::OnRender(
688691
// Tell the backdrop contents which portion of the rendered output will
689692
// actually be used. The contents may optionally use this hint to avoid
690693
// unnecessary rendering work.
691-
backdrop_filter_contents->SetCoverageHint(
692-
stencil_coverage_stack.back().coverage);
694+
if (!stencil_coverage_stack.empty() &&
695+
stencil_coverage_stack.back().coverage.has_value()) {
696+
auto coverage_hint = Rect(
697+
stencil_coverage_stack.back().coverage->origin - global_pass_position,
698+
stencil_coverage_stack.back().coverage->size);
699+
backdrop_filter_contents->SetCoverageHint(coverage_hint);
700+
}
693701

694702
Entity backdrop_entity;
695703
backdrop_entity.SetContents(std::move(backdrop_filter_contents));
696704
backdrop_entity.SetTransformation(
697-
Matrix::MakeTranslation(Vector3(local_pass_position)));
705+
Matrix::MakeTranslation(Vector3(-local_pass_position)));
698706
backdrop_entity.SetStencilDepth(stencil_depth_floor);
699707

700708
render_element(backdrop_entity);

impeller/golden_tests/golden_playground_test_mac.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ static const std::vector<std::string> kSkipTests = {
2323
"impeller_Play_AiksTest_CanRenderRadialGradient_Vulkan",
2424
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Metal",
2525
"impeller_Play_AiksTest_CanRenderRadialGradientManyColors_Vulkan",
26+
"impeller_Play_AiksTest_CanRenderBackdropBlurInteractive_Metal",
27+
"impeller_Play_AiksTest_CanRenderBackdropBlurInteractive_Vulkan",
2628
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal",
2729
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Vulkan",
2830
"impeller_Play_AiksTest_ColorWheel_Metal",

0 commit comments

Comments
 (0)