1/*
2 * Copyright (c) 2021-2024 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 DISPLAY_H
17#define 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 cutout info of the display.
129     *
130     * @return Cutout info of the display.
131     */
132    sptr<CutoutInfo> GetCutoutInfo() const;
133
134    /**
135     * @brief Judge if current display has immersive window.
136     * @param immersive The flag to represent if current display has immersive window.
137     *
138     * @return DM error codes.
139     */
140    DMError HasImmersiveWindow(bool& immersive);
141
142    /**
143     * @brief Get the supported HDR format of the screen.
144     *
145     * @param colorSpaces Supported HDR format of the screen.
146     * @return DM_OK means get success, others means get failed.
147     */
148    DMError GetSupportedHDRFormats(std::vector<uint32_t>& hdrFormats) const;
149
150    /**
151     * @brief Get the supported color space of the screen.
152     *
153     * @param colorSpaces Supported color space of the screen.
154     * @return DM_OK means get success, others means get failed.
155     */
156    DMError GetSupportedColorSpaces(std::vector<uint32_t>& colorSpaces) const;
157
158    /**
159     * @brief get available area of the display.(the screen area without dock and statusbar)
160     * @param area available area of the screen.
161     * @return DMError
162     */
163    DMError GetAvailableArea(DMRect& area) const;
164
165protected:
166    // No more methods or variables can be defined here.
167    Display(const std::string& name, sptr<DisplayInfo> info);
168private:
169    // No more methods or variables can be defined here.
170    void UpdateDisplayInfo(sptr<DisplayInfo>) const;
171    void UpdateDisplayInfo() const;
172    class Impl;
173    sptr<Impl> pImpl_;
174};
175} // namespace OHOS::Rosen
176
177#endif // DISPLAY_H