• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #ifndef RENDER_SERVICE_CLIENT_CORE_MESSAGE_RS_MESSAGE_PROCESSOR_H
16 #define RENDER_SERVICE_CLIENT_CORE_MESSAGE_RS_MESSAGE_PROCESSOR_H
17 
18 #include <memory>
19 #include <unordered_map>
20 #include "transaction/rs_transaction_data.h"
21 
22 #include "common/rs_macros.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RSCommand;
27 class RSB_EXPORT RSMessageProcessor final {
28 public:
29     static RSB_EXPORT RSMessageProcessor& Instance();
30 
31     void AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>& command);
32     void AddUIMessage(uint32_t pid, std::unique_ptr<RSCommand>&& command);
33 
34     bool HasTransaction() const;
35     bool HasTransaction(uint32_t pid) const;
36 
37     RSTransactionData&& GetTransaction(uint32_t pid);
38     std::unordered_map<uint32_t, RSTransactionData>&& GetAllTransactions();
39 private:
40     RSMessageProcessor() = default;
41     ~RSMessageProcessor();
42     RSMessageProcessor(const RSMessageProcessor&) = delete;
43     RSMessageProcessor(const RSMessageProcessor&&) = delete;
44     RSMessageProcessor& operator=(const RSMessageProcessor&) = delete;
45     RSMessageProcessor& operator=(const RSMessageProcessor&&) = delete;
46 
47 private:
48     std::unordered_map<uint32_t, RSTransactionData> transactionMap_;
49 };
50 } // namespace Rosen
51 } // namespace OHOS
52 #endif // RENDER_SERVICE_CLIENT_CORE_MESSAGE_RS_MESSAGE_PROCESSOR_H
53