Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
d5045a5f
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
d5045a5f
编写于
8月 11, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ICU] Use new normalizer2 compose/decompose API
It's considerably faster than the fallback implementation we had previously!
上级
2b73a1f1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
110 addition
and
56 deletion
+110
-56
src/hb-buffer.cc
src/hb-buffer.cc
+4
-5
src/hb-glib.cc
src/hb-glib.cc
+11
-15
src/hb-icu.cc
src/hb-icu.cc
+60
-15
src/hb-unicode-private.hh
src/hb-unicode-private.hh
+2
-11
src/hb-unicode.cc
src/hb-unicode.cc
+33
-2
src/hb-warning.cc
src/hb-warning.cc
+0
-8
未找到文件。
src/hb-buffer.cc
浏览文件 @
d5045a5f
...
@@ -37,8 +37,6 @@
...
@@ -37,8 +37,6 @@
#define HB_DEBUG_BUFFER (HB_DEBUG+0)
#define HB_DEBUG_BUFFER (HB_DEBUG+0)
#endif
#endif
#define _HB_BUFFER_UNICODE_FUNCS_DEFAULT (const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_default))
/* Here is how the buffer works internally:
/* Here is how the buffer works internally:
*
*
* There are two info pointers: info and out_info. They always have
* There are two info pointers: info and out_info. They always have
...
@@ -144,7 +142,7 @@ hb_buffer_t::reset (void)
...
@@ -144,7 +142,7 @@ hb_buffer_t::reset (void)
return
;
return
;
hb_unicode_funcs_destroy
(
unicode
);
hb_unicode_funcs_destroy
(
unicode
);
unicode
=
_HB_BUFFER_UNICODE_FUNCS_DEFAULT
;
unicode
=
hb_unicode_funcs_get_default
()
;
hb_segment_properties_t
default_props
=
_HB_BUFFER_PROPS_DEFAULT
;
hb_segment_properties_t
default_props
=
_HB_BUFFER_PROPS_DEFAULT
;
props
=
default_props
;
props
=
default_props
;
...
@@ -552,7 +550,7 @@ hb_buffer_get_empty (void)
...
@@ -552,7 +550,7 @@ hb_buffer_get_empty (void)
static
const
hb_buffer_t
_hb_buffer_nil
=
{
static
const
hb_buffer_t
_hb_buffer_nil
=
{
HB_OBJECT_HEADER_STATIC
,
HB_OBJECT_HEADER_STATIC
,
_HB_BUFFER_UNICODE_FUNCS_DEFAULT
,
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_unicode_funcs_nil
)
,
_HB_BUFFER_PROPS_DEFAULT
,
_HB_BUFFER_PROPS_DEFAULT
,
true
,
/* in_error */
true
,
/* in_error */
...
@@ -608,7 +606,8 @@ hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
...
@@ -608,7 +606,8 @@ hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
return
;
return
;
if
(
!
unicode
)
if
(
!
unicode
)
unicode
=
_HB_BUFFER_UNICODE_FUNCS_DEFAULT
;
unicode
=
hb_unicode_funcs_get_default
();
hb_unicode_funcs_reference
(
unicode
);
hb_unicode_funcs_reference
(
unicode
);
hb_unicode_funcs_destroy
(
buffer
->
unicode
);
hb_unicode_funcs_destroy
(
buffer
->
unicode
);
...
...
src/hb-glib.cc
浏览文件 @
d5045a5f
...
@@ -250,9 +250,6 @@ hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
...
@@ -250,9 +250,6 @@ hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
/* We don't ifdef-out the fallback code such that compiler always
/* We don't ifdef-out the fallback code such that compiler always
* sees it and makes sure it's compilable. */
* sees it and makes sure it's compilable. */
if
(
!
a
||
!
b
)
return
false
;
gchar
utf8
[
12
];
gchar
utf8
[
12
];
gchar
*
normalized
;
gchar
*
normalized
;
int
len
;
int
len
;
...
@@ -367,22 +364,21 @@ hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
...
@@ -367,22 +364,21 @@ hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
return
utf8_decomposed_len
;
return
utf8_decomposed_len
;
}
}
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_glib_unicode_funcs
;
hb_unicode_funcs_t
*
const
hb_unicode_funcs_t
_hb_glib_unicode_funcs
=
{
hb_glib_get_unicode_funcs
(
void
)
HB_OBJECT_HEADER_STATIC
,
{
static
const
hb_unicode_funcs_t
_hb_glib_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
NULL
,
/* parent */
true
,
/* immutable */
true
,
/* immutable */
{
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name,
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
#undef HB_UNICODE_FUNC_IMPLEMENT
}
}
};
};
hb_unicode_funcs_t
*
hb_glib_get_unicode_funcs
(
void
)
{
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_glib_unicode_funcs
);
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_glib_unicode_funcs
);
}
}
src/hb-icu.cc
浏览文件 @
d5045a5f
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "hb-unicode-private.hh"
#include "hb-unicode-private.hh"
#include <unicode/uver
sion
.h>
#include <unicode/uver
num
.h>
#include <unicode/uchar.h>
#include <unicode/uchar.h>
#include <unicode/unorm.h>
#include <unicode/unorm.h>
#include <unicode/ustring.h>
#include <unicode/ustring.h>
...
@@ -164,6 +164,10 @@ hb_icu_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED,
...
@@ -164,6 +164,10 @@ hb_icu_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return
hb_icu_script_to_script
(
scriptCode
);
return
hb_icu_script_to_script
(
scriptCode
);
}
}
#if U_ICU_VERSION_MAJOR_NUM >= 49
static
const
UNormalizer2
*
normalizer
;
#endif
static
hb_bool_t
static
hb_bool_t
hb_icu_unicode_compose
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_icu_unicode_compose
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
a
,
hb_codepoint_t
a
,
...
@@ -171,8 +175,17 @@ hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
...
@@ -171,8 +175,17 @@ hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t
*
ab
,
hb_codepoint_t
*
ab
,
void
*
user_data
HB_UNUSED
)
void
*
user_data
HB_UNUSED
)
{
{
if
(
!
a
||
!
b
)
#if U_ICU_VERSION_MAJOR_NUM >= 49
return
false
;
{
UChar32
ret
=
unorm2_composePair
(
normalizer
,
a
,
b
);
if
(
ret
<
0
)
return
false
;
*
ab
=
ret
;
return
true
;
}
#endif
/* We don't ifdef-out the fallback code such that compiler always
* sees it and makes sure it's compilable. */
UChar
utf16
[
4
],
normalized
[
5
];
UChar
utf16
[
4
],
normalized
[
5
];
unsigned
int
len
;
unsigned
int
len
;
...
@@ -207,6 +220,32 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
...
@@ -207,6 +220,32 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t
*
b
,
hb_codepoint_t
*
b
,
void
*
user_data
HB_UNUSED
)
void
*
user_data
HB_UNUSED
)
{
{
#if U_ICU_VERSION_MAJOR_NUM >= 49
{
UChar
decomposed
[
4
];
int
len
;
UErrorCode
icu_err
=
U_ZERO_ERROR
;
len
=
unorm2_getRawDecomposition
(
normalizer
,
ab
,
decomposed
,
ARRAY_LENGTH
(
decomposed
),
&
icu_err
);
if
(
U_FAILURE
(
icu_err
)
||
len
<
0
)
return
false
;
len
=
u_countChar32
(
decomposed
,
len
);
if
(
len
==
1
)
{
U16_GET_UNSAFE
(
decomposed
,
0
,
*
a
);
*
b
=
0
;
return
*
a
!=
ab
;
}
else
if
(
len
==
2
)
{
len
=
0
;
U16_NEXT_UNSAFE
(
decomposed
,
len
,
*
a
);
U16_NEXT_UNSAFE
(
decomposed
,
len
,
*
b
);
}
return
true
;
}
#endif
/* We don't ifdef-out the fallback code such that compiler always
* sees it and makes sure it's compilable. */
UChar
utf16
[
2
],
normalized
[
2
*
HB_UNICODE_MAX_DECOMPOSITION_LEN
+
1
];
UChar
utf16
[
2
],
normalized
[
2
*
HB_UNICODE_MAX_DECOMPOSITION_LEN
+
1
];
unsigned
int
len
;
unsigned
int
len
;
hb_bool_t
ret
,
err
;
hb_bool_t
ret
,
err
;
...
@@ -306,22 +345,28 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
...
@@ -306,22 +345,28 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
}
}
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_icu_unicode_funcs
;
hb_unicode_funcs_t
*
const
hb_unicode_funcs_t
_hb_icu_unicode_funcs
=
{
hb_icu_get_unicode_funcs
(
void
)
HB_OBJECT_HEADER_STATIC
,
{
static
const
hb_unicode_funcs_t
_hb_icu_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
NULL
,
/* parent */
true
,
/* immutable */
true
,
/* immutable */
{
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name,
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
#undef HB_UNICODE_FUNC_IMPLEMENT
}
}
};
};
hb_unicode_funcs_t
*
#if U_ICU_VERSION_MAJOR_NUM >= 49
hb_icu_get_unicode_funcs
(
void
)
if
(
!
hb_atomic_ptr_get
(
&
normalizer
))
{
{
UErrorCode
icu_err
=
U_ZERO_ERROR
;
/* We ignore failure in getNFCInstace(). */
hb_atomic_ptr_cmpexch
(
&
normalizer
,
NULL
,
unorm2_getNFCInstance
(
&
icu_err
));
}
#endif
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_icu_unicode_funcs
);
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_icu_unicode_funcs
);
}
}
...
...
src/hb-unicode-private.hh
浏览文件 @
d5045a5f
...
@@ -80,13 +80,14 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
...
@@ -80,13 +80,14 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
hb_codepoint_t
*
ab
)
hb_codepoint_t
*
ab
)
{
{
*
ab
=
0
;
*
ab
=
0
;
if
(
unlikely
(
!
a
||
!
b
))
return
false
;
return
func
.
compose
(
this
,
a
,
b
,
ab
,
user_data
.
compose
);
return
func
.
compose
(
this
,
a
,
b
,
ab
,
user_data
.
compose
);
}
}
inline
hb_bool_t
decompose
(
hb_codepoint_t
ab
,
inline
hb_bool_t
decompose
(
hb_codepoint_t
ab
,
hb_codepoint_t
*
a
,
hb_codepoint_t
*
b
)
hb_codepoint_t
*
a
,
hb_codepoint_t
*
b
)
{
{
*
a
=
*
b
=
0
;
*
a
=
ab
;
*
b
=
0
;
return
func
.
decompose
(
this
,
ab
,
a
,
b
,
user_data
.
decompose
);
return
func
.
decompose
(
this
,
ab
,
a
,
b
,
user_data
.
decompose
);
}
}
...
@@ -182,17 +183,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
...
@@ -182,17 +183,7 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
};
};
#ifdef HAVE_GLIB
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_glib_unicode_funcs
;
#define _hb_unicode_funcs_default _hb_glib_unicode_funcs
#elif defined(HAVE_ICU)
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_icu_unicode_funcs
;
#define _hb_unicode_funcs_default _hb_icu_unicode_funcs
#else
#define HB_UNICODE_FUNCS_NIL 1
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
#define _hb_unicode_funcs_default _hb_unicode_funcs_nil
#endif
/* Modified combining marks */
/* Modified combining marks */
...
...
src/hb-unicode.cc
浏览文件 @
d5045a5f
...
@@ -109,12 +109,44 @@ hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED
...
@@ -109,12 +109,44 @@ hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED
}
}
#define HB_UNICODE_FUNCS_IMPLEMENT_SET \
HB_UNICODE_FUNCS_IMPLEMENT (glib) \
HB_UNICODE_FUNCS_IMPLEMENT (icu) \
HB_UNICODE_FUNCS_IMPLEMENT (nil) \
/* ^--- Add new callbacks before nil */
#define hb_nil_get_unicode_funcs hb_unicode_funcs_get_empty
/* Prototype them all */
#define HB_UNICODE_FUNCS_IMPLEMENT(set) \
extern "C" hb_unicode_funcs_t *hb_##set##_get_unicode_funcs (void);
HB_UNICODE_FUNCS_IMPLEMENT_SET
#undef HB_UNICODE_FUNCS_IMPLEMENT
hb_unicode_funcs_t
*
hb_unicode_funcs_t
*
hb_unicode_funcs_get_default
(
void
)
hb_unicode_funcs_get_default
(
void
)
{
{
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_unicode_funcs_default
);
#define HB_UNICODE_FUNCS_IMPLEMENT(set) \
return hb_##set##_get_unicode_funcs ();
#ifdef HAVE_GLIB
HB_UNICODE_FUNCS_IMPLEMENT
(
glib
)
#elif defined(HAVE_ICU)
HB_UNICODE_FUNCS_IMPLEMENT
(
icu
)
#else
#define HB_UNICODE_FUNCS_NIL 1
HB_UNICODE_FUNCS_IMPLEMENT
(
nil
)
#endif
#undef HB_UNICODE_FUNCS_IMPLEMENT
}
}
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HB_UNICODE_FUNCS_NIL)
#pragma message("Could not find any Unicode functions implementation, you have to provide your own.")
#pragma message("To suppress this warnings, define HB_NO_UNICODE_FUNCS.")
#endif
hb_unicode_funcs_t
*
hb_unicode_funcs_t
*
hb_unicode_funcs_create
(
hb_unicode_funcs_t
*
parent
)
hb_unicode_funcs_create
(
hb_unicode_funcs_t
*
parent
)
{
{
...
@@ -140,7 +172,6 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
...
@@ -140,7 +172,6 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
}
}
extern
HB_INTERNAL
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
=
{
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
=
{
HB_OBJECT_HEADER_STATIC
,
HB_OBJECT_HEADER_STATIC
,
...
...
src/hb-warning.cc
浏览文件 @
d5045a5f
...
@@ -37,11 +37,3 @@
...
@@ -37,11 +37,3 @@
#if defined(HB_ATOMIC_INT_NIL) || defined(HB_MUTEX_IMPL_NIL)
#if defined(HB_ATOMIC_INT_NIL) || defined(HB_MUTEX_IMPL_NIL)
#pragma message("To suppress these warnings, define HB_NO_MT.")
#pragma message("To suppress these warnings, define HB_NO_MT.")
#endif
#endif
#include "hb-unicode-private.hh"
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HB_UNICODE_FUNCS_NIL)
#pragma message("Could not find any Unicode functions implementation, you have to provide your own.")
#pragma message("To suppress this warnings, define HB_NO_UNICODE_FUNCS.")
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录