diff --git a/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json b/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json index f9328400bf323435f6dacffdf1239434a0bb49b0..9d4d2d2e0e8d219ae7a407eb55aeb4709f5d3966 100644 --- a/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json +++ b/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json @@ -6,5 +6,7 @@ { "name": "OH_NativeBuffer_Map" }, { "name": "OH_NativeBuffer_Unmap" }, { "name": "OH_NativeBuffer_GetSeqNum" }, - { "name": "OH_NativeBuffer_SetColorSpace" } + { "name": "OH_NativeBuffer_SetColorSpace" }, + { "name": "OH_NativeBuffer_MapPlanes" }, + { "name": "OH_NativeBuffer_FromNativeWindowBuffer" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_buffer/native_buffer.h b/graphic/graphic_2d/native_buffer/native_buffer.h index 1acf363f9c74763d736dafdd7675048737ceeda1..7c15af5f0bc4aef26b13aa0ba14cb944ca23a02b 100644 --- a/graphic/graphic_2d/native_buffer/native_buffer.h +++ b/graphic/graphic_2d/native_buffer/native_buffer.h @@ -38,6 +38,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -311,6 +312,31 @@ typedef struct { int32_t stride; ///< the stride of memory } OH_NativeBuffer_Config; +/** + * @brief Holds info for a single image plane. \n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @since 12 + * @version 1.0 + */ +typedef struct { + uint64_t offset; ///< Offset in bytes of plane. + uint32_t rowStride; ///< Distance in bytes from the first value of one row of the image to the first value of the next row. + uint32_t columnStride; ///< Distance in bytes from the first value of one column of the image to the first value of the next column. +} OH_NativeBuffer_Plane; + +/** + * @brief Holds all image planes. \n + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @since 12 + * @version 1.0 + */ +typedef struct { + uint32_t planeCount; ///< Number of distinct planes. + OH_NativeBuffer_Plane planes[4]; ///< Array of image planes. +} OH_NativeBuffer_Planes; + /** * @brief Alloc a OH_NativeBuffer that matches the passed BufferRequestConfig. \n * A new OH_NativeBuffer instance is created each time this function is called. @@ -405,6 +431,31 @@ uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer); * @version 1.0 */ int32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace); + +/** + * @brief Provide direct cpu access to the potentially multi-plannar OH_NativeBuffer in the process's address space. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @param buffer Indicates the pointer to a OH_NativeBuffer instance. + * @param virAddr Indicates the address of the OH_NativeBuffer in virtual memory. + * @param outPlanes Indicates all image planes that contain the pixel data. + * @return Returns an error code, 0 is sucess, otherwise, failed. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes); + +/** + * @brief Converts an OHNativeWindowBuffer instance to an OH_NativeBuffer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @param nativeWindowBuffer Indicates the pointer to a OHNativeWindowBuffer instance. + * @param buffer Indicates the pointer to a OH_NativeBuffer pointer. + * @return Returns an error code, 0 is sucess, otherwise, failed. + * @since 12 + * @version 1.0 + */ +int32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer); #ifdef __cplusplus } #endif