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

Side by Side Diff: runtime/observatory/lib/src/elements/helpers/rendering_queue.dart

Issue 2173373002: Revert "Use Timer and not AnimationFrame during Observatory UI tests" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert "Use Timer and not AnimationFrame during Observatory UI tests" Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/observatory/tests/observatory_ui/curly_block/element_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 30
31 Future<num> get next => _stream.stream.first; 31 Future<num> get next => _stream.stream.first;
32 32
33 /// Trigger the next barrier with an optional numer of ms elapsed. 33 /// Trigger the next barrier with an optional numer of ms elapsed.
34 void triggerRenderingBarrier({num step: 20}) { 34 void triggerRenderingBarrier({num step: 20}) {
35 assert(step != null); 35 assert(step != null);
36 _stream.add(_ms += step); 36 _stream.add(_ms += step);
37 } 37 }
38 } 38 }
39 39
40 /// MOCK synchronization system for timed barrier triggering.
41 class TimedRenderingBarrier implements RenderingBarrier {
42 final StreamController<num> _stream = new StreamController<num>.broadcast();
43 num _ms = 0;
44
45 Future<num> get next => _stream.stream.first;
46
47 TimedRenderingBarrier({num milliseconds: 1}) {
48 assert(milliseconds != null);
49 assert(milliseconds > 0);
50 new Timer.periodic(new Duration(milliseconds: milliseconds), (Timer t) {
51 _stream.add(_ms += milliseconds);
52 });
53 }
54 }
55
56 /// RenderingTask queuing and synchronization system. 40 /// RenderingTask queuing and synchronization system.
57 class RenderingQueue { 41 class RenderingQueue {
58 final RenderingBarrier _barrier; 42 final RenderingBarrier _barrier;
59 final Queue<RenderingTask> _queue = new Queue<RenderingTask>(); 43 final Queue<RenderingTask> _queue = new Queue<RenderingTask>();
60 44
61 bool get isEmpty => _queue.isEmpty; 45 bool get isEmpty => _queue.isEmpty;
62 bool get isNotEmpty => _queue.isNotEmpty; 46 bool get isNotEmpty => _queue.isNotEmpty;
63 47
64 /// Creates a RenderingQueue with the default synchronization barrier. 48 /// Creates a RenderingQueue with the default synchronization barrier.
65 RenderingQueue() : this.fromBarrier(new NextAnimationFrameBarrier()); 49 RenderingQueue() : this.fromBarrier(new NextAnimationFrameBarrier());
(...skipping 13 matching lines...) Expand all
79 _queue.addLast(r); 63 _queue.addLast(r);
80 } 64 }
81 65
82 Future _render() async { 66 Future _render() async {
83 await _barrier.next; 67 await _barrier.next;
84 while (_queue.isNotEmpty) { 68 while (_queue.isNotEmpty) {
85 _queue.removeFirst().render(); 69 _queue.removeFirst().render();
86 } 70 }
87 } 71 }
88 } 72 }
OLDNEW
« no previous file with comments | « no previous file | runtime/observatory/tests/observatory_ui/curly_block/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698