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

[Impeller] Turn on golden tests that use the ImGui widgets functions #50606

Merged
merged 2 commits into from
Feb 13, 2024
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
7 changes: 0 additions & 7 deletions impeller/golden_tests/golden_playground_test_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ 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(GaussianBlurAnimatedBackdrop),
IMP_AIKSTEST(CanRenderBackdropBlurInteractive),
IMP_AIKSTEST(ClippedBlurFilterRendersCorrectlyInteractive),
IMP_AIKSTEST(GradientStrokesRenderCorrectly),
IMP_AIKSTEST(SolidStrokesRenderCorrectly),
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),
Expand Down
81 changes: 43 additions & 38 deletions impeller/playground/widgets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,43 @@
namespace impeller {

Point DrawPlaygroundPoint(PlaygroundPoint& point) {
impeller::Point mouse_pos(ImGui::GetMousePos().x, ImGui::GetMousePos().y);
if (!point.prev_mouse_pos.has_value()) {
point.prev_mouse_pos = mouse_pos;
}
if (ImGui::GetCurrentContext()) {
impeller::Point mouse_pos(ImGui::GetMousePos().x, ImGui::GetMousePos().y);
if (!point.prev_mouse_pos.has_value()) {
point.prev_mouse_pos = mouse_pos;
}

if (ImGui::IsKeyPressed(ImGuiKey_R)) {
point.position = point.reset_position;
point.dragging = false;
}
if (ImGui::IsKeyPressed(ImGuiKey_R)) {
point.position = point.reset_position;
point.dragging = false;
}

bool hovering =
point.position.GetDistance(mouse_pos) < point.radius &&
point.position.GetDistance(point.prev_mouse_pos.value()) < point.radius;
if (!ImGui::IsMouseDown(0)) {
point.dragging = false;
} else if (hovering && ImGui::IsMouseClicked(0)) {
point.dragging = true;
}
if (point.dragging) {
point.position += mouse_pos - point.prev_mouse_pos.value();
}
ImGui::GetBackgroundDrawList()->AddCircleFilled(
{point.position.x, point.position.y}, point.radius,
ImColor(point.color.red, point.color.green, point.color.blue,
(hovering || point.dragging) ? 0.6f : 0.3f));
if (hovering || point.dragging) {
ImGui::GetBackgroundDrawList()->AddText(
{point.position.x - point.radius, point.position.y + point.radius + 10},
ImColor(point.color.red, point.color.green, point.color.blue, 1.0f),
impeller::SPrintF("x:%0.3f y:%0.3f", point.position.x, point.position.y)
.c_str());
bool hovering =
point.position.GetDistance(mouse_pos) < point.radius &&
point.position.GetDistance(point.prev_mouse_pos.value()) < point.radius;
if (!ImGui::IsMouseDown(0)) {
point.dragging = false;
} else if (hovering && ImGui::IsMouseClicked(0)) {
point.dragging = true;
}
if (point.dragging) {
point.position += mouse_pos - point.prev_mouse_pos.value();
}
ImGui::GetBackgroundDrawList()->AddCircleFilled(
{point.position.x, point.position.y}, point.radius,
ImColor(point.color.red, point.color.green, point.color.blue,
(hovering || point.dragging) ? 0.6f : 0.3f));
if (hovering || point.dragging) {
ImGui::GetBackgroundDrawList()->AddText(
{point.position.x - point.radius,
point.position.y + point.radius + 10},
ImColor(point.color.red, point.color.green, point.color.blue, 1.0f),
impeller::SPrintF("x:%0.3f y:%0.3f", point.position.x,
point.position.y)
.c_str());
}
point.prev_mouse_pos = mouse_pos;
}
point.prev_mouse_pos = mouse_pos;
return point.position;
}

Expand All @@ -48,14 +52,15 @@ std::tuple<Point, Point> DrawPlaygroundLine(PlaygroundPoint& point_a,
Point position_a = DrawPlaygroundPoint(point_a);
Point position_b = DrawPlaygroundPoint(point_b);

auto dir = (position_b - position_a).Normalize() * point_a.radius;
auto line_a = position_a + dir;
auto line_b = position_b - dir;
ImGui::GetBackgroundDrawList()->AddLine(
{line_a.x, line_a.y}, {line_b.x, line_b.y},
ImColor(point_b.color.red, point_b.color.green, point_b.color.blue,
0.3f));

if (ImGui::GetCurrentContext()) {
auto dir = (position_b - position_a).Normalize() * point_a.radius;
auto line_a = position_a + dir;
auto line_b = position_b - dir;
ImGui::GetBackgroundDrawList()->AddLine(
{line_a.x, line_a.y}, {line_b.x, line_b.y},
ImColor(point_b.color.red, point_b.color.green, point_b.color.blue,
0.3f));
}
return std::make_tuple(position_a, position_b);
}
//
Expand Down
2 changes: 1 addition & 1 deletion testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 578
_NUM_EXPECTED_GENERATED_IMPELLER_GOLDEN_FILES = 599

logger = logging.getLogger(__name__)
logger_handler = logging.StreamHandler()
Expand Down