@@ -7,6 +7,7 @@ import 'dart:collection';
77import 'dart:sky' as sky;
88
99import 'package:sky/base/hit_test.dart' ;
10+ import 'package:sky/base/scheduler.dart' as scheduler;
1011import 'package:sky/mojo/activity.dart' as activity;
1112import 'package:sky/rendering/box.dart' ;
1213import 'package:sky/rendering/object.dart' ;
@@ -651,6 +652,11 @@ abstract class Component extends Widget {
651652 _scheduleComponentForRender (this );
652653 }
653654
655+ static void flushBuild () {
656+ if (! _dirtyComponents.isEmpty)
657+ _buildDirtyComponents ();
658+ }
659+
654660 Widget build ();
655661
656662}
@@ -759,13 +765,15 @@ void _absorbDirtyComponents(List<Component> list) {
759765}
760766
761767void _buildDirtyComponents () {
768+ assert (! _dirtyComponents.isEmpty);
769+
762770 Stopwatch sw;
763771 if (_shouldLogRenderDuration)
764772 sw = new Stopwatch ()..start ();
765773
766774 _inRenderDirtyComponents = true ;
767775 try {
768- sky.tracing.begin ('Widgets._buildDirtyComponents ' );
776+ sky.tracing.begin ('Component.flushBuild ' );
769777 List <Component > sortedDirtyComponents = new List <Component >();
770778 _absorbDirtyComponents (sortedDirtyComponents);
771779 int index = 0 ;
@@ -784,7 +792,7 @@ void _buildDirtyComponents() {
784792 } finally {
785793 _buildScheduled = false ;
786794 _inRenderDirtyComponents = false ;
787- sky.tracing.end ('Widgets._buildDirtyComponents ' );
795+ sky.tracing.end ('Component.flushBuild ' );
788796 }
789797
790798 Widget ._notifyMountStatusChanged ();
@@ -795,21 +803,20 @@ void _buildDirtyComponents() {
795803 if (_debugFrameTimes.length >= 1000 ) {
796804 _debugFrameTimes.sort ();
797805 const int i = 99 ;
798- print ('_buildDirtyComponents : ${i +1 }th fastest frame out of the last ${_debugFrameTimes .length }: ${_debugFrameTimes [i ]} microseconds' );
806+ print ('Component.flushBuild : ${i +1 }th fastest frame out of the last ${_debugFrameTimes .length }: ${_debugFrameTimes [i ]} microseconds' );
799807 _debugFrameTimes.clear ();
800808 }
801809 }
802810}
803811
804- void _scheduleComponentForRender (Component c ) {
805- _dirtyComponents.add (c );
812+ void _scheduleComponentForRender (Component component ) {
813+ _dirtyComponents.add (component );
806814 if (! _buildScheduled) {
807815 _buildScheduled = true ;
808- new Future . microtask (_buildDirtyComponents );
816+ scheduler. ensureVisualUpdate ( );
809817 }
810818}
811819
812-
813820// RenderObjectWrappers correspond to a desired state of a RenderObject.
814821// They are fully immutable, with one exception: A Widget which is a
815822// Component which lives within an MultiChildRenderObjectWrapper's
@@ -1178,6 +1185,11 @@ class WidgetSkyBinding extends SkyBinding {
11781185 }
11791186 }
11801187
1188+ void beginFrame (double timeStamp) {
1189+ Component .flushBuild ();
1190+ super .beginFrame (timeStamp);
1191+ }
1192+
11811193}
11821194
11831195abstract class App extends StatefulComponent {
0 commit comments