1 /* 2 * Copyright (c) 2024 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 #ifndef C_INCLUDE_DRAWING_REGION_H 17 #define C_INCLUDE_DRAWING_REGION_H 18 19 /** 20 * @addtogroup Drawing 21 * @{ 22 * 23 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 26 * 27 * @since 8 28 * @version 1.0 29 */ 30 31 /** 32 * @file drawing_region.h 33 * 34 * @brief Declares functions related to the <b>region</b> object in the drawing module. 35 * 36 * @since 12 37 * @version 1.0 38 */ 39 40 #include "drawing_types.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /** 47 * @brief Enumerates of operations when two regions are combined. 48 * 49 * @since 12 50 * @version 1.0 51 */ 52 typedef enum { 53 /** 54 * Difference operation. 55 */ 56 REGION_OP_MODE_DIFFERENCE, 57 /** 58 * Intersect operation. 59 */ 60 REGION_OP_MODE_INTERSECT, 61 /** 62 * Union operation. 63 */ 64 REGION_OP_MODE_UNION, 65 /** 66 * Xor operation. 67 */ 68 REGION_OP_MODE_XOR, 69 /** 70 * Reverse difference operation. 71 */ 72 REGION_OP_MODE_REVERSE_DIFFERENCE, 73 /** 74 * Replace operation. 75 */ 76 REGION_OP_MODE_REPLACE, 77 } OH_Drawing_RegionOpMode; 78 79 /** 80 * @brief Creates an <b>OH_Drawing_Region</b> object. 81 * 82 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 83 * @return Returns the pointer to the <b>OH_Drawing_Region</b> object created. 84 * @since 12 85 * @version 1.0 86 */ 87 OH_Drawing_Region* OH_Drawing_RegionCreate(void); 88 89 /** 90 * @brief Determines whether the region contains the specified coordinates. 91 * 92 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 93 * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object. 94 * @param int32_t x-coordinate. 95 * @param int32_t y-coordinate. 96 * @return Returns <b>true</b> if (x, y) is inside region; returns <b>false</b> otherwise. 97 * @since 12 98 * @version 1.0 99 */ 100 bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y); 101 102 /** 103 * @brief Combines two regions. 104 * 105 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 106 * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object. 107 * @param dst Indicates the pointer to an <b>OH_Drawing_Region</b> object. 108 * @param op Indicates the operation to apply to combine. 109 * @return Returns <b>true</b> if constructed region is not empty; returns <b>false</b> otherwise. 110 * @since 12 111 * @version 1.0 112 */ 113 bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* dst, OH_Drawing_RegionOpMode op); 114 115 /** 116 * @brief Set the region to the specified rect. 117 * 118 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 119 * @param OH_Drawing_Region Indicates the pointer to an <b>OH_Drawing_Region</b> object. 120 * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 121 * @return Return true if constructed Region is not empty. 122 * @since 12 123 * @version 1.0 124 */ 125 bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect); 126 127 /** 128 * @brief Constructs region that matchs outline of path within clip. 129 * 130 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 131 * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object. 132 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 133 * @param clip Indicates the pointer to an <b>OH_Drawing_Region</b> object. 134 * @return Returns <b>true</b> if constructed region is not empty; returns <b>false</b> otherwise. 135 * @since 12 136 * @version 1.0 137 */ 138 bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip); 139 140 /** 141 * @brief Destroys an <b>OH_Drawing_Region</b> object and reclaims the memory occupied by the object. 142 * 143 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 144 * @param OH_Drawing_Region Indicates the pointer to an <b>OH_Drawing_Region</b> object. 145 * @since 12 146 * @version 1.0 147 */ 148 void OH_Drawing_RegionDestroy(OH_Drawing_Region*); 149 150 #ifdef __cplusplus 151 } 152 #endif 153 /** @} */ 154 #endif 155