• 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 #include "pointer_drawing_manager.h"
17 
18 #include "image/bitmap.h"
19 #include "image_source.h"
20 #include "image_type.h"
21 #include "image_utils.h"
22 
23 #include "define_multimodal.h"
24 #include "input_device_manager.h"
25 #include "input_windows_manager.h"
26 #include "ipc_skeleton.h"
27 #include "mmi_log.h"
28 #include "pipeline/rs_recording_canvas.h"
29 #include "preferences.h"
30 #include "preferences_impl.h"
31 #include "preferences_errno.h"
32 #include "preferences_helper.h"
33 #include "preferences_xml_utils.h"
34 #include "util.h"
35 
36 namespace OHOS {
37 namespace MMI {
38 namespace {
39 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "PointerDrawingManager" };
40 const std::string IMAGE_POINTER_DEFAULT_PATH = "/system/etc/multimodalinput/mouse_icon/";
41 const std::string DefaultIconPath = IMAGE_POINTER_DEFAULT_PATH + "Default.svg";
42 constexpr int32_t BASELINE_DENSITY = 160;
43 constexpr int32_t CALCULATE_MIDDLE = 2;
44 constexpr int32_t DEVICE_INDEPENDENT_PIXELS = 40;
45 constexpr int32_t POINTER_WINDOW_INIT_SIZE = 64;
46 constexpr int32_t DEFAULT_POINTER_SIZE = 1;
47 constexpr int32_t MIN_POINTER_SIZE = 1;
48 constexpr int32_t MAX_POINTER_SIZE = 7;
49 constexpr int32_t DEFAULT_VALUE = -1;
50 constexpr int32_t ANIMATION_DURATION = 500;
51 constexpr float ROTATION_ANGLE = 360.f;
52 constexpr float LOADING_CENTER_RATIO = 0.5f;
53 constexpr float RUNNING_X_RATIO = 0.3f;
54 constexpr float RUNNING_Y_RATIO = 0.675f;
55 constexpr float INCREASE_RATIO = 1.22;
56 constexpr int32_t MIN_POINTER_COLOR = 0x000000;
57 constexpr int32_t MAX_POINTER_COLOR = 0xffffff;
58 const std::string MOUSE_FILE_NAME = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
59 } // namespace
60 } // namespace MMI
61 } // namespace OHOS
62 
63 namespace OHOS {
64 namespace MMI {
PointerDrawingManager()65 PointerDrawingManager::PointerDrawingManager()
66 {
67     InitStyle();
68 }
69 
DrawPointer(int32_t displayId,int32_t physicalX,int32_t physicalY,const MOUSE_ICON mouseStyle)70 void PointerDrawingManager::DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY,
71     const MOUSE_ICON mouseStyle)
72 {
73     CALL_DEBUG_ENTER;
74     MMI_HILOGD("Display:%{public}d,physicalX:%{public}d,physicalY:%{public}d,mouseStyle:%{public}d",
75         displayId, physicalX, physicalY, mouseStyle);
76     FixCursorPosition(physicalX, physicalY);
77     lastPhysicalX_ = physicalX;
78     lastPhysicalY_ = physicalY;
79 
80     AdjustMouseFocus(ICON_TYPE(mouseIcons_[mouseStyle].alignmentWay), physicalX, physicalY);
81     if (surfaceNode_ != nullptr) {
82         surfaceNode_->SetBounds(physicalX + displayInfo_.x,
83             physicalY + displayInfo_.y,
84             surfaceNode_->GetStagingProperties().GetBounds().z_,
85             surfaceNode_->GetStagingProperties().GetBounds().w_);
86         Rosen::RSTransaction::FlushImplicitTransaction();
87         MMI_HILOGD("Pointer window move success");
88         if (lastMouseStyle_.id == mouseStyle) {
89             MMI_HILOGD("The lastMouseStyle is equal with mouseStyle");
90             return;
91         }
92         lastMouseStyle_.id = mouseStyle;
93         int32_t ret = InitLayer(mouseStyle);
94         if (ret != RET_OK) {
95             MMI_HILOGE("Init layer failed");
96             return;
97         }
98         UpdatePointerVisible();
99         MMI_HILOGD("Leave, display:%{public}d,physicalX:%{public}d,physicalY:%{public}d",
100             displayId, physicalX, physicalY);
101         return;
102     }
103 
104     CreatePointerWindow(displayId, physicalX, physicalY);
105     CHKPV(surfaceNode_);
106     int32_t ret = InitLayer(mouseStyle);
107     if (ret != RET_OK) {
108         MMI_HILOGE("Init layer failed");
109         return;
110     }
111     UpdatePointerVisible();
112     MMI_HILOGD("Leave, display:%{public}d,physicalX:%{public}d,physicalY:%{public}d",
113         displayId, physicalX, physicalY);
114 }
115 
InitLayer(const MOUSE_ICON mouseStyle)116 int32_t PointerDrawingManager::InitLayer(const MOUSE_ICON mouseStyle)
117 {
118     CALL_DEBUG_ENTER;
119     if (surfaceNode_ == nullptr) {
120         MMI_HILOGD("surfaceNode_ is nullptr");
121         return RET_ERR;
122     }
123     DrawLoadingPointerStyle(mouseStyle);
124     DrawRunningPointerAnimate(mouseStyle);
125     sptr<OHOS::Surface> layer = GetLayer();
126     if (layer == nullptr) {
127         MMI_HILOGE("Init layer is failed, Layer is nullptr");
128         surfaceNode_->DetachToDisplay(screenId_);
129         surfaceNode_ = nullptr;
130         Rosen::RSTransaction::FlushImplicitTransaction();
131         MMI_HILOGD("Pointer window destroy success");
132         return RET_ERR;
133     }
134 
135     sptr<OHOS::SurfaceBuffer> buffer = GetSurfaceBuffer(layer);
136     if (buffer == nullptr || buffer->GetVirAddr() == nullptr) {
137         MMI_HILOGE("Init layer is failed, buffer or virAddr is nullptr");
138         surfaceNode_->DetachToDisplay(screenId_);
139         surfaceNode_ = nullptr;
140         Rosen::RSTransaction::FlushImplicitTransaction();
141         MMI_HILOGD("Pointer window destroy success");
142         return RET_ERR;
143     }
144 
145     auto addr = static_cast<uint8_t *>(buffer->GetVirAddr());
146     DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), mouseStyle);
147     OHOS::BufferFlushConfig flushConfig = {
148         .damage = {
149             .w = buffer->GetWidth(),
150             .h = buffer->GetHeight(),
151         },
152     };
153     OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig);
154     if (ret != OHOS::SURFACE_ERROR_OK) {
155         MMI_HILOGE("Init layer failed, FlushBuffer return ret:%{public}s", SurfaceErrorStr(ret).c_str());
156         return RET_ERR;
157     }
158     MMI_HILOGD("Init layer success");
159     return RET_OK;
160 }
161 
DrawLoadingPointerStyle(const MOUSE_ICON mouseStyle)162 void PointerDrawingManager::DrawLoadingPointerStyle(const MOUSE_ICON mouseStyle)
163 {
164     CALL_DEBUG_ENTER;
165     CHKPV(surfaceNode_);
166     Rosen::RSAnimationTimingProtocol protocol;
167     if (mouseStyle != MOUSE_ICON::LOADING &&
168         (mouseStyle != MOUSE_ICON::DEFAULT ||
169             mouseIcons_[mouseStyle].iconPath != (IMAGE_POINTER_DEFAULT_PATH + "Loading.svg"))) {
170         protocol.SetDuration(0);
171         Rosen::RSNode::Animate(
172             protocol,
173             Rosen::RSAnimationTimingCurve::LINEAR,
174             [&]() { surfaceNode_->SetRotation(0); },
175             []() { MMI_HILOGE("animate callback"); });
176         MMI_HILOGD("current pointer is not loading");
177         Rosen::RSTransaction::FlushImplicitTransaction();
178         return;
179     }
180     float ratio = imageWidth_ * 1.0 / IMAGE_WIDTH;
181     surfaceNode_->SetPivot({LOADING_CENTER_RATIO * ratio, LOADING_CENTER_RATIO * ratio});
182     protocol.SetDuration(ANIMATION_DURATION);
183     protocol.SetRepeatCount(DEFAULT_VALUE);
184 
185     // create property animation
186     Rosen::RSNode::Animate(
187         protocol,
188         Rosen::RSAnimationTimingCurve::LINEAR,
189         [&]() { surfaceNode_->SetRotation(ROTATION_ANGLE); },
190         []() { MMI_HILOGE("animate callback"); });
191 
192     Rosen::RSTransaction::FlushImplicitTransaction();
193 }
194 
DrawRunningPointerAnimate(const MOUSE_ICON mouseStyle)195 void PointerDrawingManager::DrawRunningPointerAnimate(const MOUSE_ICON mouseStyle)
196 {
197     CALL_DEBUG_ENTER;
198     CHKPV(surfaceNode_);
199     if (mouseStyle != MOUSE_ICON::RUNNING &&
200         (mouseStyle != MOUSE_ICON::DEFAULT ||
201             mouseIcons_[mouseStyle].iconPath != (IMAGE_POINTER_DEFAULT_PATH + "Loading_Left.svg"))) {
202         if (canvasNode_ != nullptr) {
203             canvasNode_->SetVisible(false);
204         }
205         MMI_HILOGD("current pointer is not running");
206         return;
207     }
208     canvasNode_->SetVisible(true);
209     float ratio = imageWidth_ * 1.0 / IMAGE_WIDTH;
210     canvasNode_->SetPivot({RUNNING_X_RATIO * ratio, RUNNING_Y_RATIO * ratio});
211     std::shared_ptr<OHOS::Media::PixelMap> pixelmap =
212         DecodeImageToPixelMap(mouseIcons_[MOUSE_ICON::RUNNING_RIGHT].iconPath);
213     CHKPV(pixelmap);
214     MMI_HILOGD("set mouseicon to OHOS system");
215     auto canvas = static_cast<Rosen::RSRecordingCanvas *>(canvasNode_->BeginRecording(imageWidth_, imageHeight_));
216     canvas->DrawPixelMap(pixelmap, 0, 0, SkSamplingOptions(), nullptr);
217     canvasNode_->FinishRecording();
218 
219     Rosen::RSAnimationTimingProtocol protocol;
220     protocol.SetDuration(ANIMATION_DURATION);
221     protocol.SetRepeatCount(DEFAULT_VALUE);
222 
223     // create property animation
224     Rosen::RSNode::Animate(
225         protocol,
226         Rosen::RSAnimationTimingCurve::LINEAR,
227         [&]() { canvasNode_->SetRotation(ROTATION_ANGLE); },
228         []() { MMI_HILOGE("animate callback"); });
229 
230     Rosen::RSTransaction::FlushImplicitTransaction();
231 }
232 
AdjustMouseFocus(ICON_TYPE iconType,int32_t & physicalX,int32_t & physicalY)233 void PointerDrawingManager::AdjustMouseFocus(ICON_TYPE iconType, int32_t &physicalX, int32_t &physicalY)
234 {
235     CALL_DEBUG_ENTER;
236     switch (iconType) {
237         case ANGLE_SW: {
238             physicalY -= imageHeight_;
239             break;
240         }
241         case ANGLE_CENTER: {
242             physicalX -= imageWidth_ / CALCULATE_MIDDLE;
243             physicalY -= imageHeight_ / CALCULATE_MIDDLE;
244             break;
245         }
246         case ANGLE_NW:
247             if (userIcon_ != nullptr && lastMouseStyle_.id == MOUSE_ICON::DEVELOPER_DEFINED_ICON) {
248                 physicalX -= userIconHotSpotX_;
249                 physicalY -= userIconHotSpotY_;
250             }
251             break;
252         default: {
253             MMI_HILOGD("No need adjust mouse focus");
254             break;
255         }
256     }
257 }
258 
SetMouseDisplayState(bool state)259 void PointerDrawingManager::SetMouseDisplayState(bool state)
260 {
261     CALL_DEBUG_ENTER;
262     if (mouseDisplayState_ != state) {
263         mouseDisplayState_ = state;
264         if (mouseDisplayState_) {
265             InitLayer(MOUSE_ICON(lastMouseStyle_.id));
266         }
267         UpdatePointerVisible();
268     }
269 }
270 
GetMouseDisplayState() const271 bool PointerDrawingManager::GetMouseDisplayState() const
272 {
273     return mouseDisplayState_;
274 }
275 
FixCursorPosition(int32_t & physicalX,int32_t & physicalY)276 void PointerDrawingManager::FixCursorPosition(int32_t &physicalX, int32_t &physicalY)
277 {
278     if (physicalX < 0) {
279         physicalX = 0;
280     }
281 
282     if (physicalY < 0) {
283         physicalY = 0;
284     }
285     const int32_t cursorUnit = 16;
286     if (displayInfo_.direction == DIRECTION0 || displayInfo_.direction == DIRECTION180) {
287         if (physicalX > (displayInfo_.width - imageWidth_ / cursorUnit)) {
288             physicalX = displayInfo_.width - imageWidth_ / cursorUnit;
289         }
290         if (physicalY > (displayInfo_.height - imageHeight_ / cursorUnit)) {
291             physicalY = displayInfo_.height - imageHeight_ / cursorUnit;
292         }
293     } else {
294         if (physicalX > (displayInfo_.height - imageHeight_ / cursorUnit)) {
295             physicalX = displayInfo_.height - imageHeight_ / cursorUnit;
296         }
297         if (physicalY > (displayInfo_.width - imageWidth_ / cursorUnit)) {
298             physicalY = displayInfo_.width - imageWidth_ / cursorUnit;
299         }
300     }
301 }
302 
CreatePointerWindow(int32_t displayId,int32_t physicalX,int32_t physicalY)303 void PointerDrawingManager::CreatePointerWindow(int32_t displayId, int32_t physicalX, int32_t physicalY)
304 {
305     CALL_INFO_TRACE;
306     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
307     surfaceNodeConfig.SurfaceNodeName = "pointer window";
308     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
309     surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
310     CHKPV(surfaceNode_);
311     surfaceNode_->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT_FILL);
312     surfaceNode_->SetPositionZ(Rosen::RSSurfaceNode::POINTER_WINDOW_POSITION_Z);
313     surfaceNode_->SetBounds(physicalX, physicalY, IMAGE_WIDTH, IMAGE_HEIGHT);
314     surfaceNode_->SetBackgroundColor(SK_ColorTRANSPARENT);
315     screenId_ = static_cast<uint64_t>(displayId);
316     std::cout << "ScreenId: " << screenId_ << std::endl;
317     surfaceNode_->AttachToDisplay(screenId_);
318     surfaceNode_->SetRotation(0);
319 
320     canvasNode_ = Rosen::RSCanvasNode::Create();
321     canvasNode_->SetBounds(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
322     canvasNode_->SetFrame(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
323     canvasNode_->SetBackgroundColor(SK_ColorTRANSPARENT);
324     canvasNode_->SetCornerRadius(1);
325     canvasNode_->SetPositionZ(Rosen::RSSurfaceNode::POINTER_WINDOW_POSITION_Z);
326     canvasNode_->SetRotation(0);
327     surfaceNode_->AddChild(canvasNode_, DEFAULT_VALUE);
328     Rosen::RSTransaction::FlushImplicitTransaction();
329 }
330 
GetLayer()331 sptr<OHOS::Surface> PointerDrawingManager::GetLayer()
332 {
333     CALL_DEBUG_ENTER;
334     if (surfaceNode_ == nullptr) {
335         MMI_HILOGE("Draw pointer is failed, get node is nullptr");
336         return nullptr;
337     }
338     return surfaceNode_->GetSurface();
339 }
340 
GetSurfaceBuffer(sptr<OHOS::Surface> layer) const341 sptr<OHOS::SurfaceBuffer> PointerDrawingManager::GetSurfaceBuffer(sptr<OHOS::Surface> layer) const
342 {
343     CALL_DEBUG_ENTER;
344     sptr<OHOS::SurfaceBuffer> buffer;
345     int32_t releaseFence = 0;
346     OHOS::BufferRequestConfig config = {
347         .width = IMAGE_WIDTH,
348         .height = IMAGE_HEIGHT,
349         .strideAlignment = 0x8,
350         .format = GRAPHIC_PIXEL_FMT_RGBA_8888,
351         .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA,
352     };
353 
354     OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config);
355     if (ret != OHOS::SURFACE_ERROR_OK) {
356         MMI_HILOGE("Request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str());
357         return nullptr;
358     }
359     return buffer;
360 }
361 
DoDraw(uint8_t * addr,uint32_t width,uint32_t height,const MOUSE_ICON mouseStyle)362 void PointerDrawingManager::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const MOUSE_ICON mouseStyle)
363 {
364     CALL_DEBUG_ENTER;
365     OHOS::Rosen::Drawing::Bitmap bitmap;
366     OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888,
367         OHOS::Rosen::Drawing::ALPHATYPE_OPAQUE };
368     bitmap.Build(width, height, format);
369     OHOS::Rosen::Drawing::Canvas canvas;
370     canvas.Bind(bitmap);
371     canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT);
372     DrawPixelmap(canvas, mouseStyle);
373     static constexpr uint32_t stride = 4;
374     uint32_t addrSize = width * height * stride;
375     errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize);
376     if (ret != EOK) {
377         MMI_HILOGE("Memcpy data is error, ret:%{public}d", ret);
378         return;
379     }
380 }
381 
DrawPixelmap(OHOS::Rosen::Drawing::Canvas & canvas,const MOUSE_ICON mouseStyle)382 void PointerDrawingManager::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const MOUSE_ICON mouseStyle)
383 {
384     CALL_DEBUG_ENTER;
385     OHOS::Rosen::Drawing::Pen pen;
386     pen.SetAntiAlias(true);
387     pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE);
388     OHOS::Rosen::Drawing::scalar penWidth = 1;
389     pen.SetWidth(penWidth);
390     canvas.AttachPen(pen);
391     if (mouseStyle == MOUSE_ICON::DEVELOPER_DEFINED_ICON) {
392         MMI_HILOGD("set mouseicon by userIcon_");
393         canvas.DrawBitmap(*userIcon_, 0, 0);
394     } else {
395         std::shared_ptr<OHOS::Media::PixelMap> pixelmap;
396         if (mouseStyle == MOUSE_ICON::RUNNING) {
397             pixelmap = DecodeImageToPixelMap(mouseIcons_[MOUSE_ICON::RUNNING_LEFT].iconPath);
398         } else {
399             pixelmap = DecodeImageToPixelMap(mouseIcons_[mouseStyle].iconPath);
400         }
401         CHKPV(pixelmap);
402         MMI_HILOGD("set mouseicon to OHOS system");
403         canvas.DrawBitmap(*pixelmap, 0, 0);
404     }
405 }
406 
SetMouseIcon(int32_t windowId,void * pixelMap)407 int32_t PointerDrawingManager::SetMouseIcon(int32_t windowId, void* pixelMap)
408 {
409     CALL_DEBUG_ENTER;
410     if (pixelMap == nullptr) {
411         MMI_HILOGE("pixelMap is null!");
412         return RET_ERR;
413     }
414     if (windowId < 0) {
415         MMI_HILOGE("get invalid windowId, %{public}d", windowId);
416         return RET_ERR;
417     }
418     OHOS::Media::PixelMap* pixelMapPtr = static_cast<OHOS::Media::PixelMap*>(pixelMap);
419     userIcon_.reset(pixelMapPtr);
420     userIconHotSpotX_ = 0;
421     userIconHotSpotY_ = 0;
422     PointerStyle style;
423     style.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
424     int32_t ret = SetPointerStyle(-1, windowId, style);
425     if (ret == RET_ERR) {
426         MMI_HILOGE("SetPointerStyle return RET_ERR here!");
427     }
428     return ret;
429 }
430 
SetMouseHotSpot(int32_t windowId,int32_t hotSpotX,int32_t hotSpotY)431 int32_t PointerDrawingManager::SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)
432 {
433     CALL_DEBUG_ENTER;
434     if (windowId < 0) {
435         MMI_HILOGE("invalid windowId, %{public}d", windowId);
436         return RET_ERR;
437     }
438     if (hotSpotX < 0 || hotSpotY < 0 || userIcon_ == nullptr) {
439         MMI_HILOGE("invalid value");
440         return RET_ERR;
441     }
442     PointerStyle pointerStyle;
443     int32_t ret = WinMgr->GetPointerStyle(pid_, windowId, pointerStyle);
444     if (ret != RET_OK || pointerStyle.id != MOUSE_ICON::DEVELOPER_DEFINED_ICON) {
445         MMI_HILOGE("Get pointer style failed, pid %{publid}d, pointerStyle %{public}d", pid_, pointerStyle.id);
446         return RET_ERR;
447     }
448     userIconHotSpotX_ = hotSpotX;
449     userIconHotSpotY_ = hotSpotY;
450     return RET_OK;
451 }
452 
DecodeImageToPixelMap(const std::string & imagePath)453 std::shared_ptr<OHOS::Media::PixelMap> PointerDrawingManager::DecodeImageToPixelMap(const std::string &imagePath)
454 {
455     CALL_DEBUG_ENTER;
456     OHOS::Media::SourceOptions opts;
457     opts.formatHint = "image/svg+xml";
458     uint32_t ret = 0;
459     auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret);
460     CHKPP(imageSource);
461     std::set<std::string> formats;
462     ret = imageSource->GetSupportedFormats(formats);
463     MMI_HILOGD("Get supported format ret:%{public}u", ret);
464 
465     OHOS::Media::DecodeOptions decodeOpts;
466     decodeOpts.desiredSize = {
467         .width = imageWidth_,
468         .height = imageHeight_
469     };
470     int32_t pointerColor = GetPointerColor();
471     if (tempPointerColor_ != DEFAULT_VALUE) {
472         decodeOpts.SVGOpts.fillColor = {.isValidColor = true, .color = pointerColor};
473     }
474 
475     std::shared_ptr<OHOS::Media::PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, ret);
476     if (pixelMap == nullptr) {
477         MMI_HILOGE("The pixelMap is nullptr");
478     }
479     return pixelMap;
480 }
481 
SetPointerColor(int32_t color)482 int32_t PointerDrawingManager::SetPointerColor(int32_t color)
483 {
484     CALL_DEBUG_ENTER;
485     if (color < MIN_POINTER_COLOR) {
486         color = MIN_POINTER_COLOR;
487     } else if (color > MAX_POINTER_COLOR) {
488         color = MAX_POINTER_COLOR;
489     }
490     int32_t errCode = RET_OK;
491     std::shared_ptr<NativePreferences::Preferences> pref =
492         NativePreferences::PreferencesHelper::GetPreferences(MOUSE_FILE_NAME, errCode);
493     if (pref == nullptr) {
494         MMI_HILOGE("pref is nullptr,  errCode: %{public}d", errCode);
495         return RET_ERR;
496     }
497     std::string name = "pointerColor";
498     int32_t ret = pref->PutInt(name, color);
499     if (ret != RET_OK) {
500         MMI_HILOGE("Put color is failed, ret:%{public}d", ret);
501         return RET_ERR;
502     }
503     ret = pref->FlushSync();
504     if (ret != RET_OK) {
505         MMI_HILOGE("Flush sync is failed, ret:%{public}d", ret);
506         return RET_ERR;
507     }
508     MMI_HILOGD("Set pointer color successfully, color:%{public}d", color);
509     NativePreferences::PreferencesHelper::RemovePreferencesFromCache(MOUSE_FILE_NAME);
510 
511     ret = InitLayer(MOUSE_ICON(lastMouseStyle_.id));
512     if (ret != RET_OK) {
513         MMI_HILOGE("Init layer failed");
514         return RET_ERR;
515     }
516     UpdatePointerVisible();
517     return RET_OK;
518 }
519 
GetPointerColor()520 int32_t PointerDrawingManager::GetPointerColor()
521 {
522     CALL_DEBUG_ENTER;
523     int32_t errCode = RET_OK;
524     std::shared_ptr<NativePreferences::Preferences> pref =
525         NativePreferences::PreferencesHelper::GetPreferences(MOUSE_FILE_NAME, errCode);
526     if (pref == nullptr) {
527         MMI_HILOGE("pref is nullptr,  errCode: %{public}d", errCode);
528         return RET_ERR;
529     }
530     std::string name = "pointerColor";
531     int32_t pointerColor = pref->GetInt(name, DEFAULT_VALUE);
532     tempPointerColor_ = pointerColor;
533     if (pointerColor == DEFAULT_VALUE) {
534         pointerColor = MIN_POINTER_COLOR;
535     }
536     MMI_HILOGD("Get pointer color successfully, pointerColor:%{public}d", pointerColor);
537     NativePreferences::PreferencesHelper::RemovePreferencesFromCache(MOUSE_FILE_NAME);
538     return pointerColor;
539 }
540 
UpdateDisplayInfo(const DisplayInfo & displayInfo)541 void PointerDrawingManager::UpdateDisplayInfo(const DisplayInfo& displayInfo)
542 {
543     CALL_DEBUG_ENTER;
544     hasDisplay_ = true;
545     displayInfo_ = displayInfo;
546     int32_t size = GetPointerSize();
547     imageWidth_ = pow(INCREASE_RATIO, size - 1) * displayInfo.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY;
548     imageHeight_ = pow(INCREASE_RATIO, size - 1) * displayInfo.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY;
549     IMAGE_WIDTH = (imageWidth_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE;
550     IMAGE_HEIGHT = (imageHeight_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE;
551 }
552 
SetPointerSize(int32_t size)553 int32_t PointerDrawingManager::SetPointerSize(int32_t size)
554 {
555     CALL_DEBUG_ENTER;
556     if (size < MIN_POINTER_SIZE) {
557         size = MIN_POINTER_SIZE;
558     } else if (size > MAX_POINTER_SIZE) {
559         size = MAX_POINTER_SIZE;
560     }
561     int32_t errCode = RET_OK;
562     std::shared_ptr<NativePreferences::Preferences> pref =
563         NativePreferences::PreferencesHelper::GetPreferences(MOUSE_FILE_NAME, errCode);
564     if (pref == nullptr) {
565         MMI_HILOGE("pref is nullptr,  errCode: %{public}d", errCode);
566         return RET_ERR;
567     }
568     std::string name = "pointerSize";
569     int32_t ret = pref->PutInt(name, size);
570     if (ret != RET_OK) {
571         MMI_HILOGE("Put size is failed, ret:%{public}d", ret);
572         return RET_ERR;
573     }
574     ret = pref->FlushSync();
575     if (ret != RET_OK) {
576         MMI_HILOGE("Flush sync is failed, ret:%{public}d", ret);
577         return RET_ERR;
578     }
579     MMI_HILOGD("Set pointer size successfully, size:%{public}d", size);
580     NativePreferences::PreferencesHelper::RemovePreferencesFromCache(MOUSE_FILE_NAME);
581 
582     if (surfaceNode_ == nullptr) {
583         MMI_HILOGI("surfaceNode_ is nullptr");
584         return RET_OK;
585     }
586     imageWidth_ = pow(INCREASE_RATIO, size - 1) * displayInfo_.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY;
587     imageHeight_ = pow(INCREASE_RATIO, size - 1) * displayInfo_.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY;
588     IMAGE_WIDTH = (imageWidth_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE;
589     IMAGE_HEIGHT = (imageHeight_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE;
590 
591     CreatePointerWindow(displayInfo_.id, lastPhysicalX_, lastPhysicalY_);
592     ret = InitLayer(MOUSE_ICON(lastMouseStyle_.id));
593     if (ret != RET_OK) {
594         MMI_HILOGE("Init layer failed");
595         return RET_ERR;
596     }
597     UpdatePointerVisible();
598     return RET_OK;
599 }
600 
GetPointerSize()601 int32_t PointerDrawingManager::GetPointerSize()
602 {
603     CALL_DEBUG_ENTER;
604     int32_t errCode = RET_OK;
605     std::shared_ptr<NativePreferences::Preferences> pref =
606         NativePreferences::PreferencesHelper::GetPreferences(MOUSE_FILE_NAME, errCode);
607     if (pref == nullptr) {
608         MMI_HILOGE("pref is nullptr,  errCode: %{public}d", errCode);
609         return RET_ERR;
610     }
611     std::string name = "pointerSize";
612     int32_t pointerSize = pref->GetInt(name, DEFAULT_POINTER_SIZE);
613     MMI_HILOGD("Get pointer size successfully, pointerSize:%{public}d", pointerSize);
614     NativePreferences::PreferencesHelper::RemovePreferencesFromCache(MOUSE_FILE_NAME);
615     return pointerSize;
616 }
617 
OnDisplayInfo(const DisplayGroupInfo & displayGroupInfo)618 void PointerDrawingManager::OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo)
619 {
620     CALL_DEBUG_ENTER;
621     for (const auto& item : displayGroupInfo.displaysInfo) {
622         if (item.id == displayInfo_.id) {
623             UpdateDisplayInfo(item);
624             DrawManager();
625             return;
626         }
627     }
628     UpdateDisplayInfo(displayGroupInfo.displaysInfo[0]);
629     lastPhysicalX_ = displayGroupInfo.displaysInfo[0].width / CALCULATE_MIDDLE;
630     lastPhysicalY_ = displayGroupInfo.displaysInfo[0].height / CALCULATE_MIDDLE;
631     MouseEventHdr->OnDisplayLost(displayInfo_.id);
632     if (surfaceNode_ != nullptr) {
633         surfaceNode_->DetachToDisplay(screenId_);
634         surfaceNode_ = nullptr;
635         Rosen::RSTransaction::FlushImplicitTransaction();
636         MMI_HILOGD("Pointer window destroy success");
637     }
638     MMI_HILOGD("displayId_:%{public}d, displayWidth_:%{public}d, displayHeight_:%{public}d",
639         displayInfo_.id, displayInfo_.width, displayInfo_.height);
640 }
641 
OnWindowInfo(const WinInfo & info)642 void PointerDrawingManager::OnWindowInfo(const WinInfo &info)
643 {
644     CALL_DEBUG_ENTER;
645     windowId_ = info.windowId;
646     pid_ = info.windowPid;
647 }
648 
UpdatePointerDevice(bool hasPointerDevice,bool isPointerVisible)649 void PointerDrawingManager::UpdatePointerDevice(bool hasPointerDevice, bool isPointerVisible)
650 {
651     CALL_DEBUG_ENTER;
652     hasPointerDevice_ = hasPointerDevice;
653     if (hasPointerDevice_) {
654         SetPointerVisible(getpid(), isPointerVisible);
655     } else {
656         DeletePointerVisible(getpid());
657     }
658     DrawManager();
659 }
660 
DrawManager()661 void PointerDrawingManager::DrawManager()
662 {
663     if (hasDisplay_ && hasPointerDevice_ && surfaceNode_ == nullptr) {
664         MMI_HILOGD("Draw pointer begin");
665         PointerStyle pointerStyle;
666         int32_t ret = WinMgr->GetPointerStyle(pid_, windowId_, pointerStyle);
667         MMI_HILOGD("get pid %{publid}d with pointerStyle %{public}d", pid_, pointerStyle.id);
668         if (ret != RET_OK) {
669             MMI_HILOGE("Get pointer style failed, pointerStyleInfo is nullptr");
670             return;
671         }
672         if (lastPhysicalX_ == -1 || lastPhysicalY_ == -1) {
673             DrawPointer(displayInfo_.id, displayInfo_.width / CALCULATE_MIDDLE, displayInfo_.height / CALCULATE_MIDDLE,
674                 MOUSE_ICON(pointerStyle.id));
675             MMI_HILOGD("Draw manager, mouseStyle:%{public}d, last physical is initial value", pointerStyle.id);
676             return;
677         }
678         DrawPointer(displayInfo_.id, lastPhysicalX_, lastPhysicalY_, MOUSE_ICON(pointerStyle.id));
679         MMI_HILOGD("Draw manager, mouseStyle:%{public}d", pointerStyle.id);
680         return;
681     }
682     if (!hasPointerDevice_ && surfaceNode_ != nullptr) {
683         MMI_HILOGD("Pointer window destroy start");
684         surfaceNode_->DetachToDisplay(screenId_);
685         surfaceNode_ = nullptr;
686         Rosen::RSTransaction::FlushImplicitTransaction();
687         MMI_HILOGD("Pointer window destroy success");
688     }
689 }
690 
Init()691 bool PointerDrawingManager::Init()
692 {
693     CALL_DEBUG_ENTER;
694     InputDevMgr->Attach(shared_from_this());
695     pidInfos_.clear();
696     return true;
697 }
698 
GetInstance()699 std::shared_ptr<IPointerDrawingManager> IPointerDrawingManager::GetInstance()
700 {
701     if (iPointDrawMgr_ == nullptr) {
702         iPointDrawMgr_ = std::make_shared<PointerDrawingManager>();
703     }
704     return iPointDrawMgr_;
705 }
706 
UpdatePointerVisible()707 void PointerDrawingManager::UpdatePointerVisible()
708 {
709     CALL_DEBUG_ENTER;
710     CHKPV(surfaceNode_);
711     if (IsPointerVisible() && mouseDisplayState_) {
712         surfaceNode_->SetVisible(true);
713         MMI_HILOGD("Pointer window show success");
714     } else {
715         surfaceNode_->SetVisible(false);
716         MMI_HILOGD("Pointer window hide success");
717     }
718     Rosen::RSTransaction::FlushImplicitTransaction();
719 }
720 
IsPointerVisible()721 bool PointerDrawingManager::IsPointerVisible()
722 {
723     CALL_DEBUG_ENTER;
724     if (pidInfos_.empty()) {
725         MMI_HILOGD("Visible property is true");
726         return true;
727     }
728     auto info = pidInfos_.back();
729     MMI_HILOGD("Visible property:%{public}zu.%{public}d-%{public}d", pidInfos_.size(), info.pid, info.visible);
730     return info.visible;
731 }
732 
DeletePointerVisible(int32_t pid)733 void PointerDrawingManager::DeletePointerVisible(int32_t pid)
734 {
735     CALL_DEBUG_ENTER;
736     auto it = pidInfos_.begin();
737     for (; it != pidInfos_.end(); ++it) {
738         if (it->pid == pid) {
739             pidInfos_.erase(it);
740             break;
741         }
742     }
743     if (it != pidInfos_.end()) {
744         if (IsPointerVisible()) {
745             InitLayer(MOUSE_ICON(lastMouseStyle_.id));
746         }
747         UpdatePointerVisible();
748     }
749 }
750 
SetPointerVisible(int32_t pid,bool visible)751 int32_t PointerDrawingManager::SetPointerVisible(int32_t pid, bool visible)
752 {
753     CALL_DEBUG_ENTER;
754     for (auto it = pidInfos_.begin(); it != pidInfos_.end(); ++it) {
755         if (it->pid == pid) {
756             pidInfos_.erase(it);
757             break;
758         }
759     }
760     PidInfo info = { .pid = pid, .visible = visible };
761     pidInfos_.push_back(info);
762     if (visible) {
763         InitLayer(MOUSE_ICON(lastMouseStyle_.id));
764     }
765     UpdatePointerVisible();
766     return RET_OK;
767 }
768 
SetPointerLocation(int32_t pid,int32_t x,int32_t y)769 void PointerDrawingManager::SetPointerLocation(int32_t pid, int32_t x, int32_t y)
770 {
771     CALL_DEBUG_ENTER;
772     FixCursorPosition(x, y);
773     lastPhysicalX_ = x;
774     lastPhysicalY_ = y;
775     if (surfaceNode_ != nullptr) {
776         surfaceNode_->SetBounds(x,
777             y,
778             surfaceNode_->GetStagingProperties().GetBounds().z_,
779             surfaceNode_->GetStagingProperties().GetBounds().w_);
780         Rosen::RSTransaction::FlushImplicitTransaction();
781         MMI_HILOGD("Pointer window move success");
782     }
783 }
784 
UpdateDefaultPointerStyle(int32_t pid,int32_t windowId,PointerStyle pointerStyle)785 int32_t PointerDrawingManager::UpdateDefaultPointerStyle(int32_t pid, int32_t windowId, PointerStyle pointerStyle)
786 {
787     if (windowId != GLOBAL_WINDOW_ID) {
788         MMI_HILOGD("No need to change the default icon style");
789         return RET_OK;
790     }
791     PointerStyle style;
792     int32_t ret = WinMgr->GetPointerStyle(pid, GLOBAL_WINDOW_ID, style);
793     if (ret != RET_OK) {
794         MMI_HILOGE("Get global pointer style failed!");
795         return RET_ERR;
796     }
797     if (pointerStyle.id != style.id) {
798         auto it = mouseIcons_.find(MOUSE_ICON(MOUSE_ICON::DEFAULT));
799         if (it == mouseIcons_.end()) {
800             MMI_HILOGE("Cannot find the default style in mouseIcons_");
801             return RET_ERR;
802         }
803         std::string newIconPath;
804         if (pointerStyle.id == MOUSE_ICON::DEFAULT) {
805             newIconPath = DefaultIconPath;
806         } else {
807             newIconPath = mouseIcons_[MOUSE_ICON(pointerStyle.id)].iconPath;
808         }
809         MMI_HILOGD("default path has changed from %{public}s to %{public}s",
810             it->second.iconPath.c_str(), newIconPath.c_str());
811         it->second.iconPath = newIconPath;
812     }
813     return RET_OK;
814 }
815 
SetPointerStyle(int32_t pid,int32_t windowId,PointerStyle pointerStyle)816 int32_t PointerDrawingManager::SetPointerStyle(int32_t pid, int32_t windowId, PointerStyle pointerStyle)
817 {
818     CALL_DEBUG_ENTER;
819     auto it = mouseIcons_.find(MOUSE_ICON(pointerStyle.id));
820     if (it == mouseIcons_.end()) {
821         MMI_HILOGE("The param pointerStyle is invalid");
822         return RET_ERR;
823     }
824     int32_t ret = UpdateDefaultPointerStyle(pid, windowId, pointerStyle);
825     if (ret != RET_OK) {
826         MMI_HILOGE("Update default pointer iconPath failed!");
827         return ret;
828     }
829 
830     ret = WinMgr->SetPointerStyle(pid, windowId, pointerStyle);
831     if (ret != RET_OK) {
832         MMI_HILOGE("Set pointer style failed");
833         return ret;
834     }
835 
836     if (!InputDevMgr->HasPointerDevice()) {
837         MMI_HILOGD("The pointer device is not exist");
838         return RET_OK;
839     }
840 
841     if (!WinMgr->IsNeedRefreshLayer(windowId)) {
842         MMI_HILOGD("Not need refresh layer, window type:%{public}d, pointer style:%{public}d",
843             windowId, pointerStyle.id);
844         return RET_OK;
845     }
846 
847     if (surfaceNode_ != nullptr) {
848         int32_t physicalX = lastPhysicalX_;
849         int32_t physicalY = lastPhysicalY_;
850         AdjustMouseFocus(ICON_TYPE(mouseIcons_[MOUSE_ICON(pointerStyle.id)].alignmentWay), physicalX, physicalY);
851         MMI_HILOGD("Pointer window move start");
852         surfaceNode_->SetBounds(physicalX + displayInfo_.x,
853             physicalY + displayInfo_.y,
854             surfaceNode_->GetStagingProperties().GetBounds().z_,
855             surfaceNode_->GetStagingProperties().GetBounds().w_);
856         Rosen::RSTransaction::FlushImplicitTransaction();
857         MMI_HILOGD("Pointer window move success");
858 
859         lastMouseStyle_ = pointerStyle;
860         int32_t ret = InitLayer(MOUSE_ICON(pointerStyle.id));
861         if (ret != RET_OK) {
862             MMI_HILOGE("Init layer failed");
863             return RET_ERR;
864         }
865         UpdatePointerVisible();
866     }
867     MMI_HILOGD("Window id:%{public}d set pointer style:%{public}d success", windowId, pointerStyle.id);
868     return RET_OK;
869 }
870 
GetPointerStyle(int32_t pid,int32_t windowId,PointerStyle & pointerStyle)871 int32_t PointerDrawingManager::GetPointerStyle(int32_t pid, int32_t windowId, PointerStyle &pointerStyle)
872 {
873     CALL_DEBUG_ENTER;
874     int32_t ret = WinMgr->GetPointerStyle(pid, windowId, pointerStyle);
875     if (ret != RET_OK) {
876         MMI_HILOGE("Get pointer style failed, pointerStyleInfo is nullptr");
877         return ret;
878     }
879     MMI_HILOGD("Window id:%{public}d get pointer style:%{public}d success", windowId, pointerStyle.id);
880     return RET_OK;
881 }
882 
DrawPointerStyle()883 void PointerDrawingManager::DrawPointerStyle()
884 {
885     CALL_DEBUG_ENTER;
886     if (hasDisplay_ && hasPointerDevice_) {
887         if (surfaceNode_ != nullptr) {
888             surfaceNode_->AttachToDisplay(screenId_);
889             Rosen::RSTransaction::FlushImplicitTransaction();
890         }
891         PointerStyle pointerStyle;
892         int32_t ret = WinMgr->GetPointerStyle(pid_, windowId_, pointerStyle);
893         if (ret != RET_OK) {
894             MMI_HILOGE("Draw pointer style failed, pointerStyleInfo is nullptr");
895             return;
896         }
897         if (lastPhysicalX_ == -1 || lastPhysicalY_ == -1) {
898             DrawPointer(displayInfo_.id, displayInfo_.width / CALCULATE_MIDDLE, displayInfo_.height / CALCULATE_MIDDLE,
899                 MOUSE_ICON(pointerStyle.id));
900             MMI_HILOGD("Draw pointer style, mouseStyle:%{public}d", pointerStyle.id);
901             return;
902         }
903 
904         DrawPointer(displayInfo_.id, lastPhysicalX_, lastPhysicalY_, MOUSE_ICON(pointerStyle.id));
905         MMI_HILOGD("Draw pointer style, mouseStyle:%{public}d", pointerStyle.id);
906     }
907 }
908 
CheckMouseIconPath()909 void PointerDrawingManager::CheckMouseIconPath()
910 {
911     for (auto iter = mouseIcons_.begin(); iter != mouseIcons_.end();) {
912         if ((ReadCursorStyleFile(iter->second.iconPath)) != RET_OK) {
913             iter = mouseIcons_.erase(iter);
914             continue;
915         }
916         ++iter;
917     }
918 }
919 
InitStyle()920 void PointerDrawingManager::InitStyle()
921 {
922     CALL_DEBUG_ENTER;
923     mouseIcons_ = {
924         {DEFAULT, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Default.svg"}},
925         {EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "East.svg"}},
926         {WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "West.svg"}},
927         {SOUTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "South.svg"}},
928         {NORTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North.svg"}},
929         {WEST_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "West_East.svg"}},
930         {NORTH_SOUTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North_South.svg"}},
931         {NORTH_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North_East.svg"}},
932         {NORTH_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North_West.svg"}},
933         {SOUTH_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "South_East.svg"}},
934         {SOUTH_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "South_West.svg"}},
935         {NORTH_EAST_SOUTH_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North_East_South_West.svg"}},
936         {NORTH_WEST_SOUTH_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "North_West_South_East.svg"}},
937         {CROSS, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Cross.svg"}},
938         {CURSOR_COPY, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Copy.svg"}},
939         {CURSOR_FORBID, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Forbid.svg"}},
940         {COLOR_SUCKER, {ANGLE_SW, IMAGE_POINTER_DEFAULT_PATH + "Colorsucker.svg"}},
941         {HAND_GRABBING, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Hand_Grabbing.svg"}},
942         {HAND_OPEN, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Hand_Open.svg"}},
943         {HAND_POINTING, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Hand_Pointing.svg"}},
944         {HELP, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Help.svg"}},
945         {CURSOR_MOVE, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Move.svg"}},
946         {RESIZE_LEFT_RIGHT, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Resize_Left_Right.svg"}},
947         {RESIZE_UP_DOWN, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Resize_Up_Down.svg"}},
948         {SCREENSHOT_CHOOSE, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Screenshot_Cross.svg"}},
949         {SCREENSHOT_CURSOR, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Screenshot_Cursor.png"}},
950         {TEXT_CURSOR, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Text_Cursor.svg"}},
951         {ZOOM_IN, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Zoom_In.svg"}},
952         {ZOOM_OUT, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Zoom_Out.svg"}},
953         {MIDDLE_BTN_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_East.svg"}},
954         {MIDDLE_BTN_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_West.svg"}},
955         {MIDDLE_BTN_SOUTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_South.svg"}},
956         {MIDDLE_BTN_NORTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_North.svg"}},
957         {MIDDLE_BTN_NORTH_SOUTH, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_North_South.svg"}},
958         {MIDDLE_BTN_NORTH_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_North_East.svg"}},
959         {MIDDLE_BTN_NORTH_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_North_West.svg"}},
960         {MIDDLE_BTN_SOUTH_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_South_East.svg"}},
961         {MIDDLE_BTN_SOUTH_WEST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "MID_Btn_South_West.svg"}},
962         {MIDDLE_BTN_NORTH_SOUTH_WEST_EAST, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH +
963             "MID_Btn_North_South_West_East.svg"}},
964         {HORIZONTAL_TEXT_CURSOR, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Horizontal_Text_Cursor.svg"}},
965         {CURSOR_CROSS, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Cursor_Cross.svg"}},
966         {CURSOR_CIRCLE, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Cursor_Circle.png"}},
967         {LOADING, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Loading.svg"}},
968         {RUNNING, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Loading_Left.svg"}},
969         {RUNNING_LEFT, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Loading_Left.svg"}},
970         {RUNNING_RIGHT, {ANGLE_CENTER, IMAGE_POINTER_DEFAULT_PATH + "Loading_Right.svg"}},
971         {DEVELOPER_DEFINED_ICON, {ANGLE_NW, IMAGE_POINTER_DEFAULT_PATH + "Default.svg"}},
972     };
973     CheckMouseIconPath();
974 }
975 } // namespace MMI
976 } // namespace OHOS
977