1 /*
2 * Copyright (c) 2023 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 #include "utils/region.h"
17
18 #include "impl_factory.h"
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace Drawing {
Region()23 Region::Region() : impl_(ImplFactory::CreateRegionImpl()) {}
24
Region(const Region & other)25 Region::Region(const Region& other) : Region()
26 {
27 impl_->Clone(other);
28 }
29
operator =(const Region & other)30 Region& Region::operator=(const Region& other)
31 {
32 impl_->Clone(other);
33 return *this;
34 }
35
operator ==(const Region & other) const36 bool Region::operator==(const Region& other) const
37 {
38 return impl_->Equals(other);
39 }
40
Contains(int32_t x,int32_t y) const41 bool Region::Contains(int32_t x, int32_t y) const
42 {
43 return impl_->Contains(x, y);
44 }
45
SetEmpty()46 void Region::SetEmpty()
47 {
48 return impl_->SetEmpty();
49 }
50
SetRect(const RectI & rectI)51 bool Region::SetRect(const RectI& rectI)
52 {
53 return impl_->SetRect(rectI);
54 }
55
SetRegion(const Region & region)56 bool Region::SetRegion(const Region& region)
57 {
58 return impl_->SetRegion(region);
59 }
60
SetPath(const Path & path,const Region & clip)61 bool Region::SetPath(const Path& path, const Region& clip)
62 {
63 return impl_->SetPath(path, clip);
64 }
65
GetBoundaryPath(Path * path) const66 bool Region::GetBoundaryPath(Path* path) const
67 {
68 return impl_->GetBoundaryPath(path);
69 }
70
GetBounds() const71 RectI Region::GetBounds() const
72 {
73 return impl_->GetBounds();
74 }
75
IsComplex() const76 bool Region::IsComplex() const
77 {
78 return impl_->IsComplex();
79 }
80
IsIntersects(const Region & other) const81 bool Region::IsIntersects(const Region& other) const
82 {
83 return impl_->IsIntersects(other);
84 }
85
IsEmpty() const86 bool Region::IsEmpty() const
87 {
88 return impl_->IsEmpty();
89 }
90
IsRect() const91 bool Region::IsRect() const
92 {
93 return impl_->IsRect();
94 }
95
IsRegionContained(const Region & other) const96 bool Region::IsRegionContained(const Region& other) const
97 {
98 return impl_->IsRegionContained(other);
99 }
100
Op(const Region & region,RegionOp op)101 bool Region::Op(const Region& region, RegionOp op)
102 {
103 return impl_->Op(region, op);
104 }
105
QuickReject(const RectI & rectI) const106 bool Region::QuickReject(const RectI& rectI) const
107 {
108 return impl_->QuickReject(rectI);
109 }
110
QuickReject(const Region & region) const111 bool Region::QuickReject(const Region& region) const
112 {
113 return impl_->QuickReject(region);
114 }
115
Translate(int32_t x,int32_t y)116 void Region::Translate(int32_t x, int32_t y)
117 {
118 return impl_->Translate(x, y);
119 }
120
Serialize() const121 std::shared_ptr<Data> Region::Serialize() const
122 {
123 return impl_->Serialize();
124 }
125
Deserialize(std::shared_ptr<Data> data)126 bool Region::Deserialize(std::shared_ptr<Data> data)
127 {
128 return impl_->Deserialize(data);
129 }
130 } // namespace Drawing
131 } // namespace Rosen
132 } // namespace OHOS
133