• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_RENDER_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H
17 
18 #include <memory>
19 
20 #include "animation/rs_animation_manager.h"
21 #include "pipeline/rs_base_render_node.h"
22 #include "pipeline/rs_dirty_region_manager.h"
23 #include "property/rs_properties.h"
24 
25 class SkCanvas;
26 namespace OHOS {
27 namespace Rosen {
28 class DrawCmdList;
29 class RSPaintFilterCanvas;
30 
31 class RSRenderNode : public RSBaseRenderNode {
32 public:
33     using WeakPtr = std::weak_ptr<RSRenderNode>;
34     using SharedPtr = std::shared_ptr<RSRenderNode>;
35     static inline constexpr RSRenderNodeType Type = RSRenderNodeType::RS_NODE;
36 
37     virtual ~RSRenderNode();
38 
39     bool Animate(int64_t timestamp) override;
40     bool Update(RSDirtyRegionManager& dirtyManager, const RSProperties* parent, bool parentDirty);
41 
42     RSProperties& GetMutableRenderProperties();
43     const RSProperties& GetRenderProperties() const;
44 
45     // used for animation test
GetAnimationManager()46     RSAnimationManager& GetAnimationManager()
47     {
48         return animationManager_;
49     }
50 
51     virtual void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas);
ProcessRenderContents(RSPaintFilterCanvas & canvas)52     virtual void ProcessRenderContents(RSPaintFilterCanvas& canvas) {}
53     virtual void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas);
54 
GetType()55     RSRenderNodeType GetType() const override
56     {
57         return RSRenderNodeType::RS_NODE;
58     }
59 
HasTransition(bool recursive)60     bool HasTransition(bool recursive) const override
61     {
62         return animationManager_.HasTransition() || RSBaseRenderNode::HasTransition(recursive);
63     }
64 
65 protected:
66     explicit RSRenderNode(NodeId id, std::weak_ptr<RSContext> context = {});
67     void UpdateDirtyRegion(RSDirtyRegionManager& dirtyManager);
68     bool IsDirty() const override;
69 
70 private:
71     void FallbackAnimationsToRoot();
72 
73     RectI oldDirty_;
74     RSProperties renderProperties_;
75     RSAnimationManager animationManager_;
76 
77     friend class RSRenderTransition;
78 };
79 } // namespace Rosen
80 } // namespace OHOS
81 
82 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_RENDER_NODE_H
83