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

[Impeller] Add interactive Blur+Clip AiksTest. #49283

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3909,6 +3909,52 @@ TEST_P(AiksTest, GaussianBlurRotatedAndClipped) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, GaussianBlurRotatedAndClippedInteractive) {
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");

auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Entity::TileMode::kMirror, Entity::TileMode::kDecal};

static float rotation = 0;
static int selected_tile_mode = 3;

ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
{
ImGui::SliderFloat("Rotation (degrees)", &rotation, -180, 180);
ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names,
sizeof(tile_mode_names) / sizeof(char*));
}
ImGui::End();

Canvas canvas;
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,
tile_modes[selected_tile_mode])};
auto [handle_a, handle_b] = IMPELLER_PLAYGROUND_LINE(
Point(362, 309), Point(662, 459), 20, Color::Red(), Color::Red());
Vector2 center = Vector2(1024, 768) / 2;
canvas.Scale(GetContentScale());
canvas.ClipRect(
Rect::MakeLTRB(handle_a.x, handle_a.y, handle_b.x, handle_b.y));
canvas.Translate({center.x, center.y, 0});
canvas.Scale({0.6, 0.6, 1});
canvas.Rotate(Degrees(rotation));

canvas.DrawImageRect(std::make_shared<Image>(boston), /*source=*/bounds,
/*dest=*/bounds.Shift(-image_center), paint);
return canvas.EndRecordingAsPicture();
};

ASSERT_TRUE(OpenPlaygroundHere(callback));
}

TEST_P(AiksTest, SubpassWithClearColorOptimization) {
Canvas canvas;

Expand Down
13 changes: 11 additions & 2 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ TEST_P(EntityTest, GaussianBlurFilter) {
static Color input_color = Color::Black();
static int selected_blur_type = 0;
static int selected_pass_variation = 0;
static bool combined_sigma = false;
static float blur_amount_coarse[2] = {0, 0};
static float blur_amount_fine[2] = {10, 10};
static int selected_blur_style = 0;
Expand Down Expand Up @@ -1039,8 +1040,16 @@ TEST_P(EntityTest, GaussianBlurFilter) {
pass_variation_names,
sizeof(pass_variation_names) / sizeof(char*));
}
ImGui::SliderFloat2("Sigma (coarse)", blur_amount_coarse, 0, 1000);
ImGui::SliderFloat2("Sigma (fine)", blur_amount_fine, 0, 10);
ImGui::Checkbox("Combined sigma", &combined_sigma);
if (combined_sigma) {
ImGui::SliderFloat("Sigma (coarse)", blur_amount_coarse, 0, 1000);
ImGui::SliderFloat("Sigma (fine)", blur_amount_fine, 0, 10);
blur_amount_coarse[1] = blur_amount_coarse[0];
blur_amount_fine[1] = blur_amount_fine[0];
} else {
ImGui::SliderFloat2("Sigma (coarse)", blur_amount_coarse, 0, 1000);
ImGui::SliderFloat2("Sigma (fine)", blur_amount_fine, 0, 10);
}
ImGui::Combo("Blur style", &selected_blur_style, blur_style_names,
sizeof(blur_style_names) / sizeof(char*));
ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names,
Expand Down
18 changes: 10 additions & 8 deletions impeller/golden_tests/golden_playground_test_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ static const std::vector<std::string> kSkipTests = {
"impeller_Play_AiksTest_ClippedBlurFilterRendersCorrectlyInteractive_Metal",
"impeller_Play_AiksTest_ClippedBlurFilterRendersCorrectlyInteractive_"
"Vulkan",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Vulkan",
"impeller_Play_AiksTest_ColorWheel_Metal",
"impeller_Play_AiksTest_ColorWheel_Vulkan",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_"
"Metal",
"impeller_Play_AiksTest_CoverageOriginShouldBeAccountedForInSubpasses_"
"Vulkan",
"impeller_Play_AiksTest_GaussianBlurRotatedAndClippedInteractive_Metal",
"impeller_Play_AiksTest_GaussianBlurRotatedAndClippedInteractive_Vulkan",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_ColorWheel_Metal",
"impeller_Play_AiksTest_ColorWheel_Vulkan",
"impeller_Play_AiksTest_SceneColorSource_Metal",
"impeller_Play_AiksTest_SceneColorSource_Vulkan",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Metal",
"impeller_Play_AiksTest_SolidStrokesRenderCorrectly_Vulkan",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Metal",
"impeller_Play_AiksTest_TextFrameSubpixelAlignment_Vulkan",
// TextRotated is flakey and we can't seem to get it to stabilize on Skia
// Gold.
"impeller_Play_AiksTest_TextRotated_Metal",
Expand Down