harmony 鸿蒙OH_NativeBuffer

2023-10-30 浏览 (847)

OH_NativeBuffer

Overview

The OH_NativeBuffer module provides the capabilities of NativeBuffer. Using the functions provided by this module, you can apply for, use, and release the shared memory, and query its attributes.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Since

9

Summary

Files

NameDescription
native_buffer.hDeclares the functions for obtaining and using NativeBuffer.
File to include: <native_buffer/native_buffer.h>
Library: libnative_buffer.so

Structs

NameDescription
OH_NativeBuffer_ConfigDefines the OH_NativeBuffer attribute configuration, which is used when you apply for a new OH_NativeBuffer instance or query the attributes of an existing instance.

Types

NameDescription
OH_NativeBufferProvides the declaration of an OH_NativeBuffer struct.

Enums

NameDescription
OH_NativeBuffer_Usage { NATIVEBUFFER_USAGE_CPU_READ = (1ULL << 0), NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL << 1), NATIVEBUFFER_USAGE_MEM_DMA = (1ULL << 3) }Enumerates the OH_NativeBuffer usages.
OH_NativeBuffer_Format {
NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3, NATIVEBUFFER_PIXEL_FMT_RGBA_5658, NATIVEBUFFER_PIXEL_FMT_RGBX_4444, NATIVEBUFFER_PIXEL_FMT_RGBA_4444,
NATIVEBUFFER_PIXEL_FMT_RGB_444, NATIVEBUFFER_PIXEL_FMT_RGBX_5551, NATIVEBUFFER_PIXEL_FMT_RGBA_5551, NATIVEBUFFER_PIXEL_FMT_RGB_555,
NATIVEBUFFER_PIXEL_FMT_RGBX_8888, NATIVEBUFFER_PIXEL_FMT_RGBA_8888, NATIVEBUFFER_PIXEL_FMT_RGB_888, NATIVEBUFFER_PIXEL_FMT_BGR_565,
NATIVEBUFFER_PIXEL_FMT_BGRX_4444, NATIVEBUFFER_PIXEL_FMT_BGRA_4444, NATIVEBUFFER_PIXEL_FMT_BGRX_5551, NATIVEBUFFER_PIXEL_FMT_BGRA_5551,
NATIVEBUFFER_PIXEL_FMT_BGRX_8888, NATIVEBUFFER_PIXEL_FMT_BGRA_8888, NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF
}
Enumerates the OH_NativeBuffer formats.

Functions

NameDescription
OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config *config)Creates an OH_NativeBuffer instance based on an OH_NativeBuffer_Config struct. A new OH_NativeBuffer instance is created each time this function is called.
OH_NativeBuffer_Reference (OH_NativeBuffer *buffer)Increases the reference count of an OH_NativeBuffer instance by 1.
OH_NativeBuffer_Unreference (OH_NativeBuffer *buffer)Decreases the reference count of an OH_NativeBuffer instance by 1 and, when the reference count reaches 0, destroys the instance.
OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config *config)Obtains the attributes of an OH_NativeBuffer instance.
OH_NativeBuffer_Map (OH_NativeBuffer *buffer, void **virAddr)Maps the ION memory corresponding to an OH_NativeBuffer instance to the process address space.
OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer)Unmaps the ION memory corresponding to an OH_NativeBuffer instance from the process address space.
OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer)Obtains the sequence number of an OH_NativeBuffer instance.

Type Description

OH_NativeBuffer

typedef struct OH_NativeBuffer OH_NativeBuffer

Description

Provides the declaration of an OH_NativeBuffer struct.

Enum Description

OH_NativeBuffer_Format

enum OH_NativeBuffer_Format

Description

Enumerates the OH_NativeBuffer formats.

@SysCap SystemCapability.Graphic.Graphic2D.NativeBuffer

ValueDescription
NATIVEBUFFER_PIXEL_FMT_RGB_565RGB565.
NATIVEBUFFER_PIXEL_FMT_RGBA_5658RGBA5658.
NATIVEBUFFER_PIXEL_FMT_RGBX_4444RGBX4444.
NATIVEBUFFER_PIXEL_FMT_RGBA_4444RGBA4444.
NATIVEBUFFER_PIXEL_FMT_RGB_444RGB444.
NATIVEBUFFER_PIXEL_FMT_RGBX_5551RGBX5551.
NATIVEBUFFER_PIXEL_FMT_RGBA_5551RGBA5551.
NATIVEBUFFER_PIXEL_FMT_RGB_555RGB555.
NATIVEBUFFER_PIXEL_FMT_RGBX_8888RGBX8888.
NATIVEBUFFER_PIXEL_FMT_RGBA_8888RGBA8888.
NATIVEBUFFER_PIXEL_FMT_RGB_888RGB888.
NATIVEBUFFER_PIXEL_FMT_BGR_565BGR565.
NATIVEBUFFER_PIXEL_FMT_BGRX_4444BGRX4444.
NATIVEBUFFER_PIXEL_FMT_BGRA_4444BGRA4444.
NATIVEBUFFER_PIXEL_FMT_BGRX_5551BGRX5551.
NATIVEBUFFER_PIXEL_FMT_BGRA_5551BGRA5551.
NATIVEBUFFER_PIXEL_FMT_BGRX_8888BGRX8888.
NATIVEBUFFER_PIXEL_FMT_BGRA_8888BGRA8888.
NATIVEBUFFER_PIXEL_FMT_BUTTInvalid format.

Since

10

OH_NativeBuffer_Usage

enum OH_NativeBuffer_Usage

Description

Enumerates the OH_NativeBuffer usages.

@SysCap SystemCapability.Graphic.Graphic2D.NativeBuffer

ValueDescription
NATIVEBUFFER_USAGE_CPU_READRead by the CPU.
NATIVEBUFFER_USAGE_CPU_WRITEWrite by the CPU.
NATIVEBUFFER_USAGE_MEM_DMADirect memory access to the buffer.

Since

10

Function Description

OH_NativeBuffer_Alloc()

OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config)

Description

Creates an OH_NativeBuffer instance based on an OH_NativeBuffer_Config struct. A new OH_NativeBuffer instance is created each time this function is called.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
configPointer to an OH_NativeBuffer_Config instance.

Returns

Returns the pointer to the OH_NativeBuffer instance created if the operation is successful; returns NULL otherwise.

OH_NativeBuffer_GetConfig()

void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config * config )

Description

Obtains the attributes of an OH_NativeBuffer instance.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
configPointer to an OH_NativeBuffer_Config instance, which is used to receive the attributes of OH_NativeBuffer.

OH_NativeBuffer_GetSeqNum()

uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer)

Description

Obtains the sequence number of an OH_NativeBuffer instance.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns the unique sequence number of the OH_NativeBuffer instance.

OH_NativeBuffer_Map()

int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr )

Description

Maps the ION memory corresponding to an OH_NativeBuffer instance to the process address space.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
virAddrDouble pointer to the address of the virtual memory.

Returns

Returns 0 if the operation is successful.

OH_NativeBuffer_Reference()

int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer)

Description

Increases the reference count of an OH_NativeBuffer instance by 1.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful.

OH_NativeBuffer_Unmap()

int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer)

Description

Unmaps the ION memory corresponding to an OH_NativeBuffer instance from the process address space.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful.

OH_NativeBuffer_Unreference()

int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer * buffer)

Description

Decreases the reference count of an OH_NativeBuffer instance by 1 and, when the reference count reaches 0, destroys the instance.

@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Native APIs

harmony 鸿蒙AVCapability

harmony 鸿蒙AVDemuxer

harmony 鸿蒙AVMuxer

harmony 鸿蒙AVScreenCapture

harmony 鸿蒙AVSource

harmony 鸿蒙AudioDecoder

harmony 鸿蒙AudioEncoder

harmony 鸿蒙CodecBase

harmony 鸿蒙Core

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/e2d9146fafc84d81b57c8f7e82e157a3