blob: 7cc0eaa892fdabab572b23831b2a2225207f7c5e [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// Cross-platform Region class based on the X11 region implementation
20
21#ifndef __RFB_REGION_INCLUDED__
22#define __RFB_REGION_INCLUDED__
23
24#include <rfb/Rect.h>
25#include <vector>
26
27struct _XRegion;
28
29namespace rfb {
30
31 struct ShortRect {
32 short x1, y1, x2, y2;
33 };
34
35 class Region {
36 public:
37 // Create an empty region
38 Region();
39 // Create a rectangular region
40 Region(const Rect& r);
41
42 Region(const Region& r);
43 Region &operator=(const Region& src);
44
45 ~Region();
46
47 // the following methods alter the region in place:
48
49 void clear();
50 void reset(const Rect& r);
51 void translate(const rfb::Point& delta);
52 void setOrderedRects(const std::vector<Rect>& rects);
53 void setExtentsAndOrderedRects(const ShortRect* extents, int nRects,
54 const ShortRect* rects);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055
56 void assign_intersect(const Region& r);
57 void assign_union(const Region& r);
58 void assign_subtract(const Region& r);
59
60 // the following three operations return a new region:
61
62 Region intersect(const Region& r) const;
63 Region union_(const Region& r) const;
64 Region subtract(const Region& r) const;
65
66 bool equals(const Region& b) const;
67 int numRects() const;
68 bool is_empty() const { return numRects() == 0; }
69
70 bool get_rects(std::vector<Rect>* rects, bool left2right=true,
Pierre Ossman1d696c62019-06-24 16:01:54 +020071 bool topdown=true) const;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000072 Rect get_bounding_rect() const;
73
74 void debug_print(const char *prefix) const;
75
76 protected:
77
78 struct _XRegion* xrgn;
79 };
80
81};
82
83#endif // __RFB_REGION_INCLUDED__