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
33f5ac66
Unverified
Commit
33f5ac66
authored
Aug 18, 2021
by
ColdPaleLight
Committed by
GitHub
Aug 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ImageInfo adds a new getter named sizeBytes to decouple ImageCache and ui.Image (#86555)
parent
df399f9a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+1
-1
image_stream.dart
packages/flutter/lib/src/painting/image_stream.dart
+3
-0
image_info_test.dart
packages/flutter/test/painting/image_info_test.dart
+26
-0
mocks_for_image_cache.dart
packages/flutter/test/painting/mocks_for_image_cache.dart
+3
-0
No files found.
packages/flutter/lib/src/painting/image_cache.dart
View file @
33f5ac66
...
...
@@ -411,7 +411,7 @@ class ImageCache {
void
listener
(
ImageInfo
?
info
,
bool
syncCall
)
{
int
?
sizeBytes
;
if
(
info
!=
null
)
{
sizeBytes
=
info
.
image
.
height
*
info
.
image
.
width
*
4
;
sizeBytes
=
info
.
sizeBytes
;
info
.
dispose
();
}
final
_CachedImage
image
=
_CachedImage
(
...
...
packages/flutter/lib/src/painting/image_stream.dart
View file @
33f5ac66
...
...
@@ -98,6 +98,9 @@ class ImageInfo {
/// the image.
final
ui
.
Image
image
;
/// The size of raw image pixels in bytes.
int
get
sizeBytes
=>
image
.
height
*
image
.
width
*
4
;
/// The linear scale factor for drawing this image at its intended size.
///
/// The scale factor applies to the width and the height.
...
...
packages/flutter/test/painting/image_info_test.dart
0 → 100644
View file @
33f5ac66
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
Image
;
import
'package:flutter/painting.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
Future
<
void
>
main
()
async
{
final
ui
.
Image
smallImage
=
await
createTestImage
(
width:
10
,
height:
20
);
final
ui
.
Image
middleImage
=
await
createTestImage
(
width:
20
,
height:
100
);
final
ui
.
Image
bigImage
=
await
createTestImage
(
width:
100
,
height:
200
);
test
(
'ImageInfo sizeBytes'
,
()
{
ImageInfo
imageInfo
=
ImageInfo
(
image:
smallImage
);
expect
(
imageInfo
.
sizeBytes
,
equals
(
800
));
imageInfo
=
ImageInfo
(
image:
middleImage
);
expect
(
imageInfo
.
sizeBytes
,
equals
(
8000
));
imageInfo
=
ImageInfo
(
image:
bigImage
);
expect
(
imageInfo
.
sizeBytes
,
equals
(
80000
));
});
}
packages/flutter/test/painting/mocks_for_image_cache.dart
View file @
33f5ac66
...
...
@@ -43,6 +43,9 @@ class TestImageInfo implements ImageInfo {
image
.
dispose
();
}
@override
int
get
sizeBytes
=>
image
.
height
*
image
.
width
*
4
;
@override
int
get
hashCode
=>
hashValues
(
value
,
image
,
scale
,
debugLabel
);
...
...
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