From 6432ce942bd9d6b5483084da075b68353ca7a8fd Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 13 Feb 2024 10:36:53 -0800 Subject: [PATCH 1/2] [Impeller] removed more golden test exemptions --- .../golden_playground_test_mac.cc | 7 -- impeller/playground/widgets.cc | 81 ++++++++++--------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/impeller/golden_tests/golden_playground_test_mac.cc b/impeller/golden_tests/golden_playground_test_mac.cc index 1d124a7c38a40..f6d0246448ecf 100644 --- a/impeller/golden_tests/golden_playground_test_mac.cc +++ b/impeller/golden_tests/golden_playground_test_mac.cc @@ -63,13 +63,6 @@ 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(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), diff --git a/impeller/playground/widgets.cc b/impeller/playground/widgets.cc index b1fd5cd145b9b..62122996c6b9e 100644 --- a/impeller/playground/widgets.cc +++ b/impeller/playground/widgets.cc @@ -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; } @@ -48,14 +52,15 @@ std::tuple 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); } // From c6cd69f5f27ed16df8d3a07c9f7f126a5709fd83 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 13 Feb 2024 11:03:17 -0800 Subject: [PATCH 2/2] updated golden count --- testing/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index bd3712d63f339..5dbbae7d246a2 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 = 578 +_NUM_EXPECTED_GENERATED_IMPELLER_GOLDEN_FILES = 599 logger = logging.getLogger(__name__) logger_handler = logging.StreamHandler()