1 #ifndef SRAREGION_H
2 #define SRAREGION_H
3 
4 /* -=- SRA - Simple Region Algorithm
5  * A simple rectangular region implementation.
6  * Copyright (c) 2001 James "Wez" Weatherall, Johannes E. Schindelin
7  */
8 
9 /* -=- sraRect */
10 
11 typedef struct _rect {
12 	int x1;
13 	int y1;
14 	int x2;
15 	int y2;
16 } sraRect;
17 
18 typedef struct sraRegion sraRegion;
19 
20 /* -=- Region manipulation functions */
21 
22 extern sraRegion *sraRgnCreate();
23 extern sraRegion *sraRgnCreateRect(int x1, int y1, int x2, int y2);
24 extern sraRegion *sraRgnCreateRgn(const sraRegion *src);
25 
26 extern void sraRgnDestroy(sraRegion *rgn);
27 extern void sraRgnMakeEmpty(sraRegion *rgn);
28 extern rfbBool sraRgnAnd(sraRegion *dst, const sraRegion *src);
29 extern void sraRgnOr(sraRegion *dst, const sraRegion *src);
30 extern rfbBool sraRgnSubtract(sraRegion *dst, const sraRegion *src);
31 
32 extern void sraRgnOffset(sraRegion *dst, int dx, int dy);
33 
34 extern rfbBool sraRgnPopRect(sraRegion *region, sraRect *rect,
35 			  unsigned long flags);
36 
37 extern unsigned long sraRgnCountRects(const sraRegion *rgn);
38 extern rfbBool sraRgnEmpty(const sraRegion *rgn);
39 
40 extern sraRegion *sraRgnBBox(const sraRegion *src);
41 
42 /* -=- rectangle iterator */
43 
44 typedef struct sraRectangleIterator {
45   rfbBool reverseX,reverseY;
46   int ptrSize,ptrPos;
47   struct sraSpan** sPtrs;
48 } sraRectangleIterator;
49 
50 extern sraRectangleIterator *sraRgnGetIterator(sraRegion *s);
51 extern sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY);
52 extern rfbBool sraRgnIteratorNext(sraRectangleIterator *i,sraRect *r);
53 extern void sraRgnReleaseIterator(sraRectangleIterator *i);
54 
55 void sraRgnPrint(const sraRegion *s);
56 
57 /* -=- Rectangle clipper (for speed) */
58 
59 extern rfbBool sraClipRect(int *x, int *y, int *w, int *h,
60 			int cx, int cy, int cw, int ch);
61 
62 extern rfbBool sraClipRect2(int *x, int *y, int *x2, int *y2,
63 			int cx, int cy, int cx2, int cy2);
64 
65 #endif
66