• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef REGION_H
17 #define REGION_H
18 
19 #include "impl_interface/region_impl.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 namespace Drawing {
24 enum class RegionOp {
25     DIFFERENCE,
26     INTERSECT,
27     UNION,
28     XOR,
29     REVERSE_DIFFERENCE,
30     REPLACE,
31 };
32 class Region {
33 public:
34     Region();
35     virtual ~Region() = default;
36 
GetDrawingType()37     virtual DrawingType GetDrawingType() const
38     {
39         return DrawingType::COMMON;
40     }
41 
42     /*
43      * @brief        Constructs a rectangular Region matching the bounds of rect.
44      * @param rectI  Bounds of constructed Region.
45      * @return       If rectI is empty, constructs empty and returns false.
46      */
47     virtual bool SetRect(const RectI& rectI);
48 
49     /*
50      * @brief        Constructs Region to match outline of path within clip.
51      * @param &path  Providing outline
52      * @param &clip  Containing path.
53      * @return       Return true if constructed Region is not empty.
54      */
55     virtual bool SetPath(const Path& path, const Region& clip);
56 
57     /*
58      * @brief         Determines whether it intersects other.
59      * @param &other  Other Region object.
60      * @return        If true indicates that other and Region have area in common.
61      */
62     bool IsIntersects(const Region& other) const;
63 
64     /*
65      * @brief          Replaces Region with the result of Region op region.
66      * @param &region  Operand.
67      * @param op       Operation type.
68      * @return         Returns true if replaced Region is not empty.
69      */
70     virtual bool Op(const Region& region, RegionOp op);
71 
72     /*
73      * @brief   Get the adaptation layer instance, called in the adaptation layer.
74      * @return  Adaptation Layer instance.
75      */
76     template<typename T>
GetImpl()77     const std::shared_ptr<T> GetImpl() const
78     {
79         return impl_->DowncastingTo<T>();
80     }
81 
82 private:
83     std::shared_ptr<RegionImpl> impl_;
84 };
85 } // namespace Drawing
86 } // namespace Rosen
87 } // namespace OHOS
88 #endif
89