• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_DMSERVER_CUTOUT_INFO_H
17 #define FOUNDATION_DMSERVER_CUTOUT_INFO_H
18 
19 #include <parcel.h>
20 
21 #include "class_var_definition.h"
22 #include "display.h"
23 #include "dm_common.h"
24 
25 namespace OHOS::Rosen {
26 struct DMRect {
27     int32_t posX_;
28     int32_t posY_;
29     uint32_t width_;
30     uint32_t height_;
31 
32     bool operator==(const DMRect& a) const
33     {
34         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
35     }
36 
37     bool operator!=(const DMRect& a) const
38     {
39         return !this->operator==(a);
40     }
41 
isUninitializedRectDMRect42     bool isUninitializedRect() const
43     {
44         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
45     }
46 
IsInsideOfDMRect47     bool IsInsideOf(const DMRect& a) const
48     {
49         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
50             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
51     }
52 };
53 
54 struct WaterfallDisplayAreaRects {
55     DMRect left;
56     DMRect top;
57     DMRect right;
58     DMRect bottom;
59 
isUninitializedWaterfallDisplayAreaRects60     bool isUninitialized() const
61     {
62         return (left.isUninitializedRect() && top.isUninitializedRect() && right.isUninitializedRect() &&
63             bottom.isUninitializedRect());
64     }
65 };
66 
67 class CutoutInfo : public Parcelable {
68 public:
69     CutoutInfo() = default;
70     CutoutInfo(const std::vector<DMRect>& boundingRects, WaterfallDisplayAreaRects waterfallDisplayAreaRects);
71     ~CutoutInfo() = default;
72     WM_DISALLOW_COPY_AND_MOVE(CutoutInfo);
73 
74     virtual bool Marshalling(Parcel& parcel) const override;
75     static CutoutInfo *Unmarshalling(Parcel& parcel);
76 
77     DEFINE_VAR_FUNC_GET_SET(WaterfallDisplayAreaRects, WaterfallDisplayAreaRects, waterfallDisplayAreaRects);
78     DEFINE_VAR_FUNC_GET_SET(std::vector<DMRect>, BoundingRects, boundingRects);
79 private:
80     bool WriteBoundingRectsVector(const std::vector<DMRect>& boundingRects, Parcel &parcel) const;
81     static bool ReadBoundingRectsVector(std::vector<DMRect>& unmarBoundingRects, Parcel &parcel);
82     static bool ReadWaterfallDisplayAreaRects(WaterfallDisplayAreaRects& waterfallDisplayAreaRects, Parcel &parcel);
83 };
84 } // namespace OHOS::Rosen
85 #endif // FOUNDATION_DMSERVER_CUTOUT_INFO_H