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
Contains(int32_t x,int32_t y) const36 bool Region::Contains(int32_t x, int32_t y) const
37 {
38 return impl_->Contains(x, y);
39 }
40
SetRect(const RectI & rectI)41 bool Region::SetRect(const RectI& rectI)
42 {
43 return impl_->SetRect(rectI);
44 }
45
SetPath(const Path & path,const Region & clip)46 bool Region::SetPath(const Path& path, const Region& clip)
47 {
48 return impl_->SetPath(path, clip);
49 }
50
GetBoundaryPath(Path * path) const51 bool Region::GetBoundaryPath(Path* path) const
52 {
53 return impl_->GetBoundaryPath(path);
54 }
55
IsIntersects(const Region & other) const56 bool Region::IsIntersects(const Region& other) const
57 {
58 return impl_->IsIntersects(other);
59 }
60
IsEmpty() const61 bool Region::IsEmpty() const
62 {
63 return impl_->IsEmpty();
64 }
65
IsRect() const66 bool Region::IsRect() const
67 {
68 return impl_->IsRect();
69 }
70
IsRegionContained(const Region & other) const71 bool Region::IsRegionContained(const Region& other) const
72 {
73 return impl_->IsRegionContained(other);
74 }
75
Op(const Region & region,RegionOp op)76 bool Region::Op(const Region& region, RegionOp op)
77 {
78 return impl_->Op(region, op);
79 }
80
QuickReject(const RectI & rectI) const81 bool Region::QuickReject(const RectI& rectI) const
82 {
83 return impl_->QuickReject(rectI);
84 }
85
Serialize() const86 std::shared_ptr<Data> Region::Serialize() const
87 {
88 return impl_->Serialize();
89 }
90
Deserialize(std::shared_ptr<Data> data)91 bool Region::Deserialize(std::shared_ptr<Data> data)
92 {
93 return impl_->Deserialize(data);
94 }
95 } // namespace Drawing
96 } // namespace Rosen
97 } // namespace OHOS
98