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 "ui/rs_display_node.h"
17
18 #include "command/rs_display_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 namespace OHOS {
23 namespace Rosen {
24
Create(const RSDisplayNodeConfig & displayNodeConfig)25 RSDisplayNode::SharedPtr RSDisplayNode::Create(const RSDisplayNodeConfig& displayNodeConfig)
26 {
27 SharedPtr node(new RSDisplayNode(displayNodeConfig));
28 RSNodeMap::MutableInstance().RegisterNode(node);
29
30 std::unique_ptr<RSCommand> command = std::make_unique<RSDisplayNodeCreate>(node->GetId(), displayNodeConfig);
31 auto transactionProxy = RSTransactionProxy::GetInstance();
32 if (transactionProxy != nullptr) {
33 transactionProxy->AddCommand(command, true);
34 }
35 ROSEN_LOGD("RSDisplayNode::Create, id:%" PRIu64, node->GetId());
36 return node;
37 }
38
SetScreenId(uint64_t screenId)39 void RSDisplayNode::SetScreenId(uint64_t screenId)
40 {
41 std::unique_ptr<RSCommand> command = std::make_unique<RSDisplayNodeSetScreenId>(GetId(), screenId);
42 auto transactionProxy = RSTransactionProxy::GetInstance();
43 if (transactionProxy != nullptr) {
44 transactionProxy->AddCommand(command, true);
45 }
46 ROSEN_LOGD("RSDisplayNode::SetScreenId, ScreenId:%" PRIu64, screenId);
47 }
48
SetDisplayOffset(int32_t offsetX,int32_t offsetY)49 void RSDisplayNode::SetDisplayOffset(int32_t offsetX, int32_t offsetY)
50 {
51 std::unique_ptr<RSCommand> command = std::make_unique<RSDisplayNodeSetDisplayOffset>(GetId(), offsetX, offsetY);
52 auto transactionProxy = RSTransactionProxy::GetInstance();
53 if (transactionProxy != nullptr) {
54 transactionProxy->AddCommand(command, true);
55 }
56 ROSEN_LOGD("RSDisplayNode::SetDisplayOffset, offsetX:%d, offsetY:%d", offsetX, offsetY);
57 }
58
SetSecurityDisplay(bool isSecurityDisplay)59 void RSDisplayNode::SetSecurityDisplay(bool isSecurityDisplay)
60 {
61 isSecurityDisplay_ = isSecurityDisplay;
62 std::unique_ptr<RSCommand> command = std::make_unique<RSDisplayNodeSetSecurityDisplay>(GetId(), isSecurityDisplay);
63 auto transactionProxy = RSTransactionProxy::GetInstance();
64 if (transactionProxy != nullptr) {
65 transactionProxy->AddCommand(command, true);
66 }
67 ROSEN_LOGD("RSDisplayNode::SetSecurityDisplay, displayNodeId:[%" PRIu64 "] isSecurityDisplay:[%s]", GetId(),
68 isSecurityDisplay ? "true" : "false");
69 }
70
GetSecurityDisplay() const71 bool RSDisplayNode::GetSecurityDisplay() const
72 {
73 return isSecurityDisplay_;
74 }
75
SetDisplayNodeMirrorConfig(const RSDisplayNodeConfig & displayNodeConfig)76 void RSDisplayNode::SetDisplayNodeMirrorConfig(const RSDisplayNodeConfig& displayNodeConfig)
77 {
78 isMirroredDisplay_ = displayNodeConfig.isMirrored;
79 std::unique_ptr<RSCommand> command = std::make_unique<RSDisplayNodeSetDisplayMode>(GetId(), displayNodeConfig);
80 auto transactionProxy = RSTransactionProxy::GetInstance();
81 if (transactionProxy != nullptr) {
82 transactionProxy->AddCommand(command, true);
83 }
84 ROSEN_LOGD("RSDisplayNode::SetDisplayNodeMirrorConfig, displayNodeId:[%" PRIu64 "] isMirrored:[%s]", GetId(),
85 displayNodeConfig.isMirrored ? "true" : "false");
86 }
87
IsMirrorDisplay() const88 bool RSDisplayNode::IsMirrorDisplay() const
89 {
90 return isMirroredDisplay_;
91 }
92
RSDisplayNode(const RSDisplayNodeConfig & config)93 RSDisplayNode::RSDisplayNode(const RSDisplayNodeConfig& config)
94 : RSNode(true), screenId_(config.screenId), offsetX_(0), offsetY_(0), isMirroredDisplay_(config.isMirrored)
95 {
96 (void)screenId_;
97 (void)offsetX_;
98 (void)offsetY_;
99 }
100
101 RSDisplayNode::~RSDisplayNode() = default;
102
103 } // namespace Rosen
104 } // namespace OHOS
105