Android底层开发之字符绘制TextLayoutCache
2014-08-12 20:12
676 查看
查看TextLayoutCache调试信息
版本为Android 4.2.2_r1
关于TextLayoutCache:
The input of TextLayoutCache is a font and a Java UTF-16 string and its output is a list of glyph identifiers with their x/y positions.
来自:https://medium.com/@romainguy/androids-font-renderer-c368bbde87d9
以TextLayoutCache查看Log默认只能看到如下一条信息,如何打开调试信息呢?
08-12 07:21:38.490: D/TextLayoutCache(100): Using debug level = 0 - Debug Enabled = 0
追踪了一下:
void TextLayoutCache::init() {
mCache.setOnEntryRemovedListener(this);
mDebugLevel = readRtlDebugLevel();
mDebugEnabled = mDebugLevel & kRtlDebugCaches;
ALOGD("Using debug level = %d - Debug Enabled = %d", mDebugLevel, mDebugEnabled);
mCacheStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
if (mDebugEnabled) {
ALOGD("Initialization is done - Start time = %lld", mCacheStartTime);
}
mInitialized = true;
}
位于:frameworks/base/core/jni/android/graphics/TextLayoutCache.cpp
/**
* Debug level for app developers.
*/
#define RTL_PROPERTY_DEBUG "rtl.debug_level"
/**
* Debug levels. Debug levels are used as flags.
*/
enum RtlDebugLevel {
kRtlDebugDisabled = 0,
kRtlDebugMemory = 1,
kRtlDebugCaches = 2,
kRtlDebugAllocations = 3
};
static RtlDebugLevel readRtlDebugLevel() {
char property[PROPERTY_VALUE_MAX];
if (property_get(RTL_PROPERTY_DEBUG, property, NULL) > 0) {
return (RtlDebugLevel) atoi(property);
}
return kRtlDebugDisabled;
}
位于:frameworks/base/core/jni/android/graphics/RtlProperties.h
当rtl.debug_level等于2(kRtlDebugCaches)调试信息才可以被打开。在adb shell中执行:
#打开调试
setprop rtl.debug_level 2
#仅重启Android
stop && start
之后就可以以TextLayoutCache来查看它的LOG了。以下是部分信息截图:
片断1 SystemUI的文字处理过程:
片断2 自己编写的测试程序文字处理过程:
后续
打开调试信息,看init中调用的是harfbuzz还是icu。像下面这段代码一样:
#if RTL_USE_HARFBUZZ
LOGD("TextLayoutCache is using HARFBUZZ");
#else
LOGD("TextLayoutCache is using ICU");
#endif
ICU和HARFBUZZ关系这里闲聊文本渲染技术的近期发展有讲到,在ICU官网上已经看到推荐以前使用ICU的客户使用HARFBUZZ,他们的团队也已经加入到了HARFBUZZ中开发了。讲它俩关系的文章中已经提到这种可能了,真是神预言。
版本为Android 4.2.2_r1
关于TextLayoutCache:
The input of TextLayoutCache is a font and a Java UTF-16 string and its output is a list of glyph identifiers with their x/y positions.
来自:https://medium.com/@romainguy/androids-font-renderer-c368bbde87d9
以TextLayoutCache查看Log默认只能看到如下一条信息,如何打开调试信息呢?
08-12 07:21:38.490: D/TextLayoutCache(100): Using debug level = 0 - Debug Enabled = 0
追踪了一下:
void TextLayoutCache::init() {
mCache.setOnEntryRemovedListener(this);
mDebugLevel = readRtlDebugLevel();
mDebugEnabled = mDebugLevel & kRtlDebugCaches;
ALOGD("Using debug level = %d - Debug Enabled = %d", mDebugLevel, mDebugEnabled);
mCacheStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
if (mDebugEnabled) {
ALOGD("Initialization is done - Start time = %lld", mCacheStartTime);
}
mInitialized = true;
}
位于:frameworks/base/core/jni/android/graphics/TextLayoutCache.cpp
/**
* Debug level for app developers.
*/
#define RTL_PROPERTY_DEBUG "rtl.debug_level"
/**
* Debug levels. Debug levels are used as flags.
*/
enum RtlDebugLevel {
kRtlDebugDisabled = 0,
kRtlDebugMemory = 1,
kRtlDebugCaches = 2,
kRtlDebugAllocations = 3
};
static RtlDebugLevel readRtlDebugLevel() {
char property[PROPERTY_VALUE_MAX];
if (property_get(RTL_PROPERTY_DEBUG, property, NULL) > 0) {
return (RtlDebugLevel) atoi(property);
}
return kRtlDebugDisabled;
}
位于:frameworks/base/core/jni/android/graphics/RtlProperties.h
当rtl.debug_level等于2(kRtlDebugCaches)调试信息才可以被打开。在adb shell中执行:
#打开调试
setprop rtl.debug_level 2
#仅重启Android
stop && start
之后就可以以TextLayoutCache来查看它的LOG了。以下是部分信息截图:
片断1 SystemUI的文字处理过程:
片断2 自己编写的测试程序文字处理过程:
后续
打开调试信息,看init中调用的是harfbuzz还是icu。像下面这段代码一样:
#if RTL_USE_HARFBUZZ
LOGD("TextLayoutCache is using HARFBUZZ");
#else
LOGD("TextLayoutCache is using ICU");
#endif
ICU和HARFBUZZ关系这里闲聊文本渲染技术的近期发展有讲到,在ICU官网上已经看到推荐以前使用ICU的客户使用HARFBUZZ,他们的团队也已经加入到了HARFBUZZ中开发了。讲它俩关系的文章中已经提到这种可能了,真是神预言。
相关文章推荐
- Android底层开发之字符绘制TextLayoutCache
- Android编程开发之EditText中不输入特定字符会显示相关提示信息的方法
- Android开发笔记(一百三十八)文本输入布局TextInputLayout
- android Textview 实现展开收缩功能(字符宽度)(StaticLayout)
- Android开发-DesignDemo-AndroidStudio(十二)TextInputLayout
- Android开发之TextInputLayout的简单使用(增强EditText)
- android开发(十六) 如何限制 EditText 最大输入字符数
- Android开发-DesignDemo-AndroidStudio(十二)TextInputLayout
- Android开发2(Toast,AlertDialog,Snackbar,TextInputLayout的使用)
- Android开发——Material Design系列之TextInputLayout
- Android 开发关于Button或TextView控件英文字符全部显示大小写问题
- Android开发(29)--EditText中输入特定的字符,不输会有提示信息
- 快速开发android应用2-使用TextInputLayout实现用户登录及验证
- Android开发:在EditText中关闭软键盘
- Android应用开发——TextView控件属性列表
- android系统开发小问题-启动过程中android字符没有显示出来
- eclipse中开发android程序时,打开layout配置文件eclipse关闭
- Direct2D (39) : 使用 IDWriteTextLayout.Draw() 方法绘制文本
- Android (C开发)底层开发之一 【环境搭建】
- Android简明开发教程十四:Context Menu 绘制几何图形