Commit 6047c6da authored by Hixie's avatar Hixie

Be clearer about whether renderView can be null.

parent 7dd28659
...@@ -24,6 +24,7 @@ abstract class Renderer extends Scheduler ...@@ -24,6 +24,7 @@ abstract class Renderer extends Scheduler
_instance = this; _instance = this;
ui.window.onMetricsChanged = handleMetricsChanged; ui.window.onMetricsChanged = handleMetricsChanged;
initRenderView(); initRenderView();
assert(renderView != null);
assert(() { assert(() {
initServiceExtensions(); initServiceExtensions();
return true; return true;
...@@ -39,24 +40,25 @@ abstract class Renderer extends Scheduler ...@@ -39,24 +40,25 @@ abstract class Renderer extends Scheduler
renderView = new RenderView(); renderView = new RenderView();
renderView.scheduleInitialFrame(); renderView.scheduleInitialFrame();
} }
handleMetricsChanged(); // configures _renderView's metrics handleMetricsChanged(); // configures renderView's metrics
} }
/// The render tree that's attached to the output surface. /// The render tree that's attached to the output surface.
RenderView get renderView => _renderView; RenderView get renderView => _renderView;
RenderView _renderView; RenderView _renderView;
void set renderView(RenderView value) { void set renderView(RenderView value) {
assert(value != null);
if (_renderView == value) if (_renderView == value)
return; return;
if (_renderView != null) if (_renderView != null)
_renderView.detach(); _renderView.detach();
_renderView = value; _renderView = value;
if (_renderView != null) _renderView.attach();
_renderView.attach();
} }
void handleMetricsChanged() { void handleMetricsChanged() {
_renderView.rootConstraints = new ViewConstraints(size: ui.window.size); assert(renderView != null);
renderView.rootConstraints = new ViewConstraints(size: ui.window.size);
} }
void _handlePersistentFrameCallback(Duration timeStamp) { void _handlePersistentFrameCallback(Duration timeStamp) {
...@@ -65,32 +67,35 @@ abstract class Renderer extends Scheduler ...@@ -65,32 +67,35 @@ abstract class Renderer extends Scheduler
/// Pump the rendering pipeline to generate a frame. /// Pump the rendering pipeline to generate a frame.
void beginFrame() { void beginFrame() {
assert(renderView != null);
RenderObject.flushLayout(); RenderObject.flushLayout();
_renderView.updateCompositingBits(); renderView.updateCompositingBits();
RenderObject.flushPaint(); RenderObject.flushPaint();
_renderView.compositeFrame(); renderView.compositeFrame();
} }
void hitTest(HitTestResult result, Point position) { void hitTest(HitTestResult result, Point position) {
_renderView.hitTest(result, position: position); assert(renderView != null);
renderView.hitTest(result, position: position);
super.hitTest(result, position); super.hitTest(result, position);
} }
} }
/// Prints a textual representation of the entire render tree. /// Prints a textual representation of the entire render tree.
void debugDumpRenderTree() { void debugDumpRenderTree() {
debugPrint(Renderer.instance.renderView.toStringDeep()); debugPrint(Renderer.instance?.renderView?.toStringDeep());
} }
/// Prints a textual representation of the entire layer tree. /// Prints a textual representation of the entire layer tree.
void debugDumpLayerTree() { void debugDumpLayerTree() {
debugPrint(Renderer.instance.renderView.layer.toStringDeep()); debugPrint(Renderer.instance?.renderView?.layer?.toStringDeep());
} }
/// A concrete binding for applications that use the Rendering framework /// A concrete binding for applications that use the Rendering framework
/// directly. This is the glue that binds the framework to the Flutter engine. /// directly. This is the glue that binds the framework to the Flutter engine.
class RenderingFlutterBinding extends BindingBase with Scheduler, Renderer, Gesturer { class RenderingFlutterBinding extends BindingBase with Scheduler, Renderer, Gesturer {
RenderingFlutterBinding({ RenderBox root }) { RenderingFlutterBinding({ RenderBox root }) {
assert(renderView != null);
renderView.child = root; renderView.child = root;
} }
} }
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