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
e4e8ab47
Unverified
Commit
e4e8ab47
authored
Jul 14, 2018
by
Jonah Williams
Committed by
GitHub
Jul 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
increase cache size if image is loaded that is larger than max size (#19352)
parent
5d0d1b03
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+6
-0
image_cache_test.dart
packages/flutter/test/painting/image_cache_test.dart
+10
-0
No files found.
packages/flutter/lib/src/painting/image_cache.dart
View file @
e4e8ab47
...
@@ -145,6 +145,12 @@ class ImageCache {
...
@@ -145,6 +145,12 @@ class ImageCache {
// Images that fail to load don't contribute to cache size.
// Images that fail to load don't contribute to cache size.
final
int
imageSize
=
info
.
image
==
null
?
0
:
info
.
image
.
height
*
info
.
image
.
width
*
4
;
final
int
imageSize
=
info
.
image
==
null
?
0
:
info
.
image
.
height
*
info
.
image
.
width
*
4
;
final
_CachedImage
image
=
new
_CachedImage
(
result
,
imageSize
);
final
_CachedImage
image
=
new
_CachedImage
(
result
,
imageSize
);
// If the image is bigger than the maximum cache size, and the cache size
// is not zero, then increase the cache size to the size of the image plus
// some change.
if
(
maximumSizeBytes
>
0
&&
imageSize
>
maximumSizeBytes
)
{
_maximumSizeBytes
=
imageSize
+
1000
;
}
_currentSizeBytes
+=
imageSize
;
_currentSizeBytes
+=
imageSize
;
_pendingImages
.
remove
(
key
);
_pendingImages
.
remove
(
key
);
_cache
[
key
]
=
image
;
_cache
[
key
]
=
image
;
...
...
packages/flutter/test/painting/image_cache_test.dart
View file @
e4e8ab47
...
@@ -118,5 +118,15 @@ void main() {
...
@@ -118,5 +118,15 @@ void main() {
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
.
currentSizeBytes
,
256
);
expect
(
imageCache
.
currentSizeBytes
,
256
);
});
});
test
(
'Increases cache size if an image is loaded that is larger then the maximum size'
,
()
async
{
const
TestImage
testImage
=
const
TestImage
(
width:
8
,
height:
8
);
imageCache
.
maximumSizeBytes
=
1
;
await
extractOneFrame
(
const
TestImageProvider
(
1
,
1
,
image:
testImage
).
resolve
(
ImageConfiguration
.
empty
));
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
.
currentSizeBytes
,
256
);
expect
(
imageCache
.
maximumSizeBytes
,
256
+
1000
);
});
});
});
}
}
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