• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 HDI_BACKEND_HDI_SCREEN_H
17 #define HDI_BACKEND_HDI_SCREEN_H
18 
19 #include <functional>
20 #include <vector>
21 #include <refbase.h>
22 
23 #include "hdi_layer.h"
24 #include "hdi_device.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 
29 using OnVsyncFunc = std::function<void()>;
30 
31 class HdiScreen {
32 public:
33     HdiScreen(uint32_t screenId);
34     virtual ~HdiScreen();
35 
36     static std::unique_ptr<HdiScreen> CreateHdiScreen(uint32_t screenId);
37     bool Init();
38 
39     int32_t GetScreenCapability(GraphicDisplayCapability &info) const;
40     int32_t GetScreenSupportedModes(std::vector<GraphicDisplayModeInfo> &modes) const;
41     int32_t GetScreenMode(uint32_t &modeId) const;
42     int32_t SetScreenMode(uint32_t modeId) const;
43     int32_t GetScreenPowerStatus(GraphicDispPowerStatus &status) const;
44     int32_t SetScreenPowerStatus(GraphicDispPowerStatus status) const;
45     int32_t GetScreenBacklight(uint32_t &level) const;
46     int32_t SetScreenBacklight(uint32_t level) const;
47     int32_t SetScreenVsyncEnabled(bool enabled) const;
48 
49     int32_t GetScreenSupportedColorGamuts(std::vector<GraphicColorGamut> &gamuts) const;
50     int32_t SetScreenColorGamut(GraphicColorGamut gamut) const;
51     int32_t GetScreenColorGamut(GraphicColorGamut &gamut) const;
52     int32_t SetScreenGamutMap(GraphicGamutMap gamutMap) const;
53     int32_t GetScreenGamutMap(GraphicGamutMap &gamutMap) const;
54     int32_t SetScreenColorTransform(const std::vector<float>& matrix) const;
55     int32_t GetHDRCapabilityInfos(GraphicHDRCapability &info) const;
56     int32_t GetSupportedMetaDataKey(std::vector<GraphicHDRMetadataKey> &keys) const;
57 
58     static void OnVsync(uint32_t sequence, uint64_t ns, void *data);
59 
60     /* only used for mock and fuzz tests */
61     bool SetHdiDevice(HdiDevice* device);
62 
63 private:
64     uint32_t screenId_;
65     HdiDevice *device_ = nullptr;
66 
67     void Destroy();
68 };
69 
70 } // namespace Rosen
71 } // namespace OHOS
72 
73 #endif // HDI_BACKEND_HDI_SCREEN_H