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()21 RSGraphicRootNode::RSGraphicRootNode()
22 {
23 RSSurfaceNodeConfig config;
24 config.SurfaceNodeName = "TestScreenSurface";
25 screenSurfaceNode_ = RSSurfaceNode::Create(config, RSSurfaceNodeType::LEASH_WINDOW_NODE);
26 }
27
SetTestSurface(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> node)28 void RSGraphicRootNode::SetTestSurface(
29 std::shared_ptr<OHOS::Rosen::RSSurfaceNode> node)
30 {
31 testSurfaceNodes_.push_back(node);
32 screenSurfaceNode_->AddChild(testSurfaceNodes_.back(), -1);
33 }
34
ResetTestSurface()35 void RSGraphicRootNode::ResetTestSurface()
36 {
37 screenSurfaceNode_->ClearChildren();
38 testSurfaceNodes_.clear();
39 }
40
AddChild(std::shared_ptr<RSNode> child,int index)41 void RSGraphicRootNode::AddChild(std::shared_ptr<RSNode> child, int index)
42 {
43 if (testSurfaceNodes_.back()) {
44 testSurfaceNodes_.back()->AddChild(child, index);
45 }
46 }
47
RemoveChild(std::shared_ptr<RSNode> child)48 void RSGraphicRootNode::RemoveChild(std::shared_ptr<RSNode> child)
49 {
50 if (testSurfaceNode_) {
51 testSurfaceNode_->RemoveChild(child);
52 }
53 }
54
ClearChildren()55 void RSGraphicRootNode::ClearChildren()
56 {
57 if (testSurfaceNode_) {
58 testSurfaceNode_->ClearChildren();
59 }
60 }
61
RegisterNode(std::shared_ptr<RSNode> node)62 void RSGraphicRootNode::RegisterNode(std::shared_ptr<RSNode> node)
63 {
64 nodes_.push_back(node);
65 }
66
67 } // namespace Rosen
68 } // namespace OHOS
69