diff --git a/graphic/graphic_2d/native_drawing/drawing_gpu_context.h b/graphic/graphic_2d/native_drawing/drawing_gpu_context.h index 8d5df8ea9f63d7b1837cbeb21fd4940c7cc53e7e..1949a5e725f78c553096ebece81194d738b81f27 100644 --- a/graphic/graphic_2d/native_drawing/drawing_gpu_context.h +++ b/graphic/graphic_2d/native_drawing/drawing_gpu_context.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -68,6 +68,16 @@ typedef struct { */ OH_Drawing_GpuContext* OH_Drawing_GpuContextCreateFromGL(OH_Drawing_GpuContextOptions gpuContextOptions); +/** + * @brief Creates an OH_Drawing_GpuContext object, whose GPU backend context depends on device. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_GpuContext object created. + * @since 16 + * @version 1.0 + */ +OH_Drawing_GpuContext* OH_Drawing_GpuContextCreate(void); + /** * @brief Destroys an OH_Drawing_GpuContext object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_surface.h b/graphic/graphic_2d/native_drawing/drawing_surface.h index d8aa609ada5a7b61d1b87dd71a3a0e6fdccae207..67f951f74e6ec4ae8a0a1523af3bdcc427f33c10 100644 --- a/graphic/graphic_2d/native_drawing/drawing_surface.h +++ b/graphic/graphic_2d/native_drawing/drawing_surface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -37,9 +37,10 @@ * @version 1.0 */ -#ifndef C_INCLUDE_DRAWING_GPU_SURFACE_H -#define C_INCLUDE_DRAWING_GPU_SURFACE_H +#ifndef C_INCLUDE_DRAWING_SURFACE_H +#define C_INCLUDE_DRAWING_SURFACE_H +#include "drawing_error_code.h" #include "drawing_types.h" #ifdef __cplusplus @@ -60,6 +61,20 @@ extern "C" { OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext( OH_Drawing_GpuContext* gpuContext, bool flag, OH_Drawing_Image_Info imageInfo); +/** + * @brief Creates an OH_Drawing_Surface object on GPU indicated by context which is on-screen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param gpuContext Indicates the pointer to an OH_Drawing_GpuContext object. + * @param imageInfo Indicates the image info. + * @param window Indicates the pointer of the screen window. + * @return Returns the pointer to the OH_Drawing_Surface object created. + * @since 16 + * @version 1.0 + */ +OH_Drawing_Surface* OH_Drawing_SurfaceCreateOnScreen( + OH_Drawing_GpuContext* gpuContext, OH_Drawing_Image_Info imageInfo, void* window); + /** * @brief Gets the canvas that draws into surface. * @@ -72,6 +87,19 @@ OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext( */ OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface* surface); +/** + * @brief Resolves all pending GPU operations on the surface. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param surface Indicates the pointer to an OH_Drawing_Surface object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if surface is nullptr. + * @since 16 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_SurfaceFlush(OH_Drawing_Surface* surface); + /** * @brief Destroys an OH_Drawing_Surface object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index e07fccd887ee78ec30d8789cd8bf88bd66bbd70e..a583691e7017e9689cf273435110e29074d75e93 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -298,6 +298,10 @@ "first_introduced": "12", "name": "OH_Drawing_GpuContextCreateFromGL" }, + { + "first_introduced": "16", + "name": "OH_Drawing_GpuContextCreate" + }, { "first_introduced": "12", "name": "OH_Drawing_GpuContextDestroy" @@ -676,10 +680,18 @@ "first_introduced": "12", "name": "OH_Drawing_SurfaceCreateFromGpuContext" }, + { + "first_introduced": "16", + "name": "OH_Drawing_SurfaceCreateOnScreen" + }, { "first_introduced": "12", "name": "OH_Drawing_SurfaceGetCanvas" }, + { + "first_introduced": "16", + "name": "OH_Drawing_SurfaceFlush" + }, { "first_introduced": "12", "name": "OH_Drawing_SurfaceDestroy"