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 16 #include "pipeline/rs_root_render_node.h" 17 18 #include "command/rs_surface_node_command.h" 19 #include "platform/drawing/rs_surface.h" 20 #include "transaction/rs_transaction_proxy.h" 21 #include "visitor/rs_node_visitor.h" 22 #ifdef ROSEN_OHOS 23 #include <surface.h> 24 #endif 25 26 namespace OHOS { 27 namespace Rosen { RSRootRenderNode(NodeId id,std::weak_ptr<RSContext> context)28RSRootRenderNode::RSRootRenderNode(NodeId id, std::weak_ptr<RSContext> context) : RSCanvasRenderNode(id, context) {} 29 ~RSRootRenderNode()30RSRootRenderNode::~RSRootRenderNode() {} 31 AttachRSSurfaceNode(NodeId surfaceNodeId)32void RSRootRenderNode::AttachRSSurfaceNode(NodeId surfaceNodeId) 33 { 34 surfaceNodeId_ = surfaceNodeId; 35 } 36 GetSurfaceWidth() const37int32_t RSRootRenderNode::GetSurfaceWidth() const 38 { 39 return GetRenderProperties().GetFrameWidth(); 40 } 41 GetSurfaceHeight() const42int32_t RSRootRenderNode::GetSurfaceHeight() const 43 { 44 return GetRenderProperties().GetFrameHeight(); 45 } 46 GetSurface()47std::shared_ptr<RSSurface> RSRootRenderNode::GetSurface() 48 { 49 return rsSurface_; 50 } 51 GetRSSurfaceNodeId()52NodeId RSRootRenderNode::GetRSSurfaceNodeId() 53 { 54 return surfaceNodeId_; 55 } 56 AddSurfaceRenderNode(NodeId id)57void RSRootRenderNode::AddSurfaceRenderNode(NodeId id) 58 { 59 childSurfaceNodeId_.push_back(id); 60 } 61 ClearSurfaceNodeInRS()62void RSRootRenderNode::ClearSurfaceNodeInRS() 63 { 64 for (auto childId : childSurfaceNodeId_) { 65 std::unique_ptr<RSCommand> command = std::make_unique<RSSurfaceNodeRemoveSelf>(childId); 66 auto transactionProxy = RSTransactionProxy::GetInstance(); 67 if (transactionProxy != nullptr) { 68 transactionProxy->AddCommandFromRT(command); 69 } 70 } 71 childSurfaceNodeId_.clear(); 72 } 73 Prepare(const std::shared_ptr<RSNodeVisitor> & visitor)74void RSRootRenderNode::Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) 75 { 76 visitor->PrepareRootRenderNode(*this); 77 } 78 Process(const std::shared_ptr<RSNodeVisitor> & visitor)79void RSRootRenderNode::Process(const std::shared_ptr<RSNodeVisitor>& visitor) 80 { 81 visitor->ProcessRootRenderNode(*this); 82 } 83 84 bool RSRootRenderNode::forceRaster_ = false; 85 MarkForceRaster(bool flag)86void RSRootRenderNode::MarkForceRaster(bool flag) 87 { 88 forceRaster_ = flag; 89 } 90 NeedForceRaster()91bool RSRootRenderNode::NeedForceRaster() 92 { 93 #ifdef ACE_ENABLE_GL 94 return forceRaster_; 95 #else 96 return false; 97 #endif 98 } 99 } // namespace Rosen 100 } // namespace OHOS 101