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

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

Issue 25376003: Add support for transformer clusters to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 2 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
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 db80a9f9481aff05e7e79d1f9c4ba84b1522cc50..f5446baaccf83a99edafc309ba57c916e55abbff 100644
--- a/pkg/barback/lib/src/asset_node.dart
+++ b/pkg/barback/lib/src/asset_node.dart
@@ -21,6 +21,16 @@ class AssetNode {
/// The id of the asset that this node represents.
final AssetId id;
+ /// The [AssetNode] from which [this] is forwarded.
+ ///
+ /// For nodes that aren't forwarded, this will return [this]. Otherwise, it
+ /// will return the first node in the forwarding chain.
+ ///
+ /// This is used to determine whether two nodes are forwarded from the same
+ /// source.
+ AssetNode get origin => _origin == null ? this : _origin;
+ AssetNode _origin;
+
/// The transform that created this asset node.
///
/// This is `null` for source assets. It can change if the upstream transform
@@ -113,10 +123,10 @@ class AssetNode {
return onStateChange.firstWhere(test);
}
- AssetNode._(this.id, this._transform)
+ AssetNode._(this.id, this._transform, this._origin)
: _state = AssetState.DIRTY;
- AssetNode._available(Asset asset, this._transform)
+ AssetNode._available(Asset asset, this._transform, this._origin)
: id = asset.id,
_asset = asset,
_state = AssetState.AVAILABLE;
@@ -130,17 +140,20 @@ class AssetNodeController {
/// Creates a controller for a dirty node.
AssetNodeController(AssetId id, [TransformNode transform])
- : node = new AssetNode._(id, transform);
+ : node = new AssetNode._(id, transform, null);
/// Creates a controller for an available node with the given concrete
/// [asset].
AssetNodeController.available(Asset asset, [TransformNode transform])
- : node = new AssetNode._available(asset, transform);
+ : node = new AssetNode._available(asset, transform, null);
/// Creates a controller for a node whose initial state matches the current
/// state of [node].
+ ///
+ /// [AssetNode.origin] of the returned node will automatically be set to
+ /// `node.origin`.
AssetNodeController.from(AssetNode node)
- : node = new AssetNode._(node.id, node.transform) {
+ : node = new AssetNode._(node.id, node.transform, node.origin) {
if (node.state.isAvailable) {
setAvailable(node.asset);
} else if (node.state.isRemoved) {
@@ -180,12 +193,11 @@ class AssetNodeController {
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;
+ /// Sets the origin of [node] to [origin] and the transform to
+ /// `origin.transform`.
+ void setOrigin(AssetNode origin) {
+ node._origin = origin;
+ node._transform = origin.transform;
}
}

Powered by Google App Engine
This is Rietveld 408576698