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 #include "accessibility_zoom_gesture.h"
17 #include "accessible_ability_manager_service.h"
18 #include "hilog_wrapper.h"
19 #include "window_accessibility_controller.h"
20
21 namespace OHOS {
22 namespace Accessibility {
23 namespace {
24 constexpr size_t POINTER_COUNT_1 = 1;
25 constexpr float TAP_MIN_DISTANCE = 8.0f;
26 constexpr int32_t MULTI_TAP_TIMER = 300; // ms
27 constexpr int32_t LONG_PRESS_TIMER = 500; // ms
28 constexpr int64_t US_TO_MS = 1000;
29 constexpr float MIN_SCALE_SPAN = 26.0f;
30 constexpr float DOUBLE_TAP_SLOP = 100.0f;
31 constexpr float HALF = 0.5f;
32 constexpr uint32_t TRIPLE_TAP_COUNT = 3;
33 constexpr float DEFAULT_SCALE = 2.0f;
34 } // namespace
35
AccessibilityZoomGesture()36 AccessibilityZoomGesture::AccessibilityZoomGesture()
37 {
38 HILOG_DEBUG();
39
40 zoomGestureEventHandler_ = std::make_shared<ZoomGestureEventHandler>(
41 Singleton<AccessibleAbilityManagerService>::GetInstance().GetMainRunner(), *this);
42
43 tapDistance_ = TAP_MIN_DISTANCE;
44
45 #ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
46 AccessibilityDisplayManager &displayMgr = Singleton<AccessibilityDisplayManager>::GetInstance();
47 auto display = displayMgr.GetDefaultDisplay();
48 if (!display) {
49 HILOG_ERROR("get display is nullptr");
50 return;
51 }
52
53 float densityPixels = display->GetVirtualPixelRatio();
54 multiTapDistance_ = densityPixels * DOUBLE_TAP_SLOP + 0.5f;
55 #else
56 HILOG_DEBUG("not support display manager")
57 multiTapDistance_ = 1 * DOUBLE_TAP_SLOP + 0.5f;
58 #endif
59 }
60
OnPointerEvent(MMI::PointerEvent & event)61 bool AccessibilityZoomGesture::OnPointerEvent(MMI::PointerEvent &event)
62 {
63 HILOG_DEBUG("state_ is %{public}d.", state_);
64
65 int32_t sourceType = event.GetSourceType();
66 if (sourceType != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
67 EventTransmission::OnPointerEvent(event);
68 return false;
69 }
70
71 switch (state_) {
72 case READY_STATE:
73 CacheEvents(event);
74 RecognizeInReadyState(event);
75 break;
76 case ZOOMIN_STATE:
77 CacheEvents(event);
78 RecognizeInZoomState(event);
79 break;
80 case SLIDING_STATE:
81 RecognizeInSlidingState(event);
82 break;
83 default:
84 break;
85 }
86 return true;
87 }
88
TransferState(ACCESSIBILITY_ZOOM_STATE state)89 void AccessibilityZoomGesture::TransferState(ACCESSIBILITY_ZOOM_STATE state)
90 {
91 HILOG_DEBUG("state:%{public}d.", state);
92
93 state_ = state;
94 }
95
CacheEvents(MMI::PointerEvent & event)96 void AccessibilityZoomGesture::CacheEvents(MMI::PointerEvent &event)
97 {
98 HILOG_DEBUG();
99
100 int32_t action = event.GetPointerAction();
101 size_t pointerCount = event.GetPointerIds().size();
102 std::shared_ptr<MMI::PointerEvent> pointerEvent = std::make_shared<MMI::PointerEvent>(event);
103
104 switch (action) {
105 case MMI::PointerEvent::POINTER_ACTION_DOWN:
106 if (pointerCount == POINTER_COUNT_1) {
107 HILOG_DEBUG("Cache pointer down");
108 preLastDownEvent_ = lastDownEvent_;
109 lastDownEvent_ = pointerEvent;
110 }
111 break;
112 case MMI::PointerEvent::POINTER_ACTION_UP:
113 if (pointerCount == POINTER_COUNT_1) {
114 HILOG_DEBUG("Cache pointer up");
115 preLastUpEvent_ = lastUpEvent_;
116 lastUpEvent_ = pointerEvent;
117 }
118 break;
119 default:
120 HILOG_DEBUG("Action is %{public}d", action);
121 break;
122 }
123 cacheEvents_.emplace_back(pointerEvent);
124 }
125
SendCacheEventsToNext()126 void AccessibilityZoomGesture::SendCacheEventsToNext()
127 {
128 HILOG_DEBUG();
129
130 bool isStartNewAction = false;
131 int32_t action = MMI::PointerEvent::POINTER_ACTION_UNKNOWN;
132 std::vector<std::shared_ptr<MMI::PointerEvent>> cacheEventsTmp;
133 std::copy(cacheEvents_.begin(), cacheEvents_.end(), std::back_inserter(cacheEventsTmp));
134
135 ClearCacheEventsAndMsg();
136
137 size_t cacheEventsNum = 0;
138 size_t cacheEventsTotalNum = cacheEventsTmp.size();
139 for (auto &pointerEvent : cacheEventsTmp) {
140 cacheEventsNum++;
141 action = pointerEvent->GetPointerAction();
142 if ((cacheEventsNum > 1) &&
143 (cacheEventsNum == cacheEventsTotalNum) &&
144 (action == MMI::PointerEvent::POINTER_ACTION_DOWN)) {
145 HILOG_DEBUG("The down event needs to be parsed again");
146 isStartNewAction = true;
147 }
148 if (isStartNewAction) {
149 OnPointerEvent(*pointerEvent);
150 } else {
151 EventTransmission::OnPointerEvent(*pointerEvent);
152 }
153 }
154 }
155
ClearCacheEventsAndMsg()156 void AccessibilityZoomGesture::ClearCacheEventsAndMsg()
157 {
158 HILOG_DEBUG();
159
160 cacheEvents_.clear();
161 preLastDownEvent_ = nullptr;
162 lastDownEvent_ = nullptr;
163 preLastUpEvent_ = nullptr;
164 lastUpEvent_ = nullptr;
165 zoomGestureEventHandler_->RemoveEvent(MULTI_TAP_MSG);
166 }
167
RecognizeInReadyState(MMI::PointerEvent & event)168 void AccessibilityZoomGesture::RecognizeInReadyState(MMI::PointerEvent &event)
169 {
170 HILOG_DEBUG();
171
172 int32_t action = event.GetPointerAction();
173 size_t pointerCount = event.GetPointerIds().size();
174 bool isTripleTaps = false;
175
176 HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount);
177 switch (action) {
178 case MMI::PointerEvent::POINTER_ACTION_DOWN:
179 zoomGestureEventHandler_->RemoveEvent(MULTI_TAP_MSG);
180 if ((pointerCount == POINTER_COUNT_1) && IsDownValid()) {
181 zoomGestureEventHandler_->SendEvent(MULTI_TAP_MSG, 0, MULTI_TAP_TIMER);
182 } else {
183 SendCacheEventsToNext();
184 }
185 break;
186 case MMI::PointerEvent::POINTER_ACTION_UP:
187 if ((pointerCount == POINTER_COUNT_1) && IsUpValid()) {
188 isTripleTaps = IsTripleTaps();
189 } else {
190 SendCacheEventsToNext();
191 HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount);
192 }
193 break;
194 case MMI::PointerEvent::POINTER_ACTION_CANCEL:
195 SendCacheEventsToNext();
196 break;
197 default:
198 break;
199 }
200
201 if (isTripleTaps) {
202 OnTripleTaps(event);
203 }
204 }
205
RecognizeInZoomState(MMI::PointerEvent & event)206 void AccessibilityZoomGesture::RecognizeInZoomState(MMI::PointerEvent &event)
207 {
208 HILOG_DEBUG();
209
210 int32_t action = event.GetPointerAction();
211 size_t pointerCount = event.GetPointerIds().size();
212 bool isTripleTaps = false;
213
214 HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount);
215 switch (action) {
216 case MMI::PointerEvent::POINTER_ACTION_DOWN:
217 zoomGestureEventHandler_->RemoveEvent(MULTI_TAP_MSG);
218 if (pointerCount == POINTER_COUNT_1) {
219 if (IsDownValid()) {
220 zoomGestureEventHandler_->SendEvent(MULTI_TAP_MSG, 0, MULTI_TAP_TIMER);
221 } else {
222 SendCacheEventsToNext();
223 }
224 } else if (pointerCount > POINTER_COUNT_1) {
225 TransferState(SLIDING_STATE);
226 ClearCacheEventsAndMsg();
227 ZOOM_FOCUS_COORDINATE focusXY = {0.0f, 0.0f};
228 CalcFocusCoordinate(event, focusXY);
229 // Used for scroll algorithm.
230 lastScrollFocusX_ = focusXY.centerX;
231 lastScrollFocusY_ = focusXY.centerY;
232
233 // Used for scale algorithm.
234 float span = CalcScaleSpan(event, focusXY);
235 if (span >= MIN_SCALE_SPAN) {
236 startScaling_ = true;
237 preSpan_ = lastSpan_ = span;
238 }
239 }
240 break;
241 case MMI::PointerEvent::POINTER_ACTION_UP:
242 if ((pointerCount == POINTER_COUNT_1) && IsUpValid()) {
243 isTripleTaps = IsTripleTaps();
244 } else {
245 SendCacheEventsToNext();
246 }
247 break;
248 case MMI::PointerEvent::POINTER_ACTION_CANCEL:
249 SendCacheEventsToNext();
250 HILOG_DEBUG("action:%{public}d", action);
251 break;
252 default:
253 break;
254 }
255
256 if (isTripleTaps) {
257 OnTripleTaps(event);
258 }
259 }
260
RecognizeInSlidingState(MMI::PointerEvent & event)261 void AccessibilityZoomGesture::RecognizeInSlidingState(MMI::PointerEvent &event)
262 {
263 HILOG_DEBUG();
264
265 int32_t action = event.GetPointerAction();
266 size_t pointerCount = event.GetPointerIds().size();
267
268 // Recognize scroll and zoom gestures.
269 RecognizeScroll(event);
270 RecognizeScale(event);
271
272 HILOG_DEBUG("action:%{public}d, pointerCount:%{public}zu", action, pointerCount);
273 switch (action) {
274 case MMI::PointerEvent::POINTER_ACTION_UP:
275 if (pointerCount == POINTER_COUNT_1) {
276 TransferState(ZOOMIN_STATE);
277 }
278 break;
279 case MMI::PointerEvent::POINTER_ACTION_CANCEL:
280 TransferState(ZOOMIN_STATE);
281 break;
282 default:
283 break;
284 }
285 }
286
RecognizeScroll(MMI::PointerEvent & event)287 void AccessibilityZoomGesture::RecognizeScroll(MMI::PointerEvent &event)
288 {
289 HILOG_DEBUG();
290
291 int32_t action = event.GetPointerAction();
292 ZOOM_FOCUS_COORDINATE coordinate = {0.0f, 0.0f};
293 CalcFocusCoordinate(event, coordinate);
294
295 switch (action) {
296 case MMI::PointerEvent::POINTER_ACTION_DOWN:
297 case MMI::PointerEvent::POINTER_ACTION_UP:
298 lastScrollFocusX_ = coordinate.centerX;
299 lastScrollFocusY_ = coordinate.centerY;
300 break;
301 case MMI::PointerEvent::POINTER_ACTION_MOVE: {
302 float offsetX = coordinate.centerX - lastScrollFocusX_;
303 float offsetY = coordinate.centerY - lastScrollFocusY_;
304 if ((abs(offsetX) > 1) || (abs(offsetY) > 1)) {
305 lastScrollFocusX_ = coordinate.centerX;
306 lastScrollFocusY_ = coordinate.centerY;
307 OnScroll(offsetX, offsetY);
308 }
309 break;
310 }
311 default:
312 break;
313 }
314 }
315
RecognizeScale(MMI::PointerEvent & event)316 void AccessibilityZoomGesture::RecognizeScale(MMI::PointerEvent &event)
317 {
318 HILOG_DEBUG();
319
320 int32_t action = event.GetPointerAction();
321 size_t pointerCount = event.GetPointerIds().size();
322 if (((action == MMI::PointerEvent::POINTER_ACTION_UP) && (pointerCount == POINTER_COUNT_1)) ||
323 (action == MMI::PointerEvent::POINTER_ACTION_CANCEL)) {
324 HILOG_DEBUG("Scaling is end");
325 startScaling_ = false;
326 preSpan_ = lastSpan_ = 0;
327 return;
328 }
329
330 ZOOM_FOCUS_COORDINATE focusXY = {0.0f, 0.0f};
331 CalcFocusCoordinate(event, focusXY);
332 float span = CalcScaleSpan(event, focusXY);
333 if (!startScaling_) {
334 // When the span is greater than or equal to MIN_SCALE_SPAN, start scaling.
335 if (span >= MIN_SCALE_SPAN) {
336 startScaling_ = true;
337 preSpan_ = lastSpan_ = span;
338 }
339 } else {
340 // When the span is smaller than the MIN_SCALE_SPAN,
341 // the scale recognition will be restarted.
342 if (span < MIN_SCALE_SPAN) {
343 startScaling_ = false;
344 preSpan_ = lastSpan_ = span;
345 }
346 if ((action == MMI::PointerEvent::POINTER_ACTION_UP) ||
347 (action == MMI::PointerEvent::POINTER_ACTION_DOWN)) {
348 preSpan_ = lastSpan_ = span;
349 }
350 }
351
352 if (!startScaling_) {
353 HILOG_DEBUG("Current is not scaling");
354 return;
355 }
356
357 if (action != MMI::PointerEvent::POINTER_ACTION_MOVE) {
358 HILOG_DEBUG("Action(%{public}d) is not move", action);
359 return;
360 }
361
362 lastSpan_ = span;
363 float ratio = lastSpan_ / preSpan_;
364 if (ratio != 1) {
365 OnScale(ratio, focusXY.centerX, focusXY.centerY);
366 preSpan_ = lastSpan_;
367 }
368 }
369
CalcFocusCoordinate(MMI::PointerEvent & event,ZOOM_FOCUS_COORDINATE & coordinate)370 void AccessibilityZoomGesture::CalcFocusCoordinate(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE &coordinate)
371 {
372 HILOG_DEBUG();
373
374 float sumX = 0.0f;
375 float sumY = 0.0f;
376 int32_t upPointerId = -1;
377 int32_t action = event.GetPointerAction();
378 std::vector<int32_t> pointerIdList = event.GetPointerIds();
379 size_t count = pointerIdList.size();
380 if (!count) {
381 HILOG_DEBUG("The size of PointerIds is 0");
382 return;
383 }
384
385 if (action == MMI::PointerEvent::POINTER_ACTION_UP) {
386 upPointerId = event.GetPointerId();
387 HILOG_DEBUG("The pointer id of up is %{public}d", upPointerId);
388 count--;
389 }
390
391 if (!count) {
392 HILOG_DEBUG("The size of PointerIds(down) is invalid");
393 return;
394 }
395
396 for (int32_t pointerId : pointerIdList) {
397 if (pointerId == upPointerId) {
398 continue;
399 }
400 MMI::PointerEvent::PointerItem item;
401 event.GetPointerItem(pointerId, item);
402 sumX += static_cast<float>(item.GetDisplayX());
403 sumY += static_cast<float>(item.GetDisplayY());
404 }
405
406 coordinate.centerX = sumX / count;
407 coordinate.centerY = sumY / count;
408 HILOG_DEBUG("centerX:%{public}f, centerY:%{public}f", coordinate.centerX, coordinate.centerY);
409 }
410
CalcScaleSpan(MMI::PointerEvent & event,ZOOM_FOCUS_COORDINATE coordinate)411 float AccessibilityZoomGesture::CalcScaleSpan(MMI::PointerEvent &event, ZOOM_FOCUS_COORDINATE coordinate)
412 {
413 HILOG_DEBUG();
414
415 float span = 0.0f;
416 float sumSpanX = 0.0f;
417 float sumSpanY = 0.0f;
418 int32_t upPointerId = -1;
419 int32_t action = event.GetPointerAction();
420 std::vector<int32_t> pointerIdList = event.GetPointerIds();
421 size_t count = pointerIdList.size();
422 if (!count) {
423 HILOG_DEBUG("The size of PointerIds is 0");
424 return span;
425 }
426
427 if (action == MMI::PointerEvent::POINTER_ACTION_UP) {
428 upPointerId = event.GetPointerId();
429 HILOG_DEBUG("The pointer id of up is %{public}d", upPointerId);
430 count--;
431 }
432
433 if (!count) {
434 HILOG_DEBUG("The size of PointerIds(down) is invalid");
435 return span;
436 }
437
438 for (int32_t pointerId : pointerIdList) {
439 if (pointerId == upPointerId) {
440 continue;
441 }
442 MMI::PointerEvent::PointerItem item;
443 event.GetPointerItem(pointerId, item);
444 sumSpanX += static_cast<float>(abs(item.GetDisplayX() - coordinate.centerX));
445 sumSpanY += static_cast<float>(abs(item.GetDisplayY() - coordinate.centerY));
446 }
447
448 float spanX = sumSpanX / count;
449 float spanY = sumSpanY / count;
450 span = hypot(spanX, spanY) / HALF;
451 HILOG_DEBUG("The span is %{public}f", span);
452 return span;
453 }
454
IsDownValid()455 bool AccessibilityZoomGesture::IsDownValid()
456 {
457 HILOG_DEBUG();
458
459 if (!preLastDownEvent_) {
460 HILOG_DEBUG("This is the first down event");
461 return true;
462 }
463
464 if (CalcSeparationDistance(preLastDownEvent_, lastDownEvent_) >= multiTapDistance_) {
465 HILOG_DEBUG("The down event is vailid");
466 return false;
467 }
468 return true;
469 }
470
IsUpValid()471 bool AccessibilityZoomGesture::IsUpValid()
472 {
473 HILOG_DEBUG();
474
475 if (!lastDownEvent_) {
476 HILOG_DEBUG("The up event is invailid");
477 return false;
478 }
479
480 if (CalcIntervalTime(lastDownEvent_, lastUpEvent_) >= LONG_PRESS_TIMER) {
481 HILOG_DEBUG("The time has exceeded the long press time");
482 return false;
483 }
484
485 if (CalcSeparationDistance(lastDownEvent_, lastUpEvent_) >= tapDistance_) {
486 HILOG_DEBUG("The distance has exceeded the threshold");
487 return false;
488 }
489 return true;
490 }
491
IsTripleTaps()492 bool AccessibilityZoomGesture::IsTripleTaps()
493 {
494 HILOG_DEBUG();
495
496 uint32_t upEventCount = 0;
497 int32_t action = MMI::PointerEvent::POINTER_ACTION_UNKNOWN;
498 for (auto &pointerEvent : cacheEvents_) {
499 action = pointerEvent->GetPointerAction();
500 if (action == MMI::PointerEvent::POINTER_ACTION_UP) {
501 upEventCount++;
502 }
503 }
504
505 if (upEventCount >= TRIPLE_TAP_COUNT) {
506 HILOG_DEBUG("Triple tap detected");
507 return true;
508 }
509
510 return false;
511 }
512
CalcIntervalTime(std::shared_ptr<MMI::PointerEvent> firstEvent,std::shared_ptr<MMI::PointerEvent> secondEvent)513 int64_t AccessibilityZoomGesture::CalcIntervalTime(std::shared_ptr<MMI::PointerEvent> firstEvent,
514 std::shared_ptr<MMI::PointerEvent> secondEvent)
515 {
516 HILOG_DEBUG();
517
518 if (!firstEvent || !secondEvent) {
519 HILOG_DEBUG("The event is null");
520 return 0;
521 }
522
523 int64_t firstTime = firstEvent->GetActionTime();
524 int64_t secondTime = secondEvent->GetActionTime();
525 int64_t intervalTime = (secondTime - firstTime) / US_TO_MS;
526
527 return intervalTime;
528 }
529
CalcSeparationDistance(std::shared_ptr<MMI::PointerEvent> firstEvent,std::shared_ptr<MMI::PointerEvent> secondEvent)530 float AccessibilityZoomGesture::CalcSeparationDistance(std::shared_ptr<MMI::PointerEvent> firstEvent,
531 std::shared_ptr<MMI::PointerEvent> secondEvent)
532 {
533 HILOG_DEBUG();
534
535 if (!firstEvent || !secondEvent) {
536 HILOG_DEBUG("The event is null");
537 return 0;
538 }
539
540 MMI::PointerEvent::PointerItem firstItem;
541 MMI::PointerEvent::PointerItem secondItem;
542 firstEvent->GetPointerItem(firstEvent->GetPointerId(), firstItem);
543 secondEvent->GetPointerItem(secondEvent->GetPointerId(), secondItem);
544 int32_t durationX = secondItem.GetDisplayX() - firstItem.GetDisplayX();
545 int32_t durationY = secondItem.GetDisplayY() - firstItem.GetDisplayY();
546 float distance = static_cast<float>(hypot(durationX, durationY));
547
548 return distance;
549 }
550
OnTripleTaps(MMI::PointerEvent & event)551 void AccessibilityZoomGesture::OnTripleTaps(MMI::PointerEvent &event)
552 {
553 HILOG_DEBUG("state_ is %{public}d.", state_);
554
555 switch (state_) {
556 case READY_STATE: {
557 TransferState(ZOOMIN_STATE);
558 int32_t pointerId = event.GetPointerId();
559 MMI::PointerEvent::PointerItem item;
560 event.GetPointerItem(pointerId, item);
561 int32_t anchorX = item.GetDisplayX();
562 int32_t anchorY = item.GetDisplayY();
563 OnZoom(anchorX, anchorY);
564 break;
565 }
566 case ZOOMIN_STATE:
567 TransferState(READY_STATE);
568 OffZoom();
569 break;
570 default:
571 break;
572 }
573
574 ClearCacheEventsAndMsg();
575 }
576
ZoomGestureEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner,AccessibilityZoomGesture & zoomGesture)577 AccessibilityZoomGesture::ZoomGestureEventHandler::ZoomGestureEventHandler(
578 const std::shared_ptr<AppExecFwk::EventRunner> &runner,
579 AccessibilityZoomGesture &zoomGesture): AppExecFwk::EventHandler(runner), zoomGesture_(zoomGesture)
580 {
581 HILOG_DEBUG();
582 }
583
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)584 void AccessibilityZoomGesture::ZoomGestureEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
585 {
586 HILOG_DEBUG();
587
588 uint32_t eventId = event->GetInnerEventId();
589
590 switch (eventId) {
591 case MULTI_TAP_MSG:
592 zoomGesture_.SendCacheEventsToNext();
593 break;
594 default:
595 break;
596 }
597 }
598
OnZoom(int32_t anchorX,int32_t anchorY)599 void AccessibilityZoomGesture::OnZoom(int32_t anchorX, int32_t anchorY)
600 {
601 HILOG_DEBUG("anchorX:%{public}d, anchorY:%{public}d.", anchorX, anchorY);
602
603 OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorAndScale(anchorX, anchorY, DEFAULT_SCALE);
604 }
605
OffZoom()606 void AccessibilityZoomGesture::OffZoom()
607 {
608 HILOG_DEBUG();
609
610 OHOS::Rosen::WindowAccessibilityController::GetInstance().OffWindowZoom();
611 }
612
OnScroll(float offsetX,float offsetY)613 void AccessibilityZoomGesture::OnScroll(float offsetX, float offsetY)
614 {
615 HILOG_DEBUG("offsetX:%{public}f, offsetY:%{public}f.", offsetX, offsetY);
616
617 OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorOffset(
618 static_cast<int32_t>(offsetX), static_cast<int32_t>(offsetY));
619 }
620
OnScale(float scaleRatio,float focusX,float focusY)621 void AccessibilityZoomGesture::OnScale(float scaleRatio, float focusX, float focusY)
622 {
623 HILOG_DEBUG("scaleRatio:%{public}f, focusX:%{public}f, focusY:%{public}f.", scaleRatio, focusX, focusY);
624
625 OHOS::Rosen::WindowAccessibilityController::GetInstance().SetAnchorAndScale(
626 static_cast<int32_t>(focusX), static_cast<int32_t>(focusY), scaleRatio);
627 }
628 } // namespace Accessibility
629 } // namespace OHOS
630