Skip to content

Commit e688732

Browse files
authored
Fix platform view offsets incorrectly taking into account device pixel ratios. (flutter#14135)
This issue was hidden by an incorrect test expectation that has been corrected. Fixes b/144555069 Fixes flutter#45991
1 parent 65b126b commit e688732

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

shell/platform/embedder/embedder_layers.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,15 @@ void EmbedderLayers::PushPlatformViewLayer(
184184
layer.type = kFlutterLayerContentTypePlatformView;
185185
layer.platform_view = platform_views_referenced_.back().get();
186186

187-
const auto layer_bounds = SkRect::MakeXYWH(params.offsetPixels.x(), //
188-
params.offsetPixels.y(), //
189-
params.sizePoints.width(), //
190-
params.sizePoints.height() //
191-
);
187+
const auto layer_bounds =
188+
SkRect::MakeXYWH(params.offsetPixels.x(), //
189+
params.offsetPixels.y(), //
190+
params.sizePoints.width() * device_pixel_ratio_, //
191+
params.sizePoints.height() * device_pixel_ratio_ //
192+
);
192193

193194
const auto transformed_layer_bounds =
194-
SkMatrix::Concat(root_surface_transformation_,
195-
SkMatrix::MakeScale(device_pixel_ratio_))
196-
.mapRect(layer_bounds);
195+
root_surface_transformation_.mapRect(layer_bounds);
197196

198197
layer.offset.x = transformed_layer_bounds.x();
199198
layer.offset.y = transformed_layer_bounds.y();

shell/platform/embedder/tests/embedder_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,7 @@ TEST_F(EmbedderTest,
28032803
layer.type = kFlutterLayerContentTypePlatformView;
28042804
layer.platform_view = &platform_view;
28052805
layer.size = FlutterSizeMake(800.0, 560.0);
2806-
layer.offset = FlutterPointMake(0.0, 80.0);
2806+
layer.offset = FlutterPointMake(0.0, 40.0);
28072807

28082808
ASSERT_EQ(*layers[1], layer);
28092809
}
@@ -2902,7 +2902,7 @@ TEST_F(
29022902
layer.type = kFlutterLayerContentTypePlatformView;
29032903
layer.platform_view = &platform_view;
29042904
layer.size = FlutterSizeMake(560.0, 800.0);
2905-
layer.offset = FlutterPointMake(80.0, 0.0);
2905+
layer.offset = FlutterPointMake(40.0, 0.0);
29062906

29072907
ASSERT_EQ(*layers[1], layer);
29082908
}

0 commit comments

Comments
 (0)