1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#ifndef FOUNDATION_DM_SCREEN_H
17e0dac50fSopenharmony_ci#define FOUNDATION_DM_SCREEN_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include <cstdint>
20e0dac50fSopenharmony_ci#include <screen_manager/screen_types.h>
21e0dac50fSopenharmony_ci#include <string>
22e0dac50fSopenharmony_ci#include <surface.h>
23e0dac50fSopenharmony_ci#include <vector>
24e0dac50fSopenharmony_ci
25e0dac50fSopenharmony_ci#include "dm_common.h"
26e0dac50fSopenharmony_ci#include "noncopyable.h"
27e0dac50fSopenharmony_ci
28e0dac50fSopenharmony_cinamespace OHOS::Rosen {
29e0dac50fSopenharmony_ciclass ScreenInfo;
30e0dac50fSopenharmony_ci
31e0dac50fSopenharmony_cistruct VirtualScreenOption {
32e0dac50fSopenharmony_ci    std::string name_;
33e0dac50fSopenharmony_ci    uint32_t width_;
34e0dac50fSopenharmony_ci    uint32_t height_;
35e0dac50fSopenharmony_ci    float density_;
36e0dac50fSopenharmony_ci    sptr<Surface> surface_;
37e0dac50fSopenharmony_ci    int32_t flags_;
38e0dac50fSopenharmony_ci    bool isForShot_ {true};
39e0dac50fSopenharmony_ci    std::vector<uint64_t> missionIds_ {};
40e0dac50fSopenharmony_ci};
41e0dac50fSopenharmony_ci
42e0dac50fSopenharmony_cienum class VirtualScreenFlag : uint32_t {
43e0dac50fSopenharmony_ci    DEFAULT = 0,
44e0dac50fSopenharmony_ci    CAST = 1,
45e0dac50fSopenharmony_ci    MAX = 2,
46e0dac50fSopenharmony_ci};
47e0dac50fSopenharmony_ci
48e0dac50fSopenharmony_ciclass Screen : public RefBase {
49e0dac50fSopenharmony_cifriend class ScreenManager;
50e0dac50fSopenharmony_cipublic:
51e0dac50fSopenharmony_ci    ~Screen();
52e0dac50fSopenharmony_ci    Screen(const Screen&) = delete;
53e0dac50fSopenharmony_ci    Screen(Screen&&) = delete;
54e0dac50fSopenharmony_ci    Screen& operator=(const Screen&) = delete;
55e0dac50fSopenharmony_ci    Screen& operator=(Screen&&) = delete;
56e0dac50fSopenharmony_ci    bool IsGroup() const;
57e0dac50fSopenharmony_ci    std::string GetName() const;
58e0dac50fSopenharmony_ci
59e0dac50fSopenharmony_ci    /**
60e0dac50fSopenharmony_ci     * @brief Get screen id.
61e0dac50fSopenharmony_ci     *
62e0dac50fSopenharmony_ci     * @return Screen id.
63e0dac50fSopenharmony_ci     */
64e0dac50fSopenharmony_ci    ScreenId GetId() const;
65e0dac50fSopenharmony_ci
66e0dac50fSopenharmony_ci    /**
67e0dac50fSopenharmony_ci     * @brief Get width of the screen.
68e0dac50fSopenharmony_ci     *
69e0dac50fSopenharmony_ci     * @return Width of the screen.
70e0dac50fSopenharmony_ci     */
71e0dac50fSopenharmony_ci    uint32_t GetWidth() const;
72e0dac50fSopenharmony_ci
73e0dac50fSopenharmony_ci    /**
74e0dac50fSopenharmony_ci     * @brief Get height of the screen.
75e0dac50fSopenharmony_ci     *
76e0dac50fSopenharmony_ci     * @return Height of the screen.
77e0dac50fSopenharmony_ci     */
78e0dac50fSopenharmony_ci    uint32_t GetHeight() const;
79e0dac50fSopenharmony_ci
80e0dac50fSopenharmony_ci    /**
81e0dac50fSopenharmony_ci     * @brief Get virtual width of the screen.
82e0dac50fSopenharmony_ci     *
83e0dac50fSopenharmony_ci     * @return Virtual width of the screen.
84e0dac50fSopenharmony_ci     */
85e0dac50fSopenharmony_ci    uint32_t GetVirtualWidth() const;
86e0dac50fSopenharmony_ci
87e0dac50fSopenharmony_ci    /**
88e0dac50fSopenharmony_ci     * @brief Get virtual height of the screen.
89e0dac50fSopenharmony_ci     *
90e0dac50fSopenharmony_ci     * @return Virtual height of the screen.
91e0dac50fSopenharmony_ci     */
92e0dac50fSopenharmony_ci    uint32_t GetVirtualHeight() const;
93e0dac50fSopenharmony_ci
94e0dac50fSopenharmony_ci    /**
95e0dac50fSopenharmony_ci     * @brief Get virtual pixel ratio of the screen.
96e0dac50fSopenharmony_ci     *
97e0dac50fSopenharmony_ci     * @return Virtual pixel ratio of the screen.
98e0dac50fSopenharmony_ci     */
99e0dac50fSopenharmony_ci    float GetVirtualPixelRatio() const;
100e0dac50fSopenharmony_ci
101e0dac50fSopenharmony_ci    /**
102e0dac50fSopenharmony_ci     * @brief Get the Rotation of the screen.
103e0dac50fSopenharmony_ci     *
104e0dac50fSopenharmony_ci     * @return The Rotation of the screen.
105e0dac50fSopenharmony_ci     */
106e0dac50fSopenharmony_ci    Rotation GetRotation() const;
107e0dac50fSopenharmony_ci
108e0dac50fSopenharmony_ci    /**
109e0dac50fSopenharmony_ci     * @brief Get the orientation of the screen.
110e0dac50fSopenharmony_ci     *
111e0dac50fSopenharmony_ci     * @return Orientation of the screen.
112e0dac50fSopenharmony_ci     */
113e0dac50fSopenharmony_ci    Orientation GetOrientation() const;
114e0dac50fSopenharmony_ci
115e0dac50fSopenharmony_ci    /**
116e0dac50fSopenharmony_ci     * @brief Is a real screen.
117e0dac50fSopenharmony_ci     *
118e0dac50fSopenharmony_ci     * @return True means screen is real, false means the opposite.
119e0dac50fSopenharmony_ci     */
120e0dac50fSopenharmony_ci    bool IsReal() const;
121e0dac50fSopenharmony_ci
122e0dac50fSopenharmony_ci    /**
123e0dac50fSopenharmony_ci     * @brief Get screen parent id.
124e0dac50fSopenharmony_ci     *
125e0dac50fSopenharmony_ci     * @return Screen parent id.
126e0dac50fSopenharmony_ci     */
127e0dac50fSopenharmony_ci    ScreenId GetParentId() const;
128e0dac50fSopenharmony_ci
129e0dac50fSopenharmony_ci    /**
130e0dac50fSopenharmony_ci     * @brief Get screen mode id.
131e0dac50fSopenharmony_ci     *
132e0dac50fSopenharmony_ci     * @return Screen mode id.
133e0dac50fSopenharmony_ci     */
134e0dac50fSopenharmony_ci    uint32_t GetModeId() const;
135e0dac50fSopenharmony_ci
136e0dac50fSopenharmony_ci    /**
137e0dac50fSopenharmony_ci     * @brief Get supported modes of the screen.
138e0dac50fSopenharmony_ci     *
139e0dac50fSopenharmony_ci     * @return Supported modes of the screen.
140e0dac50fSopenharmony_ci     */
141e0dac50fSopenharmony_ci    std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const;
142e0dac50fSopenharmony_ci
143e0dac50fSopenharmony_ci    /**
144e0dac50fSopenharmony_ci     * @brief Set screen active mode.
145e0dac50fSopenharmony_ci     *
146e0dac50fSopenharmony_ci     * @param modeId Mode id.
147e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
148e0dac50fSopenharmony_ci     */
149e0dac50fSopenharmony_ci    DMError SetScreenActiveMode(uint32_t modeId);
150e0dac50fSopenharmony_ci
151e0dac50fSopenharmony_ci    /**
152e0dac50fSopenharmony_ci     * @brief Set orientation for the screen.
153e0dac50fSopenharmony_ci     *
154e0dac50fSopenharmony_ci     * @param orientation Orientation for the screen.
155e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
156e0dac50fSopenharmony_ci     */
157e0dac50fSopenharmony_ci    DMError SetOrientation(Orientation orientation) const;
158e0dac50fSopenharmony_ci
159e0dac50fSopenharmony_ci    /**
160e0dac50fSopenharmony_ci     * @brief Set the density dpi of the screen.
161e0dac50fSopenharmony_ci     *
162e0dac50fSopenharmony_ci     * @param dpi Density dpi of the screen.
163e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
164e0dac50fSopenharmony_ci     */
165e0dac50fSopenharmony_ci    DMError SetDensityDpi(uint32_t dpi) const;
166e0dac50fSopenharmony_ci
167e0dac50fSopenharmony_ci    /**
168e0dac50fSopenharmony_ci     * @brief Set the density dpi of the screen system window.
169e0dac50fSopenharmony_ci     *
170e0dac50fSopenharmony_ci     * @param dpi Density dpi of the screen.
171e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
172e0dac50fSopenharmony_ci     */
173e0dac50fSopenharmony_ci    DMError SetDensityDpiSystem(uint32_t dpi) const;
174e0dac50fSopenharmony_ci
175e0dac50fSopenharmony_ci    /**
176e0dac50fSopenharmony_ci     * @brief Get the screen info.
177e0dac50fSopenharmony_ci     *
178e0dac50fSopenharmony_ci     * @return Screen info.
179e0dac50fSopenharmony_ci     */
180e0dac50fSopenharmony_ci    sptr<ScreenInfo> GetScreenInfo() const;
181e0dac50fSopenharmony_ci
182e0dac50fSopenharmony_ci    // colorspace, gamut
183e0dac50fSopenharmony_ci    /**
184e0dac50fSopenharmony_ci     * @brief Get the supported color gamuts of the screen.
185e0dac50fSopenharmony_ci     *
186e0dac50fSopenharmony_ci     * @param colorGamuts Supported color gamuts of the screen.
187e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
188e0dac50fSopenharmony_ci     */
189e0dac50fSopenharmony_ci    DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const;
190e0dac50fSopenharmony_ci
191e0dac50fSopenharmony_ci    /**
192e0dac50fSopenharmony_ci     * @brief Get the color gamut of the screen.
193e0dac50fSopenharmony_ci     *
194e0dac50fSopenharmony_ci     * @param colorGamut Color gamut of the screen.
195e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
196e0dac50fSopenharmony_ci     */
197e0dac50fSopenharmony_ci    DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const;
198e0dac50fSopenharmony_ci
199e0dac50fSopenharmony_ci    /**
200e0dac50fSopenharmony_ci     * @brief Set the color gamut of the screen.
201e0dac50fSopenharmony_ci     *
202e0dac50fSopenharmony_ci     * @param colorGamutIdx Color gamut of the screen.
203e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
204e0dac50fSopenharmony_ci     */
205e0dac50fSopenharmony_ci    DMError SetScreenColorGamut(int32_t colorGamutIdx);
206e0dac50fSopenharmony_ci
207e0dac50fSopenharmony_ci    /**
208e0dac50fSopenharmony_ci     * @brief Get the gamut map of the screen.
209e0dac50fSopenharmony_ci     *
210e0dac50fSopenharmony_ci     * @param gamutMap Gamut map of the screen.
211e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
212e0dac50fSopenharmony_ci     */
213e0dac50fSopenharmony_ci    DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const;
214e0dac50fSopenharmony_ci
215e0dac50fSopenharmony_ci    /**
216e0dac50fSopenharmony_ci     * @brief Set the gamut map of the screen.
217e0dac50fSopenharmony_ci     *
218e0dac50fSopenharmony_ci     * @param gamutMap Gamut map of the screen.
219e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
220e0dac50fSopenharmony_ci     */
221e0dac50fSopenharmony_ci    DMError SetScreenGamutMap(ScreenGamutMap gamutMap);
222e0dac50fSopenharmony_ci
223e0dac50fSopenharmony_ci    /**
224e0dac50fSopenharmony_ci     * @brief Set color transform for the screen.
225e0dac50fSopenharmony_ci     *
226e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
227e0dac50fSopenharmony_ci     */
228e0dac50fSopenharmony_ci    DMError SetScreenColorTransform();
229e0dac50fSopenharmony_ci
230e0dac50fSopenharmony_ci    /**
231e0dac50fSopenharmony_ci     * @brief Set the resolution for the screen.
232e0dac50fSopenharmony_ci     *
233e0dac50fSopenharmony_ci     * @param width width of the screen
234e0dac50fSopenharmony_ci     * @param height height of the screen
235e0dac50fSopenharmony_ci     * @param dpi dpi of the screen
236e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
237e0dac50fSopenharmony_ci     */
238e0dac50fSopenharmony_ci    DMError SetResolution(uint32_t width, uint32_t height, uint32_t dpi) const;
239e0dac50fSopenharmony_ci
240e0dac50fSopenharmony_ci    /**
241e0dac50fSopenharmony_ci     * @brief get Density in current resolution
242e0dac50fSopenharmony_ci     * @param virtualPixelRatio virtualPixelRatio of the screen
243e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
244e0dac50fSopenharmony_ci     */
245e0dac50fSopenharmony_ci    DMError GetDensityInCurResolution(float& virtualPixelRatio) const;
246e0dac50fSopenharmony_ci
247e0dac50fSopenharmony_ci    /**
248e0dac50fSopenharmony_ci     * @brief Get the pixel format of the screen.
249e0dac50fSopenharmony_ci     *
250e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
251e0dac50fSopenharmony_ci     */
252e0dac50fSopenharmony_ci    DMError GetPixelFormat(GraphicPixelFormat& pixelFormat) const;
253e0dac50fSopenharmony_ci
254e0dac50fSopenharmony_ci    /**
255e0dac50fSopenharmony_ci     * @brief Set the pixel format of the screen.
256e0dac50fSopenharmony_ci     *
257e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
258e0dac50fSopenharmony_ci     */
259e0dac50fSopenharmony_ci    DMError SetPixelFormat(GraphicPixelFormat pixelFormat);
260e0dac50fSopenharmony_ci
261e0dac50fSopenharmony_ci    /**
262e0dac50fSopenharmony_ci     * @brief Get the supported HDR format of the screen.
263e0dac50fSopenharmony_ci     *
264e0dac50fSopenharmony_ci     * @param colorSpaces Supported HDR format of the screen.
265e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
266e0dac50fSopenharmony_ci     */
267e0dac50fSopenharmony_ci    DMError GetSupportedHDRFormats(std::vector<ScreenHDRFormat>& hdrFormats) const;
268e0dac50fSopenharmony_ci
269e0dac50fSopenharmony_ci    /**
270e0dac50fSopenharmony_ci     * @brief Get the HDR format of the screen.
271e0dac50fSopenharmony_ci     *
272e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
273e0dac50fSopenharmony_ci     */
274e0dac50fSopenharmony_ci    DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const;
275e0dac50fSopenharmony_ci
276e0dac50fSopenharmony_ci    /**
277e0dac50fSopenharmony_ci     * @brief Set the HDR format of the screen.
278e0dac50fSopenharmony_ci     *
279e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
280e0dac50fSopenharmony_ci     */
281e0dac50fSopenharmony_ci    DMError SetScreenHDRFormat(int32_t modeIdx);
282e0dac50fSopenharmony_ci
283e0dac50fSopenharmony_ci    /**
284e0dac50fSopenharmony_ci     * @brief Get the supported color space of the screen.
285e0dac50fSopenharmony_ci     *
286e0dac50fSopenharmony_ci     * @param colorSpaces Supported color space of the screen.
287e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
288e0dac50fSopenharmony_ci     */
289e0dac50fSopenharmony_ci    DMError GetSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType>& colorSpaces) const;
290e0dac50fSopenharmony_ci
291e0dac50fSopenharmony_ci    /**
292e0dac50fSopenharmony_ci     * @brief Get the color space of the screen.
293e0dac50fSopenharmony_ci     *
294e0dac50fSopenharmony_ci     * @param colorSpace Color space of the screen.
295e0dac50fSopenharmony_ci     * @return DM_OK means get success, others means get failed.
296e0dac50fSopenharmony_ci     */
297e0dac50fSopenharmony_ci    DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const;
298e0dac50fSopenharmony_ci
299e0dac50fSopenharmony_ci    /**
300e0dac50fSopenharmony_ci     * @brief Set the color space of the screen.
301e0dac50fSopenharmony_ci     *
302e0dac50fSopenharmony_ci     * @param colorSpace Color space of the screen.
303e0dac50fSopenharmony_ci     * @return DM_OK means set success, others means set failed.
304e0dac50fSopenharmony_ci     */
305e0dac50fSopenharmony_ci    DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace);
306e0dac50fSopenharmony_ci
307e0dac50fSopenharmony_ciprotected:
308e0dac50fSopenharmony_ci    // No more methods or variables can be defined here.
309e0dac50fSopenharmony_ci    explicit Screen(sptr<ScreenInfo> info);
310e0dac50fSopenharmony_ci    void UpdateScreenInfo() const;
311e0dac50fSopenharmony_ci    void UpdateScreenInfo(sptr<ScreenInfo> info) const;
312e0dac50fSopenharmony_ciprivate:
313e0dac50fSopenharmony_ci    // No more methods or variables can be defined here.
314e0dac50fSopenharmony_ci    class Impl;
315e0dac50fSopenharmony_ci    sptr<Impl> pImpl_;
316e0dac50fSopenharmony_ci};
317e0dac50fSopenharmony_ci} // namespace OHOS::Rosen
318e0dac50fSopenharmony_ci
319e0dac50fSopenharmony_ci#endif // FOUNDATION_DM_SCREEN_H