Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sky/packages/sky/lib/rendering/sky_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SkyBinding {
_renderView = renderViewOverride;
}
assert(_renderView != null);
scheduler.addPersistentFrameCallback(_beginFrame);
scheduler.addPersistentFrameCallback(beginFrame);

assert(_instance == this);
}
Expand All @@ -69,7 +69,7 @@ class SkyBinding {
void set root(RenderBox value) {
_renderView.child = value;
}
void _beginFrame(double timeStamp) {
void beginFrame(double timeStamp) {
RenderObject.flushLayout();
RenderObject.flushPaint();
_renderView.paintFrame();
Expand Down
26 changes: 19 additions & 7 deletions sky/packages/sky/lib/widgets/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:collection';
import 'dart:sky' as sky;

import 'package:sky/base/hit_test.dart';
import 'package:sky/base/scheduler.dart' as scheduler;
import 'package:sky/mojo/activity.dart' as activity;
import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/object.dart';
Expand Down Expand Up @@ -651,6 +652,11 @@ abstract class Component extends Widget {
_scheduleComponentForRender(this);
}

static void flushBuild() {
if (!_dirtyComponents.isEmpty)
_buildDirtyComponents();
}

Widget build();

}
Expand Down Expand Up @@ -759,13 +765,15 @@ void _absorbDirtyComponents(List<Component> list) {
}

void _buildDirtyComponents() {
assert(!_dirtyComponents.isEmpty);

Stopwatch sw;
if (_shouldLogRenderDuration)
sw = new Stopwatch()..start();

_inRenderDirtyComponents = true;
try {
sky.tracing.begin('Widgets._buildDirtyComponents');
sky.tracing.begin('Component.flushBuild');
List<Component> sortedDirtyComponents = new List<Component>();
_absorbDirtyComponents(sortedDirtyComponents);
int index = 0;
Expand All @@ -784,7 +792,7 @@ void _buildDirtyComponents() {
} finally {
_buildScheduled = false;
_inRenderDirtyComponents = false;
sky.tracing.end('Widgets._buildDirtyComponents');
sky.tracing.end('Component.flushBuild');
}

Widget._notifyMountStatusChanged();
Expand All @@ -795,21 +803,20 @@ void _buildDirtyComponents() {
if (_debugFrameTimes.length >= 1000) {
_debugFrameTimes.sort();
const int i = 99;
print('_buildDirtyComponents: ${i+1}th fastest frame out of the last ${_debugFrameTimes.length}: ${_debugFrameTimes[i]} microseconds');
print('Component.flushBuild: ${i+1}th fastest frame out of the last ${_debugFrameTimes.length}: ${_debugFrameTimes[i]} microseconds');
_debugFrameTimes.clear();
}
}
}

void _scheduleComponentForRender(Component c) {
_dirtyComponents.add(c);
void _scheduleComponentForRender(Component component) {
_dirtyComponents.add(component);
if (!_buildScheduled) {
_buildScheduled = true;
new Future.microtask(_buildDirtyComponents);
scheduler.ensureVisualUpdate();
}
}


// RenderObjectWrappers correspond to a desired state of a RenderObject.
// They are fully immutable, with one exception: A Widget which is a
// Component which lives within an MultiChildRenderObjectWrapper's
Expand Down Expand Up @@ -1178,6 +1185,11 @@ class WidgetSkyBinding extends SkyBinding {
}
}

void beginFrame(double timeStamp) {
Component.flushBuild();
super.beginFrame(timeStamp);
}

}

abstract class App extends StatefulComponent {
Expand Down
1 change: 1 addition & 0 deletions sky/tests/resources/display_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class TestRenderView extends RenderView {
// TEST API:

void syncCheckFrame() {
Component.flushBuild();
RenderObject.flushLayout();
paintFrame();
print(lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better
Expand Down