1 /* 2 * Copyright (c) 2023 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 TOUCH_DRAWING_MANAGER_H 17 #define TOUCH_DRAWING_MANAGER_H 18 19 #include <ui/rs_canvas_node.h> 20 #include <ui/rs_surface_node.h> 21 #include <transaction/rs_transaction.h> 22 23 #include "draw/canvas.h" 24 #include "nocopyable.h" 25 #include "pointer_event.h" 26 #include "window_info.h" 27 #include "singleton.h" 28 29 namespace OHOS { 30 namespace MMI { 31 struct Bubble { 32 int32_t innerCircleRadius { 0 }; 33 int32_t outerCircleRadius { 0 }; 34 float outerCircleWidth { 0 }; 35 }; 36 37 class TouchDrawingManager { 38 DECLARE_DELAYED_SINGLETON(TouchDrawingManager); 39 public: 40 DISALLOW_COPY_AND_MOVE(TouchDrawingManager); 41 void TouchDrawHandler(const std::shared_ptr<PointerEvent> pointerEvent); 42 void UpdateDisplayInfo(const DisplayInfo& displayInfo); 43 44 private: 45 void StartTouchDraw(const std::shared_ptr<PointerEvent> pointerEvent); 46 void CreateTouchWindow(const int32_t displayId); 47 void CreateCanvasNode(); 48 int32_t DrawGraphic(const std::shared_ptr<PointerEvent> pointerEvent); 49 bool IsValidAction(const int32_t action); 50 void GetOriginalTouchScreenCoordinates(Direction direction, int32_t width, int32_t height, 51 int32_t &physicalX, int32_t &physicalY); 52 53 private: 54 std::shared_ptr<Rosen::RSSurfaceNode> surfaceNode_; 55 std::shared_ptr<Rosen::RSCanvasNode> canvasNode_; 56 DisplayInfo displayInfo_ {}; 57 uint64_t screenId_ { 0 }; 58 Bubble bubble_; 59 Rosen::Drawing::Brush brush_; 60 Rosen::Drawing::Pen pen_; 61 }; 62 #define TOUCH_DRAWING_MANAGER ::OHOS::DelayedSingleton<TouchDrawingManager>::GetInstance() 63 } // namespace MMI 64 } // namespace OHOS 65 #endif // TOUCH_DRAWING_MANAGER_H 66