• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "command/rs_display_node_command.h"
17 
18 #include "pipeline/rs_display_render_node.h"
19 #include "platform/common/rs_log.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 
Create(RSContext & context,NodeId id,const RSDisplayNodeConfig & config)24 void DisplayNodeCommandHelper::Create(RSContext& context, NodeId id, const RSDisplayNodeConfig& config)
25 {
26     std::shared_ptr<RSBaseRenderNode> node =
27         std::make_shared<RSDisplayRenderNode>(id, config, context.weak_from_this());
28     auto& nodeMap = context.GetMutableNodeMap();
29     nodeMap.RegisterRenderNode(node);
30     context.GetGlobalRootRenderNode()->AddChild(node);
31     if (config.isMirrored) {
32         auto mirrorSourceNode = nodeMap.GetRenderNode<RSDisplayRenderNode>(config.mirrorNodeId);
33         if (mirrorSourceNode == nullptr) {
34             return;
35         }
36         auto displayNode = RSBaseRenderNode::ReinterpretCast<RSDisplayRenderNode>(node);
37         displayNode->SetMirrorSource(mirrorSourceNode);
38     }
39 }
40 
SetScreenId(RSContext & context,NodeId id,uint64_t screenId)41 void DisplayNodeCommandHelper::SetScreenId(RSContext& context, NodeId id, uint64_t screenId)
42 {
43     if (auto node = context.GetNodeMap().GetRenderNode<RSDisplayRenderNode>(id)) {
44         node->SetScreenId(screenId);
45     }
46 }
47 
SetDisplayOffset(RSContext & context,NodeId id,int32_t offsetX,int32_t offsetY)48 void DisplayNodeCommandHelper::SetDisplayOffset(RSContext& context, NodeId id, int32_t offsetX, int32_t offsetY)
49 {
50     if (auto node = context.GetNodeMap().GetRenderNode<RSDisplayRenderNode>(id)) {
51         node->SetDisplayOffset(offsetX, offsetY);
52     }
53 }
54 
SetSecurityDisplay(RSContext & context,NodeId id,bool isSecurityDisplay)55 void DisplayNodeCommandHelper::SetSecurityDisplay(RSContext& context, NodeId id, bool isSecurityDisplay)
56 {
57     if (auto node = context.GetNodeMap().GetRenderNode<RSDisplayRenderNode>(id)) {
58         node->SetSecurityDisplay(isSecurityDisplay);
59     }
60 }
61 
SetDisplayMode(RSContext & context,NodeId id,const RSDisplayNodeConfig & config)62 void DisplayNodeCommandHelper::SetDisplayMode(RSContext& context, NodeId id, const RSDisplayNodeConfig& config)
63 {
64     if (auto node = context.GetNodeMap().GetRenderNode<RSDisplayRenderNode>(id)) {
65         bool isMirror = config.isMirrored;
66         node->SetIsMirrorDisplay(isMirror);
67         if (isMirror) {
68             NodeId mirrorNodeId = config.mirrorNodeId;
69             auto& nodeMap = context.GetNodeMap();
70             auto mirrorSourceNode = nodeMap.GetRenderNode<RSDisplayRenderNode>(mirrorNodeId);
71             if (mirrorSourceNode == nullptr) {
72                 ROSEN_LOGD("DisplayNodeCommandHelper::SetDisplayMode fail, displayNodeId:[%" PRIu64
73                            "] mirrorNodeId:[%" PRIu64 "]",
74                     id, mirrorNodeId);
75                 return;
76             }
77             node->SetMirrorSource(mirrorSourceNode);
78         } else {
79             node->ResetMirrorSource();
80         }
81     }
82 }
83 
84 } // namespace Rosen
85 } // namespace OHOS
86