From 1ea1839f3ec485684eb544dab87c1b32a32eb393 Mon Sep 17 00:00:00 2001 From: shivesh-ganju Date: Wed, 26 Oct 2022 17:11:13 -0400 Subject: [PATCH] [fuchsia][scenic] Fix logical size in flatland platform view. 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/shell/platform/fuchsia/flutter/flatland_platform_view.cc b/shell/platform/fuchsia/flutter/flatland_platform_view.cc index 52c7b1bf556a9..0373c6ace6f23 100644 --- a/shell/platform/fuchsia/flutter/flatland_platform_view.cc +++ b/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/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc b/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc index cde88fd84d0d4..7fe9ed64853b4 100644 --- a/shell/platform/fuchsia/flutter/tests/flatland_platform_view_unittest.cc +++ b/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