1 /* 2 * Copyright (c) 2024 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 "rs_graphic_rootnode.h" 17 #include "transaction/rs_interfaces.h" 18 19 namespace OHOS { 20 namespace Rosen { RSGraphicRootNode()21RSGraphicRootNode::RSGraphicRootNode() 22 { 23 RSSurfaceNodeConfig config; 24 config.SurfaceNodeName = "TestScreenSurface"; 25 screenSurfaceNode_ = RSSurfaceNode::Create(config); 26 } 27 SetTestSurface(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> node)28void RSGraphicRootNode::SetTestSurface( 29 std::shared_ptr<OHOS::Rosen::RSSurfaceNode> node) 30 { 31 testSurfaceNode_ = node; 32 screenSurfaceNode_->AddChild(testSurfaceNode_, -1); 33 } 34 ResetTestSurface()35void RSGraphicRootNode::ResetTestSurface() 36 { 37 screenSurfaceNode_->RemoveChild(testSurfaceNode_); 38 testSurfaceNode_ = nullptr; 39 } 40 AddChild(std::shared_ptr<RSNode> child,int index)41void RSGraphicRootNode::AddChild(std::shared_ptr<RSNode> child, int index) 42 { 43 if (testSurfaceNode_) { 44 testSurfaceNode_->AddChild(child, index); 45 } 46 } 47 RemoveChild(std::shared_ptr<RSNode> child)48void RSGraphicRootNode::RemoveChild(std::shared_ptr<RSNode> child) 49 { 50 if (testSurfaceNode_) { 51 testSurfaceNode_->RemoveChild(child); 52 } 53 } 54 ClearChildren()55void RSGraphicRootNode::ClearChildren() 56 { 57 if (testSurfaceNode_) { 58 testSurfaceNode_->ClearChildren(); 59 } 60 } 61 62 } // namespace Rosen 63 } // namespace OHOS 64