Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
f581f428
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,发现更多精彩内容 >>
未验证
提交
f581f428
编写于
6月 08, 2020
作者:
Y
Yegor
提交者:
GitHub
6月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
nullability clean-ups (#18880)
* nullability clean-ups
上级
9d60a3fa
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
1019 addition
and
807 deletion
+1019
-807
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+2
-1
lib/ui/geometry.dart
lib/ui/geometry.dart
+114
-88
lib/ui/hash_codes.dart
lib/ui/hash_codes.dart
+1
-1
lib/ui/lerp.dart
lib/ui/lerp.dart
+26
-0
lib/ui/painting.dart
lib/ui/painting.dart
+35
-23
lib/web_ui/lib/src/engine.dart
lib/web_ui/lib/src/engine.dart
+2
-1
lib/web_ui/lib/src/engine/bitmap_canvas.dart
lib/web_ui/lib/src/engine/bitmap_canvas.dart
+5
-5
lib/web_ui/lib/src/engine/compositor/picture_recorder.dart
lib/web_ui/lib/src/engine/compositor/picture_recorder.dart
+1
-1
lib/web_ui/lib/src/engine/compositor/surface.dart
lib/web_ui/lib/src/engine/compositor/surface.dart
+1
-1
lib/web_ui/lib/src/engine/compositor/vertices.dart
lib/web_ui/lib/src/engine/compositor/vertices.dart
+0
-13
lib/web_ui/lib/src/engine/engine_canvas.dart
lib/web_ui/lib/src/engine/engine_canvas.dart
+1
-1
lib/web_ui/lib/src/engine/surface/canvas.dart
lib/web_ui/lib/src/engine/surface/canvas.dart
+560
-0
lib/web_ui/lib/src/engine/surface/debug_canvas_reuse_overlay.dart
...ui/lib/src/engine/surface/debug_canvas_reuse_overlay.dart
+1
-1
lib/web_ui/lib/src/engine/surface/recording_canvas.dart
lib/web_ui/lib/src/engine/surface/recording_canvas.dart
+2
-2
lib/web_ui/lib/src/engine/surface/render_vertices.dart
lib/web_ui/lib/src/engine/surface/render_vertices.dart
+48
-5
lib/web_ui/lib/src/engine/util.dart
lib/web_ui/lib/src/engine/util.dart
+1
-1
lib/web_ui/lib/src/ui/canvas.dart
lib/web_ui/lib/src/ui/canvas.dart
+37
-535
lib/web_ui/lib/src/ui/geometry.dart
lib/web_ui/lib/src/ui/geometry.dart
+114
-88
lib/web_ui/lib/src/ui/hash_codes.dart
lib/web_ui/lib/src/ui/hash_codes.dart
+1
-1
lib/web_ui/lib/src/ui/initialization.dart
lib/web_ui/lib/src/ui/initialization.dart
+4
-3
lib/web_ui/lib/src/ui/lerp.dart
lib/web_ui/lib/src/ui/lerp.dart
+21
-1
lib/web_ui/lib/src/ui/painting.dart
lib/web_ui/lib/src/ui/painting.dart
+39
-33
lib/web_ui/lib/src/ui/test_embedding.dart
lib/web_ui/lib/src/ui/test_embedding.dart
+2
-1
lib/web_ui/lib/src/ui/text.dart
lib/web_ui/lib/src/ui/text.dart
+1
-1
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
f581f428
...
...
@@ -454,7 +454,6 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/plugins.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_binding.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_converter.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/profiler.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/render_vertices.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/rrect_renderer.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/accessibility.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/checkable.dart
...
...
@@ -474,6 +473,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/services/serialization.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/shader.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/shadow.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/backdrop_filter.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/canvas.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/clip.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/debug_canvas_reuse_overlay.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/image_filter.dart
...
...
@@ -485,6 +485,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/path_metrics.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/picture.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/platform_view.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/recording_canvas.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/render_vertices.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/scene.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/scene_builder.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/surface/surface.dart
...
...
lib/ui/geometry.dart
浏览文件 @
f581f428
...
...
@@ -314,15 +314,21 @@ class Offset extends OffsetBase {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Offset
/*
!
*/
lerp
(
Offset
/*?*/
a
,
Offset
/*?*/
b
,
double
/*!*/
t
)
{
static
Offset
/*
?
*/
lerp
(
Offset
/*?*/
a
,
Offset
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
return
Offset
(
lerpDouble
(
a
.
dx
,
b
.
dx
,
t
),
lerpDouble
(
a
.
dy
,
b
.
dy
,
t
));
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
*
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
*
t
;
}
else
{
return
Offset
(
_lerpDouble
(
a
.
dx
,
b
.
dx
,
t
),
_lerpDouble
(
a
.
dy
,
b
.
dy
,
t
));
}
}
}
/// Compares two Offsets for equality.
...
...
@@ -579,15 +585,21 @@ class Size extends OffsetBase {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Size
/*
!
*/
lerp
(
Size
/*?*/
a
,
Size
/*?*/
b
,
double
/*!*/
t
)
{
static
Size
/*
?
*/
lerp
(
Size
/*?*/
a
,
Size
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
return
Size
(
lerpDouble
(
a
.
width
,
b
.
width
,
t
),
lerpDouble
(
a
.
height
,
b
.
height
,
t
));
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
*
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
*
t
;
}
else
{
return
Size
(
_lerpDouble
(
a
.
width
,
b
.
width
,
t
),
_lerpDouble
(
a
.
height
,
b
.
height
,
t
));
}
}
}
/// Compares two Sizes for equality.
...
...
@@ -850,22 +862,27 @@ class Rect {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Rect
/*
!
*/
lerp
(
Rect
/*?*/
a
,
Rect
/*?*/
b
,
double
/*!*/
t
)
{
static
Rect
/*
?
*/
lerp
(
Rect
/*?*/
a
,
Rect
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
Rect
.
fromLTRB
(
b
.
left
*
t
,
b
.
top
*
t
,
b
.
right
*
t
,
b
.
bottom
*
t
);
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
Rect
.
fromLTRB
(
a
.
left
*
k
,
a
.
top
*
k
,
a
.
right
*
k
,
a
.
bottom
*
k
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
Rect
.
fromLTRB
(
a
.
left
*
k
,
a
.
top
*
k
,
a
.
right
*
k
,
a
.
bottom
*
k
);
}
}
else
{
if
(
a
==
null
)
{
return
Rect
.
fromLTRB
(
b
.
left
*
t
,
b
.
top
*
t
,
b
.
right
*
t
,
b
.
bottom
*
t
);
}
else
{
return
Rect
.
fromLTRB
(
_lerpDouble
(
a
.
left
,
b
.
left
,
t
),
_lerpDouble
(
a
.
top
,
b
.
top
,
t
),
_lerpDouble
(
a
.
right
,
b
.
right
,
t
),
_lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
);
}
}
return
Rect
.
fromLTRB
(
lerpDouble
(
a
.
left
,
b
.
left
,
t
),
lerpDouble
(
a
.
top
,
b
.
top
,
t
),
lerpDouble
(
a
.
right
,
b
.
right
,
t
),
lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
);
}
@override
...
...
@@ -974,20 +991,25 @@ class Radius {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Radius
/*
!
*/
lerp
(
Radius
/*?*/
a
,
Radius
/*?*/
b
,
double
/*!*/
t
)
{
static
Radius
/*
?
*/
lerp
(
Radius
/*?*/
a
,
Radius
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
Radius
.
elliptical
(
b
.
x
*
t
,
b
.
y
*
t
);
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
Radius
.
elliptical
(
a
.
x
*
k
,
a
.
y
*
k
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
Radius
.
elliptical
(
a
.
x
*
k
,
a
.
y
*
k
);
}
}
else
{
if
(
a
==
null
)
{
return
Radius
.
elliptical
(
b
.
x
*
t
,
b
.
y
*
t
);
}
else
{
return
Radius
.
elliptical
(
_lerpDouble
(
a
.
x
,
b
.
x
,
t
),
_lerpDouble
(
a
.
y
,
b
.
y
,
t
),
);
}
}
return
Radius
.
elliptical
(
lerpDouble
(
a
.
x
,
b
.
x
,
t
),
lerpDouble
(
a
.
y
,
b
.
y
,
t
),
);
}
@override
...
...
@@ -1534,57 +1556,61 @@ class RRect {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
RRect
/*
!
*/
lerp
(
RRect
/*?*/
a
,
RRect
/*?*/
b
,
double
/*!*/
t
)
{
static
RRect
/*
?
*/
lerp
(
RRect
/*?*/
a
,
RRect
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
{
return
RRect
.
_raw
(
left:
b
.
left
*
t
,
top:
b
.
top
*
t
,
right:
b
.
right
*
t
,
bottom:
b
.
bottom
*
t
,
tlRadiusX:
b
.
tlRadiusX
*
t
,
tlRadiusY:
b
.
tlRadiusY
*
t
,
trRadiusX:
b
.
trRadiusX
*
t
,
trRadiusY:
b
.
trRadiusY
*
t
,
brRadiusX:
b
.
brRadiusX
*
t
,
brRadiusY:
b
.
brRadiusY
*
t
,
blRadiusX:
b
.
blRadiusX
*
t
,
blRadiusY:
b
.
blRadiusY
*
t
,
);
}
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
RRect
.
_raw
(
left:
a
.
left
*
k
,
top:
a
.
top
*
k
,
right:
a
.
right
*
k
,
bottom:
a
.
bottom
*
k
,
tlRadiusX:
a
.
tlRadiusX
*
k
,
tlRadiusY:
a
.
tlRadiusY
*
k
,
trRadiusX:
a
.
trRadiusX
*
k
,
trRadiusY:
a
.
trRadiusY
*
k
,
brRadiusX:
a
.
brRadiusX
*
k
,
brRadiusY:
a
.
brRadiusY
*
k
,
blRadiusX:
a
.
blRadiusX
*
k
,
blRadiusY:
a
.
blRadiusY
*
k
,
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
RRect
.
_raw
(
left:
a
.
left
*
k
,
top:
a
.
top
*
k
,
right:
a
.
right
*
k
,
bottom:
a
.
bottom
*
k
,
tlRadiusX:
a
.
tlRadiusX
*
k
,
tlRadiusY:
a
.
tlRadiusY
*
k
,
trRadiusX:
a
.
trRadiusX
*
k
,
trRadiusY:
a
.
trRadiusY
*
k
,
brRadiusX:
a
.
brRadiusX
*
k
,
brRadiusY:
a
.
brRadiusY
*
k
,
blRadiusX:
a
.
blRadiusX
*
k
,
blRadiusY:
a
.
blRadiusY
*
k
,
);
}
}
else
{
if
(
a
==
null
)
{
return
RRect
.
_raw
(
left:
b
.
left
*
t
,
top:
b
.
top
*
t
,
right:
b
.
right
*
t
,
bottom:
b
.
bottom
*
t
,
tlRadiusX:
b
.
tlRadiusX
*
t
,
tlRadiusY:
b
.
tlRadiusY
*
t
,
trRadiusX:
b
.
trRadiusX
*
t
,
trRadiusY:
b
.
trRadiusY
*
t
,
brRadiusX:
b
.
brRadiusX
*
t
,
brRadiusY:
b
.
brRadiusY
*
t
,
blRadiusX:
b
.
blRadiusX
*
t
,
blRadiusY:
b
.
blRadiusY
*
t
,
);
}
else
{
return
RRect
.
_raw
(
left:
_lerpDouble
(
a
.
left
,
b
.
left
,
t
),
top:
_lerpDouble
(
a
.
top
,
b
.
top
,
t
),
right:
_lerpDouble
(
a
.
right
,
b
.
right
,
t
),
bottom:
_lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
tlRadiusX:
_lerpDouble
(
a
.
tlRadiusX
,
b
.
tlRadiusX
,
t
),
tlRadiusY:
_lerpDouble
(
a
.
tlRadiusY
,
b
.
tlRadiusY
,
t
),
trRadiusX:
_lerpDouble
(
a
.
trRadiusX
,
b
.
trRadiusX
,
t
),
trRadiusY:
_lerpDouble
(
a
.
trRadiusY
,
b
.
trRadiusY
,
t
),
brRadiusX:
_lerpDouble
(
a
.
brRadiusX
,
b
.
brRadiusX
,
t
),
brRadiusY:
_lerpDouble
(
a
.
brRadiusY
,
b
.
brRadiusY
,
t
),
blRadiusX:
_lerpDouble
(
a
.
blRadiusX
,
b
.
blRadiusX
,
t
),
blRadiusY:
_lerpDouble
(
a
.
blRadiusY
,
b
.
blRadiusY
,
t
),
);
}
}
return
RRect
.
_raw
(
left:
lerpDouble
(
a
.
left
,
b
.
left
,
t
),
top:
lerpDouble
(
a
.
top
,
b
.
top
,
t
),
right:
lerpDouble
(
a
.
right
,
b
.
right
,
t
),
bottom:
lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
tlRadiusX:
lerpDouble
(
a
.
tlRadiusX
,
b
.
tlRadiusX
,
t
),
tlRadiusY:
lerpDouble
(
a
.
tlRadiusY
,
b
.
tlRadiusY
,
t
),
trRadiusX:
lerpDouble
(
a
.
trRadiusX
,
b
.
trRadiusX
,
t
),
trRadiusY:
lerpDouble
(
a
.
trRadiusY
,
b
.
trRadiusY
,
t
),
brRadiusX:
lerpDouble
(
a
.
brRadiusX
,
b
.
brRadiusX
,
t
),
brRadiusY:
lerpDouble
(
a
.
brRadiusY
,
b
.
brRadiusY
,
t
),
blRadiusX:
lerpDouble
(
a
.
blRadiusX
,
b
.
blRadiusX
,
t
),
blRadiusY:
lerpDouble
(
a
.
blRadiusY
,
b
.
blRadiusY
,
t
),
);
}
@override
...
...
lib/ui/hash_codes.dart
浏览文件 @
f581f428
...
...
@@ -112,7 +112,7 @@ int/*!*/ hashValues(
/// Combine the [Object.hashCode] values of an arbitrary number of objects from
/// an [Iterable] into one value. This function will return the same value if
/// given null as if given an empty list.
int
/*!*/
hashList
(
Iterable
<
Object
/*?*/
>
/*
!
*/
arguments
)
{
int
/*!*/
hashList
(
Iterable
<
Object
/*?*/
>
/*
?
*/
arguments
)
{
int
result
=
0
;
if
(
arguments
!=
null
)
{
for
(
Object
argument
in
arguments
)
...
...
lib/ui/lerp.dart
浏览文件 @
f581f428
...
...
@@ -13,3 +13,29 @@ double/*!*/ lerpDouble(num/*?*/ a, num/*?*/ b, double/*!*/ t) {
b
??=
0.0
;
return
a
+
(
b
-
a
)
*
t
as
double
;
}
/// Linearly interpolate between two doubles.
///
/// Same as [lerpDouble] but specialized for non-null `double` type.
double
/*!*/
_lerpDouble
(
double
/*!*/
a
,
double
/*!*/
b
,
double
/*!*/
t
)
{
return
a
+
(
b
-
a
)
*
t
;
}
/// Linearly interpolate between two integers.
///
/// Same as [lerpDouble] but specialized for non-null `int` type.
double
/*!*/
_lerpInt
(
int
/*!*/
a
,
int
/*!*/
b
,
double
/*!*/
t
)
{
return
a
+
(
b
-
a
)
*
t
;
}
/// Same as [num.clamp] but specialized for non-null [int].
int
/*!*/
_clampInt
(
int
/*!*/
value
,
int
/*!*/
min
,
int
/*!*/
max
)
{
assert
(
min
<=
max
);
if
(
value
<
min
)
{
return
min
;
}
else
if
(
value
>
max
)
{
return
max
;
}
else
{
return
value
;
}
}
lib/ui/painting.dart
浏览文件 @
f581f428
...
...
@@ -259,18 +259,24 @@ class Color {
/// an [AnimationController].
static
Color
/*?*/
lerp
(
Color
/*?*/
a
,
Color
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
_scaleAlpha
(
b
,
t
);
if
(
b
==
null
)
return
_scaleAlpha
(
a
,
1.0
-
t
);
return
Color
.
fromARGB
(
lerpDouble
(
a
.
alpha
,
b
.
alpha
,
t
).
toInt
().
clamp
(
0
,
255
)
as
int
,
lerpDouble
(
a
.
red
,
b
.
red
,
t
).
toInt
().
clamp
(
0
,
255
)
as
int
,
lerpDouble
(
a
.
green
,
b
.
green
,
t
).
toInt
().
clamp
(
0
,
255
)
as
int
,
lerpDouble
(
a
.
blue
,
b
.
blue
,
t
).
toInt
().
clamp
(
0
,
255
)
as
int
,
);
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
_scaleAlpha
(
a
,
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
_scaleAlpha
(
b
,
t
);
}
else
{
return
Color
.
fromARGB
(
_clampInt
(
_lerpInt
(
a
.
alpha
,
b
.
alpha
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
red
,
b
.
red
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
green
,
b
.
green
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
blue
,
b
.
blue
,
t
).
toInt
(),
0
,
255
),
);
}
}
}
/// Combine the foreground color as a transparent color over top
...
...
@@ -4288,17 +4294,23 @@ class Shadow {
/// {@endtemplate}
static
Shadow
/*?*/
lerp
(
Shadow
/*?*/
a
,
Shadow
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
.
scale
(
t
);
if
(
b
==
null
)
return
a
.
scale
(
1.0
-
t
);
return
Shadow
(
color:
Color
.
lerp
(
a
.
color
,
b
.
color
,
t
),
offset:
Offset
.
lerp
(
a
.
offset
,
b
.
offset
,
t
),
blurRadius:
lerpDouble
(
a
.
blurRadius
,
b
.
blurRadius
,
t
),
);
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
.
scale
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
.
scale
(
t
);
}
else
{
return
Shadow
(
color:
Color
.
lerp
(
a
.
color
,
b
.
color
,
t
),
offset:
Offset
.
lerp
(
a
.
offset
,
b
.
offset
,
t
),
blurRadius:
lerpDouble
(
a
.
blurRadius
,
b
.
blurRadius
,
t
),
);
}
}
}
/// Linearly interpolate between two lists of shadows.
...
...
lib/web_ui/lib/src/engine.dart
浏览文件 @
f581f428
...
...
@@ -70,7 +70,6 @@ part 'engine/plugins.dart';
part
'engine/pointer_binding.dart'
;
part
'engine/pointer_converter.dart'
;
part
'engine/profiler.dart'
;
part
'engine/render_vertices.dart'
;
part
'engine/rrect_renderer.dart'
;
part
'engine/semantics/accessibility.dart'
;
part
'engine/semantics/checkable.dart'
;
...
...
@@ -90,6 +89,7 @@ part 'engine/services/serialization.dart';
part
'engine/shader.dart'
;
part
'engine/shadow.dart'
;
part
'engine/surface/backdrop_filter.dart'
;
part
'engine/surface/canvas.dart'
;
part
'engine/surface/clip.dart'
;
part
'engine/surface/debug_canvas_reuse_overlay.dart'
;
part
'engine/surface/image_filter.dart'
;
...
...
@@ -100,6 +100,7 @@ part 'engine/surface/path_metrics.dart';
part
'engine/surface/picture.dart'
;
part
'engine/surface/platform_view.dart'
;
part
'engine/surface/recording_canvas.dart'
;
part
'engine/surface/render_vertices.dart'
;
part
'engine/surface/scene.dart'
;
part
'engine/surface/scene_builder.dart'
;
part
'engine/surface/surface.dart'
;
...
...
lib/web_ui/lib/src/engine/bitmap_canvas.dart
浏览文件 @
f581f428
...
...
@@ -761,20 +761,20 @@ class BitmapCanvas extends EngineCanvas {
/// and use a SkTriColorShader to render.
@override
void
drawVertices
(
ui
.
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
)
{
Surface
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
)
{
// TODO(flutter_web): Implement shaders for [Paint.shader] and
// blendMode. https://github.com/flutter/flutter/issues/40096
// Move rendering to OffscreenCanvas so that transform is preserved
// as well.
assert
(
paint
.
shader
==
null
,
'Linear/Radial/SweepGradient and ImageShader not supported yet'
);
final
Int32List
colors
=
vertices
.
colors
;
final
ui
.
VertexMode
mode
=
vertices
.
mode
;
final
Int32List
colors
=
vertices
.
_
colors
;
final
ui
.
VertexMode
mode
=
vertices
.
_
mode
;
html
.
CanvasRenderingContext2D
ctx
=
_canvasPool
.
context
;
if
(
colors
==
null
)
{
final
Float32List
positions
=
mode
==
ui
.
VertexMode
.
triangles
?
vertices
.
positions
:
_convertVertexPositions
(
mode
,
vertices
.
positions
);
?
vertices
.
_
positions
:
_convertVertexPositions
(
mode
,
vertices
.
_
positions
);
// Draw hairline for vertices if no vertex colors are specified.
save
();
final
ui
.
Color
color
=
paint
.
color
??
ui
.
Color
(
0xFF000000
);
...
...
lib/web_ui/lib/src/engine/compositor/picture_recorder.dart
浏览文件 @
f581f428
...
...
@@ -15,7 +15,7 @@ class SkPictureRecorder implements ui.PictureRecorder {
_recorder
=
js
.
JsObject
(
canvasKit
[
'SkPictureRecorder'
]);
final
js
.
JsObject
skRect
=
js
.
JsObject
(
canvasKit
[
'LTRBRect'
],
<
double
>[
bounds
.
left
,
bounds
.
top
,
bounds
.
right
,
bounds
.
bottom
]);
final
js
.
JsObject
skCanvas
=
final
js
.
JsObject
/*!*/
skCanvas
=
_recorder
.
callMethod
(
'beginRecording'
,
<
js
.
JsObject
>[
skRect
]);
_recordingCanvas
=
SkCanvas
(
skCanvas
);
return
_recordingCanvas
;
...
...
lib/web_ui/lib/src/engine/compositor/surface.dart
浏览文件 @
f581f428
...
...
@@ -158,7 +158,7 @@ class SkSurface {
SkSurface
(
this
.
_surface
,
this
.
_glContext
);
SkCanvas
getCanvas
()
{
final
js
.
JsObject
skCanvas
=
_surface
.
callMethod
(
'getCanvas'
);
final
js
.
JsObject
/*!*/
skCanvas
=
_surface
.
callMethod
(
'getCanvas'
);
return
SkCanvas
(
skCanvas
);
}
...
...
lib/web_ui/lib/src/engine/compositor/vertices.dart
浏览文件 @
f581f428
...
...
@@ -110,17 +110,4 @@ class SkVertices implements ui.Vertices {
return
false
;
}
}
@override
Int32List
get
colors
=>
null
;
@override
Float32List
get
positions
=>
null
;
@override
ui
.
VertexMode
get
mode
=>
null
;
Float32List
get
textureCoordinates
=>
null
;
Uint16List
get
indices
=>
null
;
}
lib/web_ui/lib/src/engine/engine_canvas.dart
浏览文件 @
f581f428
...
...
@@ -68,7 +68,7 @@ abstract class EngineCanvas {
void
drawParagraph
(
EngineParagraph
paragraph
,
ui
.
Offset
offset
);
void
drawVertices
(
ui
.
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
);
Surface
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
);
void
drawPoints
(
ui
.
PointMode
pointMode
,
Float32List
points
,
SurfacePaintData
paint
);
...
...
lib/web_ui/lib/src/engine/surface/canvas.dart
0 → 100644
浏览文件 @
f581f428
// Copyright 2013 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.
// @dart = 2.6
part of
engine
;
class
SurfaceCanvas
implements
ui
.
Canvas
{
RecordingCanvas
/*!*/
_canvas
;
SurfaceCanvas
(
EnginePictureRecorder
recorder
,
[
ui
.
Rect
cullRect
])
:
assert
(
recorder
!=
null
)
{
if
(
recorder
.
isRecording
)
{
throw
ArgumentError
(
'"recorder" must not already be associated with another Canvas.'
);
}
cullRect
??=
ui
.
Rect
.
largest
;
_canvas
=
recorder
.
beginRecording
(
cullRect
);
}
@override
void
save
()
{
_canvas
.
save
();
}
@override
void
saveLayer
(
ui
.
Rect
/*?*/
bounds
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
paint
!=
null
);
if
(
bounds
==
null
)
{
_saveLayerWithoutBounds
(
paint
);
}
else
{
assert
(
rectIsValid
(
bounds
));
_saveLayer
(
bounds
,
paint
);
}
}
void
_saveLayerWithoutBounds
(
ui
.
Paint
paint
)
{
_canvas
.
saveLayerWithoutBounds
(
paint
);
}
void
_saveLayer
(
ui
.
Rect
bounds
,
ui
.
Paint
paint
)
{
_canvas
.
saveLayer
(
bounds
,
paint
);
}
@override
void
restore
()
{
_canvas
.
restore
();
}
@override
int
/*!*/
getSaveCount
()
=>
_canvas
.
saveCount
;
@override
void
translate
(
double
/*!*/
dx
,
double
/*!*/
dy
)
{
_canvas
.
translate
(
dx
,
dy
);
}
@override
void
scale
(
double
/*!*/
sx
,
[
double
/*?*/
sy
])
=>
_scale
(
sx
,
sy
??
sx
);
void
_scale
(
double
sx
,
double
sy
)
{
_canvas
.
scale
(
sx
,
sy
);
}
@override
void
rotate
(
double
/*!*/
radians
)
{
_canvas
.
rotate
(
radians
);
}
@override
void
skew
(
double
/*!*/
sx
,
double
/*!*/
sy
)
{
_canvas
.
skew
(
sx
,
sy
);
}
@override
void
transform
(
Float64List
/*!*/
matrix4
)
{
assert
(
matrix4
!=
null
);
if
(
matrix4
.
length
!=
16
)
{
throw
ArgumentError
(
'"matrix4" must have 16 entries.'
);
}
_transform
(
toMatrix32
(
matrix4
));
}
void
_transform
(
Float32List
matrix4
)
{
_canvas
.
transform
(
matrix4
);
}
@override
void
clipRect
(
ui
.
Rect
/*!*/
rect
,
{
ui
.
ClipOp
clipOp
/*!*/
=
ui
.
ClipOp
.
intersect
,
bool
/*!*/
doAntiAlias
=
true
})
{
assert
(
rectIsValid
(
rect
));
assert
(
clipOp
!=
null
);
assert
(
doAntiAlias
!=
null
);
_clipRect
(
rect
,
clipOp
,
doAntiAlias
);
}
void
_clipRect
(
ui
.
Rect
rect
,
ui
.
ClipOp
clipOp
,
bool
doAntiAlias
)
{
_canvas
.
clipRect
(
rect
);
}
@override
void
clipRRect
(
ui
.
RRect
/*!*/
rrect
,
{
bool
/*!*/
doAntiAlias
=
true
})
{
assert
(
rrectIsValid
(
rrect
));
assert
(
doAntiAlias
!=
null
);
_clipRRect
(
rrect
,
doAntiAlias
);
}
void
_clipRRect
(
ui
.
RRect
rrect
,
bool
doAntiAlias
)
{
_canvas
.
clipRRect
(
rrect
);
}
@override
void
clipPath
(
ui
.
Path
/*!*/
path
,
{
bool
/*!*/
doAntiAlias
=
true
})
{
assert
(
path
!=
null
);
// path is checked on the engine side
assert
(
doAntiAlias
!=
null
);
_clipPath
(
path
,
doAntiAlias
);
}
void
_clipPath
(
ui
.
Path
path
,
bool
doAntiAlias
)
{
_canvas
.
clipPath
(
path
,
doAntiAlias:
doAntiAlias
);
}
@override
void
drawColor
(
ui
.
Color
/*!*/
color
,
ui
.
BlendMode
/*!*/
blendMode
)
{
assert
(
color
!=
null
);
assert
(
blendMode
!=
null
);
_drawColor
(
color
,
blendMode
);
}
void
_drawColor
(
ui
.
Color
color
,
ui
.
BlendMode
blendMode
)
{
_canvas
.
drawColor
(
color
,
blendMode
);
}
@override
void
drawLine
(
ui
.
Offset
/*!*/
p1
,
ui
.
Offset
/*!*/
p2
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
offsetIsValid
(
p1
));
assert
(
offsetIsValid
(
p2
));
assert
(
paint
!=
null
);
_drawLine
(
p1
,
p2
,
paint
);
}
void
_drawLine
(
ui
.
Offset
p1
,
ui
.
Offset
p2
,
ui
.
Paint
paint
)
{
_canvas
.
drawLine
(
p1
,
p2
,
paint
);
}
@override
void
drawPaint
(
ui
.
Paint
/*!*/
paint
)
{
assert
(
paint
!=
null
);
_drawPaint
(
paint
);
}
void
_drawPaint
(
ui
.
Paint
paint
)
{
_canvas
.
drawPaint
(
paint
);
}
@override
void
drawRect
(
ui
.
Rect
/*!*/
rect
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
rectIsValid
(
rect
));
assert
(
paint
!=
null
);
_drawRect
(
rect
,
paint
);
}
void
_drawRect
(
ui
.
Rect
rect
,
ui
.
Paint
paint
)
{
_canvas
.
drawRect
(
rect
,
paint
);
}
@override
void
drawRRect
(
ui
.
RRect
/*!*/
rrect
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
rrectIsValid
(
rrect
));
assert
(
paint
!=
null
);
_drawRRect
(
rrect
,
paint
);
}
void
_drawRRect
(
ui
.
RRect
rrect
,
ui
.
Paint
paint
)
{
_canvas
.
drawRRect
(
rrect
,
paint
);
}
@override
void
drawDRRect
(
ui
.
RRect
/*!*/
outer
,
ui
.
RRect
/*!*/
inner
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
rrectIsValid
(
outer
));
assert
(
rrectIsValid
(
inner
));
assert
(
paint
!=
null
);
_drawDRRect
(
outer
,
inner
,
paint
);
}
void
_drawDRRect
(
ui
.
RRect
outer
,
ui
.
RRect
inner
,
ui
.
Paint
paint
)
{
_canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
}
@override
void
drawOval
(
ui
.
Rect
/*!*/
rect
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
rectIsValid
(
rect
));
assert
(
paint
!=
null
);
_drawOval
(
rect
,
paint
);
}
void
_drawOval
(
ui
.
Rect
rect
,
ui
.
Paint
paint
)
{
_canvas
.
drawOval
(
rect
,
paint
);
}
@override
void
drawCircle
(
ui
.
Offset
/*!*/
c
,
double
/*!*/
radius
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
offsetIsValid
(
c
));
assert
(
paint
!=
null
);
_drawCircle
(
c
,
radius
,
paint
);
}
void
_drawCircle
(
ui
.
Offset
c
,
double
radius
,
ui
.
Paint
paint
)
{
_canvas
.
drawCircle
(
c
,
radius
,
paint
);
}
@override
void
drawArc
(
ui
.
Rect
/*!*/
rect
,
double
/*!*/
startAngle
,
double
/*!*/
sweepAngle
,
bool
/*!*/
useCenter
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
rectIsValid
(
rect
));
assert
(
paint
!=
null
);
const
double
pi
=
math
.
pi
;
const
double
pi2
=
2.0
*
pi
;
final
ui
.
Path
path
=
ui
.
Path
();
if
(
useCenter
)
{
path
.
moveTo
(
(
rect
.
left
+
rect
.
right
)
/
2.0
,
(
rect
.
top
+
rect
.
bottom
)
/
2.0
);
}
bool
forceMoveTo
=
!
useCenter
;
if
(
sweepAngle
<=
-
pi2
)
{
path
.
arcTo
(
rect
,
startAngle
,
-
pi
,
forceMoveTo
);
startAngle
-=
pi
;
path
.
arcTo
(
rect
,
startAngle
,
-
pi
,
false
);
startAngle
-=
pi
;
forceMoveTo
=
false
;
sweepAngle
+=
pi2
;
}
while
(
sweepAngle
>=
pi2
)
{
path
.
arcTo
(
rect
,
startAngle
,
pi
,
forceMoveTo
);
startAngle
+=
pi
;
path
.
arcTo
(
rect
,
startAngle
,
pi
,
false
);
startAngle
+=
pi
;
forceMoveTo
=
false
;
sweepAngle
-=
pi2
;
}
path
.
arcTo
(
rect
,
startAngle
,
sweepAngle
,
forceMoveTo
);
if
(
useCenter
)
{
path
.
close
();
}
_canvas
.
drawPath
(
path
,
paint
);
}
@override
void
drawPath
(
ui
.
Path
/*!*/
path
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
path
!=
null
);
// path is checked on the engine side
assert
(
paint
!=
null
);
_drawPath
(
path
,
paint
);
}
void
_drawPath
(
ui
.
Path
path
,
ui
.
Paint
paint
)
{
_canvas
.
drawPath
(
path
,
paint
);
}
@override
void
drawImage
(
ui
.
Image
/*!*/
image
,
ui
.
Offset
/*!*/
offset
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
image
!=
null
);
// image is checked on the engine side
assert
(
offsetIsValid
(
offset
));
assert
(
paint
!=
null
);
_drawImage
(
image
,
offset
,
paint
);
}
void
_drawImage
(
ui
.
Image
image
,
ui
.
Offset
p
,
ui
.
Paint
paint
)
{
_canvas
.
drawImage
(
image
,
p
,
paint
);
}
@override
void
drawImageRect
(
ui
.
Image
/*!*/
image
,
ui
.
Rect
/*!*/
src
,
ui
.
Rect
/*!*/
dst
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
image
!=
null
);
// image is checked on the engine side
assert
(
rectIsValid
(
src
));
assert
(
rectIsValid
(
dst
));
assert
(
paint
!=
null
);
_drawImageRect
(
image
,
src
,
dst
,
paint
);
}
void
_drawImageRect
(
ui
.
Image
image
,
ui
.
Rect
src
,
ui
.
Rect
dst
,
ui
.
Paint
paint
)
{
_canvas
.
drawImageRect
(
image
,
src
,
dst
,
paint
);
}
@override
void
drawImageNine
(
ui
.
Image
/*!*/
image
,
ui
.
Rect
/*!*/
center
,
ui
.
Rect
/*!*/
dst
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
image
!=
null
);
// image is checked on the engine side
assert
(
rectIsValid
(
center
));
assert
(
rectIsValid
(
dst
));
assert
(
paint
!=
null
);
// Assert you can fit the scaled part of the image (exluding the
// center source).
assert
(
image
.
width
-
center
.
width
<
dst
.
width
);
assert
(
image
.
height
-
center
.
height
<
dst
.
height
);
// The four unscaled corner rectangles in the from the src.
final
ui
.
Rect
srcTopLeft
=
ui
.
Rect
.
fromLTWH
(
0
,
0
,
center
.
left
,
center
.
top
,
);
final
ui
.
Rect
srcTopRight
=
ui
.
Rect
.
fromLTWH
(
center
.
right
,
0
,
image
.
width
-
center
.
right
,
center
.
top
,
);
final
ui
.
Rect
srcBottomLeft
=
ui
.
Rect
.
fromLTWH
(
0
,
center
.
bottom
,
center
.
left
,
image
.
height
-
center
.
bottom
,
);
final
ui
.
Rect
srcBottomRight
=
ui
.
Rect
.
fromLTWH
(
center
.
right
,
center
.
bottom
,
image
.
width
-
center
.
right
,
image
.
height
-
center
.
bottom
,
);
final
ui
.
Rect
dstTopLeft
=
srcTopLeft
.
shift
(
dst
.
topLeft
);
// The center rectangle in the dst region
final
ui
.
Rect
dstCenter
=
ui
.
Rect
.
fromLTWH
(
dstTopLeft
.
right
,
dstTopLeft
.
bottom
,
dst
.
width
-
(
srcTopLeft
.
width
+
srcTopRight
.
width
),
dst
.
height
-
(
srcTopLeft
.
height
+
srcBottomLeft
.
height
),
);
drawImageRect
(
image
,
srcTopLeft
,
dstTopLeft
,
paint
);
final
ui
.
Rect
dstTopRight
=
ui
.
Rect
.
fromLTWH
(
dstCenter
.
right
,
dst
.
top
,
srcTopRight
.
width
,
srcTopRight
.
height
,
);
drawImageRect
(
image
,
srcTopRight
,
dstTopRight
,
paint
);
final
ui
.
Rect
dstBottomLeft
=
ui
.
Rect
.
fromLTWH
(
dst
.
left
,
dstCenter
.
bottom
,
srcBottomLeft
.
width
,
srcBottomLeft
.
height
,
);
drawImageRect
(
image
,
srcBottomLeft
,
dstBottomLeft
,
paint
);
final
ui
.
Rect
dstBottomRight
=
ui
.
Rect
.
fromLTWH
(
dstCenter
.
right
,
dstCenter
.
bottom
,
srcBottomRight
.
width
,
srcBottomRight
.
height
,
);
drawImageRect
(
image
,
srcBottomRight
,
dstBottomRight
,
paint
);
// Draw the top center rectangle.
drawImageRect
(
image
,
ui
.
Rect
.
fromLTRB
(
srcTopLeft
.
right
,
srcTopLeft
.
top
,
srcTopRight
.
left
,
srcTopRight
.
bottom
,
),
ui
.
Rect
.
fromLTRB
(
dstTopLeft
.
right
,
dstTopLeft
.
top
,
dstTopRight
.
left
,
dstTopRight
.
bottom
,
),
paint
,
);
// Draw the middle left rectangle.
drawImageRect
(
image
,
ui
.
Rect
.
fromLTRB
(
srcTopLeft
.
left
,
srcTopLeft
.
bottom
,
srcBottomLeft
.
right
,
srcBottomLeft
.
top
,
),
ui
.
Rect
.
fromLTRB
(
dstTopLeft
.
left
,
dstTopLeft
.
bottom
,
dstBottomLeft
.
right
,
dstBottomLeft
.
top
,
),
paint
,
);
// Draw the center rectangle.
drawImageRect
(
image
,
center
,
dstCenter
,
paint
);
// Draw the middle right rectangle.
drawImageRect
(
image
,
ui
.
Rect
.
fromLTRB
(
srcTopRight
.
left
,
srcTopRight
.
bottom
,
srcBottomRight
.
right
,
srcBottomRight
.
top
,
),
ui
.
Rect
.
fromLTRB
(
dstTopRight
.
left
,
dstTopRight
.
bottom
,
dstBottomRight
.
right
,
dstBottomRight
.
top
,
),
paint
,
);
// Draw the bottom center rectangle.
drawImageRect
(
image
,
ui
.
Rect
.
fromLTRB
(
srcBottomLeft
.
right
,
srcBottomLeft
.
top
,
srcBottomRight
.
left
,
srcBottomRight
.
bottom
,
),
ui
.
Rect
.
fromLTRB
(
dstBottomLeft
.
right
,
dstBottomLeft
.
top
,
dstBottomRight
.
left
,
dstBottomRight
.
bottom
,
),
paint
,
);
}
@override
void
drawPicture
(
ui
.
Picture
/*!*/
picture
)
{
assert
(
picture
!=
null
);
// picture is checked on the engine side
// TODO(het): Support this
throw
UnimplementedError
();
}
@override
void
drawParagraph
(
ui
.
Paragraph
/*!*/
paragraph
,
ui
.
Offset
/*!*/
offset
)
{
assert
(
paragraph
!=
null
);
assert
(
offsetIsValid
(
offset
));
_drawParagraph
(
paragraph
,
offset
);
}
void
_drawParagraph
(
ui
.
Paragraph
paragraph
,
ui
.
Offset
offset
)
{
_canvas
.
drawParagraph
(
paragraph
,
offset
);
}
@override
void
drawPoints
(
ui
.
PointMode
/*!*/
pointMode
,
List
<
ui
.
Offset
/*!*/
>
/*!*/
points
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
pointMode
!=
null
);
assert
(
points
!=
null
);
assert
(
paint
!=
null
);
final
Float32List
pointList
=
offsetListToFloat32List
(
points
);
drawRawPoints
(
pointMode
,
pointList
,
paint
);
}
@override
void
drawRawPoints
(
ui
.
PointMode
/*!*/
pointMode
,
Float32List
/*!*/
points
,
ui
.
Paint
/*!*/
paint
)
{
assert
(
pointMode
!=
null
);
assert
(
points
!=
null
);
assert
(
paint
!=
null
);
if
(
points
.
length
%
2
!=
0
)
{
throw
ArgumentError
(
'"points" must have an even number of values.'
);
}
_canvas
.
drawRawPoints
(
pointMode
,
points
,
paint
);
}
@override
void
drawVertices
(
ui
.
Vertices
/*!*/
vertices
,
ui
.
BlendMode
/*!*/
blendMode
,
ui
.
Paint
/*!*/
paint
)
{
if
(
vertices
==
null
)
{
return
;
}
//assert(vertices != null); // vertices is checked on the engine side
assert
(
paint
!=
null
);
assert
(
blendMode
!=
null
);
_canvas
.
drawVertices
(
vertices
,
blendMode
,
paint
);
}
@override
void
drawAtlas
(
ui
.
Image
/*!*/
atlas
,
List
<
ui
.
RSTransform
/*!*/
>
/*!*/
transforms
,
List
<
ui
.
Rect
/*!*/
>
/*!*/
rects
,
List
<
ui
.
Color
/*!*/
>
/*!*/
colors
,
ui
.
BlendMode
/*!*/
blendMode
,
ui
.
Rect
/*?*/
cullRect
,
ui
.
Paint
/*!*/
paint
,
)
{
assert
(
atlas
!=
null
);
// atlas is checked on the engine side
assert
(
transforms
!=
null
);
assert
(
rects
!=
null
);
assert
(
colors
!=
null
);
assert
(
blendMode
!=
null
);
assert
(
paint
!=
null
);
final
int
rectCount
=
rects
.
length
;
if
(
transforms
.
length
!=
rectCount
)
{
throw
ArgumentError
(
'"transforms" and "rects" lengths must match.'
);
}
if
(
colors
.
isNotEmpty
&&
colors
.
length
!=
rectCount
)
{
throw
ArgumentError
(
'If non-null, "colors" length must match that of "transforms" and "rects".'
);
}
// TODO(het): Do we need to support this?
throw
UnimplementedError
();
}
@override
void
drawRawAtlas
(
ui
.
Image
/*!*/
atlas
,
Float32List
/*!*/
rstTransforms
,
Float32List
/*!*/
rects
,
Int32List
/*!*/
colors
,
ui
.
BlendMode
/*!*/
blendMode
,
ui
.
Rect
/*?*/
cullRect
,
ui
.
Paint
/*!*/
paint
,
)
{
assert
(
atlas
!=
null
);
// atlas is checked on the engine side
assert
(
rstTransforms
!=
null
);
assert
(
rects
!=
null
);
assert
(
colors
!=
null
);
assert
(
blendMode
!=
null
);
assert
(
paint
!=
null
);
final
int
rectCount
=
rects
.
length
;
if
(
rstTransforms
.
length
!=
rectCount
)
{
throw
ArgumentError
(
'"rstTransforms" and "rects" lengths must match.'
);
}
if
(
rectCount
%
4
!=
0
)
{
throw
ArgumentError
(
'"rstTransforms" and "rects" lengths must be a multiple of four.'
);
}
if
(
colors
!=
null
&&
colors
.
length
*
4
!=
rectCount
)
{
throw
ArgumentError
(
'If non-null, "colors" length must be one fourth the length of "rstTransforms" and "rects".'
);
}
// TODO(het): Do we need to support this?
throw
UnimplementedError
();
}
@override
void
drawShadow
(
ui
.
Path
/*!*/
path
,
ui
.
Color
/*!*/
color
,
double
/*!*/
elevation
,
bool
/*!*/
transparentOccluder
,
)
{
assert
(
path
!=
null
);
// path is checked on the engine side
assert
(
color
!=
null
);
assert
(
transparentOccluder
!=
null
);
_canvas
.
drawShadow
(
path
,
color
,
elevation
,
transparentOccluder
);
}
}
lib/web_ui/lib/src/engine/surface/debug_canvas_reuse_overlay.dart
浏览文件 @
f581f428
...
...
@@ -72,7 +72,7 @@ class DebugCanvasReuseOverlay {
}
static
DebugCanvasReuseOverlay
_instance
;
static
DebugCanvasReuseOverlay
get
instance
{
static
DebugCanvasReuseOverlay
/*!*/
get
instance
{
if
(
_instance
==
null
)
{
// Only call the constructor when assertions are enabled to guard against
// mistakingly including this class in a release build.
...
...
lib/web_ui/lib/src/engine/surface/recording_canvas.dart
浏览文件 @
f581f428
...
...
@@ -542,12 +542,12 @@ class RecordingCanvas {
}
void
drawVertices
(
ui
.
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaint
paint
)
{
Surface
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaint
paint
)
{
assert
(!
_debugRecordingEnded
);
_hasArbitraryPaint
=
true
;
_didDraw
=
true
;
final
PaintDrawVertices
command
=
PaintDrawVertices
(
vertices
,
blendMode
,
paint
.
paintData
);
_growPaintBoundsByPoints
(
vertices
.
positions
,
0
,
paint
,
command
);
_growPaintBoundsByPoints
(
vertices
.
_
positions
,
0
,
paint
,
command
);
_commands
.
add
(
command
);
}
...
...
lib/web_ui/lib/src/engine/render_vertices.dart
→
lib/web_ui/lib/src/engine/
surface/
render_vertices.dart
浏览文件 @
f581f428
...
...
@@ -7,6 +7,49 @@ part of engine;
_GlRenderer
_glRenderer
;
class
SurfaceVertices
implements
ui
.
Vertices
{
final
ui
.
VertexMode
_mode
;
final
Float32List
_positions
;
final
Int32List
/*?*/
_colors
;
final
Uint16List
_indices
;
// ignore: unused_field
SurfaceVertices
(
ui
.
VertexMode
mode
,
List
<
ui
.
Offset
>
positions
,
{
List
<
ui
.
Color
>
colors
,
List
<
int
>
indices
,
})
:
assert
(
mode
!=
null
),
assert
(
positions
!=
null
),
_mode
=
mode
,
_colors
=
colors
!=
null
?
_int32ListFromColors
(
colors
)
:
null
,
_indices
=
indices
!=
null
?
Uint16List
.
fromList
(
indices
)
:
null
,
_positions
=
offsetListToFloat32List
(
positions
)
{
initWebGl
();
}
SurfaceVertices
.
raw
(
ui
.
VertexMode
mode
,
Float32List
positions
,
{
Int32List
colors
,
Uint16List
indices
,
})
:
assert
(
mode
!=
null
),
assert
(
positions
!=
null
),
_mode
=
mode
,
_positions
=
positions
,
_colors
=
colors
,
_indices
=
indices
{
initWebGl
();
}
static
Int32List
_int32ListFromColors
(
List
<
ui
.
Color
>
colors
)
{
Int32List
list
=
Int32List
(
colors
.
length
);
for
(
int
i
=
0
,
len
=
colors
.
length
;
i
<
len
;
i
++)
{
list
[
i
]
=
colors
[
i
].
value
;
}
return
list
;
}
}
void
initWebGl
(
)
{
_glRenderer
??=
_WebGlRenderer
();
}
...
...
@@ -22,7 +65,7 @@ abstract class _GlRenderer {
int
canvasWidthInPixels
,
int
canvasHeightInPixels
,
Matrix4
transform
,
ui
.
Vertices
vertices
,
Surface
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
);
...
...
@@ -85,11 +128,11 @@ class _WebGlRenderer implements _GlRenderer {
int
canvasWidthInPixels
,
int
canvasHeightInPixels
,
Matrix4
transform
,
ui
.
Vertices
vertices
,
Surface
Vertices
vertices
,
ui
.
BlendMode
blendMode
,
SurfacePaintData
paint
)
{
// Compute bounds of vertices.
final
Float32List
positions
=
vertices
.
positions
;
final
Float32List
positions
=
vertices
.
_
positions
;
ui
.
Rect
bounds
=
_computeVerticesBounds
(
positions
,
transform
);
double
minValueX
=
bounds
.
left
;
double
minValueY
=
bounds
.
top
;
...
...
@@ -152,14 +195,14 @@ class _WebGlRenderer implements _GlRenderer {
Object
colorsBuffer
=
gl
.
createBuffer
();
gl
.
bindArrayBuffer
(
colorsBuffer
);
// Buffer kBGRA_8888.
gl
.
bufferData
(
vertices
.
colors
,
gl
.
kStaticDraw
);
gl
.
bufferData
(
vertices
.
_
colors
,
gl
.
kStaticDraw
);
js_util
.
callMethod
(
gl
.
glContext
,
'vertexAttribPointer'
,
<
dynamic
>[
1
,
4
,
gl
.
kUnsignedByte
,
true
,
0
,
0
]);
gl
.
enableVertexAttribArray
(
1
);
gl
.
clear
();
final
int
vertexCount
=
positions
.
length
~/
2
;
gl
.
drawTriangles
(
vertexCount
,
vertices
.
mode
);
gl
.
drawTriangles
(
vertexCount
,
vertices
.
_
mode
);
context
.
save
();
context
.
resetTransform
();
...
...
lib/web_ui/lib/src/engine/util.dart
浏览文件 @
f581f428
...
...
@@ -35,7 +35,7 @@ typedef Callbacker<T> = String Function(Callback<T> callback);
/// return _futurize(_doSomethingAndCallback);
/// }
/// ```
Future
<
T
>
futurize
<
T
>(
Callbacker
<
T
>
callbacker
)
{
Future
<
T
>
/*!*/
futurize
<
T
>(
Callbacker
<
T
>
callbacker
)
{
final
Completer
<
T
>
completer
=
Completer
<
T
>.
sync
();
final
String
error
=
callbacker
((
T
t
)
{
if
(
t
==
null
)
{
...
...
lib/web_ui/lib/src/ui/canvas.dart
浏览文件 @
f581f428
此差异已折叠。
点击以展开。
lib/web_ui/lib/src/ui/geometry.dart
浏览文件 @
f581f428
...
...
@@ -314,15 +314,21 @@ class Offset extends OffsetBase {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Offset
/*
!
*/
lerp
(
Offset
/*?*/
a
,
Offset
/*?*/
b
,
double
/*!*/
t
)
{
static
Offset
/*
?
*/
lerp
(
Offset
/*?*/
a
,
Offset
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
return
Offset
(
lerpDouble
(
a
.
dx
,
b
.
dx
,
t
),
lerpDouble
(
a
.
dy
,
b
.
dy
,
t
));
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
*
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
*
t
;
}
else
{
return
Offset
(
_lerpDouble
(
a
.
dx
,
b
.
dx
,
t
),
_lerpDouble
(
a
.
dy
,
b
.
dy
,
t
));
}
}
}
/// Compares two Offsets for equality.
...
...
@@ -579,15 +585,21 @@ class Size extends OffsetBase {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Size
/*
!
*/
lerp
(
Size
/*?*/
a
,
Size
/*?*/
b
,
double
/*!*/
t
)
{
static
Size
/*
?
*/
lerp
(
Size
/*?*/
a
,
Size
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
return
Size
(
lerpDouble
(
a
.
width
,
b
.
width
,
t
),
lerpDouble
(
a
.
height
,
b
.
height
,
t
));
if
(
b
==
null
)
{
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
*
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
*
t
;
}
else
{
return
Size
(
_lerpDouble
(
a
.
width
,
b
.
width
,
t
),
_lerpDouble
(
a
.
height
,
b
.
height
,
t
));
}
}
}
/// Compares two Sizes for equality.
...
...
@@ -847,22 +859,27 @@ class Rect {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Rect
/*
!
*/
lerp
(
Rect
/*?*/
a
,
Rect
/*?*/
b
,
double
/*!*/
t
)
{
static
Rect
/*
?
*/
lerp
(
Rect
/*?*/
a
,
Rect
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
Rect
.
fromLTRB
(
b
.
left
*
t
,
b
.
top
*
t
,
b
.
right
*
t
,
b
.
bottom
*
t
);
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
Rect
.
fromLTRB
(
a
.
left
*
k
,
a
.
top
*
k
,
a
.
right
*
k
,
a
.
bottom
*
k
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
Rect
.
fromLTRB
(
a
.
left
*
k
,
a
.
top
*
k
,
a
.
right
*
k
,
a
.
bottom
*
k
);
}
}
else
{
if
(
a
==
null
)
{
return
Rect
.
fromLTRB
(
b
.
left
*
t
,
b
.
top
*
t
,
b
.
right
*
t
,
b
.
bottom
*
t
);
}
else
{
return
Rect
.
fromLTRB
(
_lerpDouble
(
a
.
left
,
b
.
left
,
t
),
_lerpDouble
(
a
.
top
,
b
.
top
,
t
),
_lerpDouble
(
a
.
right
,
b
.
right
,
t
),
_lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
);
}
}
return
Rect
.
fromLTRB
(
lerpDouble
(
a
.
left
,
b
.
left
,
t
),
lerpDouble
(
a
.
top
,
b
.
top
,
t
),
lerpDouble
(
a
.
right
,
b
.
right
,
t
),
lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
);
}
@override
...
...
@@ -971,20 +988,25 @@ class Radius {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
Radius
/*
!
*/
lerp
(
Radius
/*?*/
a
,
Radius
/*?*/
b
,
double
/*!*/
t
)
{
static
Radius
/*
?
*/
lerp
(
Radius
/*?*/
a
,
Radius
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
Radius
.
elliptical
(
b
.
x
*
t
,
b
.
y
*
t
);
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
Radius
.
elliptical
(
a
.
x
*
k
,
a
.
y
*
k
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
Radius
.
elliptical
(
a
.
x
*
k
,
a
.
y
*
k
);
}
}
else
{
if
(
a
==
null
)
{
return
Radius
.
elliptical
(
b
.
x
*
t
,
b
.
y
*
t
);
}
else
{
return
Radius
.
elliptical
(
_lerpDouble
(
a
.
x
,
b
.
x
,
t
),
_lerpDouble
(
a
.
y
,
b
.
y
,
t
),
);
}
}
return
Radius
.
elliptical
(
lerpDouble
(
a
.
x
,
b
.
x
,
t
),
lerpDouble
(
a
.
y
,
b
.
y
,
t
),
);
}
@override
...
...
@@ -1540,57 +1562,61 @@ class RRect {
///
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static
RRect
/*
!
*/
lerp
(
RRect
/*?*/
a
,
RRect
/*?*/
b
,
double
/*!*/
t
)
{
static
RRect
/*
?
*/
lerp
(
RRect
/*?*/
a
,
RRect
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
{
return
RRect
.
_raw
(
left:
b
.
left
*
t
,
top:
b
.
top
*
t
,
right:
b
.
right
*
t
,
bottom:
b
.
bottom
*
t
,
tlRadiusX:
b
.
tlRadiusX
*
t
,
tlRadiusY:
b
.
tlRadiusY
*
t
,
trRadiusX:
b
.
trRadiusX
*
t
,
trRadiusY:
b
.
trRadiusY
*
t
,
brRadiusX:
b
.
brRadiusX
*
t
,
brRadiusY:
b
.
brRadiusY
*
t
,
blRadiusX:
b
.
blRadiusX
*
t
,
blRadiusY:
b
.
blRadiusY
*
t
,
);
}
if
(
b
==
null
)
{
final
double
k
=
1.0
-
t
;
return
RRect
.
_raw
(
left:
a
.
left
*
k
,
top:
a
.
top
*
k
,
right:
a
.
right
*
k
,
bottom:
a
.
bottom
*
k
,
tlRadiusX:
a
.
tlRadiusX
*
k
,
tlRadiusY:
a
.
tlRadiusY
*
k
,
trRadiusX:
a
.
trRadiusX
*
k
,
trRadiusY:
a
.
trRadiusY
*
k
,
brRadiusX:
a
.
brRadiusX
*
k
,
brRadiusY:
a
.
brRadiusY
*
k
,
blRadiusX:
a
.
blRadiusX
*
k
,
blRadiusY:
a
.
blRadiusY
*
k
,
);
if
(
a
==
null
)
{
return
null
;
}
else
{
final
double
k
=
1.0
-
t
;
return
RRect
.
_raw
(
left:
a
.
left
*
k
,
top:
a
.
top
*
k
,
right:
a
.
right
*
k
,
bottom:
a
.
bottom
*
k
,
tlRadiusX:
a
.
tlRadiusX
*
k
,
tlRadiusY:
a
.
tlRadiusY
*
k
,
trRadiusX:
a
.
trRadiusX
*
k
,
trRadiusY:
a
.
trRadiusY
*
k
,
brRadiusX:
a
.
brRadiusX
*
k
,
brRadiusY:
a
.
brRadiusY
*
k
,
blRadiusX:
a
.
blRadiusX
*
k
,
blRadiusY:
a
.
blRadiusY
*
k
,
);
}
}
else
{
if
(
a
==
null
)
{
return
RRect
.
_raw
(
left:
b
.
left
*
t
,
top:
b
.
top
*
t
,
right:
b
.
right
*
t
,
bottom:
b
.
bottom
*
t
,
tlRadiusX:
b
.
tlRadiusX
*
t
,
tlRadiusY:
b
.
tlRadiusY
*
t
,
trRadiusX:
b
.
trRadiusX
*
t
,
trRadiusY:
b
.
trRadiusY
*
t
,
brRadiusX:
b
.
brRadiusX
*
t
,
brRadiusY:
b
.
brRadiusY
*
t
,
blRadiusX:
b
.
blRadiusX
*
t
,
blRadiusY:
b
.
blRadiusY
*
t
,
);
}
else
{
return
RRect
.
_raw
(
left:
_lerpDouble
(
a
.
left
,
b
.
left
,
t
),
top:
_lerpDouble
(
a
.
top
,
b
.
top
,
t
),
right:
_lerpDouble
(
a
.
right
,
b
.
right
,
t
),
bottom:
_lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
tlRadiusX:
_lerpDouble
(
a
.
tlRadiusX
,
b
.
tlRadiusX
,
t
),
tlRadiusY:
_lerpDouble
(
a
.
tlRadiusY
,
b
.
tlRadiusY
,
t
),
trRadiusX:
_lerpDouble
(
a
.
trRadiusX
,
b
.
trRadiusX
,
t
),
trRadiusY:
_lerpDouble
(
a
.
trRadiusY
,
b
.
trRadiusY
,
t
),
brRadiusX:
_lerpDouble
(
a
.
brRadiusX
,
b
.
brRadiusX
,
t
),
brRadiusY:
_lerpDouble
(
a
.
brRadiusY
,
b
.
brRadiusY
,
t
),
blRadiusX:
_lerpDouble
(
a
.
blRadiusX
,
b
.
blRadiusX
,
t
),
blRadiusY:
_lerpDouble
(
a
.
blRadiusY
,
b
.
blRadiusY
,
t
),
);
}
}
return
RRect
.
_raw
(
left:
lerpDouble
(
a
.
left
,
b
.
left
,
t
),
top:
lerpDouble
(
a
.
top
,
b
.
top
,
t
),
right:
lerpDouble
(
a
.
right
,
b
.
right
,
t
),
bottom:
lerpDouble
(
a
.
bottom
,
b
.
bottom
,
t
),
tlRadiusX:
lerpDouble
(
a
.
tlRadiusX
,
b
.
tlRadiusX
,
t
),
tlRadiusY:
lerpDouble
(
a
.
tlRadiusY
,
b
.
tlRadiusY
,
t
),
trRadiusX:
lerpDouble
(
a
.
trRadiusX
,
b
.
trRadiusX
,
t
),
trRadiusY:
lerpDouble
(
a
.
trRadiusY
,
b
.
trRadiusY
,
t
),
brRadiusX:
lerpDouble
(
a
.
brRadiusX
,
b
.
brRadiusX
,
t
),
brRadiusY:
lerpDouble
(
a
.
brRadiusY
,
b
.
brRadiusY
,
t
),
blRadiusX:
lerpDouble
(
a
.
blRadiusX
,
b
.
blRadiusX
,
t
),
blRadiusY:
lerpDouble
(
a
.
blRadiusY
,
b
.
blRadiusY
,
t
),
);
}
@override
...
...
lib/web_ui/lib/src/ui/hash_codes.dart
浏览文件 @
f581f428
...
...
@@ -114,7 +114,7 @@ int/*!*/ hashValues(
/// Combine the [Object.hashCode] values of an arbitrary number of objects from
/// an [Iterable] into one value. This function will return the same value if
/// given null as if given an empty list.
int
/*!*/
hashList
(
Iterable
<
Object
/*?*/
>
/*
!
*/
arguments
)
{
int
/*!*/
hashList
(
Iterable
<
Object
/*?*/
>
/*
?
*/
arguments
)
{
int
result
=
0
;
if
(
arguments
!=
null
)
{
for
(
Object
argument
in
arguments
)
...
...
lib/web_ui/lib/src/ui/initialization.dart
浏览文件 @
f581f428
...
...
@@ -45,7 +45,8 @@ Future<void> _initializePlatform({
_webOnlyIsInitialized
=
true
;
}
/*late*/
engine
.
AssetManager
/*!*/
_assetManager
;
// TODO(yjbanov): can we make this late non-null? See https://github.com/dart-lang/sdk/issues/42214
engine
.
AssetManager
/*?*/
_assetManager
;
engine
.
FontCollection
_fontCollection
;
bool
_webOnlyIsInitialized
=
false
;
...
...
@@ -106,7 +107,7 @@ set debugEmulateFlutterTesterEnvironment(bool/*!*/ value) {
bool
_debugEmulateFlutterTesterEnvironment
=
false
;
/// This class handles downloading assets over the network.
engine
.
AssetManager
get
webOnlyAssetManager
=>
_assetManager
;
engine
.
AssetManager
/*!*/
get
webOnlyAssetManager
=>
_assetManager
;
/// A collection of fonts that may be used by the platform.
engine
.
FontCollection
get
webOnlyFontCollection
=>
_fontCollection
;
engine
.
FontCollection
/*!*/
get
webOnlyFontCollection
=>
_fontCollection
;
lib/web_ui/lib/src/ui/lerp.dart
浏览文件 @
f581f428
...
...
@@ -6,7 +6,7 @@
part of
ui
;
/// Linearly interpolate between two numbers.
double
/*
!
*/
lerpDouble
(
num
/*?*/
a
,
num
/*?*/
b
,
double
/*!*/
t
)
{
double
/*
?
*/
lerpDouble
(
num
/*?*/
a
,
num
/*?*/
b
,
double
/*!*/
t
)
{
if
(
a
==
null
&&
b
==
null
)
{
return
null
;
}
...
...
@@ -14,3 +14,23 @@ double/*!*/ lerpDouble(num/*?*/ a, num/*?*/ b, double/*!*/ t) {
b
??=
0.0
;
return
a
+
(
b
-
a
)
*
t
;
}
double
/*!*/
_lerpDouble
(
double
/*!*/
a
,
double
/*!*/
b
,
double
/*!*/
t
)
{
return
a
+
(
b
-
a
)
*
t
;
}
double
/*!*/
_lerpInt
(
int
/*!*/
a
,
int
/*!*/
b
,
double
/*!*/
t
)
{
return
a
+
(
b
-
a
)
*
t
;
}
/// Same as [num.clamp] but specialized for [int].
int
/*!*/
_clampInt
(
int
/*!*/
value
,
int
/*!*/
min
,
int
/*!*/
max
)
{
assert
(
min
<=
max
);
if
(
value
<
min
)
{
return
min
;
}
else
if
(
value
>
max
)
{
return
max
;
}
else
{
return
value
;
}
}
lib/web_ui/lib/src/ui/painting.dart
浏览文件 @
f581f428
...
...
@@ -33,7 +33,7 @@ void _validateColorStops(List<Color> colors, List<double> colorStops) {
}
Color
_scaleAlpha
(
Color
a
,
double
factor
)
{
return
a
.
withAlpha
(
(
a
.
alpha
*
factor
).
round
().
clamp
(
0
,
255
));
return
a
.
withAlpha
(
_clampInt
((
a
.
alpha
*
factor
).
round
(),
0
,
255
));
}
/// An immutable 32 bit color value in ARGB
...
...
@@ -172,21 +172,24 @@ class Color {
/// an [AnimationController].
static
Color
/*?*/
lerp
(
Color
/*?*/
a
,
Color
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
{
return
null
;
}
if
(
a
==
null
)
{
return
_scaleAlpha
(
b
,
t
);
}
if
(
b
==
null
)
{
return
_scaleAlpha
(
a
,
1.0
-
t
);
if
(
a
==
null
)
{
return
null
;
}
else
{
return
_scaleAlpha
(
a
,
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
_scaleAlpha
(
b
,
t
);
}
else
{
return
Color
.
fromARGB
(
_clampInt
(
_lerpInt
(
a
.
alpha
,
b
.
alpha
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
red
,
b
.
red
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
green
,
b
.
green
,
t
).
toInt
(),
0
,
255
),
_clampInt
(
_lerpInt
(
a
.
blue
,
b
.
blue
,
t
).
toInt
(),
0
,
255
),
);
}
}
return
Color
.
fromARGB
(
lerpDouble
(
a
.
alpha
,
b
.
alpha
,
t
).
toInt
().
clamp
(
0
,
255
),
lerpDouble
(
a
.
red
,
b
.
red
,
t
).
toInt
().
clamp
(
0
,
255
),
lerpDouble
(
a
.
green
,
b
.
green
,
t
).
toInt
().
clamp
(
0
,
255
),
lerpDouble
(
a
.
blue
,
b
.
blue
,
t
).
toInt
().
clamp
(
0
,
255
),
);
}
/// Combine the foreground color as a transparent color over top
...
...
@@ -1187,7 +1190,7 @@ abstract class Gradient extends Shader {
Float64List
/*?*/
matrix4
,
])
=>
engine
.
GradientSweep
(
center
,
colors
,
colorStops
,
tileMode
,
startAngle
,
endAngle
,
engine
.
toMatrix32
(
matrix4
)
);
center
,
colors
,
colorStops
,
tileMode
,
startAngle
,
endAngle
,
matrix4
!=
null
?
engine
.
toMatrix32
(
matrix4
)
:
null
);
}
/// Opaque handle to raw decoded image data (pixels).
...
...
@@ -1528,7 +1531,7 @@ abstract class FrameInfo {
int
get
_durationMillis
=>
0
;
/// The [Image] object for this frame.
Image
get
image
=>
null
;
Image
/*!*/
get
image
;
}
/// A handle to an image codec.
...
...
@@ -1555,7 +1558,7 @@ class Codec {
///
/// The returned future can complete with an error if the decoding has failed.
Future
<
FrameInfo
/*!*/
>
/*!*/
getNextFrame
()
{
return
engine
.
futurize
(
_getNextFrame
);
return
engine
.
futurize
<
FrameInfo
/*!*/
>
(
_getNextFrame
);
}
/// Returns an error message on failure, null on success.
...
...
@@ -1580,7 +1583,7 @@ Future<Codec/*!*/>/*!*/ instantiateImageCodec(
int
/*?*/
targetWidth
,
int
/*?*/
targetHeight
,
})
{
return
engine
.
futurize
((
engine
.
Callback
<
Codec
>
callback
)
=>
return
engine
.
futurize
<
Codec
/*!*/
>
((
engine
.
Callback
<
Codec
>
callback
)
=>
// TODO: Implement targetWidth and targetHeight support.
_instantiateImageCodec
(
list
,
callback
,
null
));
}
...
...
@@ -1604,9 +1607,9 @@ String/*?*/ _instantiateImageCodec(
return
null
;
}
Future
<
Codec
/*?*/
>
webOnlyInstantiateImageCodecFromUrl
(
Uri
/*!*/
uri
,
Future
<
Codec
/*?*/
>
/*!*/
webOnlyInstantiateImageCodecFromUrl
(
Uri
/*!*/
uri
,
{
engine
.
WebOnlyImageCodecChunkCallback
/*?*/
chunkCallback
})
{
return
engine
.
futurize
((
engine
.
Callback
<
Codec
>
callback
)
=>
return
engine
.
futurize
<
Codec
/*?*/
>
((
engine
.
Callback
<
Codec
>
callback
)
=>
_instantiateImageCodecFromUrl
(
uri
,
chunkCallback
,
callback
));
}
...
...
@@ -1760,20 +1763,23 @@ class Shadow {
/// {@endtemplate}
static
Shadow
/*?*/
lerp
(
Shadow
/*?*/
a
,
Shadow
/*?*/
b
,
double
/*!*/
t
)
{
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
{
return
null
;
}
if
(
a
==
null
)
{
return
b
.
scale
(
t
);
}
if
(
b
==
null
)
{
return
a
.
scale
(
1.0
-
t
);
if
(
a
==
null
)
{
return
null
;
}
else
{
return
a
.
scale
(
1.0
-
t
);
}
}
else
{
if
(
a
==
null
)
{
return
b
.
scale
(
t
);
}
else
{
return
Shadow
(
color:
Color
.
lerp
(
a
.
color
,
b
.
color
,
t
),
offset:
Offset
.
lerp
(
a
.
offset
,
b
.
offset
,
t
),
blurRadius:
_lerpDouble
(
a
.
blurRadius
,
b
.
blurRadius
,
t
),
);
}
}
return
Shadow
(
color:
Color
.
lerp
(
a
.
color
,
b
.
color
,
t
),
offset:
Offset
.
lerp
(
a
.
offset
,
b
.
offset
,
t
),
blurRadius:
lerpDouble
(
a
.
blurRadius
,
b
.
blurRadius
,
t
),
);
}
/// Linearly interpolate between two lists of shadows.
...
...
@@ -1788,7 +1794,7 @@ class Shadow {
}
a
??=
<
Shadow
>[];
b
??=
<
Shadow
>[];
final
List
<
Shadow
>
result
=
<
Shadow
>[];
final
List
<
Shadow
/*!*/
>
result
=
<
Shadow
/*!*/
>[];
final
int
commonLength
=
math
.
min
(
a
.
length
,
b
.
length
);
for
(
int
i
=
0
;
i
<
commonLength
;
i
+=
1
)
result
.
add
(
Shadow
.
lerp
(
a
[
i
],
b
[
i
],
t
));
...
...
lib/web_ui/lib/src/ui/test_embedding.dart
浏览文件 @
f581f428
...
...
@@ -27,7 +27,8 @@ Future<dynamic>/*!*/ ensureTestPlatformInitializedThenRunTest(
/// Used to track when the platform is initialized. This ensures the test fonts
/// are available.
/*late*/
Future
<
void
>
/*!*/
_platformInitializedFuture
;
// TODO(yjbanov): can we make this late non-null? See https://github.com/dart-lang/sdk/issues/42214
Future
<
void
>
/*?*/
_platformInitializedFuture
;
/// Initializes domRenderer with specific devicePixelRatio and physicalSize.
Future
<
void
>
/*!*/
webOnlyInitializeTestDomRenderer
({
double
/*!*/
devicePixelRatio
=
3.0
})
{
...
...
lib/web_ui/lib/src/ui/text.dart
浏览文件 @
f581f428
...
...
@@ -135,7 +135,7 @@ class FontWeight {
assert
(
t
!=
null
);
if
(
a
==
null
&&
b
==
null
)
return
null
;
return
values
[
lerpDouble
(
a
?.
index
??
normal
.
index
,
b
?.
index
??
normal
.
index
,
t
).
round
().
clamp
(
0
,
8
)
as
int
];
return
values
[
_clampInt
(
lerpDouble
(
a
?.
index
??
normal
.
index
,
b
?.
index
??
normal
.
index
,
t
).
round
(),
0
,
8
)
];
}
@override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录