• 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 HDI_BACKEND_HDI_DEVICE_IMPL_H
17 #define HDI_BACKEND_HDI_DEVICE_IMPL_H
18 
19 #include "hdi_device.h"
20 #include "v1_2/include/idisplay_composer_interface.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class HdiDeviceImpl : public HdiDevice {
25 public:
26     HdiDeviceImpl();
27     virtual ~HdiDeviceImpl();
28     bool Init();
29     /* set & get device screen info begin */
30     int32_t RegHotPlugCallback(HotPlugCallback callback, void *data) override;
31     int32_t RegRefreshCallback(RefreshCallback callback, void *data) override;
32     int32_t RegScreenVBlankCallback(uint32_t screenId, VBlankCallback callback, void *data) override;
33     bool RegHwcDeadCallback(OnHwcDeadCallback callback, void *data) override;
34     int32_t RegScreenVBlankIdleCallback(OnVBlankIdleCallback callback, void *data) override;
35     int32_t SetScreenConstraint(uint32_t screenId, uint64_t frameId, uint64_t timestamp, uint32_t type) override;
36     int32_t GetDisplayProperty(uint32_t screenId, uint32_t propertyId, uint64_t& propertyValue) override;
37     int32_t GetScreenCapability(uint32_t screenId, GraphicDisplayCapability &info) override;
38     int32_t GetScreenSupportedModes(uint32_t screenId, std::vector<GraphicDisplayModeInfo> &modes) override;
39     int32_t GetScreenMode(uint32_t screenId, uint32_t &modeId) override;
40     int32_t SetScreenMode(uint32_t screenId, uint32_t modeId) override;
41     int32_t SetScreenActiveRect(uint32_t screenId, const GraphicIRect& activeRect) override;
42     int32_t SetScreenOverlayResolution(uint32_t screenId, uint32_t width, uint32_t height) override;
43     int32_t GetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus &status) override;
44     int32_t SetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus status) override;
45     int32_t GetScreenBacklight(uint32_t screenId, uint32_t &level) override;
46     int32_t SetScreenBacklight(uint32_t screenId, uint32_t level) override;
47     int32_t PrepareScreenLayers(uint32_t screenId, bool &needFlushFb) override;
48     int32_t GetScreenCompChange(uint32_t screenId, std::vector<uint32_t> &layersId,
49                                 std::vector<int32_t> &types) override;
50     int32_t SetScreenClientBuffer(uint32_t screenId, const BufferHandle *buffer, uint32_t cacheIndex,
51                                   const sptr<SyncFence> &fence) override;
52     int32_t SetScreenClientBufferCacheCount(uint32_t screen, uint32_t count) override;
53     int32_t SetScreenClientDamage(uint32_t screenId, const std::vector<GraphicIRect> &damageRect) override;
54     int32_t SetScreenVsyncEnabled(uint32_t screenId, bool enabled) override;
55     int32_t GetScreenSupportedColorGamuts(uint32_t screenId, std::vector<GraphicColorGamut> &gamuts) override;
56     int32_t SetScreenColorGamut(uint32_t screenId, GraphicColorGamut gamut) override;
57     int32_t GetScreenColorGamut(uint32_t screenId, GraphicColorGamut &gamut) override;
58     int32_t SetScreenGamutMap(uint32_t screenId, GraphicGamutMap gamutMap) override;
59     int32_t GetScreenGamutMap(uint32_t screenId, GraphicGamutMap &gamutMap) override;
60     int32_t SetScreenColorTransform(uint32_t screenId, const std::vector<float>& matrix) override;
61     int32_t GetHDRCapabilityInfos(uint32_t screenId, GraphicHDRCapability &info) override;
62     int32_t GetSupportedMetaDataKey(uint32_t screenId, std::vector<GraphicHDRMetadataKey> &keys) override;
63     int32_t Commit(uint32_t screenId, sptr<SyncFence> &fence) override;
64     int32_t CommitAndGetReleaseFence(uint32_t screenId, sptr<SyncFence> &fence, int32_t &skipState, bool &needFlush,
65         std::vector<uint32_t>& layers, std::vector<sptr<SyncFence>>& fences, bool isValidated) override;
66     int32_t GetDisplayIdentificationData(uint32_t screenId, uint8_t& outPort, std::vector<uint8_t>& edidData) override;
67     /* set & get device screen info end */
68 
69     /* set & get device layer info begin */
70     int32_t SetLayerAlpha(uint32_t screenId, uint32_t layerId, const GraphicLayerAlpha &alpha) override;
71     int32_t SetLayerSize(uint32_t screenId, uint32_t layerId, const GraphicIRect &layerRect) override;
72     int32_t SetTransformMode(uint32_t screenId, uint32_t layerId, GraphicTransformType type) override;
73     int32_t SetLayerVisibleRegion(uint32_t screenId, uint32_t layerId,
74                                   const std::vector<GraphicIRect> &visibles) override;
75     int32_t SetLayerDirtyRegion(uint32_t screenId, uint32_t layerId,
76                                 const std::vector<GraphicIRect> &dirtyRegions) override;
77     int32_t SetLayerBuffer(uint32_t screenId, uint32_t layerId, const GraphicLayerBuffer &layerBuffer) override;
78     int32_t SetLayerCompositionType(uint32_t screenId, uint32_t layerId, GraphicCompositionType type) override;
79     int32_t SetLayerBlendType(uint32_t screenId, uint32_t layerId, GraphicBlendType type) override;
80     int32_t SetLayerCrop(uint32_t screenId, uint32_t layerId, const GraphicIRect &crop) override;
81     int32_t SetLayerZorder(uint32_t screenId, uint32_t layerId, uint32_t zorder) override;
82     int32_t SetLayerPreMulti(uint32_t screenId, uint32_t layerId, bool isPreMulti) override;
83     int32_t SetLayerColor(uint32_t screenId, uint32_t layerId, GraphicLayerColor layerColor) override;
84     int32_t SetLayerColorTransform(uint32_t screenId, uint32_t layerId, const std::vector<float> &matrix) override;
85     int32_t SetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace colorSpace) override;
86     int32_t GetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace &colorSpace) override;
87     int32_t SetLayerMetaData(uint32_t screenId, uint32_t layerId,
88                              const std::vector<GraphicHDRMetaData> &metaData) override;
89     int32_t SetLayerMetaDataSet(uint32_t screenId, uint32_t layerId, GraphicHDRMetadataKey key,
90                                 const std::vector<uint8_t> &metaData) override;
91     std::vector<std::string>& GetSupportedLayerPerFrameParameterKey() override;
92     int32_t SetLayerPerFrameParameter(uint32_t devId, uint32_t layerId, const std::string& key,
93                                       const std::vector<int8_t>& value) override;
94     int32_t SetLayerPerFrameParameterSmq(uint32_t devId, uint32_t layerId, const std::string& key,
95                                          const std::vector<int8_t>& value) override;
96     int32_t SetDisplayPerFrameParameterSmq(uint32_t devId, const std::string& key,
97                                            const std::vector<int8_t>& value) override;
98     int32_t SetLayerTunnelHandle(uint32_t screenId, uint32_t layerId, GraphicExtDataHandle *handle) override;
99     int32_t GetSupportedPresentTimestampType(uint32_t screenId, uint32_t layerId,
100                                              GraphicPresentTimestampType &type) override;
101     int32_t GetPresentTimestamp(uint32_t screenId, uint32_t layerId, GraphicPresentTimestamp &timestamp) override;
102     int32_t SetLayerMaskInfo(uint32_t screenId, uint32_t layerId, uint32_t maskInfo) override;
103     /* set & get device layer info end */
104 
105     int32_t CreateLayer(uint32_t screenId, const GraphicLayerInfo &layerInfo, uint32_t cacheCount,
106                         uint32_t &layerId) override;
107     int32_t CloseLayer(uint32_t screenId, uint32_t layerId) override;
108     int32_t ClearLayerBuffer(uint32_t screenId, uint32_t layerId) override;
109     int32_t ClearClientBuffer(uint32_t screenId) override;
110     void Destroy() override;
111 
112 private:
113     HdiDeviceImpl(const HdiDeviceImpl& rhs) = delete;
114     HdiDeviceImpl& operator=(const HdiDeviceImpl& rhs) = delete;
115     HdiDeviceImpl(HdiDeviceImpl&& rhs) = delete;
116     HdiDeviceImpl& operator=(HdiDeviceImpl&& rhs) = delete;
117 
118     std::once_flag layerPerFrameParameterKeyCreateFlag_;
119     std::vector<std::string> layerPerFrameParameterKeys_{};
120 };
121 
122 } // namespace Rosen
123 } // namespace OHOS
124 #endif // HDI_BACKEND_HDI_DEVICE_IMPL_H