Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b81f3f8b
Commit
b81f3f8b
authored
Feb 01, 2016
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style cleanup
parent
bf115ec5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+5
-3
asset_vendor.dart
packages/flutter/lib/src/widgets/asset_vendor.dart
+4
-6
No files found.
packages/flutter/lib/src/services/asset_bundle.dart
View file @
b81f3f8b
...
...
@@ -43,15 +43,17 @@ class NetworkAssetBundle extends AssetBundle {
}
abstract
class
CachingAssetBundle
extends
AssetBundle
{
Map
<
String
,
ImageResource
>
imageCache
=
new
Map
<
String
,
ImageResource
>();
Map
<
String
,
Future
<
String
>>
_stringCache
=
new
Map
<
String
,
Future
<
String
>>();
final
Map
<
String
,
ImageResource
>
imageResourceCache
=
new
Map
<
String
,
ImageResource
>();
final
Map
<
String
,
Future
<
String
>>
_stringCache
=
new
Map
<
String
,
Future
<
String
>>();
Future
<
ui
.
Image
>
fetchImage
(
String
key
)
async
{
return
await
decodeImageFromDataPipe
(
await
load
(
key
));
}
ImageResource
loadImage
(
String
key
)
{
return
imageCache
.
putIfAbsent
(
key
,
()
{
return
image
Resource
Cache
.
putIfAbsent
(
key
,
()
{
return
new
ImageResource
(
fetchImage
(
key
));
});
}
...
...
packages/flutter/lib/src/widgets/asset_vendor.dart
View file @
b81f3f8b
...
...
@@ -30,7 +30,7 @@ class _ResolvingAssetBundle extends CachingAssetBundle {
final
AssetBundle
bundle
;
final
_AssetResolver
resolver
;
Map
<
String
,
String
>
keyCache
=
<
String
,
String
>{};
final
Map
<
String
,
String
>
keyCache
=
<
String
,
String
>{};
Future
<
core
.
MojoDataPipeConsumer
>
load
(
String
key
)
async
{
if
(!
keyCache
.
containsKey
(
key
))
...
...
@@ -56,7 +56,7 @@ class _ResolutionAwareAssetBundle extends _ResolvingAssetBundle {
// At this point the key should be in our key cache, and the image
// resource should be in our image cache
double
scale
=
resolver
.
getScale
(
keyCache
[
key
]);
this
.
imag
eCache
[
key
].
scale
=
scale
;
imageResourc
eCache
[
key
].
scale
=
scale
;
return
await
decodeImageFromDataPipe
(
pipe
);
}
}
...
...
@@ -110,9 +110,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver {
double
getScale
(
String
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
1.0
;
}
...
...
@@ -134,9 +133,8 @@ class _ResolutionAwareAssetResolver extends _VariantAssetResolver {
String
chooseVariant
(
String
main
,
List
<
String
>
candidates
)
{
SplayTreeMap
<
double
,
String
>
mapping
=
new
SplayTreeMap
<
double
,
String
>();
for
(
String
candidate
in
candidates
)
{
for
(
String
candidate
in
candidates
)
mapping
[
getScale
(
candidate
)]
=
candidate
;
}
mapping
[
_naturalResolution
]
=
main
;
return
_findNearest
(
mapping
,
devicePixelRatio
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment