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  * @kit ArkGraphics2D
37  * @library libnative_drawing.so
38  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
39  * @since 12
40  * @version 1.0
41  */
42 
43 #include "drawing_types.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Operations when two regions are combined.
51  *
52  * @since 12
53  * @version 1.0
54  */
55 typedef enum {
56     /**
57      * Difference operation.
58      */
59     REGION_OP_MODE_DIFFERENCE,
60     /**
61      * Intersect operation.
62      */
63     REGION_OP_MODE_INTERSECT,
64     /**
65      * Union operation.
66      */
67     REGION_OP_MODE_UNION,
68     /**
69      * Xor operation.
70      */
71     REGION_OP_MODE_XOR,
72     /**
73      * Reverse difference operation.
74      */
75     REGION_OP_MODE_REVERSE_DIFFERENCE,
76     /**
77      * Replace operation.
78      */
79     REGION_OP_MODE_REPLACE,
80 } OH_Drawing_RegionOpMode;
81 
82 /**
83  * @brief Creates an <b>OH_Drawing_Region</b> object.
84  *
85  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
86  * @return Returns the pointer to the <b>OH_Drawing_Region</b> object created.
87  * @since 12
88  * @version 1.0
89  */
90 OH_Drawing_Region* OH_Drawing_RegionCreate(void);
91 
92 /**
93  * @brief Determines whether the region contains the specified coordinates.
94  *
95  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
96  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
97  * @param int32_t x-coordinate.
98  * @param int32_t y-coordinate.
99  * @return Returns <b>true</b> if (x, y) is inside region; returns <b>false</b> otherwise.
100  * @since 12
101  * @version 1.0
102  */
103 bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y);
104 
105 /**
106  * @brief Combines two regions.
107  *
108  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
109  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
110  * @param other Indicates the pointer to an <b>OH_Drawing_Region</b> object.
111  * @param op Indicates the operation to apply to combine.
112  * @return Returns <b>true</b> if constructed Region is not empty; returns <b>false</b> otherwise.
113  * @since 12
114  * @version 1.0
115  */
116 bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* other, OH_Drawing_RegionOpMode op);
117 
118 /**
119  * @brief Sets the region to the specified rect.
120  *
121  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
122  * @param OH_Drawing_Region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
123  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
124  * @return Return true if constructed Region is not empty.
125  * @since 12
126  * @version 1.0
127  */
128 bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect);
129 
130 /**
131  * @brief Constructs region that matchs outline of path within clip.
132  *
133  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
134  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
135  * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object.
136  * @param clip Indicates the pointer to an <b>OH_Drawing_Region</b> object.
137  * @return Returns <b>true</b> if constructed Region is not empty; returns <b>false</b> otherwise.
138  * @since 12
139  * @version 1.0
140  */
141 bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip);
142 
143 /**
144  * @brief Destroys an <b>OH_Drawing_Region</b> object and reclaims the memory occupied by the object.
145  *
146  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
147  * @param OH_Drawing_Region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
148  * @since 12
149  * @version 1.0
150  */
151 void OH_Drawing_RegionDestroy(OH_Drawing_Region*);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 /** @} */
157 #endif
158