• 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_message_processor.h"
17 
18 #include "command/rs_command.h"
19 #include "platform/common/rs_log.h"
20 #include "transaction/rs_transaction_data.h"
21 
22 namespace OHOS {
23 namespace Rosen {
Instance()24 RSMessageProcessor& RSMessageProcessor::Instance()
25 {
26     static RSMessageProcessor processor;
27     return processor;
28 }
29 
~RSMessageProcessor()30 RSMessageProcessor::~RSMessageProcessor() {}
31 
AddUIMessage(uint32_t pid,std::unique_ptr<RSCommand> & command)32 void RSMessageProcessor::AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>& command)
33 {
34     transactionMap_[pid].AddCommand(std::move(command), 0, FollowType::NONE);
35 }
36 
AddUIMessage(uint32_t pid,std::unique_ptr<RSCommand> && command)37 void RSMessageProcessor::AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>&& command)
38 {
39     transactionMap_[pid].AddCommand(std::move(command), 0, FollowType::NONE);
40 }
41 
HasTransaction() const42 bool RSMessageProcessor::HasTransaction() const
43 {
44     return !transactionMap_.empty();
45 }
46 
HasTransaction(uint32_t pid) const47 bool RSMessageProcessor::HasTransaction(uint32_t pid) const
48 {
49     auto iter = transactionMap_.find(pid);
50     return iter != transactionMap_.end() && !iter->second.IsEmpty();
51 }
52 
GetTransaction(uint32_t pid)53 RSTransactionData&& RSMessageProcessor::GetTransaction(uint32_t pid)
54 {
55     return std::move(transactionMap_[pid]);
56 }
57 
GetAllTransactions()58 std::unordered_map<uint32_t, RSTransactionData>&& RSMessageProcessor::GetAllTransactions()
59 {
60     return std::move(transactionMap_);
61 }
62 
63 } // namespace Rosen
64 } // namespace OHOS
65