Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: sky/specs/animation.md

Issue 931333002: Specs: update the run loop and timer stuff to use the new model with task filters, priorities, and … (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/specs/elements.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/animation.md
diff --git a/sky/specs/animation.md b/sky/specs/animation.md
index 7707373f8a60b327a60abc97ac7210da5239cbb4..06f72e6f802cfc952665d3da41c5309c5200e979 100644
--- a/sky/specs/animation.md
+++ b/sky/specs/animation.md
@@ -4,26 +4,28 @@ Animation API
```dart
typedef void TimerCallback();
-class AnimationTimer extends Timer {
- external factory whenIdle(TimerCallback callback, { double budget: 1.0 });
- // calls callback next time the system is idle
- // - if budget is in the range 0.0 < budget <= 1.0, then callback is
- // guaranteed to have that many milliseconds before being killed
- // - if budget <= 0.0, then the callback could be killed [at any time](script.md).
- // - if budget > 1.0, then it is treated as 1.0.
-
- external factory beforePaint(TimerCallback callback, { int priority: 0 });
- // runs this timeout before this frame's layout/paint phases begin
- external factory nextFrame(TimerCallback callback, { int priority: 0 });
- // runs this timeout right away
+external void _addTask({ TimerCallback callback, Duration budget, int bits, int priority, Queue queue });
+// see (runloop.md)[runloop.md] for the semantics of tasks and queues
+// _addTask() does the zone magic on callback
- // for beforePaint and nextFrame, the callbacks are first sorted by
- // priority, and then run in decreasing order of priority,
- // tie-breaking by registration time, earliest first.
-
- // once there is no more time for callbacks this frame, the Timers
- // are all canceled, so isActive will become false
+external final Queue get _idleQueue;
+external final Queue get _paintQueue;
+external final Queue get _nextPaintQueue;
+class AnimationTimer extends Timer {
+ factory whenIdle(TimerCallback callback, { Duration budget: 1.0 }) {
+ if (budget.inMilliseconds > 1.0)
+ budget = new Duration(milliseconds: 1.0);
+ _addTask(callback: callback, budget: budget, bits: IdleTask, priority: IdlePriority, queue: _idleQueue);
+ }
+
+ factory beforePaint(TimerCallback callback, { int priority: 0 }) {
+ _addTask(callback: callback, budget: new Duration(milliseconds: 1.0), bits: PaintTask, priority: priority, queue: _paintQueue);
+ }
+
+ factory nextFrame(TimerCallback callback, { int priority: 0 }) {
+ _addTask(callback: callback, budget: new Duration(milliseconds: 1.0), bits: PaintTask, priority: priority, queue: _nextPaintQueue);
+ }
}
```
« no previous file with comments | « no previous file | sky/specs/elements.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698