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_DM_DISPLAY_H
17#define FOUNDATION_DM_DISPLAY_H
18
19#include <string>
20#include "dm_common.h"
21#include "noncopyable.h"
22
23namespace OHOS::Rosen {
24class DisplayInfo;
25class CutoutInfo;
26
27class Display : public RefBase {
28friend class DisplayManager;
29public:
30    ~Display();
31    Display(const Display&) = delete;
32    Display(Display&&) = delete;
33    Display& operator=(const Display&) = delete;
34    Display& operator=(Display&&) = delete;
35
36    /**
37     * @brief Get id of the display.
38     *
39     * @return Display id.
40     */
41    DisplayId GetId() const;
42
43    /**
44     * @brief Get name of the display.
45     *
46     * @return Display name.
47     */
48    std::string GetName() const;
49
50    /**
51     * @brief Get width of the display.
52     *
53     * @return Width of the display.
54     */
55    int32_t GetWidth() const;
56
57    /**
58     * @brief Get height of the display.
59     *
60     * @return Height of the display.
61     */
62    int32_t GetHeight() const;
63
64    /**
65     * @brief Get physical width of the display.
66     *
67     * @return Physical width of the display.
68     */
69    int32_t GetPhysicalWidth() const;
70
71    /**
72     * @brief Get physical height of the display.
73     *
74     * @return Physical height of the display.
75     */
76    int32_t GetPhysicalHeight() const;
77
78    /**
79     * @brief Get the refresh rate of the display.
80     *
81     * @return Refresh rate of the display.
82     */
83    uint32_t GetRefreshRate() const;
84
85    /**
86     * @brief Get screen id.
87     *
88     * @return The screen id.
89     */
90    ScreenId GetScreenId() const;
91
92    /**
93     * @brief Get the virtual pixel ratio of the display.
94     *
95     * @return Virtual pixel ratio of the display.
96     */
97    float GetVirtualPixelRatio() const;
98
99    /**
100     * @brief Get the Dpi of the display.
101     *
102     * @return Dpi of the display.
103     */
104    int GetDpi() const;
105
106    /**
107     * @brief Get the rotation of the display.
108     *
109     * @return Rotation of the display..
110     */
111    Rotation GetRotation() const;
112
113    /**
114     * @brief Get the Orientation of the display.
115     *
116     * @return Orientation indicates the direction of the display content.
117     */
118    Orientation GetOrientation() const;
119
120    /**
121     * @brief Get info of the display.
122     *
123     * @return Info of the display.
124     */
125    sptr<DisplayInfo> GetDisplayInfo() const;
126
127    /**
128     * @brief Get info of the display by JS.
129     *
130     * @return Info of the display.
131     */
132    sptr<DisplayInfo> GetDisplayInfoByJs() const;
133
134    /**
135     * @brief Get cutout info of the display.
136     *
137     * @return Cutout info of the display.
138     */
139    sptr<CutoutInfo> GetCutoutInfo() const;
140
141    /**
142     * @brief Judge if current display has immersive window.
143     * @param immersive The flag to represent if current display has immersive window.
144     *
145     * @return DM error codes.
146     */
147    DMError HasImmersiveWindow(bool& immersive);
148
149    /**
150     * @brief Get the supported HDR format of the screen.
151     *
152     * @param colorSpaces Supported HDR format of the screen.
153     * @return DM_OK means get success, others means get failed.
154     */
155    DMError GetSupportedHDRFormats(std::vector<uint32_t>& hdrFormats) const;
156
157    /**
158     * @brief Get the supported color space of the screen.
159     *
160     * @param colorSpaces Supported color space of the screen.
161     * @return DM_OK means get success, others means get failed.
162     */
163    DMError GetSupportedColorSpaces(std::vector<uint32_t>& colorSpaces) const;
164
165    /**
166     * @brief get available area of the display.(the screen area without dock and statusbar)
167     * @param area available area of the screen.
168     * @return DMError
169     */
170    DMError GetAvailableArea(DMRect& area) const;
171
172protected:
173    // No more methods or variables can be defined here.
174    Display(const std::string& name, sptr<DisplayInfo> info);
175private:
176    // No more methods or variables can be defined here.
177    void UpdateDisplayInfo(sptr<DisplayInfo>) const;
178    void UpdateDisplayInfo() const;
179    class Impl;
180    sptr<Impl> pImpl_;
181};
182} // namespace OHOS::Rosen
183
184#endif // FOUNDATION_DM_DISPLAY_H