diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn
index fa8656ce602ccb00e10ab6b31e2f470ad1b93fa6..068299ea5f0ffbc0ce0e94077d357cbb4054dc2e 100644
--- a/graphic/graphic_2d/native_drawing/BUILD.gn
+++ b/graphic/graphic_2d/native_drawing/BUILD.gn
@@ -39,6 +39,7 @@ ohos_ndk_headers("native_drawing_header") {
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pixel_map.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_point.h",
+ "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_record_cmd.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_rect.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_region.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_register_font.h",
@@ -96,5 +97,6 @@ ohos_ndk_library("libnative_drawing_ndk") {
"native_drawing/drawing_text_typography.h",
"native_drawing/drawing_typeface.h",
"native_drawing/drawing_types.h",
+ "native_drawing/drawing_record_cmd.h",
]
}
diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h
index 4d1e8a0faf85206dfd434b47cfa6207628b4f5fd..aee44f4166adcd5d3abed52bf3d23312586b74e5 100644
--- a/graphic/graphic_2d/native_drawing/drawing_canvas.h
+++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h
@@ -828,6 +828,21 @@ OH_Drawing_ErrorCode OH_Drawing_CanvasIsClipEmpty(OH_Drawing_Canvas* canvas, boo
*/
OH_Drawing_ErrorCode OH_Drawing_CanvasGetImageInfo(OH_Drawing_Canvas* canvas, OH_Drawing_Image_Info* imageInfo);
+/**
+ * @brief Replay drawing commands.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param OH_Drawing_RecordCmd Indicates the pointer to an OH_Drawing_RecordCmd object.
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object, can be nullptr.
+ * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object, can be nullptr.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or imageInfo is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_Drawing_CanvasDrawRecordCmd(OH_Drawing_Canvas*, const OH_Drawing_RecordCmd*);
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_record_cmd.h b/graphic/graphic_2d/native_drawing/drawing_record_cmd.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b275ffc84d85dcf727623e3c39cad7d1e54ccd1
--- /dev/null
+++ b/graphic/graphic_2d/native_drawing/drawing_record_cmd.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef C_INCLUDE_DRAWING_RECORD_CMD_H
+#define C_INCLUDE_DRAWING_RECORD_CMD_H
+
+/**
+ * @addtogroup Drawing
+ * @{
+ *
+ * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ *
+ * @since 13
+ * @version 1.0
+ */
+
+/**
+ * @file drawing_record_cmd.h
+ *
+ * @brief Declares functions related to the RecordCmd object in the drawing module.
+ *
+ * @library libnative_drawing.so
+ * @since 13
+ * @version 1.0
+ */
+
+#include "drawing_types.h"
+#include "drawing_error_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates an OH_Drawing_RecordCmdUtils object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_RecordCmdUtils** Indicates the pointer to an OH_Drawing_RecordCmdUtils object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or point is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsCreate(OH_Drawing_RecordCmdUtils**);
+
+/**
+ * @brief Destroy an OH_Drawing_RecordCmdUtils object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_RecordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or point is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsDestroy(OH_Drawing_RecordCmdUtils*);
+
+/**
+ * @brief Returns the canvas that records the drawing commands.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_RecordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object.
+ * @param width Width of rectangular object.
+ * @param height Height of rectangular object.
+ * @param OH_Drawing_Canvas** Indicates the pointer to an OH_Drawing_Canvas object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or point is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+ OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsBeginRecording(OH_Drawing_RecordCmdUtils*,
+ int32_t width, int32_t height, OH_Drawing_Canvas**);
+
+/**
+ * @brief Finish the recording process of the drawing recorder and obtain the recorded drawing object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_RecordCmdUtils Indicates the pointer to an OH_Drawing_RecordCmdUtils object.
+ * @param OH_Drawing_RecordCmd** Indicates the pointer to an OH_Drawing_RecordCmd object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or point is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_RecordCmdUtilsFinishingRecording(OH_Drawing_RecordCmdUtils*, OH_Drawing_RecordCmd**);
+
+/**
+ * @brief Destroy an OH_Drawing_RecordCmd object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_RecordCmd Indicates the pointer to an OH_Drawing_RecordCmd object.
+ * @return Returns the error code.
+ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
+ * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if canvas or point is nullptr.
+ * @since 13
+ * @version 1.0
+ */
+OH_Drawing_ErrorCode OH_Drawing_RecordCmdDestroy(OH_Drawing_RecordCmd*);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+#endif
\ No newline at end of file
diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h
index edcc71cb8345836bc9647825ebc47b6d0ff63173..8c4488568a2bb25a6101cf276eb949332c752485 100644
--- a/graphic/graphic_2d/native_drawing/drawing_types.h
+++ b/graphic/graphic_2d/native_drawing/drawing_types.h
@@ -502,6 +502,21 @@ typedef struct OH_Drawing_FontMgr OH_Drawing_FontMgr;
*/
typedef struct OH_Drawing_FontStyleSet OH_Drawing_FontStyleSet;
+/**
+ * @brief Define OH_Drawing_RecordCmdUtils, which is used to replay drawing commands.
+ *
+ * @since 13
+ * @version 1.0
+ */
+typedef struct OH_Drawing_RecordCmdUtils OH_Drawing_RecordCmdUtils;
+
+/**
+ * @brief Define OH_Drawing_RecordCmd, which is used to replay drawing commands.
+ *
+ * @since 13
+ * @version 1.0
+ */
+typedef struct OH_Drawing_RecordCmd OH_Drawing_RecordCmd;
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
index 37535bc2b3cc673a3dacd154c9366bd9cd5ed9c0..777c35639097a2c65f7f62bfb958ec8b56da2146 100644
--- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
+++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
@@ -1453,5 +1453,29 @@
{
"first_introduced": "12",
"name":"OH_Drawing_SetTextShadow"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_Drawing_CanvasDrawRecordCmd"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_RecordCmdUtilsCreate"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_RecordCmdUtilsDestroy"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_RecordCmdUtilsBeginRecording"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_RecordCmdUtilsFinishingRecording"
+ },
+ {
+ "first_introduced": "13",
+ "name":"OH_Drawing_RecordCmdDestroy"
}
]
\ No newline at end of file