From 91cad8698b34e4a3790ed6fca33cfbca7d8fefe1 Mon Sep 17 00:00:00 2001 From: yzj688 Date: Mon, 9 Dec 2024 19:37:40 +0800 Subject: [PATCH] =?UTF-8?q?Drawing=20=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81G?= =?UTF-8?q?PU=E5=9C=A8=E5=B1=8F=E7=BB=98=E5=88=B6=E6=8E=A5=E5=8F=A3=20Sign?= =?UTF-8?q?ed-off-by:=20yzj688=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native_drawing/drawing_gpu_context.h | 12 ++++++- .../native_drawing/drawing_surface.h | 34 +++++++++++++++++-- .../native_drawing/libnative_drawing.ndk.json | 12 +++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_gpu_context.h b/graphic/graphic_2d/native_drawing/drawing_gpu_context.h index 8d5df8ea9..1949a5e72 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 d8aa609ad..67f951f74 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 e07fccd88..a583691e7 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" -- Gitee