| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 34 | 32 | ||
| entry/ | 06-May-2025 | - | 1,681 | 1,395 | ||
| hvigor/ | 06-May-2025 | - | 37 | 36 | ||
| screenshots/device/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 155 | 13 | 13 | |
| README.md | D | 06-May-2025 | 3.8 KiB | 83 | 60 | |
| build-profile.json5 | D | 06-May-2025 | 1.3 KiB | 58 | 58 | |
| code-linter.json5 | D | 06-May-2025 | 957 | 34 | 34 | |
| hvigorfile.ts | D | 06-May-2025 | 838 | 21 | 5 | |
| oh-package.json5 | D | 06-May-2025 | 808 | 25 | 24 | |
| ohosTest.md | D | 06-May-2025 | 1.2 KiB | 13 | 11 |
README.md
1# DisplaySoloist分级管控 2 3### 介绍 4 5本示例通过 DisplaySoloist 系列功能,使用 UI 外的线程对 XComponent 的绘制内容,设置开发者所期望的帧率。使用 [NativeDisplaySoloist](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/graphics/displaysoloist-native-guidelines.md) 和 [Drawing](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/graphics/drawing-guidelines.md) 来实现图像绘制和显示。 6 7### 效果预览 8 9| XComponent | 10| :------------------------------------------------------: | 11| <img src="./screenshots/device/index.png" width="100%"/> | 12 13使用说明 14 151.进入 XComponent 页面,依次点击“**Start**”,三个方块分别按照 30Hz、60Hz、120Hz 移动;点击“**Stop**”动画停止。 16 17### 工程目录 18 19``` 20├──entry/src/main 21│ ├──cpp // C++代码区 22│ │ ├──CMakeLists.txt // CMake配置文件 23│ │ ├──napi_init.cpp // Napi模块注册 24│ │ ├──common 25│ │ │ └──log_common.h // 日志封装定义文件 26│ │ ├──plugin // 生命周期管理模块 27│ │ │ ├──plugin_manager.cpp 28│ │ │ └──plugin_manager.h 29│ │ ├──samples // samples渲染模块 30│ │ │ ├──sample_xcomponent.cpp 31│ │ │ └──sample_xcomponent.h 32│ ├──ets // ets代码区 33│ │ ├──entryability 34│ │ │ ├──EntryAbility.ts // 程序入口类 35| | | └──EntryAbility.ets 36| | ├──interface 37│ │ │ └──XComponentContext.ts // XComponentContext 38│ │ ├──pages // 页面文件 39│ │ | └──Index.ets // XComponent页面 40│ │ ├──utils // 工具类 41| ├──resources // 资源文件目录 42``` 43 44### 具体实现 45 46* XComponent:通过在 IDE 中的 Native C++ 工程,在 TS 侧中声明对外接口为 register、unregister 以及 destroy;在 C++ 侧调用 NativeDisplaySoloist 分级管控接口,并在使用 drawing 来绘制期望帧率图像。 47 48 | 接口名 | 描述 | 49 | ------------------------------------------- | --------------------------------------------------- | 50 | OH_DisplaySoloist_Create | 创建一个OH_DisplaySoloist实例 | 51 | OH_DisplaySoloist_Destroy | 销毁一个OH_DisplaySoloist实例 | 52 | OH_DisplaySoloist_Start | 设置每帧回调函数,每次vsync信号到来时启动每帧回调 | 53 | OH_DisplaySoloist_Stop | 停止请求下一次vsync信号,并停止调用回调函数callback | 54 | OH_DisplaySoloist_SetExpectedFrameRateRange | 设置期望帧率范围 | 55 56 57### 相关权限 58 59不涉及。 60 61### 依赖 62 63不涉及。 64 65### 约束与限制 66 671.本示例仅支持在标准系统上运行; 68 692.本示例为 Stage 模型,已适配 API version 14 版本 SDK,SDK 版本号(API Version 14 5.0.2.57); 70 713.本示例需要使用 DevEco Studio 版本号(5.0.5.306)及以上版本才可编译运行。 72 73### 下载 74 75如需单独下载本工程,执行如下命令: 76 77``` 78git init 79git config core.sparsecheckout true 80echo code/DocsSample/graphic/DisplaySoloist/ > .git/info/sparse-checkout 81git remote add origin https://gitee.com/openharmony/applications_app_samples.git 82git pull origin master 83```