Skip to content

Commit 7ecb50a

Browse files
[fuchsia] Fix precision errors occuring in layer tree frame size. (flutter#33669)
This PR fixes the precision error which occurs when casting a double to int32, causing an incorrect physical display size to be propagated in the layer tree ultimately causing input events on the left edge of the display to be dropped.
1 parent 4227f6d commit 7ecb50a

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

shell/platform/fuchsia/flutter/gfx_platform_view.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,19 @@ void GfxPlatformView::OnScenicEvent(
232232
const float pixel_ratio = *view_pixel_ratio_;
233233
const std::array<float, 2> logical_size = *view_logical_size_;
234234
SetViewportMetrics({
235-
pixel_ratio, // device_pixel_ratio
236-
logical_size[0] * pixel_ratio, // physical_width
237-
logical_size[1] * pixel_ratio, // physical_height
238-
0.0f, // physical_padding_top
239-
0.0f, // physical_padding_right
240-
0.0f, // physical_padding_bottom
241-
0.0f, // physical_padding_left
242-
0.0f, // physical_view_inset_top
243-
0.0f, // physical_view_inset_right
244-
0.0f, // physical_view_inset_bottom
245-
0.0f, // physical_view_inset_left
246-
0.0f, // p_physical_system_gesture_inset_top
247-
0.0f, // p_physical_system_gesture_inset_right
235+
pixel_ratio, // device_pixel_ratio
236+
std::round(logical_size[0] * pixel_ratio), // physical_width
237+
std::round(logical_size[1] * pixel_ratio), // physical_height
238+
0.0f, // physical_padding_top
239+
0.0f, // physical_padding_right
240+
0.0f, // physical_padding_bottom
241+
0.0f, // physical_padding_left
242+
0.0f, // physical_view_inset_top
243+
0.0f, // physical_view_inset_right
244+
0.0f, // physical_view_inset_bottom
245+
0.0f, // physical_view_inset_left
246+
0.0f, // p_physical_system_gesture_inset_top
247+
0.0f, // p_physical_system_gesture_inset_right
248248
0.0f, // p_physical_system_gesture_inset_bottom
249249
0.0f, // p_physical_system_gesture_inset_left,
250250
-1.0, // p_physical_touch_slop,

shell/platform/fuchsia/flutter/platform_view_unittest.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,11 @@ TEST_F(PlatformViewTests, SetViewportMetrics) {
632632
})));
633633
session_listener->OnScenicEvent(std::move(events));
634634
RunLoopUntilIdle();
635-
EXPECT_EQ(delegate.metrics(),
636-
flutter::ViewportMetrics(
637-
valid_pixel_ratio, valid_pixel_ratio * valid_max_bound,
638-
valid_pixel_ratio * valid_max_bound, -1.0));
635+
EXPECT_EQ(
636+
delegate.metrics(),
637+
flutter::ViewportMetrics(
638+
valid_pixel_ratio, std::round(valid_pixel_ratio * valid_max_bound),
639+
std::round(valid_pixel_ratio * valid_max_bound), -1.0));
639640
}
640641

641642
// This test makes sure that the PlatformView correctly registers semantics

0 commit comments

Comments
 (0)