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

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

Issue 2994233002: Revert "Speedup Observatory elements first time rendering" (Closed)
Patch Set: Created 3 years, 4 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 | « runtime/observatory/lib/src/elements/helpers/rendering_queue.dart ('k') | no next file » | 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:async'; 5 import 'dart:async';
6 6
7 import 'package:observatory/src/elements/helpers/rendering_queue.dart'; 7 import 'package:observatory/src/elements/helpers/rendering_queue.dart';
8 export 'package:observatory/src/elements/helpers/rendering_queue.dart'; 8 export 'package:observatory/src/elements/helpers/rendering_queue.dart';
9 9
10 /// A generic renderable object. 10 /// A generic renderable object.
(...skipping 14 matching lines...) Expand all
25 assert(otherRenderScheduled != null); 25 assert(otherRenderScheduled != null);
26 } 26 }
27 } 27 }
28 28
29 /// Scheduler for rendering operations. 29 /// Scheduler for rendering operations.
30 class RenderingScheduler<T extends Renderable> implements RenderingTask { 30 class RenderingScheduler<T extends Renderable> implements RenderingTask {
31 bool _enabled = false; 31 bool _enabled = false;
32 bool _dirty = false; 32 bool _dirty = false;
33 bool _renderingScheduled = false; 33 bool _renderingScheduled = false;
34 bool _notificationScheduled = false; 34 bool _notificationScheduled = false;
35 bool _waitForBarrier = false;
36 35
37 /// Element managed by this scheduler. 36 /// Element managed by this scheduler.
38 final T element; 37 final T element;
39 38
40 /// Queue used for rendering operations. 39 /// Queue used for rendering operations.
41 final RenderingQueue queue; 40 final RenderingQueue queue;
42 41
43 final List<Future> _wait = <Future>[]; 42 final List<Future> _wait = <Future>[];
44 43
45 /// Does the element need a new rendering cycle. 44 /// Does the element need a new rendering cycle.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 dirty(); 96 dirty();
98 else 97 else
99 scheduleNotification(); 98 scheduleNotification();
100 return newValue; 99 return newValue;
101 } 100 }
102 101
103 /// Schedules a new rendering phase. 102 /// Schedules a new rendering phase.
104 void scheduleRendering() { 103 void scheduleRendering() {
105 if (_renderingScheduled) return; 104 if (_renderingScheduled) return;
106 if (!_enabled) return; 105 if (!_enabled) return;
107 queue.enqueue(this, waitForBarrier: _waitForBarrier); 106 queue.enqueue(this);
108 _waitForBarrier = true;
109 _renderingScheduled = true; 107 _renderingScheduled = true;
110 } 108 }
111 109
112 /// Renders the element (if the scheduler is enabled). 110 /// Renders the element (if the scheduler is enabled).
113 /// It will clear the dirty flag. 111 /// It will clear the dirty flag.
114 void render() { 112 void render() {
115 if (!_enabled) return; 113 if (!_enabled) return;
116 _dirty = false; 114 _dirty = false;
117 _wait.clear(); 115 _wait.clear();
118 element.render(); 116 element.render();
(...skipping 13 matching lines...) Expand all
132 _wait.addAll(it); 130 _wait.addAll(it);
133 } 131 }
134 132
135 Future _notify() async { 133 Future _notify() async {
136 await Future.wait(_wait); 134 await Future.wait(_wait);
137 _wait.clear(); 135 _wait.clear();
138 _onRendered.add(new RenderedEvent<T>(element, _dirty)); 136 _onRendered.add(new RenderedEvent<T>(element, _dirty));
139 _notificationScheduled = false; 137 _notificationScheduled = false;
140 } 138 }
141 } 139 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/helpers/rendering_queue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698