• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H
17 
18 #include "ui/rs_node.h"
19 
20 class SkCanvas;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class RSNodeMap;
25 
26 class RSC_EXPORT RSCanvasNode : public RSNode {
27 public:
28     using WeakPtr = std::weak_ptr<RSCanvasNode>;
29     using SharedPtr = std::shared_ptr<RSCanvasNode>;
30     static inline constexpr RSUINodeType Type = RSUINodeType::CANVAS_NODE;
GetType()31     RSUINodeType GetType() const override
32     {
33         return Type;
34     }
35 
36     ~RSCanvasNode() override;
37 
38     static SharedPtr Create(bool isRenderServiceNode = false);
39 
40     SkCanvas* BeginRecording(int width, int height);
41     bool IsRecording() const;
42     void FinishRecording();
43     float GetPaintWidth() const;
44     float GetPaintHeight() const;
45     void DrawOnNode(RSModifierType type, DrawFunc func) override;
46 
47 protected:
48     RSCanvasNode(bool isRenderServiceNode);
49     RSCanvasNode(const RSCanvasNode&) = delete;
50     RSCanvasNode(const RSCanvasNode&&) = delete;
51     RSCanvasNode& operator=(const RSCanvasNode&) = delete;
52     RSCanvasNode& operator=(const RSCanvasNode&&) = delete;
53 
54 private:
55     SkCanvas* recordingCanvas_ = nullptr;
56 
57     friend class RSUIDirector;
58     friend class RSAnimation;
59     friend class RSPathAnimation;
60     friend class RSPropertyAnimation;
61     friend class RSNodeMap;
62 };
63 } // namespace Rosen
64 } // namespace OHOS
65 
66 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H
67