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