Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
1f8ce953
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,发现更多精彩内容 >>
提交
1f8ce953
编写于
3月 31, 2018
作者:
L
Luigi Rosso
提交者:
Chinmay Garde
3月 31, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow setting transform on radial gradients. (#4916)
上级
d653be87
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
5 deletion
+22
-5
lib/ui/painting.dart
lib/ui/painting.dart
+9
-2
lib/ui/painting/gradient.cc
lib/ui/painting/gradient.cc
+9
-2
lib/ui/painting/gradient.h
lib/ui/painting/gradient.h
+4
-1
未找到文件。
lib/ui/painting.dart
浏览文件 @
1f8ce953
...
...
@@ -1921,23 +1921,30 @@ class Gradient extends Shader {
/// If `center`, `radius`, `colors`, or `tileMode` are null, or if `colors` or
/// `colorStops` contain null values, this constructor will throw a
/// [NoSuchMethodError].
///
/// 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.
Gradient
.
radial
(
Offset
center
,
double
radius
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
,
TileMode
tileMode
=
TileMode
.
clamp
,
Float64List
matrix4
])
:
assert
(
_offsetIsValid
(
center
)),
assert
(
colors
!=
null
),
assert
(
tileMode
!=
null
),
super
.
_
()
{
if
(
matrix4
!=
null
&&
matrix4
.
length
!=
16
)
throw
new
ArgumentError
(
'"matrix4" must have 16 entries.'
);
_validateColorStops
(
colors
,
colorStops
);
final
Int32List
colorsBuffer
=
_encodeColorList
(
colors
);
final
Float32List
colorStopsBuffer
=
colorStops
==
null
?
null
:
new
Float32List
.
fromList
(
colorStops
);
_constructor
();
_initRadial
(
center
.
dx
,
center
.
dy
,
radius
,
colorsBuffer
,
colorStopsBuffer
,
tileMode
.
index
);
_initRadial
(
center
.
dx
,
center
.
dy
,
radius
,
colorsBuffer
,
colorStopsBuffer
,
tileMode
.
index
,
matrix4
);
}
void
_initRadial
(
double
centerX
,
double
centerY
,
double
radius
,
Int32List
colors
,
Float32List
colorStops
,
int
tileMode
)
native
'Gradient_initRadial'
;
void
_initRadial
(
double
centerX
,
double
centerY
,
double
radius
,
Int32List
colors
,
Float32List
colorStops
,
int
tileMode
,
Float64List
matrix4
)
native
'Gradient_initRadial'
;
static
void
_validateColorStops
(
List
<
Color
>
colors
,
List
<
double
>
colorStops
)
{
if
(
colorStops
==
null
)
{
...
...
lib/ui/painting/gradient.cc
浏览文件 @
1f8ce953
...
...
@@ -59,17 +59,24 @@ void CanvasGradient::initRadial(double center_x,
double
radius
,
const
tonic
::
Int32List
&
colors
,
const
tonic
::
Float32List
&
color_stops
,
SkShader
::
TileMode
tile_mode
)
{
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
(
SkGradientShader
::
MakeRadial
(
SkPoint
::
Make
(
center_x
,
center_y
),
radius
,
reinterpret_cast
<
const
SkColor
*>
(
colors
.
data
()),
color_stops
.
data
(),
colors
.
num_elements
(),
tile_mode
));
colors
.
num_elements
(),
tile_mode
,
0
,
has_matrix
?
&
sk_matrix
:
nullptr
));
}
CanvasGradient
::
CanvasGradient
()
:
Shader
(
nullptr
)
{}
...
...
lib/ui/painting/gradient.h
浏览文件 @
1f8ce953
...
...
@@ -5,9 +5,11 @@
#ifndef FLUTTER_LIB_UI_PAINTING_GRADIENT_H_
#define FLUTTER_LIB_UI_PAINTING_GRADIENT_H_
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/painting/shader.h"
#include "lib/tonic/dart_wrappable.h"
#include "lib/tonic/typed_data/float32_list.h"
#include "lib/tonic/typed_data/float64_list.h"
#include "lib/tonic/typed_data/int32_list.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
...
...
@@ -38,7 +40,8 @@ class CanvasGradient : public Shader {
double
radius
,
const
tonic
::
Int32List
&
colors
,
const
tonic
::
Float32List
&
color_stops
,
SkShader
::
TileMode
tile_mode
);
SkShader
::
TileMode
tile_mode
,
const
tonic
::
Float64List
&
matrix4
);
static
void
RegisterNatives
(
tonic
::
DartLibraryNatives
*
natives
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录