1 /*
2  * Copyright (c) 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 I_POINTER_DRAWING_MANAGER_H
17 #define I_POINTER_DRAWING_MANAGER_H
18 
19 #include <map>
20 #include <memory>
21 
22 #include "pixel_map.h"
23 
24 #include "pointer_style.h"
25 #include "window_info.h"
26 #include "struct_multimodal.h"
27 #include "delegate_interface.h"
28 
29 namespace OHOS {
30 namespace MMI {
31 class IPointerDrawingManager {
32 public:
33     IPointerDrawingManager() = default;
34     virtual ~IPointerDrawingManager() = default;
35 
36     static std::shared_ptr<IPointerDrawingManager> GetInstance();
DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY, const PointerStyle pointerStyle, Direction direction)37     virtual void DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY,
38         const PointerStyle pointerStyle, Direction direction) {}
UpdateDisplayInfo(const DisplayInfo& displayInfo)39     virtual void UpdateDisplayInfo(const DisplayInfo& displayInfo) {}
OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo)40     virtual void OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo) {}
OnWindowInfo(const WinInfo &info)41     virtual void OnWindowInfo(const WinInfo &info) {}
Init()42     virtual bool Init()
43     {
44         return true;
45     }
DeletePointerVisible(int32_t pid)46     virtual void DeletePointerVisible(int32_t pid) {}
SetPointerVisible(int32_t pid, bool visible, int32_t priority, bool isHap)47     virtual int32_t SetPointerVisible(int32_t pid, bool visible, int32_t priority, bool isHap)
48     {
49         return 0;
50     }
GetPointerVisible(int32_t pid)51     virtual bool GetPointerVisible(int32_t pid)
52     {
53         return true;
54     }
SetPointerColor(int32_t color)55     virtual int32_t SetPointerColor(int32_t color)
56     {
57         return 0;
58     }
GetPointerColor()59     virtual int32_t GetPointerColor()
60     {
61         return 0;
62     }
SetPointerStyle(int32_t pid, int32_t windowId, PointerStyle pointerStyle, bool isUiExtension = false)63     virtual int32_t SetPointerStyle(int32_t pid, int32_t windowId, PointerStyle pointerStyle,
64         bool isUiExtension = false)
65     {
66         return 0;
67     }
ClearWindowPointerStyle(int32_t pid, int32_t windowId)68     virtual int32_t ClearWindowPointerStyle(int32_t pid, int32_t windowId)
69     {
70         return 0;
71     }
GetPointerStyle(int32_t pid, int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension = false)72     virtual int32_t GetPointerStyle(int32_t pid, int32_t windowId, PointerStyle &pointerStyle,
73         bool isUiExtension = false)
74     {
75         return 0;
76     }
DrawPointerStyle(const PointerStyle& pointerStyle)77     virtual void DrawPointerStyle(const PointerStyle& pointerStyle) {}
IsPointerVisible()78     virtual bool IsPointerVisible()
79     {
80         return false;
81     }
SetPointerLocation(int32_t x, int32_t y)82     virtual void SetPointerLocation(int32_t x, int32_t y) {}
SetMouseDisplayState(bool state)83     virtual void SetMouseDisplayState(bool state) {}
GetMouseDisplayState() const84     virtual bool GetMouseDisplayState() const
85     {
86         return false;
87     }
SetCustomCursor(void* pixelMap, int32_t pid, int32_t windowId, int32_t focusX, int32_t focusY)88     virtual int32_t SetCustomCursor(void* pixelMap, int32_t pid, int32_t windowId, int32_t focusX, int32_t focusY)
89     {
90         return 0;
91     }
SetMouseIcon(int32_t pid, int32_t windowId, void* pixelMap)92     virtual int32_t SetMouseIcon(int32_t pid, int32_t windowId, void* pixelMap)
93     {
94         return 0;
95     }
SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)96     virtual int32_t SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)
97     {
98         return 0;
99     }
SetPointerSize(int32_t size)100     virtual int32_t SetPointerSize(int32_t size)
101     {
102         return 0;
103     }
GetPointerSize()104     virtual int32_t GetPointerSize()
105     {
106         return 0;
107     }
GetLastMouseStyle()108     virtual PointerStyle GetLastMouseStyle()
109     {
110         return {};
111     }
GetIconStyle(const MOUSE_ICON mouseStyle)112     virtual IconStyle GetIconStyle(const MOUSE_ICON mouseStyle)
113     {
114         return {};
115     }
GetMouseIconPath()116     virtual const std::map<MOUSE_ICON, IconStyle>& GetMouseIconPath()
117     {
118         static std::map<MOUSE_ICON, IconStyle> emptyMap;
119         return emptyMap;
120     }
SwitchPointerStyle()121     virtual int32_t SwitchPointerStyle()
122     {
123         return 0;
124     }
DrawMovePointer(int32_t displayId, int32_t physicalX, int32_t physicalY)125     virtual void DrawMovePointer(int32_t displayId, int32_t physicalX, int32_t physicalY) {}
Dump(int32_t fd, const std::vector<std::string> &args)126     virtual void Dump(int32_t fd, const std::vector<std::string> &args) {}
InitPointerCallback()127     virtual void InitPointerCallback() {}
EnableHardwareCursorStats(int32_t pid, bool enable)128     virtual int32_t EnableHardwareCursorStats(int32_t pid, bool enable)
129     {
130         return 0;
131     }
GetHardwareCursorStats(int32_t pid, uint32_t &frameCount, uint32_t &vsyncCount)132     virtual int32_t GetHardwareCursorStats(int32_t pid, uint32_t &frameCount, uint32_t &vsyncCount)
133     {
134         return 0;
135     }
136 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
GetPointerSnapshot(void *pixelMapPtr)137     virtual int32_t GetPointerSnapshot(void *pixelMapPtr)
138     {
139         return 0;
140     }
141 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
ForceClearPointerVisiableStatus()142     virtual void ForceClearPointerVisiableStatus() {}
InitPointerObserver()143     virtual void InitPointerObserver() {}
OnSessionLost(int32_t pid)144     virtual void OnSessionLost(int32_t pid) {}
SkipPointerLayer(bool isSkip)145     virtual int32_t SkipPointerLayer(bool isSkip)
146     {
147         return 0;
148     }
SetDelegateProxy(std::shared_ptr<DelegateInterface> proxy)149     virtual void SetDelegateProxy(std::shared_ptr<DelegateInterface> proxy) {}
DestroyPointerWindow()150     virtual void DestroyPointerWindow() {}
DrawScreenCenterPointer(const PointerStyle &pointerStyle)151     virtual void DrawScreenCenterPointer(const PointerStyle &pointerStyle) {}
152 public:
153     static inline std::shared_ptr<IPointerDrawingManager> iPointDrawMgr_ { nullptr };
154 };
155 } // namespace MMI
156 } // namespace OHOS
157 #endif // I_POINTER_DRAWING_MANAGER_H
158