Commit a733e91b authored by Adam Barth's avatar Adam Barth

Don't freeze devicePixelRatio at startup

When we start, we might not have initialized the devicePixelRatio value. The
value will be initialized by the time we paint, so now we update the value
every time we paint.
parent 10fe17a9
......@@ -40,7 +40,7 @@ class SkyBinding {
sky.view.setMetricsChangedCallback(_handleMetricsChanged);
scheduler.init();
if (renderViewOverride == null) {
_renderView = new RenderView(child: root, devicePixelRatio: sky.view.devicePixelRatio);
_renderView = new RenderView(child: root);
_renderView.attach();
_renderView.rootConstraints = _createConstraints();
_renderView.scheduleInitialFrame();
......
......@@ -22,13 +22,11 @@ class ViewConstraints {
class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> {
RenderView({
RenderBox child,
this.devicePixelRatio,
this.timeForRotation: const Duration(microseconds: 83333)
}) {
this.child = child;
}
final double devicePixelRatio;
Duration timeForRotation;
Size _size = Size.zero;
......@@ -46,10 +44,14 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
markNeedsLayout();
}
Matrix4 get _logicalToDeviceTransform {
double devicePixelRatio = sky.view.devicePixelRatio;
return new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
}
void scheduleInitialFrame() {
Matrix4 logicalToDeviceZoom = new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
scheduleInitialLayout();
scheduleInitialPaint(new TransformLayer(transform: logicalToDeviceZoom));
scheduleInitialPaint(new TransformLayer(transform: _logicalToDeviceTransform));
scheduler.ensureVisualUpdate();
}
......@@ -98,6 +100,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
void compositeFrame() {
sky.tracing.begin('RenderView.compositeFrame');
try {
(layer as TransformLayer).transform = _logicalToDeviceTransform;
Rect bounds = Point.origin & (size * sky.view.devicePixelRatio);
sky.SceneBuilder builder = new sky.SceneBuilder(bounds);
layer.addToScene(builder, Offset.zero);
......
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