• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ui/rs_root_node.h"
17 
18 #include "command/rs_root_node_command.h"
19 #include "pipeline/rs_node_map.h"
20 #include "platform/common/rs_log.h"
21 #include "transaction/rs_transaction_proxy.h"
22 #include "ui/rs_surface_node.h"
23 #include "ui/rs_ui_director.h"
24 
25 namespace OHOS {
26 namespace Rosen {
Create(bool isRenderServiceNode)27 std::shared_ptr<RSNode> RSRootNode::Create(bool isRenderServiceNode)
28 {
29     std::shared_ptr<RSRootNode> node(new RSRootNode(isRenderServiceNode));
30     RSNodeMap::MutableInstance().RegisterNode(node);
31 
32     std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeCreate>(node->GetId());
33     auto transactionProxy = RSTransactionProxy::GetInstance();
34     if (transactionProxy != nullptr) {
35         transactionProxy->AddCommand(command, isRenderServiceNode);
36     }
37     return node;
38 }
39 
RSRootNode(bool isRenderServiceNode)40 RSRootNode::RSRootNode(bool isRenderServiceNode) : RSCanvasNode(isRenderServiceNode) {}
41 
AttachRSSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode) const42 void RSRootNode::AttachRSSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode) const
43 {
44     std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeAttachRSSurfaceNode>(GetId(), surfaceNode->GetId());
45     auto transactionProxy = RSTransactionProxy::GetInstance();
46     if (transactionProxy != nullptr) {
47         transactionProxy->AddCommand(command, IsRenderServiceNode());
48     }
49 }
50 
51 } // namespace Rosen
52 } // namespace OHOS
53