Commit dda253bb authored by Hixie's avatar Hixie

Reorder bootstrapping code in rendering/ for slightly cleaner code.

parent cf03afcd
...@@ -394,6 +394,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -394,6 +394,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
void scheduleInitialLayout() { void scheduleInitialLayout() {
assert(attached); assert(attached);
assert(parent is! RenderObject); assert(parent is! RenderObject);
assert(!_debugDoingLayout);
assert(_relayoutSubtreeRoot == null); assert(_relayoutSubtreeRoot == null);
_relayoutSubtreeRoot = this; _relayoutSubtreeRoot = this;
assert(() { assert(() {
...@@ -401,7 +402,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -401,7 +402,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
return true; return true;
}); });
_nodesNeedingLayout.add(this); _nodesNeedingLayout.add(this);
scheduler.ensureVisualUpdate();
} }
static void flushLayout() { static void flushLayout() {
sky.tracing.begin('RenderObject.flushLayout'); sky.tracing.begin('RenderObject.flushLayout');
...@@ -648,6 +648,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -648,6 +648,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
assert(parent is! RenderObject); assert(parent is! RenderObject);
assert(!_debugDoingPaint); assert(!_debugDoingPaint);
assert(hasLayer); assert(hasLayer);
assert(_layer == null);
_layer = rootLayer; _layer = rootLayer;
assert(_needsPaint); assert(_needsPaint);
_nodesNeedingPaint.add(this); _nodesNeedingPaint.add(this);
......
...@@ -40,11 +40,10 @@ class SkyBinding { ...@@ -40,11 +40,10 @@ class SkyBinding {
sky.view.setMetricsChangedCallback(_handleMetricsChanged); sky.view.setMetricsChangedCallback(_handleMetricsChanged);
scheduler.init(); scheduler.init();
if (renderViewOverride == null) { if (renderViewOverride == null) {
_renderView = new RenderView(child: root); _renderView = new RenderView(child: root, devicePixelRatio: sky.view.devicePixelRatio);
_renderView.attach(); _renderView.attach();
_renderView.rootConstraints = _createConstraints(); _renderView.rootConstraints = _createConstraints();
_renderView.scheduleInitialLayout(); _renderView.scheduleInitialFrame();
_renderView.initializeLayerTree();
} else { } else {
_renderView = renderViewOverride; _renderView = renderViewOverride;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:sky' as sky; import 'dart:sky' as sky;
import 'package:sky/base/scheduler.dart' as scheduler;
import 'package:sky/rendering/layer.dart'; import 'package:sky/rendering/layer.dart';
import 'package:sky/rendering/object.dart'; import 'package:sky/rendering/object.dart';
import 'package:sky/rendering/box.dart'; import 'package:sky/rendering/box.dart';
...@@ -21,17 +22,20 @@ class ViewConstraints { ...@@ -21,17 +22,20 @@ class ViewConstraints {
class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> { class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> {
RenderView({ RenderView({
RenderBox child, RenderBox child,
this.devicePixelRatio,
this.timeForRotation: const Duration(microseconds: 83333) this.timeForRotation: const Duration(microseconds: 83333)
}) { }) {
this.child = child; this.child = child;
} }
final double devicePixelRatio;
Duration timeForRotation;
Size _size = Size.zero; Size _size = Size.zero;
Size get size => _size; Size get size => _size;
int _orientation; // 0..3 int _orientation; // 0..3
int get orientation => _orientation; int get orientation => _orientation;
Duration timeForRotation;
ViewConstraints _rootConstraints; ViewConstraints _rootConstraints;
ViewConstraints get rootConstraints => _rootConstraints; ViewConstraints get rootConstraints => _rootConstraints;
...@@ -42,10 +46,11 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -42,10 +46,11 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
markNeedsLayout(); markNeedsLayout();
} }
void initializeLayerTree() { void scheduleInitialFrame() {
final double devicePixelRatio = sky.view.devicePixelRatio;
Matrix4 logicalToDeviceZoom = new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0); Matrix4 logicalToDeviceZoom = new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
scheduleInitialLayout();
scheduleInitialPaint(new TransformLayer(transform: logicalToDeviceZoom)); scheduleInitialPaint(new TransformLayer(transform: logicalToDeviceZoom));
scheduler.ensureVisualUpdate();
} }
// We never call layout() on this class, so this should never get // We never call layout() on this class, so this should never get
......
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