diff --git a/impeller/aiks/aiks_blur_unittests.cc b/impeller/aiks/aiks_blur_unittests.cc index 7e76260f364e6..b1593bf72ab7b 100644 --- a/impeller/aiks/aiks_blur_unittests.cc +++ b/impeller/aiks/aiks_blur_unittests.cc @@ -5,11 +5,7 @@ #include "flutter/impeller/aiks/aiks_unittests.h" #include "impeller/aiks/canvas.h" -#include "impeller/entity/contents/conical_gradient_contents.h" -#include "impeller/entity/contents/filters/inputs/filter_input.h" -#include "impeller/entity/contents/solid_color_contents.h" #include "impeller/entity/render_target_cache.h" -#include "impeller/geometry/geometry_asserts.h" #include "impeller/geometry/path_builder.h" #include "impeller/playground/widgets.h" #include "impeller/renderer/testing/mocks.h" @@ -452,14 +448,14 @@ TEST_P(AiksTest, GaussianBlurRotatedAndClippedInteractive) { static float scale = 0.6; static int selected_tile_mode = 3; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - { + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::SliderFloat("Rotation (degrees)", &rotation, -180, 180); ImGui::SliderFloat("Scale", &scale, 0, 2.0); ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, sizeof(tile_mode_names) / sizeof(char*)); + ImGui::End(); } - ImGui::End(); Canvas canvas; Rect bounds = @@ -556,13 +552,13 @@ TEST_P(AiksTest, GaussianBlurAnimatedBackdrop) { Scalar freq = 0.1; Scalar amp = 50.0; auto callback = [&](AiksContext& renderer) -> std::optional { - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - { + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::SliderFloat("Sigma", &sigma, 0, 200); ImGui::SliderFloat("Frequency", &freq, 0.01, 2.0); ImGui::SliderFloat("Amplitude", &, 1, 100); + ImGui::End(); } - ImGui::End(); Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/impeller/aiks/aiks_gradient_unittests.cc b/impeller/aiks/aiks_gradient_unittests.cc index 70fe173daaf2c..a06fec82d7dfa 100644 --- a/impeller/aiks/aiks_gradient_unittests.cc +++ b/impeller/aiks/aiks_gradient_unittests.cc @@ -6,16 +6,13 @@ #include "impeller/aiks/canvas.h" #include "impeller/entity/contents/conical_gradient_contents.h" -#include "impeller/entity/contents/filters/inputs/filter_input.h" #include "impeller/entity/contents/linear_gradient_contents.h" #include "impeller/entity/contents/radial_gradient_contents.h" -#include "impeller/entity/contents/solid_color_contents.h" #include "impeller/entity/contents/sweep_gradient_contents.h" #include "impeller/geometry/geometry_asserts.h" #include "impeller/geometry/path_builder.h" #include "impeller/playground/widgets.h" #include "third_party/imgui/imgui.h" -#include "txt/platform.h" //////////////////////////////////////////////////////////////////////////////// // This is for tests of Canvas that are interested the results of rendering @@ -308,22 +305,24 @@ TEST_P(AiksTest, CanRenderLinearGradientManyColorsUnevenStops) { Entity::TileMode::kMirror, Entity::TileMode::kDecal}; static int selected_tile_mode = 0; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, - sizeof(tile_mode_names) / sizeof(char*)); static Matrix matrix = { 1, 0, 0, 0, // 0, 1, 0, 0, // 0, 0, 1, 0, // 0, 0, 0, 1 // }; - std::string label = "##1"; - for (int i = 0; i < 4; i++) { - ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), - 4, NULL, NULL, "%.2f", 0); - label[2]++; + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + std::string label = "##1"; + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, + &(matrix.vec[i]), 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); } - ImGui::End(); Canvas canvas; Paint paint; @@ -384,22 +383,24 @@ TEST_P(AiksTest, CanRenderRadialGradient) { Entity::TileMode::kMirror, Entity::TileMode::kDecal}; static int selected_tile_mode = 0; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, - sizeof(tile_mode_names) / sizeof(char*)); static Matrix matrix = { 1, 0, 0, 0, // 0, 1, 0, 0, // 0, 0, 1, 0, // 0, 0, 0, 1 // }; - std::string label = "##1"; - for (int i = 0; i < 4; i++) { - ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), - 4, NULL, NULL, "%.2f", 0); - label[2]++; + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + std::string label = "##1"; + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, + &(matrix.vec[i]), 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); } - ImGui::End(); Canvas canvas; Paint paint; @@ -427,22 +428,24 @@ TEST_P(AiksTest, CanRenderRadialGradientManyColors) { Entity::TileMode::kMirror, Entity::TileMode::kDecal}; static int selected_tile_mode = 0; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, - sizeof(tile_mode_names) / sizeof(char*)); static Matrix matrix = { 1, 0, 0, 0, // 0, 1, 0, 0, // 0, 0, 1, 0, // 0, 0, 0, 1 // }; - std::string label = "##1"; - for (int i = 0; i < 4; i++) { - ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), - 4, NULL, NULL, "%.2f", 0); - label[2]++; + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + std::string label = "##1"; + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, + &(matrix.vec[i]), 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); } - ImGui::End(); Canvas canvas; Paint paint; @@ -660,13 +663,15 @@ TEST_P(AiksTest, GradientStrokesRenderCorrectly) { static int selected_tile_mode = 0; static float alpha = 1; - 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); - ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, - sizeof(tile_mode_names) / sizeof(char*)); - ImGui::End(); + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("Scale", &scale, 0, 6); + ImGui::Checkbox("Circle clip", &add_circle_clip); + ImGui::SliderFloat("Alpha", &alpha, 0, 1); + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + ImGui::End(); + } Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/impeller/aiks/aiks_path_unittests.cc b/impeller/aiks/aiks_path_unittests.cc index 6f194d0623e0a..09df07f167580 100644 --- a/impeller/aiks/aiks_path_unittests.cc +++ b/impeller/aiks/aiks_path_unittests.cc @@ -185,11 +185,13 @@ TEST_P(AiksTest, SolidStrokesRenderCorrectly) { static float scale = 3; static bool add_circle_clip = true; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::ColorEdit4("Color", reinterpret_cast(&color)); - ImGui::SliderFloat("Scale", &scale, 0, 6); - ImGui::Checkbox("Circle clip", &add_circle_clip); - ImGui::End(); + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::ColorEdit4("Color", reinterpret_cast(&color)); + ImGui::SliderFloat("Scale", &scale, 0, 6); + ImGui::Checkbox("Circle clip", &add_circle_clip); + ImGui::End(); + } Canvas canvas; canvas.Scale(GetContentScale()); diff --git a/impeller/aiks/aiks_playground.cc b/impeller/aiks/aiks_playground.cc index 8714b54697ac2..db1545425f771 100644 --- a/impeller/aiks/aiks_playground.cc +++ b/impeller/aiks/aiks_playground.cc @@ -9,7 +9,6 @@ #include "impeller/aiks/aiks_context.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "impeller/typographer/typographer_context.h" -#include "third_party/imgui/imgui.h" namespace impeller { @@ -57,4 +56,11 @@ bool AiksPlayground::OpenPlaygroundHere(AiksPlaygroundCallback callback) { }); } +bool AiksPlayground::ImGuiBegin(const char* name, + bool* p_open, + ImGuiWindowFlags flags) { + ImGui::Begin(name, p_open, flags); + return true; +} + } // namespace impeller diff --git a/impeller/aiks/aiks_playground.h b/impeller/aiks/aiks_playground.h index 64490cb679254..9a6bfc90beb09 100644 --- a/impeller/aiks/aiks_playground.h +++ b/impeller/aiks/aiks_playground.h @@ -11,6 +11,7 @@ #include "impeller/aiks/picture.h" #include "impeller/playground/playground_test.h" #include "impeller/typographer/typographer_context.h" +#include "third_party/imgui/imgui.h" namespace impeller { @@ -32,6 +33,10 @@ class AiksPlayground : public PlaygroundTest { bool OpenPlaygroundHere(AiksPlaygroundCallback callback); + static bool ImGuiBegin(const char* name, + bool* p_open, + ImGuiWindowFlags flags); + private: std::shared_ptr typographer_context_; AiksInspector inspector_; diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 801b3ef760b26..f4911daa72256 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -21,13 +21,8 @@ #include "impeller/aiks/paint_pass_delegate.h" #include "impeller/aiks/testing/context_spy.h" #include "impeller/core/capture.h" -#include "impeller/entity/contents/conical_gradient_contents.h" #include "impeller/entity/contents/filters/gaussian_blur_filter_contents.h" -#include "impeller/entity/contents/filters/inputs/filter_input.h" -#include "impeller/entity/contents/linear_gradient_contents.h" -#include "impeller/entity/contents/radial_gradient_contents.h" #include "impeller/entity/contents/solid_color_contents.h" -#include "impeller/entity/contents/sweep_gradient_contents.h" #include "impeller/entity/render_target_cache.h" #include "impeller/geometry/color.h" #include "impeller/geometry/constants.h" @@ -38,9 +33,6 @@ #include "impeller/playground/widgets.h" #include "impeller/renderer/command_buffer.h" #include "impeller/renderer/snapshot.h" -#include "impeller/renderer/testing/mocks.h" -#include "impeller/scene/material.h" -#include "impeller/scene/node.h" #include "impeller/typographer/backends/skia/text_frame_skia.h" #include "impeller/typographer/backends/skia/typographer_context_skia.h" #include "impeller/typographer/backends/stb/text_frame_stb.h" @@ -48,7 +40,6 @@ #include "impeller/typographer/backends/stb/typographer_context_stb.h" #include "third_party/imgui/imgui.h" #include "third_party/skia/include/core/SkFontMgr.h" -#include "third_party/skia/include/core/SkTypeface.h" #include "txt/platform.h" namespace impeller { @@ -818,12 +809,14 @@ TEST_P(AiksTest, TextFrameSubpixelAlignment) { static float phase_variation = 0.2; static float speed = 0.5; static float magnitude = 100; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::SliderFloat("Font size", &font_size, 5, 50); - ImGui::SliderFloat("Phase variation", &phase_variation, 0, 1); - ImGui::SliderFloat("Oscillation speed", &speed, 0, 2); - ImGui::SliderFloat("Oscillation magnitude", &magnitude, 0, 300); - ImGui::End(); + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("Font size", &font_size, 5, 50); + ImGui::SliderFloat("Phase variation", &phase_variation, 0, 1); + ImGui::SliderFloat("Oscillation speed", &speed, 0, 2); + ImGui::SliderFloat("Oscillation magnitude", &magnitude, 0, 300); + ImGui::End(); + } Canvas canvas; canvas.Scale(GetContentScale()); @@ -1067,15 +1060,15 @@ TEST_P(AiksTest, CanDrawPaintMultipleTimesInteractive) { static Color foreground = Color::Color::OrangeRed().WithAlpha(0.5); static int current_blend_index = 3; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - { + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::ColorEdit4("Background", reinterpret_cast(&background)); ImGui::ColorEdit4("Foreground", reinterpret_cast(&foreground)); ImGui::ListBox("Blend mode", ¤t_blend_index, modes.blend_mode_names.data(), modes.blend_mode_names.size()); + ImGui::End(); } - ImGui::End(); Canvas canvas; canvas.Scale(Vector2(0.2, 0.2)); @@ -1162,8 +1155,8 @@ TEST_P(AiksTest, ColorWheel) { static Color color1 = Color::Green(); static Color color2 = Color::Blue(); - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - { + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Checkbox("Cache the wheel", &cache_the_wheel); ImGui::ListBox("Blending mode", ¤t_blend_index, blend_modes.blend_mode_names.data(), @@ -1173,8 +1166,8 @@ TEST_P(AiksTest, ColorWheel) { ImGui::ColorEdit4("Color B", reinterpret_cast(&color1)); ImGui::ColorEdit4("Color C", reinterpret_cast(&color2)); ImGui::SliderFloat("Destination alpha", &dst_alpha, 0, 1); + ImGui::End(); } - ImGui::End(); static Point content_scale; Point new_content_scale = GetContentScale(); @@ -1868,14 +1861,16 @@ TEST_P(AiksTest, SceneColorSource) { auto callback = [&](AiksContext& renderer) -> std::optional { Paint paint; - ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); static Scalar distance = 2; - ImGui::SliderFloat("Distance", &distance, 0, 4); static Scalar y_pos = 0; - ImGui::SliderFloat("Y", &y_pos, -3, 3); static Scalar fov = 45; - ImGui::SliderFloat("FOV", &fov, 1, 180); - ImGui::End(); + if (AiksTest::ImGuiBegin("Controls", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("Distance", &distance, 0, 4); + ImGui::SliderFloat("Y", &y_pos, -3, 3); + ImGui::SliderFloat("FOV", &fov, 1, 180); + ImGui::End(); + } Scalar angle = GetSecondsElapsed(); auto camera_position = @@ -3066,13 +3061,16 @@ TEST_P(AiksTest, CaptureContext) { auto color = document.AddColor("Background color", Color::CornflowerBlue()); canvas.DrawPaint({.color = color}); - ImGui::Begin("TestDocument", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - document.GetElement()->properties.Iterate([](CaptureProperty& property) { - property.Invoke({.color = [](CaptureColorProperty& p) { - ImGui::ColorEdit4(p.label.c_str(), reinterpret_cast(&p.value)); - }}); - }); - ImGui::End(); + if (AiksTest::ImGuiBegin("TestDocument", nullptr, + ImGuiWindowFlags_AlwaysAutoResize)) { + document.GetElement()->properties.Iterate([](CaptureProperty& property) { + property.Invoke({.color = [](CaptureColorProperty& p) { + ImGui::ColorEdit4(p.label.c_str(), + reinterpret_cast(&p.value)); + }}); + }); + ImGui::End(); + } return canvas.EndRecordingAsPicture(); }; diff --git a/impeller/golden_tests/golden_playground_test.h b/impeller/golden_tests/golden_playground_test.h index 251e98a04e153..e0da049b9e2d2 100644 --- a/impeller/golden_tests/golden_playground_test.h +++ b/impeller/golden_tests/golden_playground_test.h @@ -13,6 +13,7 @@ #include "flutter/impeller/renderer/render_target.h" #include "flutter/testing/testing.h" #include "impeller/typographer/typographer_context.h" +#include "third_party/imgui/imgui.h" #if FML_OS_MACOSX #include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h" @@ -43,6 +44,10 @@ class GoldenPlaygroundTest bool OpenPlaygroundHere(AiksPlaygroundCallback callback); + static bool ImGuiBegin(const char* name, + bool* p_open, + ImGuiWindowFlags flags); + std::shared_ptr CreateTextureForFixture( const char* fixture_name, bool enable_mipmapping = false) const; diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index 68dee0d60ff4d..1d124a7c38a40 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -63,26 +63,18 @@ const std::unique_ptr& GetSharedVulkanPlayground( // If you add a new playground test to the aiks unittests and you do not want it // to also be a golden test, then add the test name here. static const std::vector kSkipTests = { - IMP_AIKSTEST(CanDrawPaintMultipleTimesInteractive), - IMP_AIKSTEST(CanRenderLinearGradientManyColorsUnevenStops), - IMP_AIKSTEST(CanRenderRadialGradient), - IMP_AIKSTEST(CanRenderRadialGradientManyColors), + IMP_AIKSTEST(GaussianBlurAnimatedBackdrop), IMP_AIKSTEST(CanRenderBackdropBlurInteractive), IMP_AIKSTEST(ClippedBlurFilterRendersCorrectlyInteractive), - IMP_AIKSTEST(CoverageOriginShouldBeAccountedForInSubpasses), - IMP_AIKSTEST(GaussianBlurRotatedAndClippedInteractive), IMP_AIKSTEST(GradientStrokesRenderCorrectly), - IMP_AIKSTEST(ColorWheel), - IMP_AIKSTEST(SceneColorSource), IMP_AIKSTEST(SolidStrokesRenderCorrectly), - IMP_AIKSTEST(TextFrameSubpixelAlignment), - IMP_AIKSTEST(GaussianBlurAnimatedBackdrop), + IMP_AIKSTEST(GaussianBlurRotatedAndClippedInteractive), + IMP_AIKSTEST(CoverageOriginShouldBeAccountedForInSubpasses), // TextRotated is flakey and we can't seem to get it to stabilize on Skia // Gold. IMP_AIKSTEST(TextRotated), // Runtime stage based tests get confused with a Metal context. "impeller_Play_AiksTest_CanRenderClippedRuntimeEffects_Vulkan", - IMP_AIKSTEST(CaptureContext), }; static const std::vector kVulkanDenyValidationTests = { @@ -235,6 +227,12 @@ bool GoldenPlaygroundTest::OpenPlaygroundHere( return SaveScreenshot(std::move(screenshot)); } +bool GoldenPlaygroundTest::ImGuiBegin(const char* name, + bool* p_open, + ImGuiWindowFlags flags) { + return false; +} + std::shared_ptr GoldenPlaygroundTest::CreateTextureForFixture( const char* fixture_name, bool enable_mipmapping) const { diff --git a/testing/run_tests.py b/testing/run_tests.py index fa53d5ffad081..bd3712d63f339 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -40,7 +40,7 @@ ENCODING = 'UTF-8' # This number must be updated when adding new golden tests to impeller. -_NUM_EXPECTED_GENERATED_IMPELLER_GOLDEN_FILES = 557 +_NUM_EXPECTED_GENERATED_IMPELLER_GOLDEN_FILES = 578 logger = logging.getLogger(__name__) logger_handler = logging.StreamHandler()