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 4c8f1971ecd148a86e2e9bdd79db2c265497b4b4..948e6759d62e3862c857b402b8b1a0c0ec2382e7 100644
--- a/graphic/graphic_2d/native_buffer/native_buffer.h
+++ b/graphic/graphic_2d/native_buffer/native_buffer.h
@@ -67,6 +67,9 @@ enum OH_NativeBuffer_Usage {
* @version 1.0
*/
enum OH_NativeBuffer_Format {
+ NATIVEBUFFER_PIXEL_FMT_CLUT8 = 0, /// < CLUT8 format */
+ NATIVEBUFFER_PIXEL_FMT_CLUT1, /// < CLUT1 format */
+ NATIVEBUFFER_PIXEL_FMT_CLUT4, /// < CLUT4 format */
NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3, /// < RGB565 format */
NATIVEBUFFER_PIXEL_FMT_RGBA_5658, /// < RGBA5658 format */
NATIVEBUFFER_PIXEL_FMT_RGBX_4444, /// < RGBX4444 format */
@@ -85,6 +88,21 @@ enum OH_NativeBuffer_Format {
NATIVEBUFFER_PIXEL_FMT_BGRA_5551, /// < BGRA5551 format */
NATIVEBUFFER_PIXEL_FMT_BGRX_8888, /// < BGRX8888 format */
NATIVEBUFFER_PIXEL_FMT_BGRA_8888, /// < BGRA8888 format */
+ NATIVEBUFFER_PIXEL_FMT_YUV_422_T, /// < YUV422 interleaved format */
+ NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP, /// < YCBCR422 semi-plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCRCR_422_SP, /// < YCRCR422 semi-plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP, /// < YCBCR420 semi-plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCRCR_420_SP, /// < YCRCR420 semi-plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P, /// < YCBCR422 plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCRCR_422_P, /// < YCRCR422 plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P, /// < YCBCR420 plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YCRCR_420_P, /// < YCRCR420 plannar format */
+ NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG, /// < YUYV422 packed format */
+ NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG, /// < UYVY422 packed format */
+ NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG, /// < YVYU422 packed format */
+ NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG, /// < VYUY422 packed format */
+ NATIVEBUFFER_PIXEL_FMT_RGBA_1010102, /// < RGBA_1010102 packed format */
+ NATIVEBUFFER_PIXEL_FMT_VENDER_MASK = 0X7FFF0000, /// < vender mask format */
NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF /// < Invalid pixel format */
};
@@ -162,6 +180,49 @@ enum OH_NativeBuffer_ColorSpace {
OH_COLORSPACE_DISPLAY_BT2020_PQ,
};
+/**
+ * @brief Indicates the transform type of a native buffer.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
+ * @since 12
+ * @version 1.0
+ */
+enum OH_NativeBuffer_TransformType {
+ NATIVEBUFFER_ROTATE_NONE = 0, /**< No rotation */
+ NATIVEBUFFER_ROTATE_90, /**< Rotation by 90 degrees */
+ NATIVEBUFFER_ROTATE_180, /**< Rotation by 180 degrees */
+ NATIVEBUFFER_ROTATE_270, /**< Rotation by 270 degrees */
+ NATIVEBUFFER_FLIP_H, /**< Flip horizontally */
+ NATIVEBUFFER_FLIP_V, /**< Flip vertically */
+ NATIVEBUFFER_FLIP_H_ROT90, /**< Flip horizontally and rotate 90 degrees */
+ NATIVEBUFFER_FLIP_V_ROT90, /**< Flip vertically and rotate 90 degrees */
+ NATIVEBUFFER_FLIP_H_ROT180, /**< Flip horizontally and rotate 180 degrees */
+ NATIVEBUFFER_FLIP_V_ROT180, /**< Flip vertically and rotate 180 degrees */
+ NATIVEBUFFER_FLIP_H_ROT270, /**< Flip horizontally and rotate 270 degrees */
+ NATIVEBUFFER_FLIP_V_ROT270, /**< Flip vertically and rotate 270 degrees */
+};
+
+/**
+ * @brief Indicates the color gamut of a native buffer.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer
+ * @since 12
+ * @version 1.0
+ */
+enum OH_NativeBuffer_ColorGamut {
+ NATIVEBUFFER_COLOR_GAMUT_NATIVE = 0, /**< Native or default */
+ NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 = 1, /**< Standard BT601 */
+ NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 = 2, /**< Standard BT709 */
+ NATIVEBUFFER_COLOR_GAMUT_DCI_P3 = 3, /**< DCI P3 */
+ NATIVEBUFFER_COLOR_GAMUT_SRGB = 4, /**< SRGB */
+ NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB = 5, /**< Adobe RGB */
+ NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 = 6, /**< Display P3 */
+ NATIVEBUFFER_COLOR_GAMUT_BT2020 = 7, /**< BT2020 */
+ NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ = 8, /**< BT2100 PQ */
+ NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG = 9, /**< BT2100 HLG */
+ NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 = 10, /**< Display BT2020*/
+};
+
/**
* @brief OH_NativeBuffer config. \n
* Used to allocating new OH_NativeBuffer andquery parameters if existing ones.
@@ -178,6 +239,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.
@@ -272,6 +358,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
diff --git a/graphic/graphic_2d/native_window/external_window.h b/graphic/graphic_2d/native_window/external_window.h
index 69c933c99ff13602da37c580d1b653766600b49c..15e077c3345594068e1def9062b4b65786581c81 100644
--- a/graphic/graphic_2d/native_window/external_window.h
+++ b/graphic/graphic_2d/native_window/external_window.h
@@ -193,6 +193,13 @@ enum NativeWindowOperation {
* [in] uint64_t uiTimestamp.
*/
SET_UI_TIMESTAMP,
+ /**
+ * get native window bufferqueue size,
+ * variable parameter in function is
+ * [out] int32_t *size.
+ * @since 12
+ */
+ GET_BUFFERQUEUE_SIZE,
};
/**
@@ -496,6 +503,54 @@ int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint3
*/
int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
+/**
+ * @brief Attach a buffer to an OHNativeWindow instance.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ * @param window Indicates the pointer to an OHNativeWindow instance.
+ * @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
+ * @return Returns an error code, 0 is success, otherwise, failed.
+ * @since 12
+ * @version 1.0
+ */
+int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
+
+/**
+ * @brief Detach a buffer from an OHNativeWindow instance.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ * @param window Indicates the pointer to an OHNativeWindow instance.
+ * @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
+ * @return Returns an error code, 0 is success, otherwise, failed.
+ * @since 12
+ * @version 1.0
+ */
+int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
+
+/**
+ * @brief Get surfaceId from native window.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ * @param window Indicates the pointer to an OHNativeWindow instance.
+ * @param surfaceId Indicates the pointer to a surfaceId.
+ * @return Returns an error code, 0 is success, otherwise, failed.
+ * @since 12
+ * @version 1.0
+ */
+int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
+
+/**
+ * @brief Creates an OHNativeWindow instance.\n
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
+ * @param surfaceId Indicates the surfaceId to a surface.
+ * @param window indicates the pointer to an OHNativeWindow instance.
+ * @return Returns an error code, 0 is Success, otherwise, failed.
+ * @since 12
+ * @version 1.0
+ */
+int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
+
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_window/libnative_window.ndk.json b/graphic/graphic_2d/native_window/libnative_window.ndk.json
index 12184c91d51dba75a7b1187f51e38fc13a7bcc98..f4bd39002037170b4fe7efea4a3c76c4bba2c396 100644
--- a/graphic/graphic_2d/native_window/libnative_window.ndk.json
+++ b/graphic/graphic_2d/native_window/libnative_window.ndk.json
@@ -16,5 +16,9 @@
{ "name": "OH_NativeWindow_NativeWindowSetScalingMode" },
{ "name": "OH_NativeWindow_NativeWindowSetMetaData" },
{ "name": "OH_NativeWindow_NativeWindowSetMetaDataSet" },
- { "name": "OH_NativeWindow_NativeWindowSetTunnelHandle" }
+ { "name": "OH_NativeWindow_NativeWindowSetTunnelHandle" },
+ { "name": "OH_NativeWindow_NativeWindowAttachBuffer" },
+ { "name": "OH_NativeWindow_NativeWindowDetachBuffer" },
+ { "name": "OH_NativeWindow_GetSurfaceId"},
+ { "name": "OH_NativeWindow_CreateNativeWindowFromSurfaceId"}
]
\ No newline at end of file