一、进程调用关系变化
1.1 进程数量变化
新增加两个uhdf进程。allocator_host进程及composer_host进程。
删除了disp_gralloc_host 进程,并使用allocator_host替换。
uhdf添加进程配置如下:
hdf_config/uhdf/device_info.hcs
ini
display_composer :: host {
hostName = "composer_host";
priority = 40;
processPriority = -8;
threadPriority = 1;
caps = ["SYS_NICE"];
uid = ["composer_host"];
gid = ["composer_host", "graphics", "vendor_mpp_driver"];
composer_device :: device {
device0 :: deviceNode {
policy = 2;
priority = 160;
moduleName = "libdisplay_composer_driver_1.0.z.so";
serviceName = "display_composer_service";
}
}
}
allocator :: host {
hostName = "allocator_host";
priority = 40;
allocator_device :: device {
device0 :: deviceNode {
policy = 2;
priority = 160;
moduleName = "liballocator_driver_1.0.z.so";
serviceName = "allocator_service";
}
}
}
1.2 拉起关系变化
- composer
以前版本composer由render_service通过单例拉起,现在通过composer service拉起接口实现层
libdisplay_composer_vdi_impl.z.so,对外提供标准的IPC服务.
- allocator
进程名字由disp_gralloc_host变更成allocator_host。通过allocator_service拉起接口实现层
libdisplay_buffer_vdi_impl.z.so,对外提供标准的IPC服务。
二、接口协议更新
2.1 接口更新
结构体定义由原来的.h变为接口描述语言IDL代替,在协议升级过程中,会遇到大量结构体命名空间不一样的冲突,总体解决思路就是去掉原有的.h头文件依赖,增加新的接口头文件即可。
- allocator_host
头文件更新:由display_type.h 更新成
v1_0/display_buffer_type.h。由DisplayBufferType.idl生成在out下
接口协议更新:
由原来的display_gralloc.cpp中提供的接口更换成
OHOS::HDI::Display::Buffer::V1_0::IDisplayBufferVdi,并新建接口实现文件:
display_buffer_vdi_impl.cpp/.h。
参考
drivers/peripheral/display/hal/default_standard/src/display_gralloc/display_buffer_vdi_impl.cpp中的接口,并按自己的实际情况完成实现。
- composer_host
头文件更新:由display_type.h 更新成
v1_0/display_composer_type.h。由DisplayComposerType.idl生成在out下
由原来的hdi_session.cpp中提供的接口更换成
OHOS::HDI::Display::Composer::V1_0::IDisplayComposerVdi,并新建接口实现文件:
display_composer_vdi_impl.cpp/.h
参考
drivers/peripheral/display/hal/default_standard/src/display_device/display_composer_vdi_impl.cpp中的接口,并按自己的实际情况完成实现。
2.2 其它头文件更新
- BufferHandle
新结构体去掉了key,如果代码中有用到,需要让以下定义保持一致:
bash
drivers/hdf_core/interfaces/inner_api/hdi/base/buffer_handle.h
drivers/peripheral/base/buffer_handle.h
foundation/graphic/graphic_2d/frameworks/surface/include/buffer_handle.h
- 其它头文件:
drivers/peripheral/display/interfaces/include下的头文件与device_type.h有关联。要解耦,不要使用。
三、开机动画
在4.0中,开机动画默认使用的是播放视频,对点屏不友好,建议修改成原图片播放方式,修改方法如下:
frameworks/bootanimation/include/boot_animationconfig.h
diff
@@ -33,7 +33,7 @@ public:
bool IsBootVideoEnabled();
private:
BootCustomConfig custConfig_;
- bool bootVideoEnabled_ = true;
+ bool bootVideoEnabled_ = false; //不使用视频开机动画模式
};
} // namespace OHOS
四、hello_composer编译报错
合入如下修改解决:
五、CPU渲染
当前4.0切换成CPU渲染是会报错的,提示一些gl.h/egl.h等文件找不到,与GPU文件解耦不足,通过合入以下修改解决:
diff
diff --git a/graphic_config.gni b/graphic_config.gni
index f7b7b3bdb..635197e80 100644
--- a/graphic_config.gni
+++ b/graphic_config.gni
@@ -13,9 +13,9 @@
declare_args() {
graphic_2d_feature_bootanimation_enable = true
- graphic_2d_feature_ace_enable_gpu = true
+ graphic_2d_feature_ace_enable_gpu = false
graphic_2d_feature_color_gamut_enable = false
- graphic_2d_feature_rs_enable_eglimage = false
+ graphic_2d_feature_rs_enable_eglimage = true
graphic_2d_feature_rs_enable_uni_render = false
graphic_2d_feature_wuji_enable = false
graphic_2d_feature_enable_afbc = false
diff --git a/rosen/modules/effect/skia_effectChain/BUILD.gn b/rosen/modules/effect/skia_effectChain/BUILD.gn
index b4a23f6ca..7e29b369b 100644
--- a/rosen/modules/effect/skia_effectChain/BUILD.gn
+++ b/rosen/modules/effect/skia_effectChain/BUILD.gn
@@ -37,6 +37,7 @@ config("effect_SKeffectChian_public_config") {
"//foundation/multimedia/image_framework/interfaces/innerkits/include",
"$graphic_2d_root/utils/log",
"include",
+ "//third_party/openGLES/api",
]
}
@@ -44,6 +45,8 @@ ohos_shared_library("skeffectchain") {
public_deps = [
"$graphic_2d_root:libsurface",
"$graphic_2d_root/rosen/modules/effect/egl:libegl_effect",
+ "//third_party/EGL:libEGL",
+ "//third_party/openGLES:libGLES",
]
if (ace_enable_gpu) {
@@ -51,6 +54,7 @@ ohos_shared_library("skeffectchain") {
public_deps += [ "$graphic_2d_root:libgl" ]
}
+ public_deps += [ "$graphic_2d_root:libgl" ]
if (defined(use_new_skia) && use_new_skia) {
public_deps += [ "//third_party/skia:skia_ohos" ]
} else {
diff --git a/rosen/modules/render_service/BUILD.gn b/rosen/modules/render_service/BUILD.gn
index 77b26ea2f..b27faca7c 100644
--- a/rosen/modules/render_service/BUILD.gn
+++ b/rosen/modules/render_service/BUILD.gn
@@ -183,6 +183,13 @@ ohos_shared_library("librender_service") {
defines += accessibility_defines
}
+ cflags = [
+ "-Wall",
+ "-Wno-unused-const-variable",
+ ]
+
+ cflags_cc = [ "-Wno-unused-const-variable" ]
+
part_name = "graphic_2d"
subsystem_name = "graphic"
}
diff --git a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp
index c7418e0fb..fac0a162d 100644
--- a/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp
+++ b/rosen/modules/render_service/core/pipeline/rs_base_render_engine.cpp
@@ -85,6 +85,7 @@ void RSBaseRenderEngine::Init()
bool RSBaseRenderEngine::NeedForceCPU(const std::vector<LayerInfoPtr>& layers)
{
+#ifdef RS_ENABLE_GL
bool forceCPU = false;
for (const auto& layer: layers) {
if (layer == nullptr) {
@@ -113,6 +114,9 @@ bool RSBaseRenderEngine::NeedForceCPU(const std::vector<LayerInfoPtr>& layers)
}
return forceCPU;
+#else
+ return true;
+#endif
}
#ifndef USE_ROSEN_DRAWING
diff --git a/rosen/modules/render_service_base/src/platform/ohos/BUILD.gn b/rosen/modules/render_service_base/src/platform/ohos/BUILD.gn
index e1bf2eb3b..cfa6676f1 100644
--- a/rosen/modules/render_service_base/src/platform/ohos/BUILD.gn
+++ b/rosen/modules/render_service_base/src/platform/ohos/BUILD.gn
@@ -109,6 +109,7 @@ ohos_source_set("rosen_ohos_sources") {
"//drivers/peripheral/display/interfaces/include/",
"$graphic_2d_root/rosen/modules/render_service_client/core",
"$graphic_2d_root/utils/log",
+ "//third_party/openGLES/api",
]
public_deps = [
@@ -116,6 +117,8 @@ ohos_source_set("rosen_ohos_sources") {
"$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
"$graphic_2d_root/rosen/modules/composer/vsync:libvsync",
"$graphic_2d_root/utils:sync_fence",
+ "//third_party/EGL:libEGL",
+ "//third_party/openGLES:libGLES",
]
if (defined(use_new_skia) && use_new_skia) {
public_deps += [ "//third_party/skia:skia_ohos" ]
五、实战经验分享
本次实战主要是把产品从3.2.3-Release升级到4.0-Release。中间看到这些变化,心里有点慌,从而记录下来,并提供给大家参考。框架上遇到的一些问题,前面几节已经给大家说明了,以下是一些升级的步骤及建议。
1、添加接口协议文件、gn编译、hcs配置。
为composer添加
display_composer_vdi_impl.cpp/.h
为gralloc添加
display_buffer_vdi_impl.cpp/.h。
在gn中添加目标
libdisplay_composer_vdi_impl和libdisplay_buffer_vdi_impl。
在device_info.hcs中添加进程配置。
2、编译修改。
这个是工作量比较大的地方。原则上就是去掉
drivers/peripheral/display/interfaces/include下的头文件依赖,并添加
#include "v1_0/display_composer_type.h"
arduino
#include "v1_0/display_buffer_type.h"
以及命名空间:
using namespace OHOS::HDI::Display::Composer::V1_0;
using namespace OHOS::HDI::Display::Buffer::V1_0;
当然gn中也要添加相应的依赖。
3、调试。
主要使用hello_composer调试,关注hdi_backend.cpp中Repaint函数执行流程,并在hilog中搜索关键命令字:REQUEST_CMD,一个完整的流程必须包含以下命令:
REQUEST_CMD_PREPARE_DISPAY_LATERS
REQUEST_CMD_SET_DISPLAY_CLIENT_DAMAGE
REQUEST_CMD_SET_DISPLAY_CLENT_BUFFER
REQUEST_CMD_COMMIT
如果so没有正常加载,也可以在以下文件中添加打印:
css
drivers/peripheral/display/buffer/hdi_service/src/allocator_service.cpp
drivers/peripheral/display/composer/hdi_service/src/display_composer_service.cpp
可以为dlopen添加详细错误信息,默认没有添加:
ini
if (libHandle_ == NULL) {
error = dlerror();
DISPLAY_LOGE("composer load path%{public}s, dlopen err=%{public}s", DISPLAY_COMPOSER_VDI_LIBRARY, error);
return HDF_FAILURE;
}
本文主要介绍OpenHarmony 4.0图形HDI基础适配及点屏差异。适用于版本升级,新特性了解及问题分析。