/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef KNUCKLE_DYNAMIC_DRAWING_MANAGER_H #define KNUCKLE_DYNAMIC_DRAWING_MANAGER_H #include "draw/canvas.h" #include "include/core/SkPaint.h" #include "include/core/SkPath.h" #include "transaction/rs_transaction.h" #include "ui/rs_canvas_drawing_node.h" #include "ui/rs_surface_node.h" #include "knuckle_drawing_manager.h" #include "knuckle_glow_trace_system.h" #include "pointer_event.h" #include "window_info.h" namespace OHOS { namespace MMI { class KnuckleDynamicDrawingManager { public: KnuckleDynamicDrawingManager(); ~KnuckleDynamicDrawingManager() = default; void KnuckleDynamicDrawHandler(std::shared_ptr pointerEvent); void UpdateDisplayInfo(const DisplayInfo& displayInfo); void SetKnuckleDrawingManager(std::shared_ptr knuckleDrawMgr); private: void StartTouchDraw(std::shared_ptr pointerEvent); void CreateTouchWindow(const int32_t displayId); void CreateCanvasNode(); int32_t DrawGraphic(std::shared_ptr pointerEvent); bool CheckPointerAction(std::shared_ptr pointerEvent); void ProcessUpAndCancelEvent(std::shared_ptr pointerEvent); void ProcessDownEvent(std::shared_ptr pointerEvent); void ProcessMoveEvent(std::shared_ptr pointerEvent); void InitPointerPathPaint(); void UpdateTrackColors(); std::shared_ptr DecodeImageToPixelMap(const std::string &imagePath); bool IsSingleKnuckle(std::shared_ptr touchEvent); void DestoryWindow(); private: std::shared_ptr surfaceNode_ { nullptr }; std::shared_ptr canvasNode_ { nullptr }; DisplayInfo displayInfo_ {}; uint64_t screenId_ { 0 }; Rosen::Drawing::Brush brush_; Rosen::Drawing::Pen pen_; std::vector traceControlPoints_; int32_t pointCounter_ { 0 }; bool isDrawing_ { true }; std::shared_ptr glowTraceSystem_ { nullptr }; Rosen::Drawing::Path pointerPath_; SkPaint pointerPathPaint_; int64_t lastUpdateTimeMillis_ { 0 }; std::shared_ptr pixelMap_ { nullptr }; bool isStop_ { false }; bool isRotate_ { false }; int32_t lastDownX_ { 0 }; int32_t lastDownY_ { 0 }; int64_t lastUpTime_ { 0 }; int32_t scaleW_ { 0 }; int32_t scaleH_ { 0 }; int64_t firstDownTime_ { 0 }; int64_t isInDrawingTime_ { 0 }; std::shared_ptr knuckleDrawMgr_ { nullptr }; }; } // namespace MMI } // namespace OHOS #endif // KNUCKLE_DYNAMIC_DRAWING_MANAGER_H