Blend
该示例演示PPE的渲染功能。
环境需求
该示例支持以下开发套件:
硬件平台 |
设备名称 |
---|---|
RTL87x2G HDK |
RTL87x2G EVB |
更多信息请参考快速入门。
硬件连线
无
配置选项
无
编译和下载
该示例的工程路径如下:
Project file: samples\peripheral\ppe\blend\proj\rtl87x2g\mdk
Project file: samples\peripheral\ppe\blend\proj\rtl87x2g\gcc
请按照以下步骤操作构建并运行该示例:
打开工程文件。
按照 快速入门 中 编译APP Image 给出的步骤构建目标文件。
编译成功后,在路径
mdk\bin
下会生成 app binapp_MP_xxx.bin
文件。按下复位按键,开始运行。
测试验证
运行代码后在DebugAnalyzer工具内观察到日志即为渲染成功。
PPE blend test passed 0
代码介绍
该章节分为以下几个部分:
源码路径
工程路径:
sdk\samples\peripheral\ppe\blend\proj
源码路径:
sdk\samples\peripheral\ppe\blend\src
该工程的工程文件代码结构如下:
└── Project: blend
└── ppe
├── config includes project construct configuration
├── display includes the peripheral drivers related with display
└── Device includes startup code
├── startup_rtl.c
└── system_rtl.c
├── CMSIS includes CMSIS header files
├── CMSE Library non-secure callable lib
├── lib includes all binary symbol files that user application is built on
├── peripheral includes all peripheral drivers and module code used by the application
└── APP source code of PPE blend sample
├── main_ns.c
└── ppe_test.c
初始化
初始化流程包含在 PPE_test()
中。
初始化前景与背景的数据。
初始包含前景与背景信息的PPE结构体。
source.address = (uint32_t) source_buffer;
source.memory = source_buffer;
source.color_key_en = DISABLE;
source.color_key_value = 0;
source.format = PPE_ABGR8888;
source.width = 64;
source.height = 64;
target.address = (uint32_t) target_buffer;
target.memory = target_buffer;
target.color_key_en = DISABLE;
target.color_key_value = 0;
target.format = PPE_ABGR8888;
target.width = 64;
target.height = 64;
设定前景的偏移量后,调用接口 :func:`PPE_blend`对前景与背景进行渲染。
ppe_translate_t trans = {.x = 0, .y = 0};
PPE_ERR err = PPE_blend(&source, &target, &trans, PPE_SRC_OVER_MODE);
小技巧
判断渲染是否出错的方式,详见 常见问题。
功能实现
执行 PPE_blend()
时,前景与背景从偏移位置开始逐像素进行混合。当代码执行完成,代表PPE已完成工作。
常见问题
判断渲染是否出错
在执行完 PPE_blend()
函数后,混合完成的内存区域会进行逐像素的检查,并与标准数据比对。若出现任一错误,能在DebugAnalyzer工具的窗口中看到下面的日志:
PPE alpha blend error
并且在最后一行日志能够观察到错误码:
PPE blend test passed ‘error code’