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 #ifndef USE_ROSEN_DRAWING 29 class DrawCmdList; 30 #else 31 namespace Drawing { 32 class DrawCmdList; 33 } 34 #endif 35 struct RSModifierContext; 36 37 class RSCanvasRenderNode : public RSRenderNode { 38 public: 39 using WeakPtr = std::weak_ptr<RSCanvasRenderNode>; 40 using SharedPtr = std::shared_ptr<RSCanvasRenderNode>; 41 static inline constexpr RSRenderNodeType Type = RSRenderNodeType::CANVAS_NODE; 42 43 explicit RSCanvasRenderNode(NodeId id, std::weak_ptr<RSContext> context = {}); 44 virtual ~RSCanvasRenderNode(); 45 46 #ifndef USE_ROSEN_DRAWING 47 void UpdateRecording(std::shared_ptr<DrawCmdList> drawCmds, RSModifierType type); 48 #else 49 void UpdateRecording(std::shared_ptr<Drawing::DrawCmdList> drawCmds, RSModifierType type); 50 #endif 51 void ClearRecording(); 52 53 void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 54 void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override; 55 void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas) override; 56 void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas) override; 57 void ProcessRenderContents(RSPaintFilterCanvas& canvas) override; 58 void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) override; 59 void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas) override; 60 61 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 62 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 63 64 // functions that are dedicated to driven render [start] 65 RSB_EXPORT void ProcessDrivenBackgroundRender(RSPaintFilterCanvas& canvas); 66 RSB_EXPORT void ProcessDrivenContentRender(RSPaintFilterCanvas& canvas); 67 RSB_EXPORT void ProcessDrivenContentRenderAfterChildren(RSPaintFilterCanvas& canvas); 68 RSB_EXPORT RectF GetDrivenContentClipFrameRect() const; 69 // functions that are dedicated to driven render [end] 70 71 void OnApplyModifiers() override; 72 GetType()73 RSRenderNodeType GetType() const override 74 { 75 return RSRenderNodeType::CANVAS_NODE; 76 } 77 private: 78 virtual void ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type) const; 79 void InternalDrawContent(RSPaintFilterCanvas& canvas); 80 // functions that are dedicated to driven render [start] 81 void DrawDrivenContent(RSPaintFilterCanvas& canvas); 82 // functions that are dedicated to driven render [end] 83 84 RSPaintFilterCanvas::SaveStatus canvasNodeSaveCount_; 85 mutable std::mutex canvasNodeProcessMutex_; 86 87 friend class RSRenderTransition; 88 friend class RSPropertiesPainter; 89 }; 90 } // namespace Rosen 91 } // namespace OHOS 92 93 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H 94