Reverts "Remove physical geometry" (flutter/engine#47862)

Reverts flutter/engine#47825
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
Looks like this was proactively added in https://github.com/flutter/engine/pull/20496, but never wired up to anything on any platform. It is also unused in framework and customer code; we never exposed this on e.g. MediaQuery.

Related framework PR: https://github.com/flutter/flutter/pull/138103 (Checks will fail until that PR is submitted).
This commit is contained in:
auto-submit[bot]
2023-11-09 16:06:19 +00:00
committed by GitHub
parent c378306ada
commit aa4fb605c3
7 changed files with 38 additions and 8 deletions

View File

@@ -135,7 +135,7 @@ _ViewConfiguration _buildViewConfiguration(
) {
return _ViewConfiguration(
devicePixelRatio: devicePixelRatio,
size: Size(width, height),
geometry: Rect.fromLTWH(0.0, 0.0, width, height),
viewPadding: ViewPadding._(
top: viewPaddingTop,
right: viewPaddingRight,

View File

@@ -1462,7 +1462,7 @@ class _PlatformConfiguration {
class _ViewConfiguration {
const _ViewConfiguration({
this.devicePixelRatio = 1.0,
this.size = Size.zero,
this.geometry = Rect.zero,
this.viewInsets = ViewPadding.zero,
this.viewPadding = ViewPadding.zero,
this.systemGestureInsets = ViewPadding.zero,
@@ -1479,8 +1479,9 @@ class _ViewConfiguration {
/// The pixel density of the output surface.
final double devicePixelRatio;
/// The size requested for the view in logical pixels.
final Size size;
/// The geometry requested for the view on the screen or within its parent
/// window, in logical pixels.
final Rect geometry;
/// The number of physical pixels on each side of the display rectangle into
/// which the view can render, but over which the operating system will likely
@@ -1550,7 +1551,7 @@ class _ViewConfiguration {
@override
String toString() {
return '$runtimeType[size: $size]';
return '$runtimeType[geometry: $geometry]';
}
}

View File

@@ -138,6 +138,25 @@ class FlutterView {
/// The value here is equal to the value exposed on [display].
double get devicePixelRatio => _viewConfiguration.devicePixelRatio;
/// The dimensions and location of the rectangle into which the scene rendered
/// in this view will be drawn on the screen, in physical pixels.
///
/// When this changes, [PlatformDispatcher.onMetricsChanged] is called.
///
/// At startup, the size and location of the view may not be known before Dart
/// code runs. If this value is observed early in the application lifecycle,
/// it may report [Rect.zero].
///
/// This value does not take into account any on-screen keyboards or other
/// system UI. The [padding] and [viewInsets] properties provide a view into
/// how much of each side of the view may be obscured by system UI.
///
/// See also:
///
/// * [WidgetsBindingObserver], for a mechanism at the widgets layer to
/// observe when this value changes.
Rect get physicalGeometry => _viewConfiguration.geometry;
/// The dimensions of the rectangle into which the scene rendered in this view
/// will be drawn on the screen, in physical pixels.
///
@@ -160,9 +179,11 @@ class FlutterView {
///
/// See also:
///
/// * [physicalGeometry], which reports the location of the view as well as
/// its size.
/// * [WidgetsBindingObserver], for a mechanism at the widgets layer to
/// observe when this value changes.
Size get physicalSize => _viewConfiguration.size;
Size get physicalSize => _viewConfiguration.geometry.size;
/// The number of physical pixels on each side of the display rectangle into
/// which the view can render, but over which the operating system will likely

View File

@@ -1340,6 +1340,7 @@ class ViewConfiguration {
const ViewConfiguration({
this.view,
this.devicePixelRatio = 1.0,
this.geometry = ui.Rect.zero,
this.visible = false,
this.viewInsets = ui.ViewPadding.zero as ViewPadding,
this.viewPadding = ui.ViewPadding.zero as ViewPadding,
@@ -1352,6 +1353,7 @@ class ViewConfiguration {
ViewConfiguration copyWith({
EngineFlutterView? view,
double? devicePixelRatio,
ui.Rect? geometry,
bool? visible,
ViewPadding? viewInsets,
ViewPadding? viewPadding,
@@ -1363,6 +1365,7 @@ class ViewConfiguration {
return ViewConfiguration(
view: view ?? this.view,
devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio,
geometry: geometry ?? this.geometry,
visible: visible ?? this.visible,
viewInsets: viewInsets ?? this.viewInsets,
viewPadding: viewPadding ?? this.viewPadding,
@@ -1375,6 +1378,7 @@ class ViewConfiguration {
final EngineFlutterView? view;
final double devicePixelRatio;
final ui.Rect geometry;
final bool visible;
final ViewPadding viewInsets;
final ViewPadding viewPadding;
@@ -1385,7 +1389,7 @@ class ViewConfiguration {
@override
String toString() {
return '$runtimeType[view: $view]';
return '$runtimeType[view: $view, geometry: $geometry]';
}
}

View File

@@ -73,6 +73,9 @@ base class EngineFlutterView implements ui.FlutterView {
late final PlatformViewMessageHandler platformViewMessageHandler =
PlatformViewMessageHandler(platformViewsContainer: dom.platformViewsHost);
@override
ui.Rect get physicalGeometry => _viewConfiguration.geometry;
@override
ui.Size get physicalSize {
if (_physicalSize == null) {

View File

@@ -15,6 +15,7 @@ abstract class FlutterView {
PlatformDispatcher get platformDispatcher;
int get viewId;
double get devicePixelRatio;
Rect get physicalGeometry;
Size get physicalSize;
ViewPadding get viewInsets;
ViewPadding get viewPadding;

View File

@@ -530,7 +530,7 @@ List<int> getCurrentViewWidths() {
final List<int> result = <int>[];
for (final FlutterView view in PlatformDispatcher.instance.views) {
result.add(view.viewId);
result.add(view.physicalSize.width.round());
result.add(view.physicalGeometry.width.round());
}
return result;
}