Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
f30ff4fc
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
未验证
提交
f30ff4fc
编写于
1月 24, 2020
作者:
F
Ferhat
提交者:
GitHub
1月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use 2d matrix for transform to work around Safari clipping bug (#15976)
上级
1e7a9deb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
14 deletion
+42
-14
lib/web_ui/lib/src/engine/util.dart
lib/web_ui/lib/src/engine/util.dart
+38
-14
lib/web_ui/test/engine/util_test.dart
lib/web_ui/test/engine/util_test.dart
+4
-0
未找到文件。
lib/web_ui/lib/src/engine/util.dart
浏览文件 @
f30ff4fc
...
...
@@ -77,7 +77,14 @@ void setElementTransform(html.Element element, Float64List matrix4) {
final
bool
isHighDevicePixelRatioScreen
=
EngineWindow
.
browserDevicePixelRatio
>
1.0
;
if
(
transformKind
==
TransformKind
.
complex
||
isHighDevicePixelRatioScreen
)
{
if
(
transformKind
==
TransformKind
.
scaleAndTranslate2d
)
{
final
String
cssTransform
=
float64ListToCssTransform2d
(
matrix4
);
element
.
style
..
transformOrigin
=
'0 0 0'
..
transform
=
cssTransform
..
top
=
null
..
left
=
null
;
}
else
if
(
transformKind
==
TransformKind
.
complex
||
isHighDevicePixelRatioScreen
)
{
final
String
cssTransform
=
float64ListToCssTransform3d
(
matrix4
);
element
.
style
..
transformOrigin
=
'0 0 0'
...
...
@@ -107,6 +114,9 @@ enum TransformKind {
/// No effect.
identity
,
/// A transform that contains only 2d scale and transform.
scaleAndTranslate2d
,
/// A translation along either X or Y axes, or both.
translation2d
,
...
...
@@ -123,12 +133,13 @@ TransformKind transformKindOf(Float64List matrix) {
// If matrix contains scaling, rotation, z translation or
// perspective transform, it is not considered simple.
final
bool
isSimpleTransform
=
m
[
0
]
==
1.0
&&
final
bool
isSimple2dTransform
=
// m[0] - scale x is simple
m
[
1
]
==
0.0
&&
m
[
2
]
==
0.0
&&
m
[
3
]
==
0.0
&&
m
[
4
]
==
0.0
&&
m
[
5
]
==
1.0
&&
// m[5] - scale y is simple
m
[
6
]
==
0.0
&&
m
[
7
]
==
0.0
&&
m
[
8
]
==
0.0
&&
...
...
@@ -140,15 +151,19 @@ TransformKind transformKindOf(Float64List matrix) {
m
[
14
]
==
0.0
&&
// z translation is NOT simple
m
[
15
]
==
1.0
;
if
(!
isSimpleTransform
)
{
if
(!
isSimple
2d
Transform
)
{
return
TransformKind
.
complex
;
}
if
(
ty
!=
0.0
||
tx
!=
0.0
)
{
return
TransformKind
.
translation2d
;
if
(
m
[
0
]
==
1.0
&&
m
[
5
]
==
1.0
)
{
if
(
ty
!=
0.0
||
tx
!=
0.0
)
{
return
TransformKind
.
translation2d
;
}
else
{
return
TransformKind
.
identity
;
}
}
else
{
return
TransformKind
.
scaleAndTranslate2d
;
}
return
TransformKind
.
identity
;
}
/// Returns `true` is the [matrix] describes an identity transformation.
...
...
@@ -157,29 +172,38 @@ bool isIdentityFloat64ListTransform(Float64List matrix) {
return
transformKindOf
(
matrix
)
==
TransformKind
.
identity
;
}
/// Converts [matrix] to CSS transform value.
String
float64ListToCssTransform2d
(
Float64List
matrix
)
{
assert
(
transformKindOf
(
matrix
)
==
TransformKind
.
scaleAndTranslate2d
);
return
'matrix(
${matrix[0]}
,0,0,
${matrix[5]}
,
${matrix[12]}
,
${matrix[13]}
)'
;
}
/// Converts [matrix] to CSS transform value.
String
float64ListToCssTransform
(
Float64List
matrix
)
{
assert
(
matrix
.
length
==
16
);
final
Float64List
m
=
matrix
;
if
(
m
[
0
]
==
1.0
&&
m
[
1
]
==
0.0
&&
if
(
m
[
1
]
==
0.0
&&
m
[
2
]
==
0.0
&&
m
[
3
]
==
0.0
&&
m
[
4
]
==
0.0
&&
m
[
5
]
==
1.0
&&
m
[
6
]
==
0.0
&&
m
[
7
]
==
0.0
&&
m
[
8
]
==
0.0
&&
m
[
9
]
==
0.0
&&
m
[
10
]
==
1.0
&&
m
[
11
]
==
0.0
&&
// 12 can be anything
// 13 can be anything
// 12 can be anything
(translation)
// 13 can be anything
(translation)
m
[
14
]
==
0.0
&&
m
[
15
]
==
1.0
)
{
final
double
tx
=
m
[
12
];
final
double
ty
=
m
[
13
];
return
'translate(
${tx}
px,
${ty}
px)'
;
if
(
m
[
0
]
==
1.0
&&
m
[
5
]
==
1.0
)
{
return
'translate(
${tx}
px,
${ty}
px)'
;
}
else
{
return
'matrix(
${m[0]}
,0,0,
${m[5]}
,
${tx}
,
${ty}
)'
;
}
}
else
{
return
'matrix3d(
${m[0]}
,
${m[1]}
,
${m[2]}
,
${m[3]}
,
${m[4]}
,
${m[5]}
,
${m[6]}
,
${m[7]}
,
${m[8]}
,
${m[9]}
,
${m[10]}
,
${m[11]}
,
${m[12]}
,
${m[13]}
,
${m[14]}
,
${m[15]}
)'
;
}
...
...
lib/web_ui/test/engine/util_test.dart
浏览文件 @
f30ff4fc
...
...
@@ -12,6 +12,7 @@ final Float64List identityTransform = Matrix4.identity().storage;
final
Float64List
xTranslation
=
(
Matrix4
.
identity
()..
translate
(
10
)).
storage
;
final
Float64List
yTranslation
=
(
Matrix4
.
identity
()..
translate
(
0
,
10
)).
storage
;
final
Float64List
zTranslation
=
(
Matrix4
.
identity
()..
translate
(
0
,
0
,
10
)).
storage
;
final
Float64List
scaleAndTransform2d
=
(
Matrix4
.
identity
()..
scale
(
2
,
3
,
1
)..
translate
(
4
,
5
,
0
)).
storage
;
void
main
(
)
{
test
(
'transformKindOf and isIdentityFloat64ListTransform identify matrix kind'
,
()
{
...
...
@@ -26,5 +27,8 @@ void main() {
expect
(
transformKindOf
(
zTranslation
),
TransformKind
.
complex
);
expect
(
isIdentityFloat64ListTransform
(
zTranslation
),
isFalse
);
expect
(
transformKindOf
(
scaleAndTransform2d
),
TransformKind
.
scaleAndTranslate2d
);
expect
(
isIdentityFloat64ListTransform
(
scaleAndTransform2d
),
isFalse
);
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录