当前位置: 首页 > news >正文

CPU点屏指导

版本要求:4.0 release及之前版本。

当前只有4.0之前的版本可以支持CPU点屏,4.1开始之后的版本包括master暂时不支持CPU点屏。

原因:4.1release开始,OHOS的arkui自己实现了flutter相关的API,摆脱了对flutter的依赖,所以框架内删除了flutter的三方库组件。但是CPU点屏依然使用了其中部分API,所以在4.1之后的版本上进行CPU点屏会出现flutter、skia等API相关报错。

注意:4.1 release解决方案,待后续更新。

点屏流程

img

点屏实操

编译阶段

从编译框架的层面将原本的GPU点屏模式改为CPU点屏模式。

路径1:vendor/hihope/rk3568/config.json

修改目的:

  1. 关闭selinux,避免点屏操作被安全机制拒绝。
  2. 去掉对GPU的依赖。
diff --git a/rk3568/config.json b/rk3568/config.json
index ea2d588..21b5ec2 100755
--- a/rk3568/config.json
+++ b/rk3568/config.json
@@ -9,7 +9,7 @@"api_version": 8,"enable_ramdisk": true,"enable_absystem": false,
-  "build_selinux": true,
+  "build_selinux": false,"build_seccomp": true,"inherit": [ "productdefine/common/inherit/rich.json", "productdefine/common/inherit/chipset_common.json" ],"subsystems": [
@@ -64,7 +64,7 @@"component": "ace_engine","features": ["ace_engine_feature_enable_accessibility = true",
-            "ace_engine_feature_enable_web = true"
+            "ace_engine_feature_enable_web = false"]},{
@@ -200,7 +200,7 @@{"component": "graphic_2d","features": [
-            "graphic_2d_feature_rs_enable_eglimage = true"
+            "graphic_2d_feature_rs_enable_eglimage = false"]}]

路径2:productdefine/common/inherit/rich.json

修改目的:

  1. 切换点屏模式。
  2. 4.0 release版本的fingerprint_auth组件对GPU有依赖,需要裁掉此组件。
diff --git a/inherit/rich.json b/inherit/rich.json
index 255af7f..5549de9 100644
--- a/inherit/rich.json
+++ b/inherit/rich.json
@@ -501,7 +501,7 @@{"component": "graphic_2d","features": [
-            "graphic_2d_feature_ace_enable_gpu = true"
+            "graphic_2d_feature_ace_enable_gpu = false"]},{
@@ -533,10 +533,6 @@{"component": "face_auth","features": []
-        },
-        {
-          "component": "fingerprint_auth",
-          "features": []}]},
@@ -1012,10 +1008,6 @@"component": "drivers_interface_user_auth","features": []},
-        {
-          "component": "drivers_interface_fingerprint_auth",
-          "features": []
-        },{"component": "drivers_interface_huks","feature":[]

路径3:foundation/graphic/graphic_2d/graphic_config.gni

修改目的:

  1. 切换点屏模式。
  2. 去掉对GPU的依赖。
  3. 解决编译报错问题。此参数在GPU点屏时,会在GPU的分支中进行定义,后续脚本中会对此参数进行判断。切换成CPU之后,没有定义此参数,直接进行了判断,所以报错。
diff --git a/graphic_config.gni b/graphic_config.gni
index f7b7b3bdb..cf220aaff 100644
--- a/graphic_config.gni
+++ b/graphic_config.gni
@@ -13,14 +13,14 @@declare_args() {graphic_2d_feature_bootanimation_enable = true
-  graphic_2d_feature_ace_enable_gpu = true
+  graphic_2d_feature_ace_enable_gpu = falsegraphic_2d_feature_color_gamut_enable = falsegraphic_2d_feature_rs_enable_eglimage = falsegraphic_2d_feature_rs_enable_uni_render = falsegraphic_2d_feature_wuji_enable = falsegraphic_2d_feature_enable_afbc = falsegraphic_2d_feature_freemem_enable = false
-  graphic_2d_feature_parallel_render_enable = true
+  graphic_2d_feature_parallel_render_enable = falsegraphic_2d_feature_enable_vulkan = falseif (defined(is_arkui_x) && is_arkui_x) {use_new_render_context = false
@@ -65,6 +65,7 @@ if (graphic_2d_feature_ace_enable_gpu) {}} else {gpu_defines = [ "ACE_DISABLE_GL" ]
+  rs_enable_parallel_render = falseace_enable_gpu = falsers_enable_gpu = falsesurface_enable_gpu = false

路径:foundation/graphic/graphic_2d/rosen/modules/render_service_base/BUILD.gn

修改目的:

  1. 解决编译中报错问题。此处的cpp源文件在GPU模式下,会被添加到config列表中。但是切换为CPU模式后,CPU分支没有引用此文件,所以在已经生效的config列表中找不到此文件,所以无法进行"sources-"的操作,最终导致报错。
diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn
index 900f4d903..2ea222a40 100644
--- a/rosen/modules/render_service_base/BUILD.gn
+++ b/rosen/modules/render_service_base/BUILD.gn
@@ -243,7 +243,7 @@ ohos_source_set("render_service_base_src") {if (current_os == "mingw" || current_os == "mac" || current_os == "linux" ||current_os == "ios") {
-    sources -= [ "src/common/rs_shared_context.cpp" ]
+    # sources -= [ "src/common/rs_shared_context.cpp" ]}if (current_os == "ohos") {

功能实现

路径:device/soc/rockchip/rk3568/hardware/display/src/display_device/hdi_gfx_composition.cpp

修改目的:

  1. 引用头文件,定义"IDisplayBufferVdi"。
  2. 进行CPU点屏时,canhandle需要返回false,否则合成会出现异常卡在开机动画界面(hello_composer测试时需要改为true)。
  3. 实现了一个简单的合成动作。将多个图层合成为一张图,并送到显示的buff中。如果不做修改会出现开机进入桌面无法操作的现象。
diff --git a/rk3568/hardware/display/src/display_device/hdi_gfx_composition.cpp b/rk3568/hardware/display/src/display_device/hdi_gfx_composition.cpp
index 93d9174..11b207a 100644
--- a/rk3568/hardware/display/src/display_device/hdi_gfx_composition.cpp
+++ b/rk3568/hardware/display/src/display_device/hdi_gfx_composition.cpp
@@ -22,6 +22,8 @@#include "hitrace_meter.h"#include "v1_0/display_composer_type.h"+#include "display_buffer_vdi_impl.h"
+using namespace OHOS::HDI::Display::Composer::V1_0;namespace OHOS {
@@ -84,7 +86,8 @@ bool HdiGfxComposition::CanHandle(HdiLayer &hdiLayer){DISPLAY_LOGD();(void)hdiLayer;
-    return true;
+    // return true;
+    return false;}bool HdiGfxComposition::UseCompositionClient(std::vector<HdiLayer *> &layers)
@@ -202,7 +205,8 @@ int32_t HdiGfxComposition::Apply(bool modeSet){StartTrace(HITRACE_TAG_HDF, "HDI:DISP:Apply");int32_t ret;
-    DISPLAY_LOGD("composer layers size %{public}zd", mCompLayers.size());
+    static std::shared_ptr<IDisplayBufferVdi> g_buffer = nullptr;
+    DISPLAY_LOGD("map composer layers size %{public}zd", mCompLayers.size());for (uint32_t i = 0; i < mCompLayers.size(); i++) {HdiLayer *layer = mCompLayers[i];CompositionType compType = layer->GetCompositionType();
@@ -213,9 +217,32 @@ int32_t HdiGfxComposition::Apply(bool modeSet)DISPLAY_LOGE("clear layer %{public}d failed", i));break;case COMPOSITION_DEVICE:
-                ret = BlitLayer(*layer, *mClientLayer);
-                DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
-                    DISPLAY_LOGE("blit layer %{public}d failed ", i));
+               // ret = BlitLayer(*layer, *mClientLayer);
+                // DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
+                //     DISPLAY_LOGE("blit layer %{public}d failed ", i));
+                {
+                    if (g_buffer== nullptr) {
+                        IDisplayBufferVdi* dispBuf = new DisplayBufferVdiImpl();
+                        DISPLAY_CHK_RETURN((dispBuf == nullptr), DISPLAY_FAILURE, DISPLAY_LOGE("map dispBuf init failed"));
+                        g_buffer.reset(dispBuf);
+                        DISPLAY_LOGD("map new DisplayBufferVdiImpl");
+                    }
+                    char *clientBuff = (char *)g_buffer->Mmap(mClientLayer->GetCurrentBuffer()->mHandle);
+                    if(clientBuff) {
+                        DISPLAY_LOGD("map in int");
+                        HdiLayerBuffer *hdiLayer = layer->GetCurrentBuffer();
+                        char *layerBuff = (char *)g_buffer->Mmap(hdiLayer->mHandle);
+                        for(int y = 0; y < hdiLayer->GetHeight(); y++) {
+                            memcpy(&clientBuff[mClientLayer->GetCurrentBuffer()->GetStride() * 
+                            (y + layer->GetLayerDisplayRect().y) + layer->GetLayerDisplayRect().x * 4],
+                            (char *)(&layerBuff[hdiLayer->GetStride() * y]), hdiLayer->GetStride());
+                        }
+                        g_buffer->Unmap(hdiLayer->mHandle);
+                        g_buffer->Unmap(mClientLayer->GetCurrentBuffer()->mHandle);
+                    } else {
+                        DISPLAY_LOGD("map in err");
+                    }
+                }break;default:DISPLAY_LOGE("the gfx composition can not surpport the type %{public}d", compType);
@@ -225,6 +252,7 @@ int32_t HdiGfxComposition::Apply(bool modeSet)FinishTrace(HITRACE_TAG_HDF);return DISPLAY_SUCCESS;}
+} // namespace OHOS} // namespace HDI} // namespace DISPLAY

http://www.mrgr.cn/news/18850.html

相关文章:

  • c++--智能指针(RAII)
  • LeetCode—string练习
  • MQTT协议详解
  • SQLite数据库(备份)
  • 2025中国(西安)国际航空维修技术及设备展览会
  • 由点坐标拟合圆和计算圆度
  • WHAT - React 函数与 useMemo vs useCallback
  • 真实:关于源代码防泄漏工作一些经验分享
  • Python高效并发编程:实现一个线程安全的队列
  • CountDownLatch的应用与原理
  • 人工智能与机器学习原理精解【15】
  • html+css+js网页设计 故宫7个页面 ui还原度100%
  • 1.2 Java基础多线程面试题
  • 前端项目开发之安装prettier和使用
  • 【微处理器原理与应用设计】Cortex-M4处理器内核和存储系统以及异常处理机制
  • C++-spdlog-使用
  • 数据结构4—双向链表(附源码)
  • 【前端面试】设计循环双端队列javascript
  • 智慧医院必备信息化系统之——LIS系统源码
  • C++——入门基础(下)