• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
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_region.h
30  *
31  * @brief Declares functions related to the <b>region</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_REGION_H
41 #define C_INCLUDE_DRAWING_REGION_H
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 Creates an <b>OH_Drawing_Region</b> copy object.
94  *
95  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
96  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object to copy.
97  * @return Returns the pointer to the <b>OH_Drawing_Region</b> object created.
98  * @since 20
99  * @version 1.0
100  */
101 OH_Drawing_Region* OH_Drawing_RegionCopy(const OH_Drawing_Region* region);
102 
103 /**
104  * @brief Determines whether the region contains the specified coordinates.
105  *
106  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
107  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
108  * @param x x-coordinate.
109  * @param y y-coordinate.
110  * @return Returns <b>true</b> if (x, y) is inside region; returns <b>false</b> otherwise.
111  * @since 12
112  * @version 1.0
113  */
114 bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y);
115 
116 /**
117  * @brief Combines two regions.
118  *
119  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
120  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
121  * @param other Indicates the pointer to an <b>OH_Drawing_Region</b> object.
122  * @param op Indicates the operation to apply to combine.
123  * @return Returns <b>true</b> if constructed Region is not empty; returns <b>false</b> otherwise.
124  * @since 12
125  * @version 1.0
126  */
127 bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* other, OH_Drawing_RegionOpMode op);
128 
129 /**
130  * @brief Sets the region to the specified rect.
131  *
132  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
133  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
134  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
135  * @return Return true if constructed Region is not empty.
136  * @since 12
137  * @version 1.0
138  */
139 bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect);
140 
141 /**
142  * @brief Constructs region that matchs outline of path within clip.
143  *
144  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
145  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
146  * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object.
147  * @param clip Indicates the pointer to an <b>OH_Drawing_Region</b> object.
148  * @return Returns <b>true</b> if constructed Region is not empty; returns <b>false</b> otherwise.
149  * @since 12
150  * @version 1.0
151  */
152 bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip);
153 
154 /**
155  * @brief Destroys an <b>OH_Drawing_Region</b> object and reclaims the memory occupied by the object.
156  *
157  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
158  * @param region Indicates the pointer to an <b>OH_Drawing_Region</b> object.
159  * @since 12
160  * @version 1.0
161  */
162 void OH_Drawing_RegionDestroy(OH_Drawing_Region* region);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 /** @} */
168 #endif
169