[Impeller] cleaned up and removed golden test exceptions (flutter/engine#50572)

This starts generating golden image tests for most interactive tests instead of having to explicitly exempt them.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
gaaclarke
2024-02-12 20:40:12 -08:00
committed by GitHub
parent 67db5ec63e
commit c4575d9ac7
9 changed files with 113 additions and 98 deletions

View File

@@ -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<Picture> {
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", &amp, 1, 100);
ImGui::End();
}
ImGui::End();
Canvas canvas;
canvas.Scale(GetContentScale());

View File

@@ -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());

View File

@@ -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<float*>(&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<float*>(&color));
ImGui::SliderFloat("Scale", &scale, 0, 6);
ImGui::Checkbox("Circle clip", &add_circle_clip);
ImGui::End();
}
Canvas canvas;
canvas.Scale(GetContentScale());

View File

@@ -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

View File

@@ -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<TypographerContext> typographer_context_;
AiksInspector inspector_;

View File

@@ -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<float*>(&background));
ImGui::ColorEdit4("Foreground", reinterpret_cast<float*>(&foreground));
ImGui::ListBox("Blend mode", &current_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", &current_blend_index,
blend_modes.blend_mode_names.data(),
@@ -1173,8 +1166,8 @@ TEST_P(AiksTest, ColorWheel) {
ImGui::ColorEdit4("Color B", reinterpret_cast<float*>(&color1));
ImGui::ColorEdit4("Color C", reinterpret_cast<float*>(&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<Picture> {
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<float*>(&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<float*>(&p.value));
}});
});
ImGui::End();
}
return canvas.EndRecordingAsPicture();
};

View File

@@ -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<Texture> CreateTextureForFixture(
const char* fixture_name,
bool enable_mipmapping = false) const;

View File

@@ -63,26 +63,18 @@ const std::unique_ptr<PlaygroundImpl>& 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<std::string> 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<std::string> 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<Texture> GoldenPlaygroundTest::CreateTextureForFixture(
const char* fixture_name,
bool enable_mipmapping) const {

View File

@@ -40,7 +40,7 @@ FONT_SUBSET_DIR = os.path.join(BUILDROOT_DIR, 'flutter', 'tools', 'font_subset')
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()