• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_ABSTRACT_DISPLAY_H
17 #define FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_H
18 
19 #include <refbase.h>
20 
21 #include "abstract_screen.h"
22 #include "display_info.h"
23 
24 namespace OHOS::Rosen {
25 enum class FreezeFlag : uint32_t {
26     FREEZING,
27     UNFREEZING,
28 };
29 
30 class AbstractDisplay : public RefBase {
31 public:
32     constexpr static int32_t DEFAULT_WIDTH = 720;
33     constexpr static int32_t DEFAULT_HIGHT = 1280;
34     constexpr static float DEFAULT_VIRTUAL_PIXEL_RATIO = 1.0;
35     constexpr static uint32_t DEFAULT_FRESH_RATE = 60;
36     AbstractDisplay(DisplayId id, std::string name, sptr<SupportedScreenModes>& info, sptr<AbstractScreen>& absScreen);
37     WM_DISALLOW_COPY_AND_MOVE(AbstractDisplay);
38     ~AbstractDisplay() = default;
IsVertical(Rotation rotation)39     static inline bool IsVertical(Rotation rotation)
40     {
41         return (rotation == Rotation::ROTATION_0 || rotation == Rotation::ROTATION_180);
42     }
43     DisplayId GetId() const;
44     int32_t GetOffsetX() const;
45     int32_t GetOffsetY() const;
46     int32_t GetWidth() const;
47     int32_t GetHeight() const;
48     uint32_t GetRefreshRate() const;
49     float GetVirtualPixelRatio() const;
50     ScreenId GetAbstractScreenId() const;
51     ScreenId GetAbstractScreenGroupId() const;
52     bool BindAbstractScreen(sptr<AbstractScreen> abstractDisplay);
53     sptr<DisplayInfo> ConvertToDisplayInfo() const;
54     Rotation GetRotation() const;
55     Orientation GetOrientation() const;
56     FreezeFlag GetFreezeFlag() const;
57 
58     void SetId(DisplayId displayId);
59     void SetOffsetX(int32_t offsetX);
60     void SetOffsetY(int32_t offsetY);
61     void SetWidth(int32_t width);
62     void SetHeight(int32_t height);
63     void SetOffset(int32_t offsetX, int32_t offsetY);
64     void SetRefreshRate(uint32_t refreshRate);
65     void SetVirtualPixelRatio(float virtualPixelRatio);
66     void SetOrientation(Orientation orientation);
67     bool RequestRotation(Rotation rotation);
68     void SetFreezeFlag(FreezeFlag);
69     DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, WaterfallDisplayCompressionStatus, waterfallDisplayCompressionStatus, false);
70 private:
71     DisplayId id_ { DISPLAY_ID_INVALID };
72     std::string name_ { "" };
73     ScreenId screenId_ { SCREEN_ID_INVALID };
74     ScreenId screenGroupId_ { SCREEN_ID_INVALID };
75     int32_t offsetX_ { 0 };
76     int32_t offsetY_ { 0 };
77     int32_t width_ { 0 };
78     int32_t height_ { 0 };
79     uint32_t refreshRate_ { 0 };
80     float virtualPixelRatio_ { 1.0 };
81     Rotation rotation_ { Rotation::ROTATION_0 };
82     Orientation orientation_ { Orientation::UNSPECIFIED };
83     FreezeFlag freezeFlag_ { FreezeFlag::UNFREEZING };
84     DEFINE_VAR_DEFAULT_FUNC_SET(DisplayState, DisplayState, displayState, DisplayState::UNKNOWN);
85 };
86 } // namespace OHOS::Rosen
87 #endif // FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_H