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);
|
||||
double radius = size.shortestSide / 2.0;
|
||||
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||
|
||||
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(
|
||||
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);
|
||||
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) {
|
||||
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.Scene scene = composite(picture, paintBounds);
|
||||
ui.window.render(scene);
|
||||
|
@ -9,8 +9,7 @@ import 'dart:ui' as ui;
|
||||
|
||||
void beginFrame(Duration timeStamp) {
|
||||
final double devicePixelRatio = ui.window.devicePixelRatio;
|
||||
// TODO(abarth): ui.window.size should be in physical units.
|
||||
final ui.Size logicalSize = ui.window.size;
|
||||
final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio;
|
||||
|
||||
final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder()
|
||||
..addText('Hello, world.');
|
||||
|
@ -19,7 +19,7 @@ void beginFrame(Duration timeStamp) {
|
||||
|
||||
// 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.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
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.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),
|
||||
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) {
|
||||
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.Scene scene = composite(picture, paintBounds);
|
||||
ui.window.render(scene);
|
||||
|
@ -71,7 +71,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
}
|
||||
|
||||
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.
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
// Second, include that picture in a scene graph.
|
||||
|
@ -64,8 +64,8 @@ void main() {
|
||||
expect(find.text('Account Balance'), findsNothing);
|
||||
|
||||
// drag the drawer out
|
||||
Point left = new Point(0.0, ui.window.size.height / 2.0);
|
||||
Point right = new Point(ui.window.size.width, left.y);
|
||||
Point left = new Point(0.0, ui.window.physicalSize.height / 2.0);
|
||||
Point right = new Point(ui.window.physicalSize.width, left.y);
|
||||
TestGesture gesture = await tester.startGesture(left);
|
||||
await tester.pump();
|
||||
await gesture.moveTo(right);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user