• 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_DMSERVER_DISPLAY_MANAGER_INTERFACE_H
17 #define FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <pixel_map.h>
21 #include <surface.h>
22 #include <set>
23 
24 #include "display_cutout_controller.h"
25 #include "display_info.h"
26 #include "dm_common.h"
27 #include "fold_screen_info.h"
28 #include "screen.h"
29 #include "screen_info.h"
30 #include "screen_group_info.h"
31 #include "display_manager_interface_code.h"
32 #include "zidl/display_manager_agent_interface.h"
33 
34 namespace OHOS::Rosen {
35 class IDisplayManager : public IRemoteBroker {
36 public:
37     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager");
38 
39     virtual sptr<DisplayInfo> GetDefaultDisplayInfo() = 0;
40     virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) = 0;
41     virtual sptr<DisplayInfo> GetDisplayInfoByScreen(ScreenId screenId) = 0;
42     virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) = 0;
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)43     virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { return false; };
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)44     virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) {};
45     virtual ScreenId CreateVirtualScreen(VirtualScreenOption option,
46         const sptr<IRemoteObject>& displayManagerAgent) = 0;
47     virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
48     virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) = 0;
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool rotate)49     virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate) { return DMError::DM_OK; }
SetVirtualMirrorScreenScaleMode(ScreenId screenId,ScreenScaleMode scaleMode)50     virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
51     {
52         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
53     }
54     virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0;
55     virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId,
56         DmErrorCode* errorCode = nullptr) = 0;
57     virtual std::shared_ptr<Media::PixelMap> GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode = nullptr)
58     {
59         *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
60         return nullptr;
61     }
62     virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
63     virtual DMError SetScreenRotationLockedFromJs(bool isLocked) = 0;
64     virtual DMError IsScreenRotationLocked(bool& isLocked) = 0;
65 
66     // colorspace, gamut
67     virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) = 0;
68     virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) = 0;
69     virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) = 0;
70     virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) = 0;
71     virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0;
72     virtual DMError SetScreenColorTransform(ScreenId screenId) = 0;
73 
GetPixelFormat(ScreenId screenId,GraphicPixelFormat & pixelFormat)74     virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
75     {
76         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
77     }
SetPixelFormat(ScreenId screenId,GraphicPixelFormat pixelFormat)78     virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
79     {
80         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
81     }
GetSupportedHDRFormats(ScreenId screenId,std::vector<ScreenHDRFormat> & hdrFormats)82     virtual DMError GetSupportedHDRFormats(ScreenId screenId,
83         std::vector<ScreenHDRFormat>& hdrFormats)
84     {
85         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
86     }
GetScreenHDRFormat(ScreenId screenId,ScreenHDRFormat & hdrFormat)87     virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
88     {
89         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
90     }
SetScreenHDRFormat(ScreenId screenId,int32_t modeIdx)91     virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
92     {
93         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
94     }
GetSupportedColorSpaces(ScreenId screenId,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)95     virtual DMError GetSupportedColorSpaces(ScreenId screenId,
96         std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
97     {
98         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
99     }
GetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType & colorSpace)100     virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)
101     {
102         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
103     }
SetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType colorSpace)104     virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)
105     {
106         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
107     }
108 
109     virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
110         DisplayManagerAgentType type) = 0;
111     virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
112         DisplayManagerAgentType type) = 0;
113     virtual bool WakeUpBegin(PowerStateChangeReason reason) = 0;
114     virtual bool WakeUpEnd() = 0;
115     virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
116     virtual bool SuspendEnd() = 0;
117     virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0;
118     virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
119     virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0;
120     virtual bool SetDisplayState(DisplayState state) = 0;
121     virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
122     virtual bool TryToCancelScreenOff() = 0;
SetScreenBrightness(uint64_t screenId,uint32_t level)123     virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; }
GetScreenBrightness(uint64_t screenId)124     virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; }
125     virtual std::vector<DisplayId> GetAllDisplayIds() = 0;
126     virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) = 0;
127     virtual void NotifyDisplayEvent(DisplayEvent event) = 0;
128     virtual bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) = 0;
129     virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
130     virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
131     virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) = 0;
132     virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
133         ScreenId& screenGroupId) = 0;
134     virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints,
135         ScreenId& screenGroupId) = 0;
136     virtual DMError StopMirror(const std::vector<ScreenId>& mirrorScreenIds) = 0;
137     virtual DMError StopExpand(const std::vector<ScreenId>& expandScreenIds) = 0;
DisableMirror(bool disableOrNot)138     virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; }
139     virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) = 0;
140     virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
141     virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0;
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)142     virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
143     {
144         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
145     }
146     virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) = 0;
147     virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) = 0;
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)148     virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { return DMError::DM_OK; }
149     virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId,
150         std::shared_ptr<class RSSurfaceNode>& surfaceNode, bool onTop = true) = 0;
151     virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId,
152         std::shared_ptr<class RSSurfaceNode>& surfaceNode) = 0;
GetAvailableArea(DisplayId displayId,DMRect & area)153     virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
IsFoldable()154     virtual bool IsFoldable() { return false; }
IsCaptured()155     virtual bool IsCaptured() { return false; }
156 
GetFoldStatus()157     virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; }
158 
GetFoldDisplayMode()159     virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; }
160 
SetFoldDisplayMode(const FoldDisplayMode)161     virtual void SetFoldDisplayMode(const FoldDisplayMode) {}
162 
SetFoldDisplayModeFromJs(const FoldDisplayMode)163     virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode) { return DMError::DM_OK; }
164 
SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)165     virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {}
166 
SetFoldStatusLocked(bool locked)167     virtual void SetFoldStatusLocked(bool locked) {}
168 
SetFoldStatusLockedFromJs(bool locked)169     virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; }
170 
GetCurrentFoldCreaseRegion()171     virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; }
172 
HasImmersiveWindow(bool & immersive)173     virtual DMError HasImmersiveWindow(bool& immersive) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
174 
175     // unique screen
MakeUniqueScreen(const std::vector<ScreenId> & screenIds)176     virtual DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) { return DMError::DM_OK; }
177 
GetVirtualScreenFlag(ScreenId screenId)178     virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId)
179     {
180         return VirtualScreenFlag::DEFAULT;
181     }
SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)182     virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
183     {
184         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
185     }
SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)186     virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
187     {
188         return DMError::DM_OK;
189     }
ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)190     virtual DMError ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
191     {
192         return DMError::DM_OK;
193     }
ResetAllFreezeStatus()194     virtual DMError ResetAllFreezeStatus()
195     {
196         return DMError::DM_OK;
197     }
SetVirtualScreenBlackList(ScreenId screenId,std::vector<uint64_t> & windowIdList)198     virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList) {}
DisablePowerOffRenderControl(ScreenId screenId)199     virtual void DisablePowerOffRenderControl(ScreenId screenId) {}
200 
GetAllDisplayPhysicalResolution()201     virtual std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalResolution()
202     {
203         return std::vector<DisplayPhysicalResolution> {};
204     }
SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)205     virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
206         std::vector<uint64_t>& windowIdList)
207     {
208         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
209     }
210 };
211 } // namespace OHOS::Rosen
212 
213 #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H