• 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 <screen_manager/screen_types.h>
20 #include <string>
21 #include <surface.h>
22 #include <vector>
23 
24 #include "dm_common.h"
25 #include "noncopyable.h"
26 
27 namespace OHOS::Rosen {
28 class ScreenInfo;
29 
30 struct Point {
31     int32_t posX_;
32     int32_t posY_;
PointPoint33     Point() : posX_(0), posY_(0) {};
PointPoint34     Point(int32_t posX, int32_t posY) : posX_(posX), posY_(posY) {};
35 };
36 
37 struct SupportedScreenModes : public RefBase {
38     uint32_t width_;
39     uint32_t height_;
40     uint32_t refreshRate_;
41 };
42 
43 struct VirtualScreenOption {
44     std::string name_;
45     uint32_t width_;
46     uint32_t height_;
47     float density_;
48     sptr<Surface> surface_;
49     int32_t flags_;
50     bool isForShot_ {true};
51 };
52 
53 struct ExpandOption {
54     ScreenId screenId_;
55     uint32_t startX_;
56     uint32_t startY_;
57 };
58 
59 class Screen : public RefBase {
60 friend class ScreenManager;
61 public:
62     ~Screen();
63     Screen(const Screen&) = delete;
64     Screen(Screen&&) = delete;
65     Screen& operator=(const Screen&) = delete;
66     Screen& operator=(Screen&&) = delete;
67     bool IsGroup() const;
68     std::string GetName() const;
69 
70     /**
71      * @brief Get screen id.
72      *
73      * @return Screen id.
74      */
75     ScreenId GetId() const;
76 
77     /**
78      * @brief Get width of the screen.
79      *
80      * @return Width of the screen.
81      */
82     uint32_t GetWidth() const;
83 
84     /**
85      * @brief Get height of the screen.
86      *
87      * @return Height of the screen.
88      */
89     uint32_t GetHeight() const;
90 
91     /**
92      * @brief Get virtual width of the screen.
93      *
94      * @return Virtual width of the screen.
95      */
96     uint32_t GetVirtualWidth() const;
97 
98     /**
99      * @brief Get virtual height of the screen.
100      *
101      * @return Virtual height of the screen.
102      */
103     uint32_t GetVirtualHeight() const;
104 
105     /**
106      * @brief Get virtual pixel ratio of the screen.
107      *
108      * @return Virtual pixel ratio of the screen.
109      */
110     float GetVirtualPixelRatio() const;
111 
112     /**
113      * @brief Get the Rotation of the screen.
114      *
115      * @return The Rotation of the screen.
116      */
117     Rotation GetRotation() const;
118 
119     /**
120      * @brief Get the orientation of the screen.
121      *
122      * @return Orientation of the screen.
123      */
124     Orientation GetOrientation() const;
125 
126     /**
127      * @brief Is a real screen.
128      *
129      * @return True means screen is real, false means the opposite.
130      */
131     bool IsReal() const;
132 
133     /**
134      * @brief Get screen parent id.
135      *
136      * @return Screen parent id.
137      */
138     ScreenId GetParentId() const;
139 
140     /**
141      * @brief Get screen mode id.
142      *
143      * @return Screen mode id.
144      */
145     uint32_t GetModeId() const;
146 
147     /**
148      * @brief Get supported modes of the screen.
149      *
150      * @return Supported modes of the screen.
151      */
152     std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const;
153 
154     /**
155      * @brief Set screen active mode.
156      *
157      * @param moddId Mode id.
158      * @return DM_OK means set success, others means set failed.
159      */
160     DMError SetScreenActiveMode(uint32_t modeId);
161 
162     /**
163      * @brief Set orientation for the screen.
164      *
165      * @param orientation Orientation for the screen.
166      * @return DM_OK means set success, others means set failed.
167      */
168     DMError SetOrientation(Orientation orientation) const;
169 
170     /**
171      * @brief Set the density dpi of the screen.
172      *
173      * @param dpi Density dpi of the screen.
174      * @return DM_OK means set success, others means set failed.
175      */
176     DMError SetDensityDpi(uint32_t dpi) const;
177 
178     /**
179      * @brief Get the screen info.
180      *
181      * @return Screen info.
182      */
183     sptr<ScreenInfo> GetScreenInfo() const;
184 
185     // colorspace, gamut
186     /**
187      * @brief Get the supported color gamuts of the screen.
188      *
189      * @param colorGamuts Supported color gamuts of the screen.
190      * @return DM_OK means get success, others means get failed.
191      */
192     DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const;
193 
194     /**
195      * @brief Get the color gamut of the screen.
196      *
197      * @param colorGamut Color gamut of the screen.
198      * @return DM_OK means get success, others means get failed.
199      */
200     DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const;
201 
202     /**
203      * @brief Set the color gamut of the screen.
204      *
205      * @param colorGamutIdx Color gamut of the screen.
206      * @return DM_OK means set success, others means set failed.
207      */
208     DMError SetScreenColorGamut(int32_t colorGamutIdx);
209 
210     /**
211      * @brief Get the gamut map of the screen.
212      *
213      * @param gamutMap Gamut map of the screen.
214      * @return DM_OK means get success, others means get failed.
215      */
216     DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const;
217 
218     /**
219      * @brief Set the gamut map of the screen.
220      *
221      * @param gamutMap Gamut map of the screen.
222      * @return DM_OK means set success, others means set failed.
223      */
224     DMError SetScreenGamutMap(ScreenGamutMap gamutMap);
225 
226     /**
227      * @brief Set color transform for the screen.
228      *
229      * @return DM_OK means set success, others means set failed.
230      */
231     DMError SetScreenColorTransform();
232 protected:
233     // No more methods or variables can be defined here.
234     explicit Screen(sptr<ScreenInfo> info);
235     void UpdateScreenInfo() const;
236     void UpdateScreenInfo(sptr<ScreenInfo> info) const;
237 private:
238     // No more methods or variables can be defined here.
239     class Impl;
240     sptr<Impl> pImpl_;
241 };
242 } // namespace OHOS::Rosen
243 
244 #endif // FOUNDATION_DM_SCREEN_H