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 class 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, 44 const std::weak_ptr<RSContext>& context = {}, bool isTextureExportNode = false); 45 virtual ~RSCanvasRenderNode(); 46 47 #ifndef USE_ROSEN_DRAWING 48 void UpdateRecording(std::shared_ptr<DrawCmdList> drawCmds, 49 RSModifierType type, bool isSingleFrameComposer = false); 50 #else 51 void UpdateRecording(std::shared_ptr<Drawing::DrawCmdList> drawCmds, 52 RSModifierType type, bool isSingleFrameComposer = false); 53 #endif 54 void ClearRecording(); 55 56 void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 57 void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override; 58 void ProcessTransitionBeforeChildren(RSPaintFilterCanvas& canvas) override; 59 void ProcessAnimatePropertyBeforeChildren(RSPaintFilterCanvas& canvas, bool includeProperty) override; 60 void ProcessRenderContents(RSPaintFilterCanvas& canvas) override; 61 void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) override; 62 void ProcessTransitionAfterChildren(RSPaintFilterCanvas& canvas) override; 63 64 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 65 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 66 67 // functions that are dedicated to driven render [start] 68 RSB_EXPORT void ProcessDrivenBackgroundRender(RSPaintFilterCanvas& canvas); 69 RSB_EXPORT void ProcessDrivenContentRender(RSPaintFilterCanvas& canvas); 70 RSB_EXPORT void ProcessDrivenContentRenderAfterChildren(RSPaintFilterCanvas& canvas); 71 RSB_EXPORT RectF GetDrivenContentClipFrameRect() const; 72 // functions that are dedicated to driven render [end] 73 74 RSB_EXPORT void ProcessShadowBatching(RSPaintFilterCanvas& canvas); 75 GetType()76 RSRenderNodeType GetType() const override 77 { 78 return RSRenderNodeType::CANVAS_NODE; 79 } 80 81 void OnTreeStateChanged() override; 82 private: 83 void ApplyDrawCmdModifier(RSModifierContext& context, RSModifierType type); 84 void InternalDrawContent(RSPaintFilterCanvas& canvas); 85 // functions that are dedicated to driven render [start] 86 void DrawDrivenContent(RSPaintFilterCanvas& canvas); 87 // functions that are dedicated to driven render [end] 88 89 void PropertyDrawableRender(RSPaintFilterCanvas& canvas, bool includeProperty); 90 void DrawShadow(RSModifierContext& context, RSPaintFilterCanvas& canvas); 91 92 RSPaintFilterCanvas::SaveStatus canvasNodeSaveCount_; 93 mutable std::mutex canvasNodeProcessMutex_; 94 95 friend class RSColorfulShadowDrawable; 96 friend class RSRenderTransition; 97 friend class RSPropertiesPainter; 98 }; 99 } // namespace Rosen 100 } // namespace OHOS 101 102 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_CANVAS_RENDER_NODE_H 103