Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
0018135a
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0018135a
编写于
9月 26, 2019
作者:
G
Gary Qian
提交者:
GitHub
9月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make kDoNotResizeDimension public so framework can use it directly (#12448)
上级
9a1784a5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
18 deletion
+30
-18
lib/ui/painting.dart
lib/ui/painting.dart
+9
-11
lib/ui/painting/codec.cc
lib/ui/painting/codec.cc
+2
-5
lib/web_ui/lib/src/ui/painting.dart
lib/web_ui/lib/src/ui/painting.dart
+11
-2
testing/dart/image_resize_test.dart
testing/dart/image_resize_test.dart
+8
-0
未找到文件。
lib/ui/painting.dart
浏览文件 @
0018135a
...
...
@@ -1019,13 +1019,11 @@ enum Clip {
antiAliasWithSaveLayer
,
}
// Indicates that the image should not be resized in this dimension.
//
// Used by [instantiateImageCodec] as a magical value to disable resizing
// in the given dimension.
//
// This needs to be kept in sync with "kDoNotResizeDimension" in codec.cc
const
int
_kDoNotResizeDimension
=
-
1
;
/// Indicates that the image should not be resized in this dimension.
///
/// Used by [instantiateImageCodec] as a magical value to disable resizing
/// in the given dimension.
const
int
kDoNotResizeDimension
=
-
1
;
/// A description of the style to use when drawing on a [Canvas].
///
...
...
@@ -1667,7 +1665,7 @@ Future<Codec> instantiateImageCodec(Uint8List list, {
int
targetHeight
,
})
{
return
_futurize
(
(
_Callback
<
Codec
>
callback
)
=>
_instantiateImageCodec
(
list
,
callback
,
null
,
targetWidth
??
_kDoNotResizeDimension
,
targetHeight
??
_
kDoNotResizeDimension
)
(
_Callback
<
Codec
>
callback
)
=>
_instantiateImageCodec
(
list
,
callback
,
null
,
targetWidth
??
kDoNotResizeDimension
,
targetHeight
??
kDoNotResizeDimension
)
);
}
...
...
@@ -1677,9 +1675,9 @@ Future<Codec> instantiateImageCodec(Uint8List list, {
/// image, in image pixels. Image in this context refers to image in every frame of the [Codec].
/// If [targetWidth] and [targetHeight] are not equal to the intrinsic dimensions of the
/// image, then the image will be scaled after being decoded. If exactly one of
/// these two arguments is not equal to [
_
kDoNotResizeDimension], then the aspect
/// these two arguments is not equal to [kDoNotResizeDimension], then the aspect
/// ratio will be maintained while forcing the image to match the given dimension.
/// If both are equal to [
_
kDoNotResizeDimension], then the image maintains its real size.
/// If both are equal to [kDoNotResizeDimension], then the image maintains its real size.
///
/// Returns an error message if the instantiation has failed, null otherwise.
String
_instantiateImageCodec
(
Uint8List
list
,
_Callback
<
Codec
>
callback
,
_ImageInfo
imageInfo
,
int
targetWidth
,
int
targetHeight
)
...
...
@@ -1724,7 +1722,7 @@ void decodeImageFromPixels(
)
{
final
_ImageInfo
imageInfo
=
_ImageInfo
(
width
,
height
,
format
.
index
,
rowBytes
);
final
Future
<
Codec
>
codecFuture
=
_futurize
(
(
_Callback
<
Codec
>
callback
)
=>
_instantiateImageCodec
(
pixels
,
callback
,
imageInfo
,
targetWidth
??
_kDoNotResizeDimension
,
targetHeight
??
_
kDoNotResizeDimension
)
(
_Callback
<
Codec
>
callback
)
=>
_instantiateImageCodec
(
pixels
,
callback
,
imageInfo
,
targetWidth
??
kDoNotResizeDimension
,
targetHeight
??
kDoNotResizeDimension
)
);
codecFuture
.
then
((
Codec
codec
)
=>
codec
.
getNextFrame
())
.
then
((
FrameInfo
frameInfo
)
=>
callback
(
frameInfo
.
image
));
...
...
lib/ui/painting/codec.cc
浏览文件 @
0018135a
...
...
@@ -33,9 +33,6 @@ namespace flutter {
namespace
{
// This needs to be kept in sync with _kDoNotResizeDimension in painting.dart
const
int
kDoNotResizeDimension
=
-
1
;
// This must be kept in sync with the enum in painting.dart
enum
PixelFormat
{
kRGBA8888
,
...
...
@@ -217,10 +214,10 @@ static void InstantiateImageCodec(Dart_NativeArguments args) {
ImageDecoder
::
ImageDescriptor
descriptor
;
descriptor
.
decompressed_image_info
=
image_info
;
if
(
targetWidth
!=
kDoNotResizeDimension
)
{
if
(
targetWidth
>
0
)
{
descriptor
.
target_width
=
targetWidth
;
}
if
(
targetHeight
!=
kDoNotResizeDimension
)
{
if
(
targetHeight
>
0
)
{
descriptor
.
target_height
=
targetHeight
;
}
descriptor
.
data
=
std
::
move
(
buffer
);
...
...
lib/web_ui/lib/src/ui/painting.dart
浏览文件 @
0018135a
...
...
@@ -1628,6 +1628,12 @@ enum PixelFormat {
bgra8888
,
}
/// Indicates that the image should not be resized in this dimension.
///
/// Used by [instantiateImageCodec] as a magical value to disable resizing
/// in the given dimension.
const
int
kDoNotResizeDimension
=
-
1
;
class
_ImageInfo
{
_ImageInfo
(
this
.
width
,
this
.
height
,
this
.
format
,
this
.
rowBytes
)
{
rowBytes
??=
width
*
4
;
...
...
@@ -1705,9 +1711,12 @@ class Codec {
///
/// The returned future can complete with an error if the image decoding has
/// failed.
Future
<
Codec
>
instantiateImageCodec
(
Uint8List
list
,
{
double
decodedCacheRatioCap
=
double
.
infinity
})
{
Future
<
Codec
>
instantiateImageCodec
(
Uint8List
list
,
{
int
targetWidth
,
int
targetHeight
,
})
{
return
engine
.
futurize
((
engine
.
Callback
<
Codec
>
callback
)
=>
// TODO: Implement targetWidth and targetHeight support.
_instantiateImageCodec
(
list
,
callback
,
null
));
}
...
...
testing/dart/image_resize_test.dart
浏览文件 @
0018135a
...
...
@@ -97,6 +97,14 @@ void main() {
expect
(
resized
.
height
,
1
);
expect
(
resized
.
width
,
10
);
});
test
(
'pixels: large negative dimensions'
,
()
async
{
final
BlackSquare
blackSquare
=
BlackSquare
.
create
();
final
Image
resized
=
await
blackSquare
.
resize
(
targetHeight:
-
100
,
targetWidth:
-
99999
);
expect
(
resized
.
height
,
2
);
expect
(
resized
.
width
,
2
);
});
}
class
BlackSquare
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录