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

Unified Diff: pkg/barback/lib/src/asset_node.dart

Issue 23038018: Factor a PhaseOutput class out of Phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/asset_forwarder.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset_node.dart
diff --git a/pkg/barback/lib/src/asset_node.dart b/pkg/barback/lib/src/asset_node.dart
index edc740834e81b14b50f93056d8dcd40519e34a49..db80a9f9481aff05e7e79d1f9c4ba84b1522cc50 100644
--- a/pkg/barback/lib/src/asset_node.dart
+++ b/pkg/barback/lib/src/asset_node.dart
@@ -23,8 +23,11 @@ class AssetNode {
/// The transform that created this asset node.
///
- /// This is `null` for source assets.
- final TransformNode transform;
+ /// This is `null` for source assets. It can change if the upstream transform
+ /// that created this asset changes; this change will *not* cause an
+ /// [onStateChange] event.
+ TransformNode get transform => _transform;
+ TransformNode _transform;
/// The current state of the asset node.
AssetState get state => _state;
@@ -110,10 +113,10 @@ class AssetNode {
return onStateChange.firstWhere(test);
}
- AssetNode._(this.id, this.transform)
+ AssetNode._(this.id, this._transform)
: _state = AssetState.DIRTY;
- AssetNode._available(Asset asset, this.transform)
+ AssetNode._available(Asset asset, this._transform)
: id = asset.id,
_asset = asset,
_state = AssetState.AVAILABLE;
@@ -134,6 +137,17 @@ class AssetNodeController {
AssetNodeController.available(Asset asset, [TransformNode transform])
: node = new AssetNode._available(asset, transform);
+ /// Creates a controller for a node whose initial state matches the current
+ /// state of [node].
+ AssetNodeController.from(AssetNode node)
+ : node = new AssetNode._(node.id, node.transform) {
+ if (node.state.isAvailable) {
+ setAvailable(node.asset);
+ } else if (node.state.isRemoved) {
+ setRemoved();
+ }
+ }
+
/// Marks the node as [AssetState.DIRTY].
void setDirty() {
assert(node._state != AssetState.REMOVED);
@@ -165,6 +179,14 @@ class AssetNodeController {
node._asset = asset;
node._stateChangeController.add(AssetState.AVAILABLE);
}
+
+ /// Sets the node's [AssetNode.transform] property.
+ ///
+ /// This is used when resolving collisions, where a node will stick around but
+ /// a different transform will have created it.
+ void setTransform(TransformNode transform) {
+ node._transform = transform;
+ }
}
// TODO(nweiz): add an error state.
« no previous file with comments | « pkg/barback/lib/src/asset_forwarder.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698