summaryrefslogtreecommitdiffstats
path: root/include/freerdp/codec/region.h
blob: 19239b6340e2c5ec7fd10ea6e3e09386cb4b2bf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/**
 * Copyright © 2014 Thincast Technologies GmbH
 * Copyright © 2014 Hardening <contact@hardening-consulting.com>
 *
 * Permission to use, copy, modify, distribute, and sell this software and
 * its documentation for any purpose is hereby granted without fee, provided
 * that the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of the copyright holders not be used in
 * advertising or publicity pertaining to distribution of the software
 * without specific, written prior permission.  The copyright holders make
 * no representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef FREERDP_CODEC_REGION_H
#define FREERDP_CODEC_REGION_H

#include <freerdp/api.h>
#include <freerdp/types.h>

#ifdef __cplusplus
extern "C"
{
#endif

	typedef struct S_REGION16_DATA REGION16_DATA;

	typedef struct
	{
		RECTANGLE_16 extents;
		REGION16_DATA* data;
	} REGION16;

	/** computes if two rectangles are equal
	 * @param r1 first rectangle
	 * @param r2 second rectangle
	 * @return if the two rectangles are equal
	 */
	FREERDP_API BOOL rectangles_equal(const RECTANGLE_16* r1, const RECTANGLE_16* r2);

	/** computes if two rectangles intersect
	 * @param r1 first rectangle
	 * @param r2 second rectangle
	 * @return if the two rectangles intersect
	 */
	FREERDP_API BOOL rectangles_intersects(const RECTANGLE_16* r1, const RECTANGLE_16* r2);

	/** computes the intersection of two rectangles
	 * @param r1 first rectangle
	 * @param r2 second rectangle
	 * @param dst resulting intersection
	 * @return if the two rectangles intersect
	 */
	FREERDP_API BOOL rectangles_intersection(const RECTANGLE_16* r1, const RECTANGLE_16* r2,
	                                         RECTANGLE_16* dst);

	/** initialize a region16
	 * @param region the region to initialise
	 */
	FREERDP_API void region16_init(REGION16* region);

	/** @return the number of rectangles of this region16 */
	FREERDP_API int region16_n_rects(const REGION16* region);

	/** returns a pointer to rectangles and the number of rectangles in this region.
	 * nbRects can be set to NULL if not interested in the number of rectangles.
	 * @param region the input region
	 * @param nbRects if non-NULL returns the number of rectangles
	 * @return a pointer on the rectangles
	 */
	FREERDP_API const RECTANGLE_16* region16_rects(const REGION16* region, UINT32* nbRects);

	/** @return the extents rectangle of this region */
	FREERDP_API const RECTANGLE_16* region16_extents(const REGION16* region);

	/** returns if the rectangle is empty
	 * @param rect the rectangle to check
	 * @return if the rectangle is empty
	 */
	FREERDP_API BOOL rectangle_is_empty(const RECTANGLE_16* rect);

	/** returns if the region is empty
	 * @param region the region to check
	 * @return if the region is empty
	 */
	FREERDP_API BOOL region16_is_empty(const REGION16* region);

	/** clears the region, the region is reset to a (0,0,0,0) region
	 * @param region the region to clear
	 */
	FREERDP_API void region16_clear(REGION16* region);

	/** dumps the region on stderr
	 * @param region the region to dump
	 */
	FREERDP_API void region16_print(const REGION16* region);

	/** copies the region to another region
	 * @param dst destination region
	 * @param src source region
	 * @return if the operation was successful (false meaning out-of-memory)
	 */
	FREERDP_API BOOL region16_copy(REGION16* dst, const REGION16* src);

	/** adds a rectangle in src and stores the resulting region in dst
	 * @param dst destination region
	 * @param src source region
	 * @param rect the rectangle to add
	 * @return if the operation was successful (false meaning out-of-memory)
	 */
	FREERDP_API BOOL region16_union_rect(REGION16* dst, const REGION16* src,
	                                     const RECTANGLE_16* rect);

	/** returns if a rectangle intersects the region
	 * @param src the region
	 * @param arg2 the rectangle
	 * @return if region and rectangle intersect
	 */
	FREERDP_API BOOL region16_intersects_rect(const REGION16* src, const RECTANGLE_16* arg2);

	/** computes the intersection between a region and a rectangle
	 * @param dst destination region
	 * @param src the source region
	 * @param arg2 the rectangle that intersects
	 * @return if the operation was successful (false meaning out-of-memory)
	 */
	FREERDP_API BOOL region16_intersect_rect(REGION16* dst, const REGION16* src,
	                                         const RECTANGLE_16* arg2);

	/** release internal data associated with this region
	 * @param region the region to release
	 */
	FREERDP_API void region16_uninit(REGION16* region);

#ifdef __cplusplus
}
#endif

#endif /* FREERDP_CODEC_REGION_H */