Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
4c05830a
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,发现更多精彩内容 >>
提交
4c05830a
编写于
3月 31, 2017
作者:
J
Jason Simmons
提交者:
GitHub
3月 31, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the SkVertices::Builder API (#3549)
上级
8f4457fe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
32 deletion
+28
-32
lib/ui/painting/vertices.cc
lib/ui/painting/vertices.cc
+28
-32
未找到文件。
lib/ui/painting/vertices.cc
浏览文件 @
4c05830a
...
...
@@ -11,26 +11,16 @@ namespace blink {
namespace
{
std
::
unique_ptr
<
SkPoint
[]
>
DecodePoints
(
const
tonic
::
Float32List
&
coords
)
{
std
::
unique_ptr
<
SkPoint
[]
>
result
;
if
(
coords
.
data
())
{
result
.
reset
(
new
SkPoint
[
coords
.
num_elements
()
/
2
]);
for
(
int
i
=
0
;
i
<
coords
.
num_elements
();
i
+=
2
)
result
[
i
/
2
]
=
SkPoint
::
Make
(
coords
[
i
],
coords
[
i
+
1
]);
}
return
result
;
void
DecodePoints
(
const
tonic
::
Float32List
&
coords
,
SkPoint
*
points
)
{
for
(
int
i
=
0
;
i
<
coords
.
num_elements
();
i
+=
2
)
points
[
i
/
2
]
=
SkPoint
::
Make
(
coords
[
i
],
coords
[
i
+
1
]);
}
template
<
typename
T
>
std
::
unique_ptr
<
T
[]
>
DecodeInts
(
const
tonic
::
Int32List
&
ints
)
{
std
::
unique_ptr
<
T
[]
>
result
;
if
(
ints
.
data
())
{
result
.
reset
(
new
T
[
ints
.
num_elements
()]);
for
(
int
i
=
0
;
i
<
ints
.
num_elements
();
i
++
)
result
[
i
]
=
ints
[
i
];
}
return
result
;
template
<
typename
T
>
void
DecodeInts
(
const
tonic
::
Int32List
&
ints
,
T
*
out
)
{
for
(
int
i
=
0
;
i
<
ints
.
num_elements
();
i
++
)
out
[
i
]
=
ints
[
i
];
}
}
// namespace
...
...
@@ -64,20 +54,26 @@ void Vertices::init(SkCanvas::VertexMode vertex_mode,
const
tonic
::
Float32List
&
texture_coordinates
,
const
tonic
::
Int32List
&
colors
,
const
tonic
::
Int32List
&
indices
)
{
std
::
unique_ptr
<
const
SkPoint
[]
>
sk_positions
(
DecodePoints
(
positions
));
std
::
unique_ptr
<
const
SkPoint
[]
>
sk_texs
(
DecodePoints
(
texture_coordinates
));
std
::
unique_ptr
<
const
SkColor
[]
>
sk_colors
(
DecodeInts
<
SkColor
>
(
colors
));
std
::
unique_ptr
<
const
uint16_t
[]
>
sk_indices
(
DecodeInts
<
uint16_t
>
(
indices
));
// TODO(fmalita): refactor to use SkVertices::Builder and avoid a copy.
vertices_
=
SkVertices
::
MakeCopy
(
vertex_mode
,
positions
.
num_elements
()
/
2
,
sk_positions
.
get
(),
sk_texs
.
get
(),
sk_colors
.
get
(),
indices
.
num_elements
(),
sk_indices
.
get
());
uint32_t
builderFlags
=
0
;
if
(
texture_coordinates
.
data
())
builderFlags
|=
SkVertices
::
kHasTexCoords_BuilderFlag
;
if
(
colors
.
data
())
builderFlags
|=
SkVertices
::
kHasColors_BuilderFlag
;
SkVertices
::
Builder
builder
(
vertex_mode
,
positions
.
num_elements
()
/
2
,
indices
.
num_elements
(),
builderFlags
);
if
(
positions
.
data
())
DecodePoints
(
positions
,
builder
.
positions
());
if
(
texture_coordinates
.
data
())
DecodePoints
(
texture_coordinates
,
builder
.
texCoords
());
if
(
colors
.
data
())
DecodeInts
<
SkColor
>
(
colors
,
builder
.
colors
());
if
(
indices
.
data
())
DecodeInts
<
uint16_t
>
(
indices
,
builder
.
indices
());
vertices_
=
builder
.
detach
();
}
}
// namespace blink
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录