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

[Impeller] Autoresize playground imgui windows #37033

Merged
merged 1 commit into from
Oct 26, 2022
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
89 changes: 2 additions & 87 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ TEST_P(AiksTest, CanRenderTiledTexture) {
if (first_frame) {
first_frame = false;
GenerateMipmap(context, texture, "table_mountain_nx");
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
Expand Down Expand Up @@ -302,14 +300,7 @@ TEST_P(AiksTest, CanSaveLayerStandalone) {
}

TEST_P(AiksTest, CanRenderLinearGradient) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -360,14 +351,7 @@ TEST_P(AiksTest, CanRenderLinearGradient) {
}

TEST_P(AiksTest, CanRenderLinearGradientManyColors) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -432,14 +416,7 @@ TEST_P(AiksTest, CanRenderLinearGradientManyColors) {
}

TEST_P(AiksTest, CanRenderLinearGradientWayManyColors) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -494,14 +471,7 @@ TEST_P(AiksTest, CanRenderLinearGradientWayManyColors) {
}

TEST_P(AiksTest, CanRenderLinearGradientManyColorsUnevenStops) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -558,14 +528,7 @@ TEST_P(AiksTest, CanRenderLinearGradientManyColorsUnevenStops) {
}

TEST_P(AiksTest, CanRenderRadialGradient) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -613,14 +576,7 @@ TEST_P(AiksTest, CanRenderRadialGradient) {
}

TEST_P(AiksTest, CanRenderRadialGradientManyColors) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -682,14 +638,7 @@ TEST_P(AiksTest, CanRenderRadialGradientManyColors) {
}

TEST_P(AiksTest, CanRenderSweepGradient) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -736,14 +685,7 @@ TEST_P(AiksTest, CanRenderSweepGradient) {
}

TEST_P(AiksTest, CanRenderSweepGradientManyColors) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
const Entity::TileMode tile_modes[] = {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Expand Down Expand Up @@ -834,14 +776,7 @@ TEST_P(AiksTest, CanRenderDifferentShapesWithSameColorSource) {
}

TEST_P(AiksTest, CanPictureConvertToImage) {
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

static int size[2] = {1000, 1000};
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::SliderInt2("Size", size, 0, 1000);
Expand Down Expand Up @@ -1295,13 +1230,7 @@ TEST_P(AiksTest, ColorWheel) {
std::shared_ptr<Image> color_wheel_image;
Matrix color_wheel_transform;

bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({25, 25});
}

// UI state.
static int current_blend_index = 3;
static float dst_alpha = 1;
Expand Down Expand Up @@ -1429,19 +1358,12 @@ TEST_P(AiksTest, TransformMultipliesCorrectly) {

TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
// Compare with https://fiddle.skia.org/c/027392122bec8ac2b5d5de00a4b9bbe2
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

static Color color = Color::Black().WithAlpha(0.5);
static float scale = 3;
static bool add_circle_clip = true;

ImGui::Begin("Controls");
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::ColorEdit4("Color", reinterpret_cast<float*>(&color));
ImGui::SliderFloat("Scale", &scale, 0, 6);
ImGui::Checkbox("Circle clip", &add_circle_clip);
Expand Down Expand Up @@ -1499,14 +1421,7 @@ TEST_P(AiksTest, SolidStrokesRenderCorrectly) {

TEST_P(AiksTest, GradientStrokesRenderCorrectly) {
// Compare with https://fiddle.skia.org/c/027392122bec8ac2b5d5de00a4b9bbe2
bool first_frame = true;
auto callback = [&](AiksContext& renderer, RenderTarget& render_target) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({480, 100});
ImGui::SetNextWindowPos({100, 550});
}

static float scale = 3;
static bool add_circle_clip = true;
const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"};
Expand All @@ -1516,7 +1431,7 @@ TEST_P(AiksTest, GradientStrokesRenderCorrectly) {
static int selected_tile_mode = 0;
static float alpha = 1;

ImGui::Begin("Controls");
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::SliderFloat("Scale", &scale, 0, 6);
ImGui::Checkbox("Circle clip", &add_circle_clip);
ImGui::SliderFloat("Alpha", &alpha, 0, 1);
Expand Down
40 changes: 1 addition & 39 deletions impeller/display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ TEST_P(DisplayListTest, CanDrawCapsAndJoins) {
}

TEST_P(DisplayListTest, CanDrawArc) {
bool first_frame = true;
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({400, 100});
ImGui::SetNextWindowPos({300, 550});
}

static float start_angle = 45;
static float sweep_angle = 270;
static bool use_center = true;
Expand Down Expand Up @@ -283,17 +276,10 @@ TEST_P(DisplayListTest, CanDrawWithColorFilterImageFilter) {
TEST_P(DisplayListTest, CanDrawWithImageBlurFilter) {
auto texture = CreateTextureForFixture("embarcadero.jpg");

bool first_frame = true;
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({400, 100});
ImGui::SetNextWindowPos({300, 550});
}

static float sigma[] = {10, 10};

ImGui::Begin("Controls");
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::SliderFloat2("Sigma", sigma, 0, 100);
ImGui::End();

Expand Down Expand Up @@ -361,14 +347,8 @@ TEST_P(DisplayListTest, CanClampTheResultingColorOfColorMatrixFilter) {

TEST_P(DisplayListTest, SaveLayerWithColorMatrixFiltersAndAlphaDrawCorrectly) {
auto texture = CreateTextureForFixture("boston.jpg");
bool first_frame = true;
enum class Type { kUseAsImageFilter, kUseAsColorFilter, kDisableFilter };
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

static float alpha = 0.5;
static int selected_type = 0;
const char* names[] = {"Use as image filter", "Use as color filter",
Expand Down Expand Up @@ -426,14 +406,8 @@ TEST_P(DisplayListTest, SaveLayerWithColorMatrixFiltersAndAlphaDrawCorrectly) {

TEST_P(DisplayListTest, SaveLayerWithBlendFiltersAndAlphaDrawCorrectly) {
auto texture = CreateTextureForFixture("boston.jpg");
bool first_frame = true;
enum class Type { kUseAsImageFilter, kUseAsColorFilter, kDisableFilter };
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

static float alpha = 0.5;
static int selected_type = 0;
const char* names[] = {"Use as image filter", "Use as color filter",
Expand Down Expand Up @@ -479,13 +453,7 @@ TEST_P(DisplayListTest, SaveLayerWithBlendFiltersAndAlphaDrawCorrectly) {
TEST_P(DisplayListTest, CanDrawBackdropFilter) {
auto texture = CreateTextureForFixture("embarcadero.jpg");

bool first_frame = true;
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

static float sigma[] = {10, 10};
static float ctm_scale = 1;
static bool use_bounds = true;
Expand Down Expand Up @@ -775,13 +743,7 @@ TEST_P(DisplayListTest, CanDrawZeroWidthLine) {
TEST_P(DisplayListTest, CanDrawWithMatrixFilter) {
auto boston = CreateTextureForFixture("boston.jpg");

bool first_frame = true;
auto callback = [&]() {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

static int selected_matrix_type = 0;
const char* matrix_type_names[] = {"Matrix", "Local Matrix"};

Expand Down
44 changes: 2 additions & 42 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,14 @@ TEST_P(EntityTest, StrokeCapAndJoinTest) {
const Point padding(300, 250);
const Point margin(140, 180);

bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({300, 100});
ImGui::SetNextWindowPos(
{0 * padding.x + margin.x, 1.7f * padding.y + margin.y});
}

// Slightly above sqrt(2) by default, so that right angles are just below
// the limit and acute angles are over the limit (causing them to get
// beveled).
static Scalar miter_limit = 1.41421357;
static Scalar width = 30;

ImGui::Begin("Controls");
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
{
ImGui::SliderFloat("Miter limit", &miter_limit, 0, 30);
ImGui::SliderFloat("Stroke width", &width, 0, 100);
Expand Down Expand Up @@ -741,14 +733,7 @@ TEST_P(EntityTest, BlendingModeOptions) {
};
}

bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowSize({350, 200});
ImGui::SetNextWindowPos({200, 450});
}

auto world_matrix = Matrix::MakeScale(GetContentScale());
auto draw_rect = [&context, &pass, &world_matrix](
Rect rect, Color color, BlendMode blend_mode) -> bool {
Expand Down Expand Up @@ -792,7 +777,7 @@ TEST_P(EntityTest, BlendingModeOptions) {
return pass.AddCommand(std::move(cmd));
};

ImGui::Begin("Controls");
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
static Color color1(1, 0, 0, 0.5), color2(0, 1, 0, 0.5);
ImGui::ColorEdit4("Color 1", reinterpret_cast<float*>(&color1));
ImGui::ColorEdit4("Color 2", reinterpret_cast<float*>(&color2));
Expand Down Expand Up @@ -879,13 +864,7 @@ TEST_P(EntityTest, GaussianBlurFilter) {
auto boston = CreateTextureForFixture("boston.jpg");
ASSERT_TRUE(boston);

bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

const char* input_type_names[] = {"Texture", "Solid Color"};
const char* blur_type_names[] = {"Image blur", "Mask blur"};
const char* pass_variation_names[] = {"Two pass", "Directional"};
Expand Down Expand Up @@ -1035,13 +1014,7 @@ TEST_P(EntityTest, MorphologyFilter) {
auto boston = CreateTextureForFixture("boston.jpg");
ASSERT_TRUE(boston);

bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

const char* morphology_type_names[] = {"Dilate", "Erode"};
const FilterContents::MorphType morphology_types[] = {
FilterContents::MorphType::kDilate, FilterContents::MorphType::kErode};
Expand Down Expand Up @@ -1563,13 +1536,7 @@ TEST_P(EntityTest, ClipContentsShouldRenderIsCorrect) {
}

TEST_P(EntityTest, RRectShadowTest) {
bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) {
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

static Color color = Color::Red();
static float corner_radius = 100;
static float blur_radius = 100;
Expand Down Expand Up @@ -1651,14 +1618,7 @@ TEST_P(EntityTest, ColorMatrixFilterEditable) {
auto bay_bridge = CreateTextureForFixture("bay_bridge.jpg");
ASSERT_TRUE(bay_bridge);

bool first_frame = true;
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
// If this is the first frame, set the ImGui's initial size and postion.
if (first_frame) {
first_frame = false;
ImGui::SetNextWindowPos({10, 10});
}

// UI state.
static FilterContents::ColorMatrix color_matrix = {
1, 0, 0, 0, 0, //
Expand Down
Loading