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

Side by Side Diff: pkg/barback/lib/src/transformer/aggregate_transformer.dart

Issue 262173009: Add aggregate transformer types to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.transformer.aggregate_transformer;
6
7 /// An alternate interface for transformers that want to perform aggregate
8 /// transformations on multiple inputs without any individual one of them being
9 /// considered "primary".
10 ///
11 /// This is useful for transformers like image spriting, where all the images in
12 /// a directory need to be combined into a single image. A normal [Transformer]
13 /// can't do this gracefully since when it's running on a single image, it has
14 /// no way of knowing what other images exist to request as secondary inputs.
15 ///
16 /// Aggregate transformers work by classifying assets into different groups
17 /// based on their ids in [classifyPrimary]. Then [apply] is run once for each
18 /// group. For example, a spriting transformer might put each image asset into a
19 /// group identified by its directory name. All images in a given directory will
20 /// end up in the same group, and they'll all be passed to one [apply] call.
21 ///
22 /// If possible, aggregate transformers should implement
23 /// [DeclaringAggregateTransformer] as well to help barback optimize the package
24 /// graph.
25 abstract class AggregateTransformer {
26 /// Classifies an asset id by returning a key identifying which group the
27 /// asset should be placed in.
28 ///
29 /// All assets for which [classifyPrimary] returns the same key are passed
30 /// together to the same [apply] call.
31 ///
32 /// Any value that can be passed across isolate boundaries can be returned. If
Bob Nystrom 2014/05/05 23:41:56 Really? I thought we were just going to use an Ass
nweiz 2014/05/06 22:46:40 That wasn't my plan. It also seems like a lot of u
Bob Nystrom 2014/05/06 23:55:09 Per our discussion, let's make this a string and d
nweiz 2014/05/07 01:28:50 Done.
33 /// [classifyPrimary] needs to do asynchronous work, it can also return a
34 /// [Future] that completes to the key.
35 ///
36 /// A return value of `null` indicates that the transformer is not interested
37 /// in an asset. Assets with a key of `null` will not be passed to any [apply]
38 /// call.
Bob Nystrom 2014/05/05 23:41:56 It might help clarify to say this is equivalent to
nweiz 2014/05/06 22:46:40 Done.
39 classifyPrimary(AssetId id);
40
41 /// Runs this transformer on a group of primary inputs specified by
42 /// [transform].
43 ///
44 /// If this does asynchronous work, it should return a [Future] that completes
45 /// once it's finished.
46 apply(AggregateTransform transform);
47
48 String toString() => runtimeType.toString().replaceAll("Transformer", "");
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698