harmony 鸿蒙OH_NativeBuffer

2025-06-12 浏览 (1)

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 properties.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Summary

Files

NameDescription
buffer_common.hDeclares the common types used in the NativeBuffer module.
Since API version 12, certain type definitions have been relocated from native_buffer.h to this header file for a more cohesive presentation. These types were available prior to API version 12 and can be used seamlessly across all versions.
native_buffer.hDeclares the functions for obtaining and using NativeBuffer.

Structs

NameDescription
struct OH_NativeBuffer_ConfigDescribes 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_PlaneDescribes the plane information of an image.
struct OH_NativeBuffer_PlanesDescribes the plane information of images in an OH_NativeBuffer instance.
struct OH_NativeBuffer_ColorXYDescribes the X and Y coordinates of the primary color.
struct OH_NativeBuffer_Smpte2086Describes the SMPTE ST 2086 static metadata.
struct OH_NativeBuffer_Cta861Describes the CTA-861.3 static metadata.
struct OH_NativeBuffer_StaticMetadataDescribes the HDR static metadata.

Types

NameDescription
typedef struct OH_NativeBuffer OH_NativeBufferProvides the declaration of an OH_NativeBuffer struct.
typedef enum OH_NativeBuffer_Usage OH_NativeBuffer_UsageDefines an enum for the OH_NativeBuffer usages.
typedef enum OH_NativeBuffer_Format OH_NativeBuffer_FormatDefines an enum for the OH_NativeBuffer formats.
typedef enum OH_NativeBuffer_ColorSpace OH_NativeBuffer_ColorSpaceDefines an enum for the color spaces of an OH_NativeBuffer instance.
typedef enum OH_NativeBuffer_TransformType OH_NativeBuffer_TransformTypeDefines an enum for the transform types of an OH_NativeBuffer instance.
typedef enum OH_NativeBuffer_ColorGamut OH_NativeBuffer_ColorGamutDefines an enum for the color gamuts of an OH_NativeBuffer instance.
typedef enum OHNativeErrorCode OHNativeErrorCodeDefines an enum for the error codes.
typedef struct OH_NativeBuffer_Config OH_NativeBuffer_ConfigDefines 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_PlaneDefines a struct for the plane information of an image.
typedef struct OH_NativeBuffer_Planes OH_NativeBuffer_PlanesDefines a struct for the plane information of images in an OH_NativeBuffer instance.
typedef enum OH_NativeBuffer_MetadataType OH_NativeBuffer_MetadataTypeDefines an enum for the OH_NativeBuffer image standards.
typedef struct OH_NativeBuffer_ColorXY OH_NativeBuffer_ColorXYDefines a struct for the X and Y coordinates of the primary color.
typedef struct OH_NativeBuffer_Smpte2086 OH_NativeBuffer_Smpte2086Defines a struct for the SMPTE ST 2086 static metadata.
typedef struct OH_NativeBuffer_Cta861 OH_NativeBuffer_Cta861Defines a struct for the CTA-861.3 static metadata.
typedef struct OH_NativeBuffer_StaticMetadata OH_NativeBuffer_StaticMetadataDefines a struct for the HDR static metadata.
typedef enum OH_NativeBuffer_MetadataKey OH_NativeBuffer_MetadataKeyDefines an enum for the keys that specify the HDR metadata of an OH_NativeBuffer instance.

Enums

NameDescription
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_ColorSpace {
OH_COLORSPACE_NONE, OH_COLORSPACE_BT601_EBU_FULL, OH_COLORSPACE_BT601_SMPTE_C_FULL, OH_COLORSPACE_BT709_FULL,
OH_COLORSPACE_BT2020_HLG_FULL, OH_COLORSPACE_BT2020_PQ_FULL, OH_COLORSPACE_BT601_EBU_LIMIT, OH_COLORSPACE_BT601_SMPTE_C_LIMIT,
OH_COLORSPACE_BT709_LIMIT, OH_COLORSPACE_BT2020_HLG_LIMIT, OH_COLORSPACE_BT2020_PQ_LIMIT, OH_COLORSPACE_SRGB_FULL,
OH_COLORSPACE_P3_FULL, OH_COLORSPACE_P3_HLG_FULL, OH_COLORSPACE_P3_PQ_FULL, OH_COLORSPACE_ADOBERGB_FULL,
OH_COLORSPACE_SRGB_LIMIT, OH_COLORSPACE_P3_LIMIT, OH_COLORSPACE_P3_HLG_LIMIT, OH_COLORSPACE_P3_PQ_LIMIT,
OH_COLORSPACE_ADOBERGB_LIMIT, OH_COLORSPACE_LINEAR_SRGB, OH_COLORSPACE_LINEAR_BT709, OH_COLORSPACE_LINEAR_P3,
OH_COLORSPACE_LINEAR_BT2020, OH_COLORSPACE_DISPLAY_SRGB, OH_COLORSPACE_DISPLAY_P3_SRGB, OH_COLORSPACE_DISPLAY_P3_HLG,
OH_COLORSPACE_DISPLAY_P3_PQ, OH_COLORSPACE_DISPLAY_BT2020_SRGB, OH_COLORSPACE_DISPLAY_BT2020_HLG, OH_COLORSPACE_DISPLAY_BT2020_PQ
}
Enumerates the color spaces of an OH_NativeBuffer instance.
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.
OH_NativeBuffer_MetadataType { OH_VIDEO_HDR_HLG, OH_VIDEO_HDR_HDR10, OH_VIDEO_HDR_VIVID,OH_VIDEO_NONE = -1 }Enumerates the OH_NativeBuffer image standards.
OH_NativeBuffer_MetadataKey { OH_HDR_METADATA_TYPE, OH_HDR_STATIC_METADATA, OH_HDR_DYNAMIC_METADATA }Enumerates the keys that specify the HDR metadata of an OH_NativeBuffer instance.

Functions

NameDescription
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.
int32_t OH_NativeBuffer_Reference (OH_NativeBuffer *buffer)Increases the reference count of an OH_NativeBuffer instance by 1.
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.
void OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config *config)Obtains the properties of an OH_NativeBuffer instance.
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.
int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer)Unmaps the ION memory allocated to an OH_NativeBuffer instance from the process address space.
uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer)Obtains the sequence number of an OH_NativeBuffer instance.
int32_t OH_NativeBuffer_SetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace)Sets the color space for an OH_NativeBuffer instance.
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.
int32_t OH_NativeBuffer_FromNativeWindowBuffer (OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer)Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer instance.
int32_t OH_NativeBuffer_GetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace)Obtains the color space of an OH_NativeBuffer instance.
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.
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.

Type Description

OH_NativeBuffer

typedef struct OH_NativeBuffer OH_NativeBuffer

Description

Provides the declaration of an OH_NativeBuffer struct.

Since: 9

OH_NativeBuffer_ColorGamut

typedef enum OH_NativeBuffer_ColorGamut OH_NativeBuffer_ColorGamut

Description

Defines an enum for the color gamuts of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_ColorSpace

typedef enum OH_NativeBuffer_ColorSpace OH_NativeBuffer_ColorSpace

Description

Defines an enum for the color spaces of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 11

OH_NativeBuffer_ColorXY

typedef struct OH_NativeBuffer_ColorXY OH_NativeBuffer_ColorXY

Description

Defines a struct for the X and Y coordinates of the primary color.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Config

typedef struct OH_NativeBuffer_Config OH_NativeBuffer_Config

Description

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.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

OH_NativeBuffer_Cta861

typedef struct OH_NativeBuffer_Cta861 OH_NativeBuffer_Cta861

Description

Defines a struct for the CTA-861.3 static metadata.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Format

typedef enum OH_NativeBuffer_Format OH_NativeBuffer_Format

Description

Defines an enum for the OH_NativeBuffer formats.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 10

OH_NativeBuffer_MetadataKey

typedef enum OH_NativeBuffer_MetadataKey OH_NativeBuffer_MetadataKey

Description

Defines an enum for the keys that specify the HDR metadata of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_MetadataType

typedef enum OH_NativeBuffer_MetadataType OH_NativeBuffer_MetadataType

Description

Defines an enum for the OH_NativeBuffer image standards.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Plane

typedef struct OH_NativeBuffer_Plane OH_NativeBuffer_Plane

Description

Defines a struct for the plane information of an image.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Planes

typedef struct OH_NativeBuffer_Planes OH_NativeBuffer_Planes

Description

Defines a struct for the plane information of images in an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Smpte2086

typedef struct OH_NativeBuffer_Smpte2086 OH_NativeBuffer_Smpte2086

Description

Defines a struct for the SMPTE ST 2086 static metadata.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_StaticMetadata

typedef struct OH_NativeBuffer_StaticMetadata OH_NativeBuffer_StaticMetadata

Description

Defines a struct for the HDR static metadata.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_TransformType

typedef enum OH_NativeBuffer_TransformType OH_NativeBuffer_TransformType

Description

Defines an enum for the transform types of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

OH_NativeBuffer_Usage

typedef enum OH_NativeBuffer_Usage OH_NativeBuffer_Usage

Description

Defines an enum for the OH_NativeBuffer usages.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 10

OHNativeErrorCode

typedef enum OHNativeErrorCodeOHNativeErrorCode

Description

Defines an enum for the error codes.

Since: 12

Enum Description

OH_NativeBuffer_ColorGamut

enum OH_NativeBuffer_ColorGamut

Description

Enumerates the color gamuts of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

ValueDescription
NATIVEBUFFER_COLOR_GAMUT_NATIVEDefault gamut.
NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601Standard BT.601 color gamut.
NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709Standard BT.709 color gamut.
NATIVEBUFFER_COLOR_GAMUT_DCI_P3DCI P3 color gamut.
NATIVEBUFFER_COLOR_GAMUT_SRGBSRGB color gamut.
NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGBAdobe RGB color gamut.
NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3Display P3 color gamut.
NATIVEBUFFER_COLOR_GAMUT_BT2020BT.2020 color gamut.
NATIVEBUFFER_COLOR_GAMUT_BT2100_PQBT.2100 PQ color gamut.
NATIVEBUFFER_COLOR_GAMUT_BT2100_HLGBT.2100 HLG color gamut format
NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020Display BT.2020 color gamut.

OH_NativeBuffer_ColorSpace

enum OH_NativeBuffer_ColorSpace

Description

Enumerates the color spaces of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 11

ValueDescription
OH_COLORSPACE_NONENo color space is available.
OH_COLORSPACE_BT601_EBU_FULLThe color gamut is BT601_P, the transfer function is BT709, the conversion matrix is BT601_P, and the data range is RANGE_FULL.
OH_COLORSPACE_BT601_SMPTE_C_FULLThe color gamut is BT601_N, the transfer function is BT709, the conversion matrix is BT601_N, and the data range is RANGE_FULL.
OH_COLORSPACE_BT709_FULLThe color gamut is BT709, the transfer function is BT709, the conversion matrix is BT709, and the data range is RANGE_FULL.
OH_COLORSPACE_BT2020_HLG_FULLThe color gamut is BT2020, the transfer function is HLG, the conversion matrix is BT2020, and the data range is RANGE_FULL.
OH_COLORSPACE_BT2020_PQ_FULLThe color gamut is BT2020, the transfer function is PQ, the conversion matrix is BT2020, and the data range is RANGE_FULL.
OH_COLORSPACE_BT601_EBU_LIMITThe color gamut is BT601_P, the transfer function is BT709, the conversion matrix is BT601_P, and the data range is RANGE_LIMITED.
OH_COLORSPACE_BT601_SMPTE_C_LIMITThe color gamut is BT601_N, the transfer function is BT709, the conversion matrix is BT601_N, and the data range is RANGE_LIMITED.
OH_COLORSPACE_BT709_LIMITThe color gamut is BT709, the transfer function is BT709, the conversion matrix is BT709, and the data range is RANGE_LIMITED.
OH_COLORSPACE_BT2020_HLG_LIMITThe color gamut is BT2020, the transfer function is HLG, the conversion matrix is BT2020, and the data range is RANGE_LIMITED.
OH_COLORSPACE_BT2020_PQ_LIMITThe color gamut is BT2020, the transfer function is PQ, the conversion matrix is BT2020, and the data range is RANGE_LIMITED.
OH_COLORSPACE_SRGB_FULLThe color gamut is SRGB, the transfer function is SRGB, the conversion matrix is BT601_N, and the data range is RANGE_FULL.
OH_COLORSPACE_P3_FULLThe color gamut is P3_D65, the transfer function is SRGB, the conversion matrix is P3, and the data range is RANGE_FULL.
OH_COLORSPACE_P3_HLG_FULLThe color gamut is P3_D65, the transfer function is HLG, the conversion matrix is P3, and the data range is RANGE_FULL.
OH_COLORSPACE_P3_PQ_FULLThe color gamut is P3_D65, the transfer function is PQ, the conversion matrix is P3, and the data range is RANGE_FULL.
OH_COLORSPACE_ADOBERGB_FULLThe color gamut is ADOBERGB, the transfer function is ADOBERGB, the conversion matrix is ADOBERGB, and the data range is RANGE_FULL.
OH_COLORSPACE_SRGB_LIMITThe color gamut is SRGB, the transfer function is SRGB, the conversion matrix is BT601_N, and the data range is RANGE_LIMITED.
OH_COLORSPACE_P3_LIMITThe color gamut is P3_D65, the transfer function is SRGB, the conversion matrix is P3, and the data range is RANGE_LIMITED.
OH_COLORSPACE_P3_HLG_LIMITThe color gamut is P3_D65, the transfer function is HLG, the conversion matrix is P3, and the data range is RANGE_LIMITED.
OH_COLORSPACE_P3_PQ_LIMITThe color gamut is P3_D65, the transfer function is PQ, the conversion matrix is P3, and the data range is RANGE_LIMITED.
OH_COLORSPACE_ADOBERGB_LIMITThe color gamut is ADOBERGB, the transfer function is ADOBERGB, the conversion matrix is ADOBERGB, and the data range is RANGE_LIMITED.
OH_COLORSPACE_LINEAR_SRGBThe color gamut is SRGB, and the transfer function is LINEAR.
OH_COLORSPACE_LINEAR_BT709It is equivalent to OH_COLORSPACE_LINEAR_SRGB.
OH_COLORSPACE_LINEAR_P3The color gamut is P3_D65, and the transfer function is LINEAR.
OH_COLORSPACE_LINEAR_BT2020The color gamut is BT2020, and the transfer function is LINEAR.
OH_COLORSPACE_DISPLAY_SRGBIt is equivalent to OH_COLORSPACE_SRGB_FULL.
OH_COLORSPACE_DISPLAY_P3_SRGBIt is equivalent to OH_COLORSPACE_P3_FULL.
OH_COLORSPACE_DISPLAY_P3_HLGIt is equivalent to OH_COLORSPACE_P3_HLG_FULL.
OH_COLORSPACE_DISPLAY_P3_PQIt is equivalent to OH_COLORSPACE_P3_PQ_FULL.
OH_COLORSPACE_DISPLAY_BT2020_SRGBThe color gamut is BT2020, the transfer function is SRGB, the conversion matrix is BT2020, and the data range is RANGE_FULL.
OH_COLORSPACE_DISPLAY_BT2020_HLGIt is equivalent to OH_COLORSPACE_BT2020_HLG_FULL.
OH_COLORSPACE_DISPLAY_BT2020_PQIt is equivalent to OH_COLORSPACE_BT2020_PQ_FULL.

OH_NativeBuffer_Format

enum OH_NativeBuffer_Format

Description

Enumerates the OH_NativeBuffer formats.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 10

ValueDescription
NATIVEBUFFER_PIXEL_FMT_CLUT812+CLUT8.
NATIVEBUFFER_PIXEL_FMT_CLUT112+CLUT1.
NATIVEBUFFER_PIXEL_FMT_CLUT412+CLUT4.
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_YUV_422_I12+YUV422 interleaved.
NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP12+YCbCr422 semi-planar.
NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP12+YCrCb422 semi-planar.
NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP12+YCbCr420 semi-planar.
NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP12+YCrCb420 semi-planar.
NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P12+YCbCr422 planar.
NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P12+YCrCb422 planar.
NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P12+YCbCr420 planar.
NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P12+YCrCb420 planar.
NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG12+YUYV422 packed.
NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG12+UYVY422 packed.
NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG12+YVYU422 packed.
NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG12+VYUY422 packed.
NATIVEBUFFER_PIXEL_FMT_RGBA_101010212+RGBA_1010102 packed.
NATIVEBUFFER_PIXEL_FMT_YCBCR_P01012+YCBCR420 semi-planar 10-bit packed.
NATIVEBUFFER_PIXEL_FMT_YCRCB_P01012+YCRCB420 semi-planar 10-bit packed.
NATIVEBUFFER_PIXEL_FMT_RAW1012+Raw 10-bit packed.
NATIVEBUFFER_PIXEL_FMT_BLOB15+BLOB.
NATIVEBUFFER_PIXEL_FMT_RGBA16_FLOAT15+RGBA16 float.
NATIVEBUFFER_PIXEL_FMT_VENDER_MASK12+Vendor mask.
NATIVEBUFFER_PIXEL_FMT_BUTTInvalid format.

OH_NativeBuffer_MetadataKey

enum OH_NativeBuffer_MetadataKey

Description

Enumerates the keys that specify the HDR metadata of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

ValueDescription
OH_HDR_METADATA_TYPEMetadata type. For details about the available options, see OH_NativeBuffer_MetadataType. size indicates the size of OH_NativeBuffer_MetadataType.
OH_HDR_STATIC_METADATAStatic metadata. For details about the available options, see OH_NativeBuffer_StaticMetadata. size indicates the size of OH_NativeBuffer_StaticMetadata.
OH_HDR_DYNAMIC_METADATADynamic metadata. For details about the available options, see the SEI byte stream in the video stream. The value range of size is 1-3000.

OH_NativeBuffer_MetadataType

enum OH_NativeBuffer_MetadataType

Description

Enumerates the OH_NativeBuffer image standards.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

ValueDescription
OH_VIDEO_HDR_HLGVideo HLG.
OH_VIDEO_HDR_HDR10Video HDR10.
OH_VIDEO_HDR_VIVIDVideo HDR Vivid.
OH_VIDEO_NONE13+No metadata.

OH_NativeBuffer_TransformType

enum OH_NativeBuffer_TransformType

Description

Enumerates the transform types of an OH_NativeBuffer instance.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

ValueDescription
NATIVEBUFFER_ROTATE_NONENo rotation.
NATIVEBUFFER_ROTATE_90Rotates by 90 degrees.
NATIVEBUFFER_ROTATE_180Rotates by 180 degrees.
NATIVEBUFFER_ROTATE_270Rotates by 270 degrees.
NATIVEBUFFER_FLIP_HFlips horizontally.
NATIVEBUFFER_FLIP_VFlips vertically.
NATIVEBUFFER_FLIP_H_ROT90Flips horizontally and rotates by 90 degrees.
NATIVEBUFFER_FLIP_V_ROT90Flips vertically and rotates by 90 degrees.
NATIVEBUFFER_FLIP_H_ROT180Flips horizontally and rotates by 180 degrees.
NATIVEBUFFER_FLIP_V_ROT180Flips vertically and rotates by 180 degrees.
NATIVEBUFFER_FLIP_H_ROT270Flips horizontally and rotates by 270 degrees.
NATIVEBUFFER_FLIP_V_ROT270Flips vertically and rotates by 270 degrees.

OH_NativeBuffer_Usage

enum OH_NativeBuffer_Usage

Description

Enumerates the OH_NativeBuffer usages.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 10

ValueDescription
NATIVEBUFFER_USAGE_CPU_READCPU readable.
NATIVEBUFFER_USAGE_CPU_WRITECPU writable.
NATIVEBUFFER_USAGE_MEM_DMADirect memory access to the buffer.
NATIVEBUFFER_USAGE_HW_RENDER12+GPU writable.
NATIVEBUFFER_USAGE_HW_TEXTURE12+GPU readable.
NATIVEBUFFER_USAGE_CPU_READ_OFTEN12+Direct mapping of CPU.
NATIVEBUFFER_USAGE_ALIGNMENT_51212+512-byte alignment.

OHNativeErrorCode

enum OHNativeErrorCode

Description

Enumerates the error codes.

Since: 12

ValueDescription
NATIVE_ERROR_OKThe operation is successful.
NATIVE_ERROR_MEM_OPERATION_ERROR15+An error occurs during memory manipulation.
NATIVE_ERROR_INVALID_ARGUMENTSAn input parameter is invalid.
NATIVE_ERROR_NO_PERMISSIONYou do not have the permission to perform the operation.
NATIVE_ERROR_NO_BUFFERNo buffer is available.
NATIVE_ERROR_NO_CONSUMERThe consumer does not exist.
NATIVE_ERROR_NOT_INITNot initialized.
NATIVE_ERROR_CONSUMER_CONNECTEDThe consumer is connected.
NATIVE_ERROR_BUFFER_STATE_INVALIDThe buffer status does not meet the expectation.
NATIVE_ERROR_BUFFER_IN_CACHEThe buffer is already in the buffer queue.
NATIVE_ERROR_BUFFER_QUEUE_FULLThe queue is full.
NATIVE_ERROR_BUFFER_NOT_IN_CACHEThe buffer is not in the buffer queue.
NATIVE_ERROR_CONSUMER_DISCONNECTEDThe consumer is disconnected.
NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTEREDNo listener is registered on the consumer side.
NATIVE_ERROR_UNSUPPORTEDThe device or platform does not support the operation.
NATIVE_ERROR_UNKNOWNUnknown error. Check the log.
NATIVE_ERROR_HDI_ERRORFailed to call the HDI.
NATIVE_ERROR_BINDER_ERRORCross-process communication failed.
NATIVE_ERROR_EGL_STATE_UNKNOWNThe EGL environment is abnormal.
NATIVE_ERROR_EGL_API_FAILEDFailed to call the EGL APIs.

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.

This function must be used in pair with OH_NativeBuffer_Unreference. Otherwise, memory leak occurs.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

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_FromNativeWindowBuffer()

int32_t OH_NativeBuffer_FromNativeWindowBuffer (OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer )

Description

Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

Parameters

NameDescription
nativeWindowBufferPointer to an OHNativeWindowBuffer instance.
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_GetColorSpace()

int32_t OH_NativeBuffer_GetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace )

Description

Obtains the color space of an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
colorSpacePointer to the color space. For details about the available options, see OH_NativeBuffer_ColorSpace.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_GetConfig()

void OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config )

Description

Obtains the properties of an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Parameters

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

OH_NativeBuffer_GetMetadataValue()

int32_t OH_NativeBuffer_GetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData )

Description

Obtains the metadata value of an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
metadataKeyKey of the metadata. For details about the available options, see OH_NativeBuffer_MetadataKey.
sizePointer to the size of the uint8_t vector. For details about the available options, see OH_NativeBuffer_MetadataKey.
metaDataDouble pointer to the uint8_t vector.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_GetSeqNum()

uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer)

Description

Obtains the sequence number of an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

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 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.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

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; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_MapPlanes()

int32_t OH_NativeBuffer_MapPlanes (OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes )

Description

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

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
virAddrDouble pointer to the address of the virtual memory.
outPlanesPointer to the plane information of all images.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_Reference()

int32_t OH_NativeBuffer_Reference (OH_NativeBuffer *buffer)

Description

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.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_SetColorSpace()

int32_t OH_NativeBuffer_SetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace )

Description

Sets the color space for an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 11

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
colorSpaceColor space. For details about the available options, see OH_NativeBuffer_ColorSpace.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_SetMetadataValue()

int32_t OH_NativeBuffer_SetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t *metaData )

Description

Sets a metadata value for an OH_NativeBuffer instance.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 12

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.
metadataKeyKey of the metadata. For details about the available options, see OH_NativeBuffer_MetadataKey.
sizeSize of the uint8_t vector. For details about the available options, see OH_NativeBuffer_MetadataKey.
metaDataPointer to the uint8_t vector.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

OH_NativeBuffer_Unmap()

int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer)

Description

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

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

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.

This function is not thread-safe.

System capability: SystemCapability.Graphic.Graphic2D.NativeBuffer

Since: 9

Parameters

NameDescription
bufferPointer to an OH_NativeBuffer instance.

Returns

Returns 0 if the operation is successful; returns an error code defined in OHNativeErrorCode otherwise.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkGraphics 2D

harmony 鸿蒙BufferHandle

harmony 鸿蒙ColorSpacePrimaries

harmony 鸿蒙DisplaySoloist_ExpectedRateRange

harmony 鸿蒙_drawing

harmony 鸿蒙NativeColorSpaceManager

harmony 鸿蒙NativeDisplaySoloist

harmony 鸿蒙NativeVsync

harmony 鸿蒙NativeWindow

harmony 鸿蒙OH_Drawing_BitmapFormat

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