1 /* 2 * Copyright (c) 2022-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 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 #include "noncopyable.h" 25 26 namespace OHOS::Rosen { 27 28 struct WaterfallDisplayAreaRects { 29 DMRect left; 30 DMRect top; 31 DMRect right; 32 DMRect bottom; 33 isUninitializedWaterfallDisplayAreaRects34 bool isUninitialized() const 35 { 36 return (left.IsUninitializedRect() && top.IsUninitializedRect() && right.IsUninitializedRect() && 37 bottom.IsUninitializedRect()); 38 } 39 }; 40 41 class CutoutInfo : public Parcelable { 42 public: 43 CutoutInfo() = default; 44 CutoutInfo(const std::vector<DMRect>& boundingRects, WaterfallDisplayAreaRects waterfallDisplayAreaRects); 45 ~CutoutInfo() = default; 46 WM_DISALLOW_COPY_AND_MOVE(CutoutInfo); 47 48 virtual bool Marshalling(Parcel& parcel) const override; 49 static CutoutInfo *Unmarshalling(Parcel& parcel); 50 51 DEFINE_VAR_FUNC_GET_SET(WaterfallDisplayAreaRects, WaterfallDisplayAreaRects, waterfallDisplayAreaRects); 52 DEFINE_VAR_FUNC_GET_SET(std::vector<DMRect>, BoundingRects, boundingRects); 53 private: 54 const static uint32_t MAX_CUTOUT_INFO_SIZE = 20; 55 bool WriteBoundingRectsVector(const std::vector<DMRect>& boundingRects, Parcel &parcel) const; 56 static bool ReadBoundingRectsVector(std::vector<DMRect>& unmarBoundingRects, Parcel &parcel); 57 static bool ReadWaterfallDisplayAreaRects(WaterfallDisplayAreaRects& waterfallDisplayAreaRects, Parcel &parcel); 58 }; 59 } // namespace OHOS::Rosen 60 #endif // FOUNDATION_DMSERVER_CUTOUT_INFO_H