Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
56e878ab
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
56e878ab
编写于
8月 24, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[graphite2] Cleanup scratch buffer allocation
上级
2f7586c6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
33 deletion
+44
-33
src/hb-graphite2.cc
src/hb-graphite2.cc
+44
-33
未找到文件。
src/hb-graphite2.cc
浏览文件 @
56e878ab
...
...
@@ -211,11 +211,6 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
gr_face
*
grface
=
HB_SHAPER_DATA_GET
(
face
)
->
grface
;
gr_font
*
grfont
=
HB_SHAPER_DATA_GET
(
font
);
unsigned
int
charlen
;
hb_glyph_info_t
*
bufferi
=
hb_buffer_get_glyph_infos
(
buffer
,
&
charlen
);
int
success
=
0
;
const
char
*
lang
=
hb_language_to_string
(
hb_buffer_get_language
(
buffer
));
const
char
*
lang_end
=
strchr
(
lang
,
'-'
);
int
lang_len
=
lang_end
?
lang_end
-
lang
:
-
1
;
...
...
@@ -229,24 +224,23 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
features
++
;
}
/* TODO Use scratch buffer for these. */
hb_codepoint_t
*
gids
=
NULL
,
*
pg
;
hb_graphite2_cluster_t
*
clusters
=
NULL
;
gr_segment
*
seg
=
NULL
;
uint32_t
*
text
=
NULL
;
const
gr_slot
*
is
;
unsigned
int
ci
=
0
,
ic
=
0
;
float
curradvx
=
0.
,
curradvy
=
0.
;
unsigned
int
glyphlen
=
0
;
unsigned
int
*
p
;
text
=
(
uint32_t
*
)
malloc
((
charlen
+
1
)
*
sizeof
(
uint32_t
));
if
(
!
text
)
goto
dieout
;
unsigned
int
scratch_size
;
char
*
scratch
=
(
char
*
)
buffer
->
get_scratch_buffer
(
&
scratch_size
);
#define ALLOCATE_ARRAY(Type, name, len) \
Type *name = (Type *) scratch; \
scratch += (len) * sizeof ((name)[0]); \
scratch_size -= (len) * sizeof ((name)[0]);
ALLOCATE_ARRAY
(
uint32_t
,
chars
,
buffer
->
len
);
p
=
text
;
for
(
unsigned
int
i
=
0
;
i
<
charlen
;
++
i
)
*
p
++
=
bufferi
++->
codepoint
;
*
p
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
buffer
->
len
;
++
i
)
chars
[
i
]
=
buffer
->
info
[
i
].
codepoint
;
hb_tag_t
script_tag
[
2
];
hb_ot_tags_from_script
(
hb_buffer_get_script
(
buffer
),
&
script_tag
[
0
],
&
script_tag
[
1
]);
...
...
@@ -254,18 +248,40 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
seg
=
gr_make_seg
(
grfont
,
grface
,
script_tag
[
1
]
==
HB_TAG_NONE
?
script_tag
[
0
]
:
script_tag
[
1
],
feats
,
gr_utf32
,
text
,
char
len
,
gr_utf32
,
chars
,
buffer
->
len
,
2
|
(
hb_buffer_get_direction
(
buffer
)
==
HB_DIRECTION_RTL
?
1
:
0
));
if
(
!
seg
)
goto
dieout
;
glyphlen
=
gr_seg_n_slots
(
seg
);
clusters
=
(
hb_graphite2_cluster_t
*
)
calloc
(
charlen
,
sizeof
(
hb_graphite2_cluster_t
));
if
(
!
glyphlen
||
!
clusters
)
goto
dieout
;
if
(
unlikely
(
!
seg
))
{
if
(
feats
)
gr_featureval_destroy
(
feats
);
return
false
;
}
unsigned
int
glyph_count
=
gr_seg_n_slots
(
seg
);
if
(
unlikely
(
!
glyph_count
))
{
if
(
feats
)
gr_featureval_destroy
(
feats
);
gr_seg_destroy
(
seg
);
return
false
;
}
scratch
=
(
char
*
)
buffer
->
get_scratch_buffer
(
&
scratch_size
);
while
((
sizeof
(
hb_graphite2_cluster_t
)
*
buffer
->
len
+
sizeof
(
hb_codepoint_t
)
*
glyph_count
)
>
scratch_size
)
{
buffer
->
ensure
(
buffer
->
allocated
*
2
);
if
(
unlikely
(
buffer
->
in_error
))
{
if
(
feats
)
gr_featureval_destroy
(
feats
);
gr_seg_destroy
(
seg
);
return
false
;
}
scratch
=
(
char
*
)
buffer
->
get_scratch_buffer
(
&
scratch_size
);
}
gids
=
(
hb_codepoint_t
*
)
malloc
(
glyphlen
*
sizeof
(
hb_codepoint_t
)
);
if
(
!
gids
)
goto
dieout
;
ALLOCATE_ARRAY
(
hb_graphite2_cluster_t
,
clusters
,
buffer
->
len
);
ALLOCATE_ARRAY
(
hb_codepoint_t
,
gids
,
glyph_count
)
;
pg
=
gids
;
memset
(
clusters
,
0
,
sizeof
(
clusters
[
0
])
*
buffer
->
len
);
hb_codepoint_t
*
pg
=
gids
;
for
(
is
=
gr_seg_first_slot
(
seg
),
ic
=
0
;
is
;
is
=
gr_slot_next_in_segment
(
is
),
ic
++
)
{
unsigned
int
before
=
gr_slot_before
(
is
);
...
...
@@ -325,13 +341,8 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
if
(
HB_DIRECTION_IS_BACKWARD
(
buffer
->
props
.
direction
))
hb_buffer_reverse_clusters
(
buffer
);
success
=
1
;
dieout:
if
(
feats
)
gr_featureval_destroy
(
feats
);
if
(
gids
)
free
(
gids
);
if
(
clusters
)
free
(
clusters
);
if
(
seg
)
gr_seg_destroy
(
seg
);
if
(
text
)
free
(
text
);
return
success
;
gr_seg_destroy
(
seg
);
return
true
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录