mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Update framework to account from engine API changes (#5887)
The engine now reports coordinates in physical pixels.
This commit is contained in:
parent
9109bb02b9
commit
179ea4a0a6
2
bin/cache/engine.version
vendored
2
bin/cache/engine.version
vendored
@ -1 +1 @@
|
|||||||
e9dd3e4e0dfb4fb6458ad5fde4218a3096022837
|
e4121f80a9695d3f18e7d68e32ad60fc0a8f01b4
|
||||||
|
@ -29,10 +29,13 @@ ui.Picture paint(ui.Rect paintBounds) {
|
|||||||
ui.Point mid = size.center(ui.Point.origin);
|
ui.Point mid = size.center(ui.Point.origin);
|
||||||
double radius = size.shortestSide / 2.0;
|
double radius = size.shortestSide / 2.0;
|
||||||
|
|
||||||
|
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||||
|
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||||
|
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(-mid.x/2.0, ui.window.size.height*2.0);
|
canvas.translate(-mid.x/2.0, logicalSize.height*2.0);
|
||||||
canvas.clipRect(
|
canvas.clipRect(
|
||||||
new ui.Rect.fromLTRB(0.0, -ui.window.size.height, ui.window.size.width, radius));
|
new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius));
|
||||||
|
|
||||||
canvas.translate(mid.x, mid.y);
|
canvas.translate(mid.x, mid.y);
|
||||||
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
|
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
|
||||||
@ -82,7 +85,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
void beginFrame(Duration timeStamp) {
|
||||||
ui.Rect paintBounds = ui.Point.origin & ui.window.size;
|
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
|
||||||
ui.Picture picture = paint(paintBounds);
|
ui.Picture picture = paint(paintBounds);
|
||||||
ui.Scene scene = composite(picture, paintBounds);
|
ui.Scene scene = composite(picture, paintBounds);
|
||||||
ui.window.render(scene);
|
ui.window.render(scene);
|
||||||
|
@ -9,8 +9,7 @@ import 'dart:ui' as ui;
|
|||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
void beginFrame(Duration timeStamp) {
|
||||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||||
// TODO(abarth): ui.window.size should be in physical units.
|
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||||
final ui.Size logicalSize = ui.window.size;
|
|
||||||
|
|
||||||
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder()
|
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder()
|
||||||
..addText('Hello, world.');
|
..addText('Hello, world.');
|
||||||
|
@ -19,7 +19,7 @@ void beginFrame(Duration timeStamp) {
|
|||||||
|
|
||||||
// PAINT
|
// PAINT
|
||||||
|
|
||||||
ui.Rect paintBounds = ui.Point.origin & ui.window.size;
|
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
|
||||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||||
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
||||||
|
@ -15,7 +15,10 @@ ui.Picture paint(ui.Rect paintBounds) {
|
|||||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||||
|
|
||||||
canvas.translate(ui.window.size.width / 2.0, ui.window.size.height / 2.0);
|
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||||
|
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||||
|
|
||||||
|
canvas.translate(logicalSize.width / 2.0, logicalSize.height / 2.0);
|
||||||
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||||
|
|
||||||
@ -41,7 +44,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
void beginFrame(Duration timeStamp) {
|
||||||
ui.Rect paintBounds = ui.Point.origin & ui.window.size;
|
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
|
||||||
ui.Picture picture = paint(paintBounds);
|
ui.Picture picture = paint(paintBounds);
|
||||||
ui.Scene scene = composite(picture, paintBounds);
|
ui.Scene scene = composite(picture, paintBounds);
|
||||||
ui.window.render(scene);
|
ui.window.render(scene);
|
||||||
|
@ -71,7 +71,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void beginFrame(Duration timeStamp) {
|
void beginFrame(Duration timeStamp) {
|
||||||
ui.Rect paintBounds = ui.Point.origin & ui.window.size;
|
ui.Rect paintBounds = ui.Point.origin & (ui.window.physicalSize / ui.window.devicePixelRatio);
|
||||||
// First, record a picture with our painting commands.
|
// First, record a picture with our painting commands.
|
||||||
ui.Picture picture = paint(paintBounds);
|
ui.Picture picture = paint(paintBounds);
|
||||||
// Second, include that picture in a scene graph.
|
// Second, include that picture in a scene graph.
|
||||||
|
@ -64,8 +64,8 @@ void main() {
|
|||||||
expect(find.text('Account Balance'), findsNothing);
|
expect(find.text('Account Balance'), findsNothing);
|
||||||
|
|
||||||
// drag the drawer out
|
// drag the drawer out
|
||||||
Point left = new Point(0.0, ui.window.size.height / 2.0);
|
Point left = new Point(0.0, ui.window.physicalSize.height / 2.0);
|
||||||
Point right = new Point(ui.window.size.width, left.y);
|
Point right = new Point(ui.window.physicalSize.width, left.y);
|
||||||
TestGesture gesture = await tester.startGesture(left);
|
TestGesture gesture = await tester.startGesture(left);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await gesture.moveTo(right);
|
await gesture.moveTo(right);
|
||||||
|
@ -40,7 +40,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
final PointerPacket packet = PointerPacket.deserialize(message);
|
final PointerPacket packet = PointerPacket.deserialize(message);
|
||||||
_pendingPointerEvents.addAll(PointerEventConverter.expand(packet.pointers));
|
_pendingPointerEvents.addAll(PointerEventConverter.expand(packet.pointers, ui.window.devicePixelRatio));
|
||||||
_flushPointerEventQueue();
|
_flushPointerEventQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ class PointerEventConverter {
|
|||||||
static Map<int, _PointerState> _pointers = <int, _PointerState>{};
|
static Map<int, _PointerState> _pointers = <int, _PointerState>{};
|
||||||
|
|
||||||
/// Expand the given packet of pointer data into a sequence of framework pointer events.
|
/// 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) {
|
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);
|
Duration timeStamp = new Duration(microseconds: datum.timeStamp);
|
||||||
assert(_pointerKindMap.containsKey(datum.kind));
|
assert(_pointerKindMap.containsKey(datum.kind));
|
||||||
PointerDeviceKind kind = _pointerKindMap[datum.kind];
|
PointerDeviceKind kind = _pointerKindMap[datum.kind];
|
||||||
|
@ -41,8 +41,11 @@ class EdgeInsets {
|
|||||||
: left = horizontal, top = vertical, right = horizontal, bottom = vertical;
|
: left = horizontal, top = vertical, right = horizontal, bottom = vertical;
|
||||||
|
|
||||||
/// Creates insets that match the given window padding.
|
/// Creates insets that match the given window padding.
|
||||||
EdgeInsets.fromWindowPadding(ui.WindowPadding padding)
|
EdgeInsets.fromWindowPadding(ui.WindowPadding padding, double devicePixelRatio)
|
||||||
: left = padding.left, top = padding.top, right = padding.right, bottom = padding.bottom;
|
: left = padding.left / devicePixelRatio,
|
||||||
|
top = padding.top / devicePixelRatio,
|
||||||
|
right = padding.right / devicePixelRatio,
|
||||||
|
bottom = padding.bottom / devicePixelRatio;
|
||||||
|
|
||||||
/// The offset from the left.
|
/// The offset from the left.
|
||||||
final double 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).
|
/// The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
|
||||||
final double wordSpacing;
|
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;
|
final TextBaseline textBaseline;
|
||||||
|
|
||||||
/// The height of this text span, as a multiple of the font size.
|
/// The height of this text span, as a multiple of the font size.
|
||||||
@ -213,6 +213,7 @@ class TextStyle {
|
|||||||
decorationStyle: decorationStyle,
|
decorationStyle: decorationStyle,
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
fontStyle: fontStyle,
|
fontStyle: fontStyle,
|
||||||
|
textBaseline: textBaseline,
|
||||||
fontFamily: fontFamily,
|
fontFamily: fontFamily,
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
letterSpacing: letterSpacing,
|
letterSpacing: letterSpacing,
|
||||||
@ -225,7 +226,6 @@ class TextStyle {
|
|||||||
ui.ParagraphStyle getParagraphStyle({ TextAlign textAlign }) {
|
ui.ParagraphStyle getParagraphStyle({ TextAlign textAlign }) {
|
||||||
return new ui.ParagraphStyle(
|
return new ui.ParagraphStyle(
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
textBaseline: textBaseline,
|
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
fontStyle: fontStyle,
|
fontStyle: fontStyle,
|
||||||
fontFamily: fontFamily,
|
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
|
/// this to force the display into 800x600 when a test is run on the device
|
||||||
/// using `flutter run`.
|
/// using `flutter run`.
|
||||||
ViewConfiguration createViewConfiguration() {
|
ViewConfiguration createViewConfiguration() {
|
||||||
|
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||||
return new ViewConfiguration(
|
return new ViewConfiguration(
|
||||||
size: ui.window.size,
|
size: ui.window.physicalSize / devicePixelRatio,
|
||||||
devicePixelRatio: ui.window.devicePixelRatio
|
devicePixelRatio: devicePixelRatio
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +171,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
@override
|
@override
|
||||||
void debugFillDescription(List<String> description) {
|
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
|
// 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('window size: ${ui.window.physicalSize} (in physical pixels)');
|
||||||
description.add('device pixel ratio: ${ui.window.devicePixelRatio} (device pixels per logical pixel)');
|
description.add('device pixel ratio: ${ui.window.devicePixelRatio} (physical pixels per logical pixel)');
|
||||||
description.add('configuration: $configuration (in logical pixels)');
|
description.add('configuration: $configuration (in logical pixels)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ class MediaQueryData {
|
|||||||
|
|
||||||
/// Creates data for a media query based on the given window.
|
/// Creates data for a media query based on the given window.
|
||||||
MediaQueryData.fromWindow(ui.Window window)
|
MediaQueryData.fromWindow(ui.Window window)
|
||||||
: size = window.size,
|
: size = window.physicalSize / window.devicePixelRatio,
|
||||||
devicePixelRatio = 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).
|
/// 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;
|
ui.TextStyle ts5 = s5.textStyle;
|
||||||
expect(ts5, equals(new ui.TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0)));
|
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;
|
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, 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);
|
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, 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();
|
ui.ParagraphStyle ps5 = s5.getParagraphStyle();
|
||||||
expect(ps5, equals(new ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0)));
|
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);
|
super(size: size);
|
||||||
|
|
||||||
static Matrix4 _getMatrix(Size size, double devicePixelRatio) {
|
static Matrix4 _getMatrix(Size size, double devicePixelRatio) {
|
||||||
final double actualWidth = ui.window.size.width * devicePixelRatio;
|
final double actualWidth = ui.window.physicalSize.width;
|
||||||
final double actualHeight = ui.window.size.height * devicePixelRatio;
|
final double actualHeight = ui.window.physicalSize.height;
|
||||||
final double desiredWidth = size.width;
|
final double desiredWidth = size.width;
|
||||||
final double desiredHeight = size.height;
|
final double desiredHeight = size.height;
|
||||||
double scale, shiftX, shiftY;
|
double scale, shiftX, shiftY;
|
||||||
|
Loading…
Reference in New Issue
Block a user