Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
919e8c21
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,发现更多精彩内容 >>
未验证
提交
919e8c21
编写于
5月 16, 2018
作者:
D
Dan Field
提交者:
GitHub
5月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for TwoPointConical gradients (#5275)
上级
cdd7e088
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
64 addition
and
4 deletion
+64
-4
lib/ui/painting.dart
lib/ui/painting.dart
+22
-3
lib/ui/painting/gradient.cc
lib/ui/painting/gradient.cc
+31
-1
lib/ui/painting/gradient.h
lib/ui/painting/gradient.h
+11
-0
未找到文件。
lib/ui/painting.dart
浏览文件 @
919e8c21
...
...
@@ -2296,25 +2296,44 @@ class Gradient extends Shader {
/// If `matrix4` is provided, the gradient fill will be transformed by the
/// specified 4x4 matrix relative to the local coordinate system. `matrix4` must
/// be a column-major matrix packed into a list of 16 values.
///
/// If `focal` is provided and not equal to `center` or `focalRadius` is
/// provided and not equal to 0.0, the generated shader will be a two point
/// conical radial gradient, with `focal` being the center of the focal
/// circle and `focalRadius` being the radius of that circle. If `focal` is
/// provided and not equal to `center`, at least one of the two offsets must
/// not be equal to [Offset.zero].
Gradient
.
radial
(
Offset
center
,
double
radius
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
,
TileMode
tileMode
=
TileMode
.
clamp
,
Float64List
matrix4
Float64List
matrix4
,
Offset
focal
,
double
focalRadius
])
:
assert
(
_offsetIsValid
(
center
)),
assert
(
colors
!=
null
),
assert
(
tileMode
!=
null
),
assert
(
matrix4
==
null
||
_matrix4IsValid
(
matrix4
)),
super
.
_
()
{
focal
??=
center
;
focalRadius
??=
0.0
;
_validateColorStops
(
colors
,
colorStops
);
final
Int32List
colorsBuffer
=
_encodeColorList
(
colors
);
final
Float32List
colorStopsBuffer
=
colorStops
==
null
?
null
:
new
Float32List
.
fromList
(
colorStops
);
if
(
center
==
focal
&&
focalRadius
!=
0.0
)
{
_constructor
();
_initRadial
(
center
.
dx
,
center
.
dy
,
radius
,
colorsBuffer
,
colorStopsBuffer
,
tileMode
.
index
,
matrix4
);
}
else
{
assert
(
center
!=
Offset
.
zero
||
focal
!=
Offset
.
zero
);
// will result in nullptr in Skia side
_constructor
();
_initConical
(
focal
.
dx
,
focal
.
dy
,
focalRadius
,
center
.
dx
,
center
.
dy
,
radius
,
colorsBuffer
,
colorStopsBuffer
,
tileMode
.
index
,
matrix4
);
}
}
void
_initRadial
(
double
centerX
,
double
centerY
,
double
radius
,
Int32List
colors
,
Float32List
colorStops
,
int
tileMode
,
Float64List
matrix4
)
native
'Gradient_initRadial'
;
void
_initConical
(
double
startX
,
double
startY
,
double
startRadius
,
double
endX
,
double
endY
,
double
endRadius
,
Int32List
colors
,
Float32List
colorStops
,
int
tileMode
,
Float64List
matrix4
)
native
'Gradient_initTwoPointConical'
;
/// Creates a sweep gradient centered at `center` that starts at `startAngle`
/// and ends at `endAngle`.
...
...
lib/ui/painting/gradient.cc
浏览文件 @
919e8c21
...
...
@@ -25,7 +25,8 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Gradient);
#define FOR_EACH_BINDING(V) \
V(Gradient, initLinear) \
V(Gradient, initRadial) \
V(Gradient, initSweep)
V(Gradient, initSweep) \
V(Gradient, initTwoPointConical)
FOR_EACH_BINDING
(
DART_NATIVE_CALLBACK
)
...
...
@@ -109,6 +110,35 @@ void CanvasGradient::initSweep(double center_x,
has_matrix
?
&
sk_matrix
:
nullptr
)));
}
void
CanvasGradient
::
initTwoPointConical
(
double
start_x
,
double
start_y
,
double
start_radius
,
double
end_x
,
double
end_y
,
double
end_radius
,
const
tonic
::
Int32List
&
colors
,
const
tonic
::
Float32List
&
color_stops
,
SkShader
::
TileMode
tile_mode
,
const
tonic
::
Float64List
&
matrix4
)
{
FXL_DCHECK
(
colors
.
num_elements
()
==
color_stops
.
num_elements
()
||
color_stops
.
data
()
==
nullptr
);
static_assert
(
sizeof
(
SkColor
)
==
sizeof
(
int32_t
),
"SkColor doesn't use int32_t."
);
SkMatrix
sk_matrix
;
bool
has_matrix
=
matrix4
.
data
()
!=
nullptr
;
if
(
has_matrix
)
{
sk_matrix
=
ToSkMatrix
(
matrix4
);
}
set_shader
(
UIDartState
::
CreateGPUObject
(
SkGradientShader
::
MakeTwoPointConical
(
SkPoint
::
Make
(
start_x
,
start_y
),
start_radius
,
SkPoint
::
Make
(
end_x
,
end_y
),
end_radius
,
reinterpret_cast
<
const
SkColor
*>
(
colors
.
data
()),
color_stops
.
data
(),
colors
.
num_elements
(),
tile_mode
,
0
,
has_matrix
?
&
sk_matrix
:
nullptr
)));
}
CanvasGradient
::
CanvasGradient
()
=
default
;
CanvasGradient
::~
CanvasGradient
()
=
default
;
...
...
lib/ui/painting/gradient.h
浏览文件 @
919e8c21
...
...
@@ -52,6 +52,17 @@ class CanvasGradient : public Shader {
double
end_angle
,
const
tonic
::
Float64List
&
matrix4
);
void
initTwoPointConical
(
double
start_x
,
double
start_y
,
double
start_radius
,
double
end_x
,
double
end_y
,
double
end_radius
,
const
tonic
::
Int32List
&
colors
,
const
tonic
::
Float32List
&
color_stops
,
SkShader
::
TileMode
tile_mode
,
const
tonic
::
Float64List
&
matrix4
);
static
void
RegisterNatives
(
tonic
::
DartLibraryNatives
*
natives
);
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录