Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 /// A generic rendering task that can be scheduled. | 9 /// A generic rendering task that can be scheduled. |
| 10 abstract class RenderingTask { | 10 abstract class RenderingTask { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 RenderingQueue() : this.fromBarrier(new NextAnimationFrameBarrier()); | 49 RenderingQueue() : this.fromBarrier(new NextAnimationFrameBarrier()); |
| 50 | 50 |
| 51 /// Creates a RenderingQueue with a custom synchronization barrier. | 51 /// Creates a RenderingQueue with a custom synchronization barrier. |
| 52 RenderingQueue.fromBarrier(this._barrier) { | 52 RenderingQueue.fromBarrier(this._barrier) { |
| 53 assert(this._barrier != null); | 53 assert(this._barrier != null); |
| 54 } | 54 } |
| 55 | 55 |
| 56 /// Add a task to the queue. | 56 /// Add a task to the queue. |
| 57 /// If the current rendering phase is running it will be executed during this | 57 /// If the current rendering phase is running it will be executed during this |
| 58 /// rendering cycle, otherwise it will be queued for the next one. | 58 /// rendering cycle, otherwise it will be queued for the next one. |
| 59 void enqueue(RenderingTask r) { | 59 void enqueue(RenderingTask r, {bool realtime: false}) { |
|
siva
2017/08/14 20:27:18
instead of calling enqueue here with a parameter r
cbernaschina
2017/08/14 21:08:49
See new Patch.
The execution on a browser which s
| |
| 60 assert(r != null); | 60 assert(r != null); |
| 61 // If no task are in the queue there is no rendering phase scheduled. | 61 // If no task are in the queue there is no rendering phase scheduled. |
| 62 if (isEmpty) _render(); | 62 if (isEmpty) { |
| 63 if (realtime) { | |
| 64 scheduleMicrotask(r.render); | |
| 65 return; | |
| 66 } else { | |
| 67 _render(); | |
| 68 } | |
| 69 } | |
| 63 _queue.addLast(r); | 70 _queue.addLast(r); |
| 64 } | 71 } |
| 65 | 72 |
| 66 Future _render() async { | 73 Future _render() async { |
| 67 await _barrier.next; | 74 await _barrier.next; |
| 68 while (_queue.isNotEmpty) { | 75 while (_queue.isNotEmpty) { |
| 69 _queue.first.render(); | 76 _queue.first.render(); |
| 70 _queue.removeFirst(); | 77 _queue.removeFirst(); |
| 71 } | 78 } |
| 72 } | 79 } |
| 73 } | 80 } |
| OLD | NEW |