默认情况下,Android4.4 chromium webview使用的skia是系统的skia
'conditions': [
# In component mode (shared_lib), we build all of skia as a single DLL.
# However, in the static mode, we need to build skia as multiple targets
# in order to support the use case where a platform (e.g. Android) may
# already have a copy of skia as a system library.
['component=="static_library" and use_system_skia==0', {
'targets': [
{
'target_name': 'skia_library',
'type': 'static_library',
'includes': [
'skia_library.gypi',
'skia_common.gypi',
],
},
],
}],
['component=="static_library" and use_system_skia==1', {
'targets': [
{
'target_name': 'skia_library',
'type': 'none',
'includes': ['skia_system.gypi'],
},
],
}],
['component=="static_library"', {
'targets': [
{
'target_name': 'skia',
'type': 'none',
'dependencies': [
'skia_library',
'skia_chrome',
],
'export_dependent_settings': [
'skia_library',
'skia_chrome',
],
},
{
'target_name': 'skia_chrome',
'type': 'static_library',
'includes': [
'skia_chrome.gypi',
'skia_common.gypi',
],
},
],
},
{ # component != static_library
'targets': [
{
'target_name': 'skia',
'type': 'shared_library',
'includes': [
'skia_library.gypi',
'skia_chrome.gypi',
'skia_common.gypi',
],
'defines': [
'SKIA_DLL',
'GR_DLL=1',
'GR_IMPLEMENTATION=1',
'SKIA_IMPLEMENTATION=1',
],
'direct_dependent_settings': {
'defines': [
'SKIA_DLL',
'GR_DLL=1',
],
},
},
{
'target_name': 'skia_library',
'type': 'none',
},
{
'target_name': 'skia_chrome',
'type': 'none',
},
],
}],
],
变量
use_system_skia
控制是否采用系统所带的skia,但如果因为升级或者移植,skia可能版本不一样,因此不如用chromium中自带的skia.
修改build/common.gypi中代码:
'use_system_skia%': '<(android_webview_build)',
编译webview的话,默认使用系统的skia, 只要注释它 则会用thirt_party的skia.
另一个参数是component,也在build/common.gypi
'component%': 'static_library',
修改为shared_library则可。修改后,gyp之后,编译可能出现问题:
warning: shared library text segment is not shareable
error: treating warnings as errors
参考
1)http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Code-Gen-Options.html#Code-Gen-Options 2)http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
--warn-shared-textrel Warn if text segment is not shareable
--no-warn-shared-textrel Do not warn if text segment is not shareable (default)
gyp生成mk文件时,在DEBUG和Rlease中都加入了warn-shared-textrel选项。
去掉则可。