• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H
17 
18 #include <memory>
19 #include <unordered_set>
20 
21 #include "modifier/rs_modifier_type.h"
22 #include "pipeline/rs_render_node.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class DrawCmdList;
27 class RSPaintFilterCanvas;
28 struct RSModifierContext;
29 
30 class RSCanvasRenderNode : public RSRenderNode {
31 public:
32     using WeakPtr = std::weak_ptr<RSCanvasRenderNode>;
33     using SharedPtr = std::shared_ptr<RSCanvasRenderNode>;
34     static inline constexpr RSRenderNodeType Type = RSRenderNodeType::CANVAS_NODE;
35 
36     explicit RSCanvasRenderNode(NodeId id, std::weak_ptr<RSContext> context = {});
37     virtual ~RSCanvasRenderNode();
38 
39     void UpdateRecording(std::shared_ptr<DrawCmdList> drawCmds, RSModifierType type);
40     void ClearRecording();
41 
42     void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override;
43     void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override;
44 
45     void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override;
46     void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override;
47 
GetType()48     RSRenderNodeType GetType() const override
49     {
50         return RSRenderNodeType::CANVAS_NODE;
51     }
52 private:
53     void ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type);
54 
55     std::pair<int, int> canvasNodeSaveCount_ = { 0, 0 };
56 
57     friend class RSRenderTransition;
58 };
59 } // namespace Rosen
60 } // namespace OHOS
61 
62 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H
63