HarmonyOS API:模块
版本:v3.1 Beta
OH_NativeBuffer
更新时间: 2023-02-17 09:19
提供NativeBuffer功能
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
起始版本:
9
汇总
文件
文件名称 | 描述 |
定义获取和使用NativeBuffer的相关函数 引用文件:<native_buffer/native_buffer.h> |
结构体
结构体名称 | 描述 |
OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性 |
函数
函数名称 | 描述 |
OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config *config) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例 |
OH_NativeBuffer_Reference (OH_NativeBuffer *buffer) | 将OH_NativeBuffer对象的引用计数加1 |
OH_NativeBuffer_Unreference (OH_NativeBuffer *buffer) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉 |
OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config *config) | 用于获取OH_NativeBuffer的属性 |
OH_NativeBuffer_Map (OH_NativeBuffer *buffer, void **virAddr) | 将OH_NativeBuffer对应的ION内存映射到进程空间 |
OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer) | 将OH_NativeBuffer对应的ION内存从进程空间移除 |
OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer) | 获取OH_NativeBuffer的序列号 |
详细描述
函数说明
OH_NativeBuffer_Alloc()
OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config)
描述:
通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
config | 参数是一个指向OH_NativeBuffer属性的指针,类型为OH_NativeBuffer_Config |
返回:
创建成功则返回一个指向OH_NativeBuffer结构体实例的指针,否则返回NULL
起始版本:
9
OH_NativeBuffer_GetConfig()
void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config * config )
描述:
用于获取OH_NativeBuffer的属性
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
config | 参数是一个指向OH_NativeBuffer_Config的指针,用于接收OH_NativeBuffer的属性 |
起始版本:
9
OH_NativeBuffer_GetSeqNum()
uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer)
描述:
获取OH_NativeBuffer的序列号
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
返回:
返回对应OH_NativeBuffer的唯一序列号
起始版本:
9
OH_NativeBuffer_Map()
int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr )
描述:
将OH_NativeBuffer对应的ION内存映射到进程空间
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
virAddr | 参数是一个二级指针,二级指针指向虚拟内存的地址 |
返回:
返回一个由GSError定义的int32_t类型的错误码
起始版本:
9
OH_NativeBuffer_Reference()
int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer)
描述:
将OH_NativeBuffer对象的引用计数加1
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
返回:
返回一个由GSError定义的int32_t类型的错误码
起始版本:
9
OH_NativeBuffer_Unmap()
int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer)
描述:
将OH_NativeBuffer对应的ION内存从进程空间移除
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
返回:
返回一个由GSError定义的int32_t类型的错误码
起始版本:
9
OH_NativeBuffer_Unreference()
int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer * buffer)
描述:
将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
参数:
Name | 描述 |
buffer | 参数是一个指向OH_NativeBuffer实例的指针 |
返回:
返回一个由GSError定义的int32_t类型的错误码
起始版本:
9
OH_NativeImage
更新时间: 2023-02-17 09:19
提供NativeImage功能。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
起始版本:
9
汇总
文件
文件名称 | 描述 |
定义获取和使用NativeImage的相关函数。 引用文件:<native_image/native_image.h> |
函数
函数名称 | 描述 |
OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget) | 创建一个OH_NativeImage实例,该实例与OPENGL ES的纹理ID和纹理目标相关联。 |
OH_NativeImage_AcquireNativeWindow (OH_NativeImage *image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用 OH_NativeWindow_DestroyNativeWindow释放。 |
OH_NativeImage_AttachContext (OH_NativeImage *image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OPENGL ES上下文, 且该OPENGL ES纹理会绑定到 GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新。 |
OH_NativeImage_DetachContext (OH_NativeImage *image) | 将OH_NativeImage实例从当前OPENGL ES上下文分离。 |
OH_NativeImage_UpdateSurfaceImage (OH_NativeImage *image) | 通过OH_NativeImage获取最新帧更新相关联的OPENGL ES纹理。 |
OH_NativeImage_GetTimestamp (OH_NativeImage *image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳。 |
OH_NativeImage_GetTransformMatrix (OH_NativeImage *image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵。 |
OH_NativeImage_Destroy (OH_NativeImage **image) | 销毁通过OH_NativeImage_Create创建的OH_NativeImage实例, 销毁后该 OH_NativeImage指针会被赋值为空。 |
详细描述
函数说明
OH_NativeImage_AcquireNativeWindow()
OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image)
描述:
获取与OH_NativeImage相关联的OHNativeWindow指针。该OHNativeWindow后续不再需要时需要调用 OH_NativeWindow_DestroyNativeWindow释放。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
返回:
成功则返回一个指向OHNativeWindow实例的指针,否则返回NULL。
起始版本:
9
OH_NativeImage_AttachContext()
int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId )
描述:
将OH_NativeImage实例附加到当前OPENGL ES上下文,且该OPENGL ES纹理会绑定到 GL_TEXTURE_EXTERNAL_OES,并通过OH_NativeImage进行更新。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
textureId | OH_NativeImage要附加到的OPENGL ES纹理的id。 |
返回:
返回一个由SurfaceError定义的int32_t类型的错误码。
起始版本:
9
OH_NativeImage_Create()
OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget )
描述:
创建一个OH_NativeImage实例,该实例与OPENGL ES的纹理ID和纹理目标相关联。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
textureId | OPENGL ES的纹理ID,OH_NativeImage实例会与之相关联。 |
textureTarget | OPENGL ES的纹理目标。 |
返回:
返回一个指向OH_NativeImage实例的指针,否则返回NULL。
起始版本:
9
OH_NativeImage_Destroy()
void OH_NativeImage_Destroy (OH_NativeImage ** image)
描述:
销毁通过OH_NativeImage_Create创建的OH_NativeImage实例, 销毁后该 OH_NativeImage指针会被赋值为空.
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
OH_NativeImage_DetachContext()
int32_t OH_NativeImage_DetachContext (OH_NativeImage * image)
描述:
将OH_NativeImage实例从当前OPENGL ES上下文分离。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
返回:
返回一个由SurfaceError定义的int32_t类型的错误码。
起始版本:
9
OH_NativeImage_GetTimestamp()
int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image)
描述:
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
返回:
返回纹理图像的相关时间戳。
起始版本:
9
OH_NativeImage_GetTransformMatrix()
int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] )
描述:
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
matrix | 用来存储要获取的4*4的变化矩阵。 |
返回:
返回一个由SurfaceError定义的int32_t类型的错误码。
起始版本:
9
OH_NativeImage_UpdateSurfaceImage()
int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image)
描述:
通过OH_NativeImage获取最新帧更新相关联的OPENGL ES纹理。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
参数:
Name | 描述 |
image | 指向OH_NativeImage实例的指针。 |
返回:
返回一个由SurfaceError定义的int32_t类型的错误码。
起始版本:
9