| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library barback.phase; | 5 library barback.phase; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset_cascade.dart'; | 9 import 'asset_cascade.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 // TODO(nweiz): Rather than passing the cascade and the phase everywhere, | 111 // TODO(nweiz): Rather than passing the cascade and the phase everywhere, |
| 112 // create an interface that just exposes [getInput]. Emit errors via | 112 // create an interface that just exposes [getInput]. Emit errors via |
| 113 // [AssetNode]s. | 113 // [AssetNode]s. |
| 114 Phase(this.cascade, Iterable transformers) | 114 Phase(this.cascade, Iterable transformers) |
| 115 : _transformers = transformers.where((op) => op is Transformer).toSet() { | 115 : _transformers = transformers.where((op) => op is Transformer).toSet() { |
| 116 _onDirtyPool.add(_onDirtyController.stream); | 116 _onDirtyPool.add(_onDirtyController.stream); |
| 117 | 117 |
| 118 for (var group in transformers.where((op) => op is TransformerGroup)) { | 118 for (var group in transformers.where((op) => op is TransformerGroup)) { |
| 119 _groups[group] = new GroupRunner(cascade, group); | 119 var runner = new GroupRunner(cascade, group); |
| 120 _onDirtyPool.add(_groups[group].onDirty); | 120 _groups[group] = runner; |
| 121 _onDirtyPool.add(runner.onDirty); |
| 122 _onLogPool.add(runner.onLog); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 /// Adds a new asset as an input for this phase. | 126 /// Adds a new asset as an input for this phase. |
| 125 /// | 127 /// |
| 126 /// [node] doesn't have to be [AssetState.AVAILABLE]. Once it is, the phase | 128 /// [node] doesn't have to be [AssetState.AVAILABLE]. Once it is, the phase |
| 127 /// will automatically begin determining which transforms can consume it as a | 129 /// will automatically begin determining which transforms can consume it as a |
| 128 /// primary input. The transforms themselves won't be applied until [process] | 130 /// primary input. The transforms themselves won't be applied until [process] |
| 129 /// is called, however. | 131 /// is called, however. |
| 130 /// | 132 /// |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 .toSet(); | 201 .toSet(); |
| 200 var oldGroups = _groups.keys.toSet(); | 202 var oldGroups = _groups.keys.toSet(); |
| 201 for (var removed in oldGroups.difference(newGroups)) { | 203 for (var removed in oldGroups.difference(newGroups)) { |
| 202 _groups.remove(removed).remove(); | 204 _groups.remove(removed).remove(); |
| 203 } | 205 } |
| 204 | 206 |
| 205 for (var added in newGroups.difference(oldGroups)) { | 207 for (var added in newGroups.difference(oldGroups)) { |
| 206 var runner = new GroupRunner(cascade, added); | 208 var runner = new GroupRunner(cascade, added); |
| 207 _groups[added] = runner; | 209 _groups[added] = runner; |
| 208 _onDirtyPool.add(runner.onDirty); | 210 _onDirtyPool.add(runner.onDirty); |
| 211 _onLogPool.add(runner.onLog); |
| 209 for (var input in _inputs.values) { | 212 for (var input in _inputs.values) { |
| 210 runner.addInput(input.input); | 213 runner.addInput(input.input); |
| 211 } | 214 } |
| 212 } | 215 } |
| 213 | 216 |
| 214 for (var forwarder in _forwarders.values) { | 217 for (var forwarder in _forwarders.values) { |
| 215 forwarder.numChannels = _groups.length + 1; | 218 forwarder.numChannels = _groups.length + 1; |
| 216 } | 219 } |
| 217 } | 220 } |
| 218 | 221 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 _outputs[asset.id].add(asset); | 306 _outputs[asset.id].add(asset); |
| 304 } else { | 307 } else { |
| 305 _outputs[asset.id] = new PhaseOutput(this, asset); | 308 _outputs[asset.id] = new PhaseOutput(this, asset); |
| 306 _outputs[asset.id].onAsset.listen((output) { | 309 _outputs[asset.id].onAsset.listen((output) { |
| 307 if (_next != null) _next.addInput(output); | 310 if (_next != null) _next.addInput(output); |
| 308 }, onDone: () => _outputs.remove(asset.id)); | 311 }, onDone: () => _outputs.remove(asset.id)); |
| 309 if (_next != null) _next.addInput(_outputs[asset.id].output); | 312 if (_next != null) _next.addInput(_outputs[asset.id].output); |
| 310 } | 313 } |
| 311 } | 314 } |
| 312 } | 315 } |
| OLD | NEW |