From 2c5486b91c55afab2521e6273a2a68bec3295062 Mon Sep 17 00:00:00 2001 From: m00472246 Date: Mon, 11 Mar 2024 20:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96offset=E7=9A=84sdk=20Signed-o?= =?UTF-8?q?ff-by:=20m00472246=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: m00472246 --- .../native_buffer/libnative_buffer.ndk.json | 4 +- .../graphic_2d/native_buffer/native_buffer.h | 51 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json b/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json index f9328400b..9d4d2d2e0 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 1acf363f9..7c15af5f0 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 -- Gitee