updated licenses info.
[platform/core/uifw/lottie-player.git] / src / vector / pixman / vregion.h
1 /* 
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  * 
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  * 
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  * 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 #ifndef VREGION_H
20 #define VREGION_H
21 #include <vglobal.h>
22 #include <vpoint.h>
23 #include <vrect.h>
24 #include <utility>
25 #include "vdebug.h"
26
27 V_BEGIN_NAMESPACE
28
29 struct VRegionData;
30
31 class VRegion {
32 public:
33     VRegion();
34     VRegion(int x, int y, int w, int h);
35     VRegion(const VRect &r);
36     VRegion(const VRegion &region);
37     VRegion(VRegion &&other);
38     ~VRegion();
39     VRegion &      operator=(const VRegion &);
40     VRegion &      operator=(VRegion &&);
41     bool           empty() const;
42     bool           contains(const VRect &r) const;
43     VRegion        united(const VRect &r) const;
44     VRegion        united(const VRegion &r) const;
45     VRegion        intersected(const VRect &r) const;
46     VRegion        intersected(const VRegion &r) const;
47     VRegion        subtracted(const VRegion &r) const;
48     void           translate(const VPoint &p);
49     inline void    translate(int dx, int dy);
50     VRegion        translated(const VPoint &p) const;
51     inline VRegion translated(int dx, int dy) const;
52     int            rectCount() const;
53     VRect          rectAt(int index) const;
54
55     VRegion  operator+(const VRect &r) const;
56     VRegion  operator+(const VRegion &r) const;
57     VRegion  operator-(const VRegion &r) const;
58     VRegion &operator+=(const VRect &r);
59     VRegion &operator+=(const VRegion &r);
60     VRegion &operator-=(const VRegion &r);
61
62     VRect boundingRect() const noexcept;
63     bool  intersects(const VRegion &region) const;
64
65     bool        operator==(const VRegion &r) const;
66     inline bool operator!=(const VRegion &r) const { return !(operator==(r)); }
67     friend VDebug &operator<<(VDebug &os, const VRegion &o);
68
69 private:
70     bool    within(const VRect &r) const;
71     VRegion copy() const;
72     void    detach();
73     void    cleanUp(VRegionData *x);
74
75     struct VRegionData *d;
76 };
77 inline void VRegion::translate(int dx, int dy)
78 {
79     translate(VPoint(dx, dy));
80 }
81
82 inline VRegion VRegion::translated(int dx, int dy) const
83 {
84     return translated(VPoint(dx, dy));
85 }
86
87 V_END_NAMESPACE
88
89 #endif  // VREGION_H