• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 KNUCKLE_DYNAMIC_DRAWING_MANAGER_H
17 #define KNUCKLE_DYNAMIC_DRAWING_MANAGER_H
18 
19 #include "include/core/SkPaint.h"
20 
21 #include "knuckle_drawing_manager.h"
22 #include "knuckle_glow_trace_system.h"
23 
24 namespace OHOS {
25 namespace MMI {
26 class KnuckleDynamicDrawingManager {
27 public:
28     KnuckleDynamicDrawingManager();
29     ~KnuckleDynamicDrawingManager() = default;
30     void KnuckleDynamicDrawHandler(std::shared_ptr<PointerEvent> pointerEvent, int32_t displayId = -1);
31     void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo);
32     void SetKnuckleDrawingManager(std::shared_ptr<KnuckleDrawingManager> knuckleDrawMgr);
33 
34 private:
35     void StartTouchDraw(std::shared_ptr<PointerEvent> pointerEvent);
36     void CreateTouchWindow(const int32_t rsId);
37     void CreateCanvasNode();
38     int32_t DrawGraphic(std::shared_ptr<PointerEvent> pointerEvent);
39 
40     bool CheckPointerAction(std::shared_ptr<PointerEvent> pointerEvent);
41     void ProcessUpAndCancelEvent(std::shared_ptr<PointerEvent> pointerEvent);
42     void ProcessDownEvent(std::shared_ptr<PointerEvent> pointerEvent);
43     void ProcessMoveEvent(std::shared_ptr<PointerEvent> pointerEvent);
44     void InitPointerPathPaint();
45     void UpdateTrackColors();
46     std::shared_ptr<OHOS::Media::PixelMap> DecodeImageToPixelMap(const std::string &imagePath);
47     bool IsSingleKnuckle(std::shared_ptr<PointerEvent> touchEvent);
48     void DestoryWindow();
49 
50 private:
51     std::shared_ptr<Rosen::RSSurfaceNode> surfaceNode_ { nullptr };
52     std::shared_ptr<Rosen::RSCanvasDrawingNode> canvasNode_ { nullptr };
53     OLD::DisplayInfo displayInfo_ {};
54     uint64_t screenId_ { 0 };
55     Rosen::Drawing::Brush brush_;
56     Rosen::Drawing::Pen pen_;
57     std::vector<Rosen::Drawing::Point> traceControlPoints_;
58 
59     int32_t pointCounter_ { 0 };
60     bool isDrawing_ { true };
61     std::shared_ptr<KnuckleGlowTraceSystem> glowTraceSystem_ { nullptr };
62     Rosen::Drawing::Path pointerPath_;
63     SkPaint pointerPathPaint_;
64     int64_t lastUpdateTimeMillis_ { 0 };
65 
66     std::shared_ptr<OHOS::Media::PixelMap> pixelMap_ { nullptr };
67     bool isStop_ { false };
68     bool isRotate_ { false };
69     int32_t lastDownX_ { 0 };
70     int32_t lastDownY_ { 0 };
71     int64_t lastUpTime_ { 0 };
72     int32_t scaleW_ { 0 };
73     int32_t scaleH_ { 0 };
74     int64_t firstDownTime_ { 0 };
75     int64_t isInDrawingTime_ { 0 };
76     std::shared_ptr<KnuckleDrawingManager> knuckleDrawMgr_ { nullptr };
77 };
78 } // namespace MMI
79 } // namespace OHOS
80 #endif // KNUCKLE_DYNAMIC_DRAWING_MANAGER_H
81