Update framework to account from engine API changes (#5887)
The engine now reports coordinates in physical pixels.
This commit is contained in:
@@ -40,7 +40,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
|
||||
0
|
||||
);
|
||||
final PointerPacket packet = PointerPacket.deserialize(message);
|
||||
_pendingPointerEvents.addAll(PointerEventConverter.expand(packet.pointers));
|
||||
_pendingPointerEvents.addAll(PointerEventConverter.expand(packet.pointers, ui.window.devicePixelRatio));
|
||||
_flushPointerEventQueue();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ class PointerEventConverter {
|
||||
static Map<int, _PointerState> _pointers = <int, _PointerState>{};
|
||||
|
||||
/// Expand the given packet of pointer data into a sequence of framework pointer events.
|
||||
static Iterable<PointerEvent> expand(Iterable<mojom.Pointer> packet) sync* {
|
||||
static Iterable<PointerEvent> expand(Iterable<mojom.Pointer> packet, double devicePixelRatio) sync* {
|
||||
for (mojom.Pointer datum in packet) {
|
||||
Point position = new Point(datum.x, datum.y);
|
||||
Point position = new Point(datum.x, datum.y) / devicePixelRatio;
|
||||
Duration timeStamp = new Duration(microseconds: datum.timeStamp);
|
||||
assert(_pointerKindMap.containsKey(datum.kind));
|
||||
PointerDeviceKind kind = _pointerKindMap[datum.kind];
|
||||
|
||||
@@ -41,8 +41,11 @@ class EdgeInsets {
|
||||
: left = horizontal, top = vertical, right = horizontal, bottom = vertical;
|
||||
|
||||
/// Creates insets that match the given window padding.
|
||||
EdgeInsets.fromWindowPadding(ui.WindowPadding padding)
|
||||
: left = padding.left, top = padding.top, right = padding.right, bottom = padding.bottom;
|
||||
EdgeInsets.fromWindowPadding(ui.WindowPadding padding, double devicePixelRatio)
|
||||
: left = padding.left / devicePixelRatio,
|
||||
top = padding.top / devicePixelRatio,
|
||||
right = padding.right / devicePixelRatio,
|
||||
bottom = padding.bottom / devicePixelRatio;
|
||||
|
||||
/// The offset from the left.
|
||||
final double left;
|
||||
|
||||
@@ -49,7 +49,7 @@ class TextStyle {
|
||||
/// The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
|
||||
final double wordSpacing;
|
||||
|
||||
/// The baseline to use for aligning the text.
|
||||
/// The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.
|
||||
final TextBaseline textBaseline;
|
||||
|
||||
/// The height of this text span, as a multiple of the font size.
|
||||
@@ -213,6 +213,7 @@ class TextStyle {
|
||||
decorationStyle: decorationStyle,
|
||||
fontWeight: fontWeight,
|
||||
fontStyle: fontStyle,
|
||||
textBaseline: textBaseline,
|
||||
fontFamily: fontFamily,
|
||||
fontSize: fontSize,
|
||||
letterSpacing: letterSpacing,
|
||||
@@ -225,7 +226,6 @@ class TextStyle {
|
||||
ui.ParagraphStyle getParagraphStyle({ TextAlign textAlign }) {
|
||||
return new ui.ParagraphStyle(
|
||||
textAlign: textAlign,
|
||||
textBaseline: textBaseline,
|
||||
fontWeight: fontWeight,
|
||||
fontStyle: fontStyle,
|
||||
fontFamily: fontFamily,
|
||||
|
||||
@@ -123,9 +123,10 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
|
||||
/// this to force the display into 800x600 when a test is run on the device
|
||||
/// using `flutter run`.
|
||||
ViewConfiguration createViewConfiguration() {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
return new ViewConfiguration(
|
||||
size: ui.window.size,
|
||||
devicePixelRatio: ui.window.devicePixelRatio
|
||||
size: ui.window.physicalSize / devicePixelRatio,
|
||||
devicePixelRatio: devicePixelRatio
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
||||
@override
|
||||
void debugFillDescription(List<String> description) {
|
||||
// call to ${super.debugFillDescription(prefix)} is omitted because the root superclasses don't include any interesting information for this class
|
||||
description.add('window size: ${ui.window.size} (in device pixels)');
|
||||
description.add('device pixel ratio: ${ui.window.devicePixelRatio} (device pixels per logical pixel)');
|
||||
description.add('window size: ${ui.window.physicalSize} (in physical pixels)');
|
||||
description.add('device pixel ratio: ${ui.window.devicePixelRatio} (physical pixels per logical pixel)');
|
||||
description.add('configuration: $configuration (in logical pixels)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ class MediaQueryData {
|
||||
|
||||
/// Creates data for a media query based on the given window.
|
||||
MediaQueryData.fromWindow(ui.Window window)
|
||||
: size = window.size,
|
||||
: size = window.physicalSize / window.devicePixelRatio,
|
||||
devicePixelRatio = window.devicePixelRatio,
|
||||
padding = new EdgeInsets.fromWindowPadding(window.padding);
|
||||
padding = new EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio);
|
||||
|
||||
/// The size of the media in logical pixel (e.g, the size of the screen).
|
||||
///
|
||||
|
||||
@@ -91,16 +91,16 @@ void main() {
|
||||
|
||||
ui.TextStyle ts5 = s5.textStyle;
|
||||
expect(ts5, equals(new ui.TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0)));
|
||||
expect(ts5.toString(), 'TextStyle(2336|color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, fontFamily: unspecified, fontSize: 12.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 123.0x)');
|
||||
expect(ts5.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 12.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 123.0x)');
|
||||
ui.TextStyle ts2 = s2.textStyle;
|
||||
expect(ts2, equals(new ui.TextStyle(color: const Color(0xFF00FF00), fontWeight: FontWeight.w800, fontSize: 10.0, height: 100.0)));
|
||||
expect(ts2.toString(), 'TextStyle(2338|color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, fontFamily: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x)');
|
||||
expect(ts2.toString(), 'TextStyle(color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x)');
|
||||
|
||||
ui.ParagraphStyle ps2 = s2.getParagraphStyle(textAlign: TextAlign.center);
|
||||
expect(ps2, equals(new ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, lineHeight: 100.0)));
|
||||
expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, textBaseline: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, fontFamily: unspecified, fontSize: 10.0, lineHeight: 100.0x)');
|
||||
expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontStyle: unspecified, fontFamily: unspecified, fontSize: 10.0, lineHeight: 100.0x)');
|
||||
ui.ParagraphStyle ps5 = s5.getParagraphStyle();
|
||||
expect(ps5, equals(new ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0)));
|
||||
expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, textBaseline: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, fontFamily: unspecified, fontSize: 12.0, lineHeight: 123.0x)');
|
||||
expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, fontFamily: unspecified, fontSize: 12.0, lineHeight: 123.0x)');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ void main() {
|
||||
)
|
||||
);
|
||||
|
||||
expect(size, equals(ui.window.size));
|
||||
expect(size, equals(ui.window.physicalSize / ui.window.devicePixelRatio));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -724,8 +724,8 @@ class TestViewConfiguration extends ViewConfiguration {
|
||||
super(size: size);
|
||||
|
||||
static Matrix4 _getMatrix(Size size, double devicePixelRatio) {
|
||||
final double actualWidth = ui.window.size.width * devicePixelRatio;
|
||||
final double actualHeight = ui.window.size.height * devicePixelRatio;
|
||||
final double actualWidth = ui.window.physicalSize.width;
|
||||
final double actualHeight = ui.window.physicalSize.height;
|
||||
final double desiredWidth = size.width;
|
||||
final double desiredHeight = size.height;
|
||||
double scale, shiftX, shiftY;
|
||||
|
||||
Reference in New Issue
Block a user