1 /* 2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Drawing 18 * @{ 19 * 20 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 21 * 22 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 23 * 24 * @since 8 25 * @version 1.0 26 */ 27 28 /** 29 * @file drawing_surface.h 30 * 31 * @brief Declares functions related to the <b>OH_Drawing_Surface</b> object in the drawing module. 32 * 33 * @kit ArkGraphics2D 34 * @library libnative_drawing.so 35 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 36 * @since 12 37 * @version 1.0 38 */ 39 40 #ifndef C_INCLUDE_DRAWING_SURFACE_H 41 #define C_INCLUDE_DRAWING_SURFACE_H 42 43 #include "drawing_error_code.h" 44 #include "drawing_types.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Creates an <b>OH_Drawing_Surface</b> object on GPU indicated by context. 52 * 53 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 54 * @param gpuContext Indicates the pointer to an <b>OH_Drawing_GpuContext</b> object. 55 * @param flag Indicates whether an allocation should count against a cache budget. 56 * @param imageInfo Indicates the image info. 57 * @return Returns the pointer to the <b>OH_Drawing_Surface</b> object created. 58 * @since 12 59 * @version 1.0 60 */ 61 OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext( 62 OH_Drawing_GpuContext* gpuContext, bool flag, OH_Drawing_Image_Info imageInfo); 63 64 /** 65 * @brief Creates an <b>OH_Drawing_Surface</b> object on GPU indicated by context which is on-screen. 66 * 67 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 68 * @param gpuContext Indicates the pointer to an <b>OH_Drawing_GpuContext</b> object. 69 * @param imageInfo Indicates the image info. 70 * @param window Indicates the pointer of the screen window. 71 * @return Returns the pointer to the <b>OH_Drawing_Surface</b> object created. 72 * @since 16 73 * @version 1.0 74 */ 75 OH_Drawing_Surface* OH_Drawing_SurfaceCreateOnScreen( 76 OH_Drawing_GpuContext* gpuContext, OH_Drawing_Image_Info imageInfo, void* window); 77 78 /** 79 * @brief Gets the canvas that draws into surface. 80 * 81 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 82 * @param surface Indicates the pointer to an <b>OH_Drawing_Surface</b> object. 83 * @return Returns the pointer to the <b>OH_Drawing_Canvas</b> object. The returned pointer does not need to be managed 84 * by the caller. 85 * @since 12 86 * @version 1.0 87 */ 88 OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface* surface); 89 90 /** 91 * @brief Resolves all pending GPU operations on the surface. 92 * 93 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 94 * @param surface Indicates the pointer to an <b>OH_Drawing_Surface</b> object. 95 * @return Returns the error code. 96 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 97 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if surface is nullptr. 98 * @since 16 99 * @version 1.0 100 */ 101 OH_Drawing_ErrorCode OH_Drawing_SurfaceFlush(OH_Drawing_Surface* surface); 102 103 /** 104 * @brief Destroys an <b>OH_Drawing_Surface</b> object and reclaims the memory occupied by the object. 105 * 106 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 107 * @param surface Indicates the pointer to an <b>OH_Drawing_Surface</b> object. 108 * @since 12 109 * @version 1.0 110 */ 111 void OH_Drawing_SurfaceDestroy(OH_Drawing_Surface* surface); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 /** @} */ 117 #endif