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 "memory/rs_memory_track.h" 22 23 #include "modifier/rs_modifier_type.h" 24 #include "pipeline/rs_render_node.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 namespace Drawing { 29 class DrawCmdList; 30 } 31 class RSModifierContext; 32 33 class RSCanvasRenderNode : public RSRenderNode { 34 public: 35 using WeakPtr = std::weak_ptr<RSCanvasRenderNode>; 36 using SharedPtr = std::shared_ptr<RSCanvasRenderNode>; 37 static inline constexpr RSRenderNodeType Type = RSRenderNodeType::CANVAS_NODE; 38 39 virtual ~RSCanvasRenderNode(); 40 41 void UpdateRecording(std::shared_ptr<Drawing::DrawCmdList> drawCmds, 42 RSModifierType type, bool isSingleFrameComposer = false); 43 void ClearRecording(); 44 45 void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas) override; 46 void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas, bool includeProperty) override; 47 void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 48 void ProcessRenderContents(RSPaintFilterCanvas& canvas) override; 49 50 void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas) override; 51 void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) override; 52 void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override; 53 54 void QuickPrepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 55 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 56 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 57 58 RSB_EXPORT void ProcessShadowBatching(RSPaintFilterCanvas& canvas); 59 60 bool OpincGetNodeSupportFlag() override; 61 GetType()62 RSRenderNodeType GetType() const override 63 { 64 return RSRenderNodeType::CANVAS_NODE; 65 } 66 67 void OnTreeStateChanged() override; 68 69 void SetHDRPresent(bool hasHdrPresent); 70 bool GetHDRPresent() const; 71 72 // [Attention] Only used in PC window resize scene now 73 void SetLinkedRootNodeId(NodeId rootNodeId); 74 RSB_EXPORT NodeId GetLinkedRootNodeId() const; 75 76 protected: 77 explicit RSCanvasRenderNode(NodeId id, 78 const std::weak_ptr<RSContext>& context = {}, bool isTextureExportNode = false); 79 80 private: 81 void ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type); 82 void InternalDrawContent(RSPaintFilterCanvas& canvas, bool needApplyMatrix); 83 84 void PropertyDrawableRender(RSPaintFilterCanvas& canvas, bool includeProperty); 85 void DrawShadow(RSModifierContext& context, RSPaintFilterCanvas& canvas); 86 87 RSPaintFilterCanvas::SaveStatus canvasNodeSaveCount_; 88 89 friend class RSCanvasNodeCommandHelper; 90 friend class RSColorfulShadowDrawable; 91 friend class RSRenderTransition; 92 friend class RSPropertiesPainter; 93 bool hasHdrPresent_ = false; 94 95 // [Attention] Only used in PC window resize scene now 96 NodeId linkedRootNodeId_ = INVALID_NODEID; 97 }; 98 } // namespace Rosen 99 } // namespace OHOS 100 101 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H 102