Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
bc5be240
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看板
提交
bc5be240
编写于
9月 01, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[OT] Restart work on serialize()
上级
6912e476
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
40 deletion
+73
-40
src/hb-open-type-private.hh
src/hb-open-type-private.hh
+30
-9
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-common-private.hh
+30
-31
src/hb-ot-layout-gsub-table.hh
src/hb-ot-layout-gsub-table.hh
+13
-0
未找到文件。
src/hb-open-type-private.hh
浏览文件 @
bc5be240
...
...
@@ -371,13 +371,14 @@ struct hb_serialize_context_t
}
template
<
typename
Type
>
inline
Type
*
allocate
(
unsigned
int
size
,
unsigned
int
alignment
=
2
)
inline
Type
*
allocate
_size
(
unsigned
int
size
,
unsigned
int
alignment
=
1
)
{
unsigned
int
padding
=
(
alignment
-
(
this
->
head
-
this
->
start
)
%
alignment
)
%
alignment
;
/* TODO speedup */
unsigned
int
padding
=
alignment
<
2
?
0
:
(
alignment
-
(
this
->
head
-
this
->
start
)
%
alignment
)
%
alignment
;
if
(
unlikely
(
this
->
ran_out_of_room
||
this
->
end
-
this
->
head
>
padding
+
size
))
{
this
->
ran_out_of_room
=
true
;
return
NULL
;
}
memset
(
this
->
head
,
0
,
padding
+
size
);
this
->
head
+=
padding
;
char
*
ret
=
this
->
head
;
this
->
head
+=
size
;
...
...
@@ -387,27 +388,35 @@ struct hb_serialize_context_t
template
<
typename
Type
>
inline
Type
*
allocate_min
(
unsigned
int
alignment
=
2
)
{
return
this
->
allocate
<
Type
>
(
Type
::
min_size
,
alignment
);
return
this
->
allocate
_size
<
Type
>
(
Type
::
min_size
,
alignment
);
}
template
<
typename
Type
>
inline
Type
*
embed
(
const
Type
&
obj
,
unsigned
int
alignment
=
2
)
{
return
this
->
allocate
<
Type
>
(
obj
.
get_size
(),
alignment
);
unsigned
int
size
=
obj
.
get_size
();
Type
*
ret
=
this
->
allocate_size
<
Type
>
(
size
,
alignment
);
if
(
unlikely
(
!
ret
))
return
NULL
;
memcpy
(
ret
,
obj
,
size
);
return
ret
;
}
template
<
typename
Type
>
inline
Type
*
extend
(
Type
&
obj
,
unsigned
int
size
,
unsigned
int
alignment
=
2
)
inline
Type
*
extend
_min
(
Type
&
obj
,
unsigned
int
alignment
=
2
)
{
unsigned
int
size
=
obj
.
min_size
;
assert
(
this
->
start
<
(
char
*
)
&
obj
&&
(
char
*
)
&
obj
<=
this
->
head
&&
(
char
*
)
&
obj
+
size
>=
this
->
head
);
this
->
allocate
<
Type
>
(((
char
*
)
&
obj
)
+
size
-
this
->
head
,
alignment
);
this
->
allocate
_size
<
Type
>
(((
char
*
)
&
obj
)
+
size
-
this
->
head
,
alignment
);
return
reinterpret_cast
<
Type
*>
(
&
obj
);
}
template
<
typename
Type
>
inline
Type
*
extend
(
Type
&
obj
)
inline
Type
*
extend
(
Type
&
obj
,
unsigned
int
alignment
=
2
)
{
return
this
->
extend
<
Type
>
(
obj
,
obj
.
get_size
());
unsigned
int
size
=
obj
.
get_size
();
assert
(
this
->
start
<
(
char
*
)
&
obj
&&
(
char
*
)
&
obj
<=
this
->
head
&&
(
char
*
)
&
obj
+
size
>=
this
->
head
);
this
->
allocate_size
<
Type
>
(((
char
*
)
&
obj
)
+
size
-
this
->
head
,
alignment
);
return
reinterpret_cast
<
Type
*>
(
&
obj
);
}
inline
void
truncate
(
void
*
head
)
...
...
@@ -585,6 +594,16 @@ struct GenericOffsetTo : OffsetType
if
(
unlikely
(
!
offset
))
return
Null
(
Type
);
return
StructAtOffset
<
Type
>
(
base
,
offset
);
}
inline
Type
&
operator
()
(
void
*
base
)
{
unsigned
int
offset
=
*
this
;
return
StructAtOffset
<
Type
>
(
base
,
offset
);
}
inline
void
set_offset
(
void
*
base
,
void
*
obj
)
{
this
->
set
((
char
*
)
obj
-
(
char
*
)
base
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
void
*
base
)
{
TRACE_SANITIZE
();
...
...
@@ -615,7 +634,9 @@ struct GenericOffsetTo : OffsetType
}
};
template
<
typename
Base
,
typename
OffsetType
,
typename
Type
>
inline
const
Type
&
operator
+
(
const
Base
&
base
,
GenericOffsetTo
<
OffsetType
,
Type
>
offset
)
{
return
offset
(
base
);
}
inline
const
Type
&
operator
+
(
const
Base
&
base
,
const
GenericOffsetTo
<
OffsetType
,
Type
>
&
offset
)
{
return
offset
(
base
);
}
template
<
typename
Base
,
typename
OffsetType
,
typename
Type
>
inline
Type
&
operator
+
(
Base
&
base
,
GenericOffsetTo
<
OffsetType
,
Type
>
&
offset
)
{
return
offset
(
base
);
}
template
<
typename
Type
>
struct
OffsetTo
:
GenericOffsetTo
<
Offset
,
Type
>
{};
...
...
src/hb-ot-layout-common-private.hh
浏览文件 @
bc5be240
...
...
@@ -355,18 +355,16 @@ struct CoverageFormat1
return
i
;
}
inline
static
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
inline
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
{
TRACE_SERIALIZE
();
CoverageFormat1
*
t
=
c
->
allocate_min
<
CoverageFormat1
>
();
if
(
unlikely
(
!
t
))
return
TRACE_RETURN
(
false
);
t
->
coverageFormat
.
set
(
1
);
t
->
glyphArray
.
len
.
set
(
num_glyphs
);
if
(
unlikely
(
!
c
->
extend
(
t
->
glyphArray
)))
return
TRACE_RETURN
(
false
);
if
(
unlikely
(
!
c
->
extend_min
(
*
this
)))
return
TRACE_RETURN
(
false
);
glyphArray
.
len
.
set
(
num_glyphs
);
if
(
unlikely
(
!
c
->
extend
(
glyphArray
)))
return
TRACE_RETURN
(
false
);
for
(
unsigned
int
i
=
0
;
i
<
num_glyphs
;
i
++
)
t
->
glyphArray
[
i
].
set
(
glyphs
[
i
]);
glyphArray
[
i
].
set
(
glyphs
[
i
]);
return
TRACE_RETURN
(
true
);
}
...
...
@@ -421,31 +419,32 @@ struct CoverageFormat2
return
NOT_COVERED
;
}
inline
static
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
inline
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
{
TRACE_SERIALIZE
();
CoverageFormat2
*
t
=
c
->
allocate_min
<
CoverageFormat2
>
();
if
(
unlikely
(
!
c
->
extend_min
(
*
this
)))
return
TRACE_RETURN
(
false
);
if
(
unlikely
(
!
num_glyphs
))
return
TRACE_RETURN
(
true
);
unsigned
int
num_ranges
=
1
;
for
(
unsigned
int
i
=
1
;
i
<
num_glyphs
;
i
++
)
if
(
glyphs
[
i
-
1
]
+
1
!=
glyphs
[
i
])
num_ranges
++
;
if
(
unlikely
(
!
t
))
return
TRACE_RETURN
(
false
);
t
->
coverageFormat
.
set
(
2
);
t
->
rangeRecord
.
len
.
set
(
num_ranges
);
if
(
unlikely
(
!
c
->
extend
(
t
->
rangeRecord
)))
return
TRACE_RETURN
(
false
);
if
(
unlikely
(
!
num_glyphs
))
return
TRACE_RETURN
(
true
);
rangeRecord
.
len
.
set
(
num_ranges
);
if
(
unlikely
(
!
c
->
extend
(
rangeRecord
)))
return
TRACE_RETURN
(
false
);
unsigned
int
range
=
0
;
t
->
rangeRecord
[
range
].
start
.
set
(
glyphs
[
0
]);
t
->
rangeRecord
[
range
].
value
.
set
(
0
);
rangeRecord
[
range
].
start
.
set
(
glyphs
[
0
]);
rangeRecord
[
range
].
value
.
set
(
0
);
for
(
unsigned
int
i
=
1
;
i
<
num_glyphs
;
i
++
)
if
(
glyphs
[
i
-
1
]
+
1
!=
glyphs
[
i
])
{
t
->
rangeRecord
[
range
].
start
.
set
(
glyphs
[
i
]);
t
->
rangeRecord
[
range
].
value
.
set
(
i
);
rangeRecord
[
range
].
start
.
set
(
glyphs
[
i
]);
rangeRecord
[
range
].
value
.
set
(
i
);
range
++
;
}
else
{
t
->
rangeRecord
[
range
].
end
=
glyphs
[
i
];
rangeRecord
[
range
].
end
=
glyphs
[
i
];
}
return
TRACE_RETURN
(
true
);
}
...
...
@@ -526,20 +525,20 @@ struct Coverage
}
}
inline
static
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
inline
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
)
{
TRACE_SERIALIZE
();
unsigned
int
format
;
if
(
unlikely
(
c
->
extend_min
(
*
this
)))
return
TRACE_RETURN
(
false
)
;
unsigned
int
num_ranges
=
1
;
for
(
unsigned
int
i
=
1
;
i
<
num_glyphs
;
i
++
)
if
(
glyphs
[
i
-
1
]
+
1
!=
glyphs
[
i
])
num_ranges
++
;
format
=
num_glyphs
*
2
<
num_ranges
*
3
?
1
:
2
;
switch
(
format
)
{
case
1
:
return
TRACE_RETURN
(
CoverageFormat1
::
serialize
(
c
,
glyphs
,
num_glyphs
));
case
2
:
return
TRACE_RETURN
(
CoverageFormat2
::
serialize
(
c
,
glyphs
,
num_glyphs
));
u
.
format
.
set
(
num_glyphs
*
2
<
num_ranges
*
3
?
1
:
2
)
;
switch
(
u
.
format
)
{
case
1
:
return
TRACE_RETURN
(
u
.
format1
.
serialize
(
c
,
glyphs
,
num_glyphs
));
case
2
:
return
TRACE_RETURN
(
u
.
format2
.
serialize
(
c
,
glyphs
,
num_glyphs
));
default:
return
TRACE_RETURN
(
false
);
}
}
...
...
src/hb-ot-layout-gsub-table.hh
浏览文件 @
bc5be240
...
...
@@ -72,6 +72,19 @@ struct SingleSubstFormat1
return
TRACE_RETURN
(
true
);
}
inline
bool
serialize
(
hb_serialize_context_t
*
c
,
const
USHORT
*
glyphs
,
unsigned
int
num_glyphs
,
SHORT
delta
)
{
TRACE_SERIALIZE
();
if
(
unlikely
(
!
c
->
extend_min
(
*
this
)))
return
TRACE_RETURN
(
false
);
deltaGlyphID
.
set
(
delta
);
coverage
.
set_offset
(
this
,
c
->
head
);
if
(
unlikely
(
!
(
this
+
coverage
).
serialize
(
c
,
glyphs
,
num_glyphs
)))
return
TRACE_RETURN
(
false
);
return
TRACE_RETURN
(
true
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
TRACE_SANITIZE
();
return
TRACE_RETURN
(
coverage
.
sanitize
(
c
,
this
)
&&
deltaGlyphID
.
sanitize
(
c
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录