diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn
index 89df5755086698d1f8175411af6930b78bf9c126..b15bd745abd9c8ec8c2df6e641df991f7daaee45 100644
--- a/graphic/graphic_2d/native_drawing/BUILD.gn
+++ b/graphic/graphic_2d/native_drawing/BUILD.gn
@@ -27,6 +27,7 @@ ohos_ndk_headers("native_drawing_header") {
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_collection.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_mgr.h",
+ "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_gpu_context.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_image.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_mask_filter.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_matrix.h",
@@ -42,6 +43,7 @@ ohos_ndk_headers("native_drawing_header") {
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_round_rect.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_sampling_options.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_shader_effect.h",
+ "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_surface.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_blob.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_typography.h",
@@ -66,6 +68,7 @@ ohos_ndk_library("libnative_drawing_ndk") {
"native_drawing/drawing_font.h",
"native_drawing/drawing_font_collection.h",
"native_drawing/drawing_font_mgr.h",
+ "native_drawing/drawing_gpu_context.h",
"native_drawing/drawing_mask_filter.h",
"native_drawing/drawing_matrix.h",
"native_drawing/drawing_memory_stream.h",
@@ -81,6 +84,7 @@ ohos_ndk_library("libnative_drawing_ndk") {
"native_drawing/drawing_image.h",
"native_drawing/drawing_sampling_options.h",
"native_drawing/drawing_shader_effect.h",
+ "native_drawing/drawing_surface.h",
"native_drawing/drawing_text_blob.h",
"native_drawing/drawing_text_declaration.h",
"native_drawing/drawing_text_typography.h",
diff --git a/graphic/graphic_2d/native_drawing/drawing_gpu_context.h b/graphic/graphic_2d/native_drawing/drawing_gpu_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0f1d3cfeb8b4789d32b7eb3eed02bcc496afe32
--- /dev/null
+++ b/graphic/graphic_2d/native_drawing/drawing_gpu_context.h
@@ -0,0 +1,82 @@
+/*
+ * 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_GPU_CONTEXT_H
+#define C_INCLUDE_DRAWING_GPU_CONTEXT_H
+
+/**
+ * @addtogroup Drawing
+ * @{
+ *
+ * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ *
+ * @since 8
+ * @version 1.0
+ */
+
+/**
+ * @file drawing_gpu_context.h
+ *
+ * @brief Declares functions related to the OH_Drawing_GpuContext object in the drawing module.
+ *
+ * @since 12
+ * @version 1.0
+ */
+
+#include "drawing_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Defines the options about GPU context.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct {
+ /** If true this allows path mask textures to be cached */
+ bool allowPathMaskCaching;
+} OH_Drawing_GpuContextOptions;
+
+/**
+ * @brief Creates an OH_Drawing_GpuContext object, whose GPU backend context is GL.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_GpuContextOptions Indicates the GPU context options.
+ * @return Returns the pointer to the OH_Drawing_GpuContext object created.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_GpuContext* OH_Drawing_GpuContextCreateFromGL(OH_Drawing_GpuContextOptions);
+
+/**
+ * @brief Destroys an OH_Drawing_GpuContext object and reclaims the memory occupied by the object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_GpuContext Indicates the pointer to an OH_Drawing_GpuContext object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_GpuContextDestroy(OH_Drawing_GpuContext*);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+#endif
\ No newline at end of file
diff --git a/graphic/graphic_2d/native_drawing/drawing_surface.h b/graphic/graphic_2d/native_drawing/drawing_surface.h
new file mode 100644
index 0000000000000000000000000000000000000000..fd685a8e4a23f3341c62adc0ea938d97ddba84cb
--- /dev/null
+++ b/graphic/graphic_2d/native_drawing/drawing_surface.h
@@ -0,0 +1,86 @@
+/*
+ * 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_GPU_SURFACE_H
+#define C_INCLUDE_DRAWING_GPU_SURFACE_H
+
+/**
+ * @addtogroup Drawing
+ * @{
+ *
+ * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ *
+ * @since 8
+ * @version 1.0
+ */
+
+/**
+ * @file drawing_surface.h
+ *
+ * @brief Declares functions related to the OH_Drawing_Surface object in the drawing module.
+ *
+ * @since 12
+ * @version 1.0
+ */
+
+#include "drawing_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates an OH_Drawing_Surface object on GPU indicated by context.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_GpuContext Indicates the pointer to an OH_Drawing_GpuContext object.
+ * @param bool Indicates whether an allocation should count against a cache budget.
+ * @param OH_Drawing_Image_Info Indicates the image info.
+ * @return Returns the pointer to the OH_Drawing_Surface object created.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext(
+ OH_Drawing_GpuContext*, bool, OH_Drawing_Image_Info);
+
+/**
+ * @brief Gets the canvas that draws into surface.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Surface Indicates the pointer to an OH_Drawing_Surface object.
+ * @return Returns the pointer to the OH_Drawing_Canvas object. The returned pointer does not need to be managed
+ * by the caller.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface*);
+
+/**
+ * @brief Destroys an OH_Drawing_Surface object and reclaims the memory occupied by the object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Surface Indicates the pointer to an OH_Drawing_Surface object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_SurfaceDestroy(OH_Drawing_Surface*);
+
+#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 7cbb5fb9f5508c4a0e1c03ba6fd00e5cdf95e267..f6afcacf20f679bd22f29b001eb4e961d3500f71 100644
--- a/graphic/graphic_2d/native_drawing/drawing_types.h
+++ b/graphic/graphic_2d/native_drawing/drawing_types.h
@@ -261,6 +261,22 @@ typedef struct OH_Drawing_SamplingOptions OH_Drawing_SamplingOptions;
*/
typedef struct OH_Drawing_TextBlobBuilder OH_Drawing_TextBlobBuilder;
+/**
+ * @brief Defines a GPU context, which is used to describe the GPU backend context.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_GpuContext OH_Drawing_GpuContext;
+
+/**
+ * @brief Defines a surface, which is used to manage the pixels that a canvas draws into.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_Surface OH_Drawing_Surface;
+
/**
* @brief Enumerates storage formats of bitmap pixels.
*
diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
index 6b4b29cfdc4fe6662d93a44b8ac6b97903bc7f03..7d0f447949be6222f12716e22add4b607a7db846 100644
--- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
+++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
@@ -138,6 +138,14 @@
{ "name": "OH_Drawing_FontSetTypeface" },
{ "name": "OH_Drawing_FontGetMetrics" },
{ "name": "OH_Drawing_FontGetTypeface" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_GpuContextCreateFromGL"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_GpuContextDestroy"
+ },
{ "name": "OH_Drawing_MaskFilterCreateBlur" },
{ "name": "OH_Drawing_MaskFilterDestroy" },
{ "name": "OH_Drawing_MatrixCreate" },
@@ -388,6 +396,18 @@
"name": "OH_Drawing_ShaderEffectCreateImageShader"
},
{ "name": "OH_Drawing_ShaderEffectDestroy" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_SurfaceCreateFromGpuContext"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_SurfaceGetCanvas"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_SurfaceDestroy"
+ },
{ "name": "OH_Drawing_TextBlobCreateFromText" },
{ "name": "OH_Drawing_TextBlobCreateFromPosText" },
{ "name": "OH_Drawing_TextBlobCreateFromString" },