• 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_SCREEN_H
17 #define FOUNDATION_DM_SCREEN_H
18 
19 #include <cstdint>
20 #include <screen_manager/screen_types.h>
21 #include <string>
22 #include <surface.h>
23 #include <vector>
24 
25 #include "dm_common.h"
26 #include "noncopyable.h"
27 
28 namespace OHOS::Rosen {
29 class ScreenInfo;
30 
31 struct VirtualScreenOption {
32     std::string name_;
33     uint32_t width_;
34     uint32_t height_;
35     float density_;
36     sptr<Surface> surface_;
37     int32_t flags_;
38     bool isForShot_ {true};
39     std::vector<uint64_t> missionIds_ {};
40     VirtualScreenType virtualScreenType_ {VirtualScreenType::UNKNOWN};
41     bool isSecurity_ {true};
42     VirtualScreenFlag virtualScreenFlag_ {VirtualScreenFlag::DEFAULT};
43 };
44 
45 class Screen : public RefBase {
46 friend class ScreenManager;
47 public:
48     ~Screen();
49     Screen(const Screen&) = delete;
50     Screen(Screen&&) = delete;
51     Screen& operator=(const Screen&) = delete;
52     Screen& operator=(Screen&&) = delete;
53     bool IsGroup() const;
54     std::string GetName() const;
55 
56     /**
57      * @brief Get screen id.
58      *
59      * @return Screen id.
60      */
61     ScreenId GetId() const;
62 
63     /**
64      * @brief Get width of the screen.
65      *
66      * @return Width of the screen.
67      */
68     uint32_t GetWidth() const;
69 
70     /**
71      * @brief Get height of the screen.
72      *
73      * @return Height of the screen.
74      */
75     uint32_t GetHeight() const;
76 
77     /**
78      * @brief Get virtual width of the screen.
79      *
80      * @return Virtual width of the screen.
81      */
82     uint32_t GetVirtualWidth() const;
83 
84     /**
85      * @brief Get virtual height of the screen.
86      *
87      * @return Virtual height of the screen.
88      */
89     uint32_t GetVirtualHeight() const;
90 
91     /**
92      * @brief Get virtual pixel ratio of the screen.
93      *
94      * @return Virtual pixel ratio of the screen.
95      */
96     float GetVirtualPixelRatio() const;
97 
98     /**
99      * @brief Get the Rotation of the screen.
100      *
101      * @return The Rotation of the screen.
102      */
103     Rotation GetRotation() const;
104 
105     /**
106      * @brief Get the orientation of the screen.
107      *
108      * @return Orientation of the screen.
109      */
110     Orientation GetOrientation() const;
111 
112     /**
113      * @brief Is a real screen.
114      *
115      * @return True means screen is real, false means the opposite.
116      */
117     bool IsReal() const;
118 
119     /**
120      * @brief Get screen parent id.
121      *
122      * @return Screen parent id.
123      */
124     ScreenId GetParentId() const;
125 
126     /**
127      * @brief Get screen serial number.
128      *
129      * @return Screen serial number.
130      */
131     std::string GetSerialNumber() const;
132 
133     /**
134      * @brief Get screen mode id.
135      *
136      * @return Screen mode id.
137      */
138     uint32_t GetModeId() const;
139 
140     /**
141      * @brief Get supported modes of the screen.
142      *
143      * @return Supported modes of the screen.
144      */
145     std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const;
146 
147     /**
148      * @brief Set screen active mode.
149      *
150      * @param modeId Mode id.
151      * @return DM_OK means set success, others means set failed.
152      */
153     DMError SetScreenActiveMode(uint32_t modeId);
154 
155     /**
156      * @brief Set orientation for the screen.
157      *
158      * @param orientation Orientation for the screen.
159      * @return DM_OK means set success, others means set failed.
160      */
161     DMError SetOrientation(Orientation orientation) const;
162 
163     /**
164      * @brief Set the density dpi of the screen.
165      *
166      * @param dpi Density dpi of the screen.
167      * @return DM_OK means set success, others means set failed.
168      */
169     DMError SetDensityDpi(uint32_t dpi) const;
170 
171     /**
172      * @brief Set the density dpi of the screen system window.
173      *
174      * @param dpi Density dpi of the screen.
175      * @return DM_OK means set success, others means set failed.
176      */
177     DMError SetDensityDpiSystem(uint32_t dpi) const;
178 
179     /**
180      * @brief Set the default density dpi of the screen system window.
181      *
182      * @param dpi Default density dpi of the screen.
183      * @return DM_OK means set success, others means set failed.
184      */
185     DMError SetDefaultDensityDpi(uint32_t dpi) const;
186 
187     /**
188      * @brief Get the screen info.
189      *
190      * @return Screen info.
191      */
192     sptr<ScreenInfo> GetScreenInfo() const;
193 
194     // colorspace, gamut
195     /**
196      * @brief Get the supported color gamuts of the screen.
197      *
198      * @param colorGamuts Supported color gamuts of the screen.
199      * @return DM_OK means get success, others means get failed.
200      */
201     DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const;
202 
203     /**
204      * @brief Get the color gamut of the screen.
205      *
206      * @param colorGamut Color gamut of the screen.
207      * @return DM_OK means get success, others means get failed.
208      */
209     DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const;
210 
211     /**
212      * @brief Set the color gamut of the screen.
213      *
214      * @param colorGamutIdx Color gamut of the screen.
215      * @return DM_OK means set success, others means set failed.
216      */
217     DMError SetScreenColorGamut(int32_t colorGamutIdx);
218 
219     /**
220      * @brief Get the gamut map of the screen.
221      *
222      * @param gamutMap Gamut map of the screen.
223      * @return DM_OK means get success, others means get failed.
224      */
225     DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const;
226 
227     /**
228      * @brief Set the gamut map of the screen.
229      *
230      * @param gamutMap Gamut map of the screen.
231      * @return DM_OK means set success, others means set failed.
232      */
233     DMError SetScreenGamutMap(ScreenGamutMap gamutMap);
234 
235     /**
236      * @brief Set color transform for the screen.
237      *
238      * @return DM_OK means set success, others means set failed.
239      */
240     DMError SetScreenColorTransform();
241 
242     /**
243      * @brief Set the resolution for the screen.
244      *
245      * @param width width of the screen
246      * @param height height of the screen
247      * @param dpi dpi of the screen
248      * @return DM_OK means set success, others means set failed.
249      */
250     DMError SetResolution(uint32_t width, uint32_t height, uint32_t dpi) const;
251 
252     /**
253      * @brief get Density in current resolution
254      * @param virtualPixelRatio virtualPixelRatio of the screen
255      * @return DM_OK means set success, others means set failed.
256      */
257     DMError GetDensityInCurResolution(float& virtualPixelRatio) const;
258 
259     /**
260      * @brief Get the pixel format of the screen.
261      *
262      * @return DM_OK means set success, others means set failed.
263      */
264     DMError GetPixelFormat(GraphicPixelFormat& pixelFormat) const;
265 
266     /**
267      * @brief Set the pixel format of the screen.
268      *
269      * @return DM_OK means set success, others means set failed.
270      */
271     DMError SetPixelFormat(GraphicPixelFormat pixelFormat);
272 
273     /**
274      * @brief Get the supported HDR format of the screen.
275      *
276      * @param colorSpaces Supported HDR format of the screen.
277      * @return DM_OK means get success, others means get failed.
278      */
279     DMError GetSupportedHDRFormats(std::vector<ScreenHDRFormat>& hdrFormats) const;
280 
281     /**
282      * @brief Get the HDR format of the screen.
283      *
284      * @return DM_OK means set success, others means set failed.
285      */
286     DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const;
287 
288     /**
289      * @brief Set the HDR format of the screen.
290      *
291      * @return DM_OK means set success, others means set failed.
292      */
293     DMError SetScreenHDRFormat(int32_t modeIdx);
294 
295     /**
296      * @brief Get the supported color space of the screen.
297      *
298      * @param colorSpaces Supported color space of the screen.
299      * @return DM_OK means get success, others means get failed.
300      */
301     DMError GetSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType>& colorSpaces) const;
302 
303     /**
304      * @brief Get the color space of the screen.
305      *
306      * @param colorSpace Color space of the screen.
307      * @return DM_OK means get success, others means get failed.
308      */
309     DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const;
310 
311     /**
312      * @brief Set the color space of the screen.
313      *
314      * @param colorSpace Color space of the screen.
315      * @return DM_OK means set success, others means set failed.
316      */
317     DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace);
318 
319 protected:
320     // No more methods or variables can be defined here.
321     explicit Screen(sptr<ScreenInfo> info);
322     void UpdateScreenInfo() const;
323     void UpdateScreenInfo(sptr<ScreenInfo> info) const;
324 private:
325     // No more methods or variables can be defined here.
326     class Impl;
327     sptr<Impl> pImpl_;
328 };
329 } // namespace OHOS::Rosen
330 
331 #endif // FOUNDATION_DM_SCREEN_H