Commit 3373d0ba authored by Adam Barth's avatar Adam Barth

Switch clients from ui.view to ui.window

parent 02a1ebab
...@@ -21,8 +21,8 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -21,8 +21,8 @@ ui.Picture paint(ui.Rect paintBounds) {
} }
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -35,23 +35,23 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -35,23 +35,23 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
return sceneBuilder.build(); return sceneBuilder.build();
} }
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
ui.Picture picture = paint(paintBounds); ui.Picture picture = paint(paintBounds);
ui.Scene scene = composite(picture, paintBounds); ui.Scene scene = composite(picture, paintBounds);
ui.view.scene = scene; ui.window.render(scene);
} }
bool handleEvent(ui.Event event) { bool handleEvent(ui.Event event) {
if (event.type == 'pointerdown') { if (event.type == 'pointerdown') {
color = new ui.Color.fromARGB(255, 0, 0, 255); color = new ui.Color.fromARGB(255, 0, 0, 255);
ui.view.scheduleFrame(); ui.window.scheduleFrame();
return true; return true;
} }
if (event.type == 'pointerup') { if (event.type == 'pointerup') {
color = new ui.Color.fromARGB(255, 0, 255, 0); color = new ui.Color.fromARGB(255, 0, 255, 0);
ui.view.scheduleFrame(); ui.window.scheduleFrame();
return true; return true;
} }
...@@ -66,7 +66,7 @@ bool handleEvent(ui.Event event) { ...@@ -66,7 +66,7 @@ bool handleEvent(ui.Event event) {
void main() { void main() {
print('Hello, world'); print('Hello, world');
color = new ui.Color.fromARGB(255, 0, 255, 0); color = new ui.Color.fromARGB(255, 0, 255, 0);
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
ui.view.setEventCallback(handleEvent); ui.window.onEvent = handleEvent;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -17,9 +17,9 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -17,9 +17,9 @@ ui.Picture paint(ui.Rect paintBounds) {
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF)); canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
canvas.save(); canvas.save();
canvas.translate(-mid.x/2.0, ui.view.height*2.0); canvas.translate(-mid.x/2.0, ui.window.size.height*2.0);
canvas.clipRect( canvas.clipRect(
new ui.Rect.fromLTRB(0.0, -ui.view.height, ui.view.width, radius)); new ui.Rect.fromLTRB(0.0, -ui.window.size.height, ui.window.size.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);
...@@ -94,8 +94,8 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -94,8 +94,8 @@ ui.Picture paint(ui.Rect paintBounds) {
} }
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -108,14 +108,14 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -108,14 +108,14 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
return sceneBuilder.build(); return sceneBuilder.build();
} }
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
ui.Picture picture = paint(paintBounds); ui.Picture picture = paint(paintBounds);
ui.Scene scene = composite(picture, paintBounds); ui.Scene scene = composite(picture, paintBounds);
ui.view.scene = scene; ui.window.render(scene);
} }
void main() { void main() {
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -37,8 +37,8 @@ ui.Picture paint(ui.Rect paintBounds) { ...@@ -37,8 +37,8 @@ ui.Picture paint(ui.Rect paintBounds) {
} }
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -51,14 +51,14 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -51,14 +51,14 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
return sceneBuilder.build(); return sceneBuilder.build();
} }
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
ui.Picture picture = paint(paintBounds); ui.Picture picture = paint(paintBounds);
ui.Scene scene = composite(picture, paintBounds); ui.Scene scene = composite(picture, paintBounds);
ui.view.scene = scene; ui.window.render(scene);
} }
void main() { void main() {
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -6,14 +6,14 @@ import 'dart:math' as math; ...@@ -6,14 +6,14 @@ import 'dart:math' as math;
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'dart:typed_data'; import 'dart:typed_data';
double timeBase = null; Duration timeBase = null;
ui.Paragraph paragraph; ui.Paragraph paragraph;
ui.Picture paint(ui.Rect paintBounds, double delta) { ui.Picture paint(ui.Rect paintBounds, double delta) {
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.view.width / 2.0, ui.view.height / 2.0); canvas.translate(ui.window.size.width / 2.0, ui.window.size.height / 2.0);
canvas.rotate(math.PI * delta / 1800); canvas.rotate(math.PI * delta / 1800);
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));
...@@ -29,8 +29,8 @@ ui.Picture paint(ui.Rect paintBounds, double delta) { ...@@ -29,8 +29,8 @@ ui.Picture paint(ui.Rect paintBounds, double delta) {
} }
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -43,15 +43,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -43,15 +43,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
return sceneBuilder.build(); return sceneBuilder.build();
} }
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
if (timeBase == null) if (timeBase == null)
timeBase = timeStamp; timeBase = timeStamp;
double delta = timeStamp - timeBase; double delta = (timeStamp - timeBase).inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND;
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
ui.Picture picture = paint(paintBounds, delta); ui.Picture picture = paint(paintBounds, delta);
ui.Scene scene = composite(picture, paintBounds); ui.Scene scene = composite(picture, paintBounds);
ui.view.scene = scene; ui.window.render(scene);
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
void main() { void main() {
...@@ -63,6 +63,6 @@ void main() { ...@@ -63,6 +63,6 @@ void main() {
builder.addText(" و أكثر قليلا لجعله أطول. "); builder.addText(" و أكثر قليلا لجعله أطول. ");
paragraph = builder.build(new ui.ParagraphStyle()); paragraph = builder.build(new ui.ParagraphStyle());
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -8,7 +8,7 @@ import 'dart:typed_data'; ...@@ -8,7 +8,7 @@ import 'dart:typed_data';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
double timeBase = null; Duration timeBase = null;
ui.Image image = null; ui.Image image = null;
String url1 = "https://raw.githubusercontent.com/dart-lang/logos/master/logos_and_wordmarks/dart-logo.png"; String url1 = "https://raw.githubusercontent.com/dart-lang/logos/master/logos_and_wordmarks/dart-logo.png";
...@@ -42,8 +42,8 @@ ui.Picture paint(ui.Rect paintBounds, double delta) { ...@@ -42,8 +42,8 @@ ui.Picture paint(ui.Rect paintBounds, double delta) {
} }
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -56,15 +56,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { ...@@ -56,15 +56,15 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
return sceneBuilder.build(); return sceneBuilder.build();
} }
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
if (timeBase == null) if (timeBase == null)
timeBase = timeStamp; timeBase = timeStamp;
double delta = timeStamp - timeBase; double delta = (timeStamp - timeBase).inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND;
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
ui.Picture picture = paint(paintBounds, delta); ui.Picture picture = paint(paintBounds, delta);
ui.Scene scene = composite(picture, paintBounds); ui.Scene scene = composite(picture, paintBounds);
ui.view.scene = scene; ui.window.render(scene);
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -72,7 +72,7 @@ void handleImageLoad(result) { ...@@ -72,7 +72,7 @@ void handleImageLoad(result) {
if (result != image) { if (result != image) {
print("${result.width}x${result.width} image loaded!"); print("${result.width}x${result.width} image loaded!");
image = result; image = result;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} else { } else {
print("Existing image was loaded again"); print("Existing image was loaded again");
} }
...@@ -93,6 +93,6 @@ bool handleEvent(ui.Event event) { ...@@ -93,6 +93,6 @@ bool handleEvent(ui.Event event) {
void main() { void main() {
imageCache.load(url1).first.then(handleImageLoad); imageCache.load(url1).first.then(handleImageLoad);
ui.view.setEventCallback(handleEvent); ui.window.onEvent = handleEvent;
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
} }
...@@ -6,16 +6,16 @@ import 'dart:math' as math; ...@@ -6,16 +6,16 @@ import 'dart:math' as math;
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'dart:typed_data'; import 'dart:typed_data';
double timeBase = null; Duration timeBase = null;
void beginFrame(double timeStamp) { void beginFrame(Duration timeStamp) {
ui.tracing.begin('beginFrame'); ui.tracing.begin('beginFrame');
if (timeBase == null) if (timeBase == null)
timeBase = timeStamp; timeBase = timeStamp;
double delta = timeStamp - timeBase; double delta = (timeStamp - timeBase).inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND;
// paint // paint
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height); ui.Rect paintBounds = ui.Point.origin & ui.window.size;
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);
...@@ -25,8 +25,8 @@ void beginFrame(double timeStamp) { ...@@ -25,8 +25,8 @@ void beginFrame(double timeStamp) {
ui.Picture picture = recorder.endRecording(); ui.Picture picture = recorder.endRecording();
// composite // composite
final double devicePixelRatio = ui.view.devicePixelRatio; final double devicePixelRatio = ui.window.devicePixelRatio;
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio); ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.window.size.width * devicePixelRatio, ui.window.size.height * devicePixelRatio);
Float64List deviceTransform = new Float64List(16) Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio ..[0] = devicePixelRatio
..[5] = devicePixelRatio ..[5] = devicePixelRatio
...@@ -36,13 +36,13 @@ void beginFrame(double timeStamp) { ...@@ -36,13 +36,13 @@ void beginFrame(double timeStamp) {
..pushTransform(deviceTransform) ..pushTransform(deviceTransform)
..addPicture(ui.Offset.zero, picture, paintBounds) ..addPicture(ui.Offset.zero, picture, paintBounds)
..pop(); ..pop();
ui.view.scene = sceneBuilder.build(); ui.window.render(sceneBuilder.build());
ui.tracing.end('beginFrame'); ui.tracing.end('beginFrame');
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
void main() { void main() {
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
} }
...@@ -101,5 +101,5 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin."""; ...@@ -101,5 +101,5 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
updateTaskDescription('Interactive Flex', topColor); updateTaskDescription('Interactive Flex', topColor);
new FlutterBinding(root: root); new FlutterBinding(root: root);
ui.view.setEventCallback(handleEvent); ui.window.onEvent = handleEvent;
} }
...@@ -12,8 +12,8 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool> ...@@ -12,8 +12,8 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
switch (await showMenu( switch (await showMenu(
context: context, context: context,
position: new MenuPosition( position: new MenuPosition(
right: ui.view.paddingRight + _kMenuMargin, right: ui.window.padding.right + _kMenuMargin,
top: ui.view.paddingTop + _kMenuMargin top: ui.window.padding.top + _kMenuMargin
), ),
items: <PopupMenuItem>[ items: <PopupMenuItem>[
new PopupMenuItem( new PopupMenuItem(
......
...@@ -27,7 +27,7 @@ SchedulerExceptionHandler debugSchedulerExceptionHandler; ...@@ -27,7 +27,7 @@ SchedulerExceptionHandler debugSchedulerExceptionHandler;
class Scheduler { class Scheduler {
/// Requires clients to use the [scheduler] singleton /// Requires clients to use the [scheduler] singleton
Scheduler._() { Scheduler._() {
ui.view.setFrameCallback(beginFrame); ui.window.onBeginFrame = beginFrame;
} }
bool _haveScheduledVisualUpdate = false; bool _haveScheduledVisualUpdate = false;
...@@ -49,13 +49,11 @@ class Scheduler { ...@@ -49,13 +49,11 @@ class Scheduler {
/// [requestAnimationFrame], then calls all the callbacks registered by /// [requestAnimationFrame], then calls all the callbacks registered by
/// [addPersistentFrameCallback], which typically drive the rendering pipeline, /// [addPersistentFrameCallback], which typically drive the rendering pipeline,
/// and finally calls the callbacks registered by [requestPostFrameCallback]. /// and finally calls the callbacks registered by [requestPostFrameCallback].
void beginFrame(double rawTimeStamp) { void beginFrame(Duration rawTimeStamp) {
assert(!_inFrame); assert(!_inFrame);
_inFrame = true; _inFrame = true;
rawTimeStamp /= timeDilation; Duration timeStamp = new Duration(
final Duration timeStamp = new Duration( microseconds: (rawTimeStamp.inMicroseconds / timeDilation).round());
microseconds: (rawTimeStamp * Duration.MICROSECONDS_PER_MILLISECOND).round()
);
_haveScheduledVisualUpdate = false; _haveScheduledVisualUpdate = false;
assert(_postFrameCallbacks.length == 0); assert(_postFrameCallbacks.length == 0);
...@@ -148,7 +146,7 @@ class Scheduler { ...@@ -148,7 +146,7 @@ class Scheduler {
void ensureVisualUpdate() { void ensureVisualUpdate() {
if (_haveScheduledVisualUpdate) if (_haveScheduledVisualUpdate)
return; return;
ui.view.scheduleFrame(); ui.window.scheduleFrame();
_haveScheduledVisualUpdate = true; _haveScheduledVisualUpdate = true;
} }
} }
......
...@@ -109,11 +109,11 @@ Simulation _createFlingScrollSimulation(double position, double velocity, double ...@@ -109,11 +109,11 @@ Simulation _createFlingScrollSimulation(double position, double velocity, double
// scrolling less than one logical pixel per frame. We're essentially // scrolling less than one logical pixel per frame. We're essentially
// normalizing by the devicePixelRatio so that the threshold has the // normalizing by the devicePixelRatio so that the threshold has the
// same effect independent of the device's pixel density. // same effect independent of the device's pixel density.
double endVelocity = 15.0 * ui.view.devicePixelRatio; double endVelocity = 15.0 * ui.window.devicePixelRatio;
// Similar to endVelocity. Stop scrolling when we're this close to // Similar to endVelocity. Stop scrolling when we're this close to
// destiniation scroll offset. // destiniation scroll offset.
double endDistance = 0.5 * ui.view.devicePixelRatio; double endDistance = 0.5 * ui.window.devicePixelRatio;
SpringDescription spring = new SpringDescription.withDampingRatio(mass: 1.0, springConstant: 170.0, ratio: 1.1); SpringDescription spring = new SpringDescription.withDampingRatio(mass: 1.0, springConstant: 170.0, ratio: 1.1);
ScrollSimulation simulation = ScrollSimulation simulation =
...@@ -124,7 +124,7 @@ Simulation _createFlingScrollSimulation(double position, double velocity, double ...@@ -124,7 +124,7 @@ Simulation _createFlingScrollSimulation(double position, double velocity, double
Simulation _createSnapScrollSimulation(double startOffset, double endOffset, double velocity) { Simulation _createSnapScrollSimulation(double startOffset, double endOffset, double velocity) {
double startVelocity = velocity * _kSecondsPerMillisecond; double startVelocity = velocity * _kSecondsPerMillisecond;
double endVelocity = 15.0 * ui.view.devicePixelRatio * velocity.sign; double endVelocity = 15.0 * ui.window.devicePixelRatio * velocity.sign;
return new FrictionSimulation.through(startOffset, endOffset, startVelocity, endVelocity); return new FrictionSimulation.through(startOffset, endOffset, startVelocity, endVelocity);
} }
......
...@@ -28,7 +28,7 @@ class Scaffold extends StatelessComponent { ...@@ -28,7 +28,7 @@ class Scaffold extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
double toolBarHeight = 0.0; double toolBarHeight = 0.0;
if (toolBar != null) if (toolBar != null)
toolBarHeight = kToolBarHeight + ui.view.paddingTop; toolBarHeight = kToolBarHeight + ui.window.padding.top;
double statusBarHeight = 0.0; double statusBarHeight = 0.0;
if (statusBar != null) if (statusBar != null)
......
...@@ -132,9 +132,9 @@ class FlutterBinding extends HitTestTarget { ...@@ -132,9 +132,9 @@ class FlutterBinding extends HitTestTarget {
assert(_instance == null); assert(_instance == null);
_instance = this; _instance = this;
ui.view.setEventCallback(_handleEvent); ui.window.onEvent = _handleEvent;
ui.window.onMetricsChanged = _handleMetricsChanged;
ui.view.setMetricsChangedCallback(_handleMetricsChanged);
if (renderViewOverride == null) { if (renderViewOverride == null) {
_renderView = new RenderView(child: root); _renderView = new RenderView(child: root);
_renderView.attach(); _renderView.attach();
...@@ -166,7 +166,7 @@ class FlutterBinding extends HitTestTarget { ...@@ -166,7 +166,7 @@ class FlutterBinding extends HitTestTarget {
bool removeMetricListener(MetricListener listener) => _metricListeners.remove(listener); bool removeMetricListener(MetricListener listener) => _metricListeners.remove(listener);
void _handleMetricsChanged() { void _handleMetricsChanged() {
Size size = new Size(ui.view.width, ui.view.height); Size size = ui.window.size;
_renderView.rootConstraints = new ViewConstraints(size: size); _renderView.rootConstraints = new ViewConstraints(size: size);
for (MetricListener listener in _metricListeners) for (MetricListener listener in _metricListeners)
listener(size); listener(size);
......
...@@ -62,7 +62,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -62,7 +62,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
} }
Matrix4 get _logicalToDeviceTransform { Matrix4 get _logicalToDeviceTransform {
double devicePixelRatio = ui.view.devicePixelRatio; double devicePixelRatio = ui.window.devicePixelRatio;
return new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0); return new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
} }
...@@ -119,10 +119,10 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -119,10 +119,10 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui.tracing.begin('RenderView.compositeFrame'); ui.tracing.begin('RenderView.compositeFrame');
try { try {
(layer as TransformLayer).transform = _logicalToDeviceTransform; (layer as TransformLayer).transform = _logicalToDeviceTransform;
Rect bounds = Point.origin & (size * ui.view.devicePixelRatio); Rect bounds = Point.origin & (size * ui.window.devicePixelRatio);
ui.SceneBuilder builder = new ui.SceneBuilder(bounds); ui.SceneBuilder builder = new ui.SceneBuilder(bounds);
layer.addToScene(builder, Offset.zero); layer.addToScene(builder, Offset.zero);
ui.view.scene = builder.build(); ui.window.render(builder.build());
} finally { } finally {
ui.tracing.end('RenderView.compositeFrame'); ui.tracing.end('RenderView.compositeFrame');
} }
...@@ -130,6 +130,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -130,6 +130,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
Rect get paintBounds => Point.origin & size; Rect get paintBounds => Point.origin & size;
String debugDescribeSettings(String prefix) => '${prefix}view width: ${ui.view.width} (in device pixels)\n${prefix}view height: ${ui.view.height} (in device pixels)\n${prefix}device pixel ratio: ${ui.view.devicePixelRatio} (device pixels per logical pixel)\n${prefix}root constraints: $rootConstraints (in logical pixels)\n'; String debugDescribeSettings(String prefix) => '${prefix}window size: ${ui.window.size} (in device pixels)\n${prefix}device pixel ratio: ${ui.window.devicePixelRatio} (device pixels per logical pixel)\n${prefix}root constraints: $rootConstraints (in logical pixels)\n';
// call to ${super.debugDescribeSettings(prefix)} is omitted because the root superclasses don't include any interesting information for this class // call to ${super.debugDescribeSettings(prefix)} is omitted because the root superclasses don't include any interesting information for this class
} }
...@@ -136,7 +136,7 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -136,7 +136,7 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
} }
Offset get _scrollOffsetRoundedToIntegerDevicePixels { Offset get _scrollOffsetRoundedToIntegerDevicePixels {
double devicePixelRatio = ui.view.devicePixelRatio; double devicePixelRatio = ui.window.devicePixelRatio;
int dxInDevicePixels = (scrollOffset.dx * devicePixelRatio).round(); int dxInDevicePixels = (scrollOffset.dx * devicePixelRatio).round();
int dyInDevicePixels = (scrollOffset.dy * devicePixelRatio).round(); int dyInDevicePixels = (scrollOffset.dy * devicePixelRatio).round();
return new Offset(dxInDevicePixels / devicePixelRatio, return new Offset(dxInDevicePixels / devicePixelRatio,
......
...@@ -26,7 +26,7 @@ void main() { ...@@ -26,7 +26,7 @@ void main() {
scheduler.requestAnimationFrame(firstCallback); scheduler.requestAnimationFrame(firstCallback);
secondId = scheduler.requestAnimationFrame(secondCallback); secondId = scheduler.requestAnimationFrame(secondCallback);
scheduler.beginFrame(16.0); scheduler.beginFrame(const Duration(milliseconds: 16));
expect(firstCallbackRan, isTrue); expect(firstCallbackRan, isTrue);
expect(secondCallbackRan, isFalse); expect(secondCallbackRan, isFalse);
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
firstCallbackRan = false; firstCallbackRan = false;
secondCallbackRan = false; secondCallbackRan = false;
scheduler.beginFrame(32.0); scheduler.beginFrame(const Duration(milliseconds: 32));
expect(firstCallbackRan, isFalse); expect(firstCallbackRan, isFalse);
expect(secondCallbackRan, isFalse); expect(secondCallbackRan, isFalse);
......
...@@ -42,7 +42,7 @@ class WidgetTester { ...@@ -42,7 +42,7 @@ class WidgetTester {
void pump([ Duration duration ]) { void pump([ Duration duration ]) {
if (duration != null) if (duration != null)
async.elapse(duration); async.elapse(duration);
scheduler.beginFrame(clock.now().millisecondsSinceEpoch.toDouble()); scheduler.beginFrame(new Duration(milliseconds: clock.now().millisecondsSinceEpoch));
async.flushMicrotasks(); async.flushMicrotasks();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment