Commit b81f3f8b authored by Kris Giesing's avatar Kris Giesing

Style cleanup

parent bf115ec5
...@@ -43,15 +43,17 @@ class NetworkAssetBundle extends AssetBundle { ...@@ -43,15 +43,17 @@ class NetworkAssetBundle extends AssetBundle {
} }
abstract class CachingAssetBundle extends AssetBundle { abstract class CachingAssetBundle extends AssetBundle {
Map<String, ImageResource> imageCache = new Map<String, ImageResource>(); final Map<String, ImageResource> imageResourceCache =
Map<String, Future<String>> _stringCache = new Map<String, Future<String>>(); new Map<String, ImageResource>();
final Map<String, Future<String>> _stringCache =
new Map<String, Future<String>>();
Future<ui.Image> fetchImage(String key) async { Future<ui.Image> fetchImage(String key) async {
return await decodeImageFromDataPipe(await load(key)); return await decodeImageFromDataPipe(await load(key));
} }
ImageResource loadImage(String key) { ImageResource loadImage(String key) {
return imageCache.putIfAbsent(key, () { return imageResourceCache.putIfAbsent(key, () {
return new ImageResource(fetchImage(key)); return new ImageResource(fetchImage(key));
}); });
} }
......
...@@ -30,7 +30,7 @@ class _ResolvingAssetBundle extends CachingAssetBundle { ...@@ -30,7 +30,7 @@ class _ResolvingAssetBundle extends CachingAssetBundle {
final AssetBundle bundle; final AssetBundle bundle;
final _AssetResolver resolver; final _AssetResolver resolver;
Map<String, String> keyCache = <String, String>{}; final Map<String, String> keyCache = <String, String>{};
Future<core.MojoDataPipeConsumer> load(String key) async { Future<core.MojoDataPipeConsumer> load(String key) async {
if (!keyCache.containsKey(key)) if (!keyCache.containsKey(key))
...@@ -56,7 +56,7 @@ class _ResolutionAwareAssetBundle extends _ResolvingAssetBundle { ...@@ -56,7 +56,7 @@ class _ResolutionAwareAssetBundle extends _ResolvingAssetBundle {
// At this point the key should be in our key cache, and the image // At this point the key should be in our key cache, and the image
// resource should be in our image cache // resource should be in our image cache
double scale = resolver.getScale(keyCache[key]); double scale = resolver.getScale(keyCache[key]);
this.imageCache[key].scale = scale; imageResourceCache[key].scale = scale;
return await decodeImageFromDataPipe(pipe); return await decodeImageFromDataPipe(pipe);
} }
} }
...@@ -110,9 +110,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver { ...@@ -110,9 +110,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver {
double getScale(String key) { double getScale(String key) {
Match match = _extractRatioRegExp.firstMatch(key); Match match = _extractRatioRegExp.firstMatch(key);
if (match != null && match.groupCount > 0) { if (match != null && match.groupCount > 0)
return double.parse(match.group(1)); return double.parse(match.group(1));
}
return 1.0; return 1.0;
} }
...@@ -134,9 +133,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver { ...@@ -134,9 +133,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver {
String chooseVariant(String main, List<String> candidates) { String chooseVariant(String main, List<String> candidates) {
SplayTreeMap<double, String> mapping = new SplayTreeMap<double, String>(); SplayTreeMap<double, String> mapping = new SplayTreeMap<double, String>();
for (String candidate in candidates) { for (String candidate in candidates)
mapping[getScale(candidate)] = candidate; mapping[getScale(candidate)] = candidate;
}
mapping[_naturalResolution] = main; mapping[_naturalResolution] = main;
return _findNearest(mapping, devicePixelRatio); return _findNearest(mapping, devicePixelRatio);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment