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