From a7e49f60307c40ac438aaad35bdd97b71ecc20af Mon Sep 17 00:00:00 2001 From: Shivesh Ganju Date: Thu, 27 Oct 2022 17:46:19 -0400 Subject: [PATCH] [fuchsia][scenic] Fix logical size in flatland platform view. (flutter/engine#37053) This PR fixes a bug identified after DPR feature was added in flatland where currently we do not multiple the logical size of the view by the pixel ratio. This change is getting tested in input tests like mouse-input-test, touch-input-test --- .../fuchsia/flutter/flatland_platform_view.cc | 40 ++++++++++--------- .../tests/flatland_platform_view_unittest.cc | 3 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/flatland_platform_view.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/flatland_platform_view.cc index 52c7b1bf55..0373c6ace6 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/flatland_platform_view.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/flatland_platform_view.cc @@ -84,25 +84,27 @@ void FlatlandPlatformView::OnGetLayout( } SetViewportMetrics({ - pixel_ratio, // device_pixel_ratio - view_logical_size_.value()[0], // physical_width - view_logical_size_.value()[1], // physical_height - 0.0f, // physical_padding_top - 0.0f, // physical_padding_right - 0.0f, // physical_padding_bottom - 0.0f, // physical_padding_left - 0.0f, // physical_view_inset_top - 0.0f, // physical_view_inset_right - 0.0f, // physical_view_inset_bottom - 0.0f, // physical_view_inset_left - 0.0f, // p_physical_system_gesture_inset_top - 0.0f, // p_physical_system_gesture_inset_right - 0.0f, // p_physical_system_gesture_inset_bottom - 0.0f, // p_physical_system_gesture_inset_left, - -1.0, // p_physical_touch_slop, - {}, // p_physical_display_features_bounds - {}, // p_physical_display_features_type - {}, // p_physical_display_features_state + pixel_ratio, // device_pixel_ratio + std::round(view_logical_size_.value()[0] * + pixel_ratio), // physical_width + std::round(view_logical_size_.value()[1] * + pixel_ratio), // physical_height + 0.0f, // physical_padding_top + 0.0f, // physical_padding_right + 0.0f, // physical_padding_bottom + 0.0f, // physical_padding_left + 0.0f, // physical_view_inset_top + 0.0f, // physical_view_inset_right + 0.0f, // physical_view_inset_bottom + 0.0f, // physical_view_inset_left + 0.0f, // p_physical_system_gesture_inset_top + 0.0f, // p_physical_system_gesture_inset_right + 0.0f, // p_physical_system_gesture_inset_bottom + 0.0f, // p_physical_system_gesture_inset_left, + -1.0, // p_physical_touch_slop, + {}, // p_physical_display_features_bounds + {}, // p_physical_display_features_type + {}, // p_physical_display_features_state }); parent_viewport_watcher_->GetLayout( diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc index cde88fd84d..7fe9ed6485 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc @@ -672,7 +672,8 @@ TEST_F(FlatlandPlatformViewTests, SetViewportMetrics) { watcher.SetLayout(width, height, kDPR); RunLoopUntilIdle(); EXPECT_EQ(delegate.metrics(), - flutter::ViewportMetrics(kDPR, width, height, -1.0)); + flutter::ViewportMetrics(kDPR, std::round(width * kDPR), + std::round(height * kDPR), -1.0)); } // This test makes sure that the PlatformView correctly registers semantics