harmony 鸿蒙native_buffer.h

  • 2025-06-12
  • 浏览 (6)

native_buffer.h

Overview

The native_buffer.h file declares the functions for obtaining and using NativeBuffer.

File to include: <native_buffer/native_buffer.h>

Library: libnative_buffer.so

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Related module: OH_NativeBuffer

Summary

Structs

Name Description
struct OH_NativeBuffer_Config Describes the OH_NativeBuffer property configuration, which is used when you apply for a new OH_NativeBuffer instance or query the properties of an existing instance.
struct OH_NativeBuffer_Plane Describes the plane information of an image.
struct OH_NativeBuffer_Planes Describes the plane information of images in an OH_NativeBuffer instance.

Types

Name Description
typedef struct OH_NativeBuffer OH_NativeBuffer Provides the declaration of an OH_NativeBuffer struct.
typedef enum OH_NativeBuffer_Usage OH_NativeBuffer_Usage Defines an enum for the OH_NativeBuffer usages.
typedef enum OH_NativeBuffer_Format OH_NativeBuffer_Format Defines an enum for the OH_NativeBuffer formats.
typedef enum OH_NativeBuffer_TransformType OH_NativeBuffer_TransformType Defines an enum for the transform types of an OH_NativeBuffer instance.
typedef enum OH_NativeBuffer_ColorGamut OH_NativeBuffer_ColorGamut Defines an enum for the color gamuts of an OH_NativeBuffer instance.
typedef enum OHNativeErrorCode OHNativeErrorCode Defines an enum for the error codes.
typedef struct OH_NativeBuffer_Config OH_NativeBuffer_Config Defines the OH_NativeBuffer property configuration, which is used when you apply for a new OH_NativeBuffer instance or query the properties of an existing instance.
typedef struct OH_NativeBuffer_Plane OH_NativeBuffer_Plane Defines a struct for the plane information of an image.
typedef struct OH_NativeBuffer_Planes OH_NativeBuffer_Planes Defines a struct for the plane information of images in an OH_NativeBuffer instance.

Enums

Name Description
OH_NativeBuffer_Usage {
NATIVEBUFFER_USAGE_CPU_READ = (1ULL << 0), NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL << 1), NATIVEBUFFER_USAGE_MEM_DMA = (1ULL << 3), NATIVEBUFFER_USAGE_HW_RENDER = (1ULL << 8),
NATIVEBUFFER_USAGE_HW_TEXTURE = (1ULL << 9), NATIVEBUFFER_USAGE_CPU_READ_OFTEN = (1ULL << 16), NATIVEBUFFER_USAGE_ALIGNMENT_512 = (1ULL << 18)
}
Enumerates the OH_NativeBuffer usages.
OH_NativeBuffer_Format {
NATIVEBUFFER_PIXEL_FMT_CLUT8 = 0, NATIVEBUFFER_PIXEL_FMT_CLUT1, NATIVEBUFFER_PIXEL_FMT_CLUT4, 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_YUV_422_I, NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP, NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP,
NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP, NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP, NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P, NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P,
NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P, NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P, NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG, NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG,
NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG, NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG, NATIVEBUFFER_PIXEL_FMT_RGBA_1010102, NATIVEBUFFER_PIXEL_FMT_YCBCR_P010,
NATIVEBUFFER_PIXEL_FMT_YCRCB_P010, NATIVEBUFFER_PIXEL_FMT_RAW10, NATIVEBUFFER_PIXEL_FMT_BLOB, NATIVEBUFFER_PIXEL_FMT_RGBA16_FLOAT,
NATIVEBUFFER_PIXEL_FMT_VENDER_MASK = 0X7FFF0000, NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF
}
Enumerates the OH_NativeBuffer formats.
OH_NativeBuffer_TransformType {
NATIVEBUFFER_ROTATE_NONE = 0, NATIVEBUFFER_ROTATE_90, NATIVEBUFFER_ROTATE_180, NATIVEBUFFER_ROTATE_270,
NATIVEBUFFER_FLIP_H, NATIVEBUFFER_FLIP_V, NATIVEBUFFER_FLIP_H_ROT90, NATIVEBUFFER_FLIP_V_ROT90,
NATIVEBUFFER_FLIP_H_ROT180, NATIVEBUFFER_FLIP_V_ROT180, NATIVEBUFFER_FLIP_H_ROT270, NATIVEBUFFER_FLIP_V_ROT270
}
Enumerates the transform types of an OH_NativeBuffer instance.
OH_NativeBuffer_ColorGamut {
NATIVEBUFFER_COLOR_GAMUT_NATIVE = 0, NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 = 1, NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 = 2, NATIVEBUFFER_COLOR_GAMUT_DCI_P3 = 3,
NATIVEBUFFER_COLOR_GAMUT_SRGB = 4, NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB = 5, NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 = 6, NATIVEBUFFER_COLOR_GAMUT_BT2020 = 7,
NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ = 8, NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG = 9, NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 = 10
}
Enumerates the color gamuts of an OH_NativeBuffer instance.
OHNativeErrorCode {
NATIVE_ERROR_OK = 0, NATIVE_ERROR_MEM_OPERATION_ERROR = 30001000, NATIVE_ERROR_INVALID_ARGUMENTS = 40001000, NATIVE_ERROR_NO_PERMISSION = 40301000,
NATIVE_ERROR_NO_BUFFER = 40601000, NATIVE_ERROR_NO_CONSUMER = 41202000, NATIVE_ERROR_NOT_INIT = 41203000, NATIVE_ERROR_CONSUMER_CONNECTED = 41206000,
NATIVE_ERROR_BUFFER_STATE_INVALID = 41207000, NATIVE_ERROR_BUFFER_IN_CACHE = 41208000, NATIVE_ERROR_BUFFER_QUEUE_FULL = 41209000, NATIVE_ERROR_BUFFER_NOT_IN_CACHE = 41210000,
NATIVE_ERROR_CONSUMER_DISCONNECTED = 41211000, NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED = 41212000, NATIVE_ERROR_UNSUPPORTED = 50102000, NATIVE_ERROR_UNKNOWN = 50002000,
NATIVE_ERROR_HDI_ERROR = 50007000, NATIVE_ERROR_BINDER_ERROR = 50401000, NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, NATIVE_ERROR_EGL_API_FAILED = 60002000
}
Enumerates the error codes.

Functions

Name Description
OH_NativeBuffer * 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.
This function must be used in pair with OH_NativeBuffer_Unreference. Otherwise, memory leak occurs.
This function is not thread-safe.
int32_t OH_NativeBuffer_Reference (OH_NativeBuffer *buffer) Increases the reference count of an OH_NativeBuffer instance by 1.
This function must be used in pair with OH_NativeBuffer_Unreference. Otherwise, memory leak occurs.
This function is not thread-safe.
int32_t 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.
This function is not thread-safe.
void OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config *config) Obtains the properties of an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_Map (OH_NativeBuffer *buffer, void **virAddr) Maps the ION memory allocated to an OH_NativeBuffer instance to the process address space.
This function must be used in pair with OH_NativeBuffer_Unmap.
This function is not thread-safe.
int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer) Unmaps the ION memory allocated to an OH_NativeBuffer instance from the process address space.
This function is not thread-safe.
uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer) Obtains the sequence number of an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_SetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace) Sets the color space for an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_MapPlanes (OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes) Maps the multi-channel ION memory corresponding to an OH_NativeBuffer instance to the process address space.
This function is not thread-safe.
int32_t OH_NativeBuffer_FromNativeWindowBuffer (OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer) Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_GetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace) Obtains the color space of an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_SetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t *metaData) Sets a metadata value for an OH_NativeBuffer instance.
This function is not thread-safe.
int32_t OH_NativeBuffer_GetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData) Obtains the metadata value of an OH_NativeBuffer instance.
This function is not thread-safe.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 2D

harmony 鸿蒙BufferHandle

harmony 鸿蒙ColorSpacePrimaries

harmony 鸿蒙DisplaySoloist_ExpectedRateRange

harmony 鸿蒙_drawing

harmony 鸿蒙NativeColorSpaceManager

harmony 鸿蒙NativeDisplaySoloist

harmony 鸿蒙NativeVsync

harmony 鸿蒙NativeWindow

harmony 鸿蒙OH_Drawing_BitmapFormat

0  赞