[Impeller] Autoresize playground imgui windows (flutter/engine#37033)
This commit is contained in:
@@ -101,8 +101,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"};
|
||||
@@ -303,14 +301,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,
|
||||
@@ -361,14 +352,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,
|
||||
@@ -433,14 +417,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,
|
||||
@@ -495,14 +472,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,
|
||||
@@ -559,14 +529,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,
|
||||
@@ -614,14 +577,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,
|
||||
@@ -683,14 +639,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,
|
||||
@@ -737,14 +686,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,
|
||||
@@ -835,14 +777,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);
|
||||
@@ -1296,13 +1231,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;
|
||||
@@ -1430,19 +1359,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);
|
||||
@@ -1500,14 +1422,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"};
|
||||
@@ -1517,7 +1432,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);
|
||||
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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;
|
||||
@@ -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"};
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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 {
|
||||
@@ -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));
|
||||
@@ -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"};
|
||||
@@ -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};
|
||||
@@ -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;
|
||||
@@ -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, //
|
||||
|
||||
@@ -213,6 +213,8 @@ bool Playground::OpenPlaygroundHere(
|
||||
fml::ScopedCleanupClosure shutdown_imgui_impeller(
|
||||
[]() { ImGui_ImplImpeller_Shutdown(); });
|
||||
|
||||
ImGui::SetNextWindowPos({10, 10});
|
||||
|
||||
::glfwSetWindowSize(window, GetWindowSize().width, GetWindowSize().height);
|
||||
::glfwSetWindowPos(window, 200, 100);
|
||||
::glfwShowWindow(window);
|
||||
|
||||
@@ -165,18 +165,11 @@ TEST_P(RendererTest, CanRenderPerspectiveCube) {
|
||||
ASSERT_TRUE(sampler);
|
||||
|
||||
Vector3 euler_angles;
|
||||
bool first_frame = true;
|
||||
SinglePassCallback callback = [&](RenderPass& pass) {
|
||||
if (first_frame) {
|
||||
first_frame = false;
|
||||
ImGui::SetNextWindowSize({400, 80});
|
||||
ImGui::SetNextWindowPos({20, 20});
|
||||
}
|
||||
|
||||
static Degrees fov_y(60);
|
||||
static Scalar distance = 10;
|
||||
|
||||
ImGui::Begin("Controls");
|
||||
ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::SliderFloat("Field of view", &fov_y.degrees, 0, 180);
|
||||
ImGui::SliderFloat("Camera distance", &distance, 0, 30);
|
||||
ImGui::End();
|
||||
@@ -598,10 +591,6 @@ TEST_P(RendererTest, CanGenerateMipmaps) {
|
||||
|
||||
bool first_frame = true;
|
||||
Renderer::RenderCallback callback = [&](RenderTarget& render_target) {
|
||||
if (first_frame) {
|
||||
ImGui::SetNextWindowPos({10, 10});
|
||||
}
|
||||
|
||||
const char* mip_filter_names[] = {"None", "Nearest", "Linear"};
|
||||
const MipFilter mip_filters[] = {MipFilter::kNone, MipFilter::kNearest,
|
||||
MipFilter::kLinear};
|
||||
|
||||
Reference in New Issue
Block a user