diff --git a/bin/cache/engine.version b/bin/cache/engine.version index 647c58715ec..989a3843063 100644 --- a/bin/cache/engine.version +++ b/bin/cache/engine.version @@ -1 +1 @@ -e9dd3e4e0dfb4fb6458ad5fde4218a3096022837 +e4121f80a9695d3f18e7d68e32ad60fc0a8f01b4 diff --git a/examples/layers/raw/canvas.dart b/examples/layers/raw/canvas.dart index bbf861c039f..0f3607eebb1 100644 --- a/examples/layers/raw/canvas.dart +++ b/examples/layers/raw/canvas.dart @@ -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); diff --git a/examples/layers/raw/hello_world.dart b/examples/layers/raw/hello_world.dart index b4dc2324000..a7e4a26de9c 100644 --- a/examples/layers/raw/hello_world.dart +++ b/examples/layers/raw/hello_world.dart @@ -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.'); diff --git a/examples/layers/raw/spinning_square.dart b/examples/layers/raw/spinning_square.dart index 24b3e737173..cae6eb0c9e8 100644 --- a/examples/layers/raw/spinning_square.dart +++ b/examples/layers/raw/spinning_square.dart @@ -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); diff --git a/examples/layers/raw/text.dart b/examples/layers/raw/text.dart index e8c36fba1e7..35c49dec08e 100644 --- a/examples/layers/raw/text.dart +++ b/examples/layers/raw/text.dart @@ -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); diff --git a/examples/layers/raw/touch_input.dart b/examples/layers/raw/touch_input.dart index b8569bf918f..7ee47f48aa9 100644 --- a/examples/layers/raw/touch_input.dart +++ b/examples/layers/raw/touch_input.dart @@ -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. diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart index feea6a40aa1..00748c04d28 100644 --- a/examples/stocks/test/icon_color_test.dart +++ b/examples/stocks/test/icon_color_test.dart @@ -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); diff --git a/packages/flutter/lib/src/gestures/binding.dart b/packages/flutter/lib/src/gestures/binding.dart index ee5517bde82..4af673179db 100644 --- a/packages/flutter/lib/src/gestures/binding.dart +++ b/packages/flutter/lib/src/gestures/binding.dart @@ -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(); } diff --git a/packages/flutter/lib/src/gestures/converter.dart b/packages/flutter/lib/src/gestures/converter.dart index 0a273ae1af8..e688cb687c1 100644 --- a/packages/flutter/lib/src/gestures/converter.dart +++ b/packages/flutter/lib/src/gestures/converter.dart @@ -37,9 +37,9 @@ class PointerEventConverter { static Map _pointers = {}; /// Expand the given packet of pointer data into a sequence of framework pointer events. - static Iterable expand(Iterable packet) sync* { + static Iterable expand(Iterable 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]; diff --git a/packages/flutter/lib/src/painting/edge_insets.dart b/packages/flutter/lib/src/painting/edge_insets.dart index a4a42727217..107499f3907 100644 --- a/packages/flutter/lib/src/painting/edge_insets.dart +++ b/packages/flutter/lib/src/painting/edge_insets.dart @@ -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; diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index f3368b2499a..2b29566aa1e 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -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, diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index 699b4aeb088..4e407409441 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -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 ); } diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index 743b9126605..248c9d657d3 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -171,8 +171,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin @override void debugFillDescription(List 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)'); } } diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index 1bf38f06b62..4d12659ea42 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -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). /// diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index cb5dbd54b5c..0da43eb10e7 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -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)'); }); } diff --git a/packages/flutter/test/widget/media_query_test.dart b/packages/flutter/test/widget/media_query_test.dart index 16bd426da5f..bba1c7ab4bf 100644 --- a/packages/flutter/test/widget/media_query_test.dart +++ b/packages/flutter/test/widget/media_query_test.dart @@ -20,6 +20,6 @@ void main() { ) ); - expect(size, equals(ui.window.size)); + expect(size, equals(ui.window.physicalSize / ui.window.devicePixelRatio)); }); } diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index ae6a18db1f3..4f4385386e8 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -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;