• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef RENDER_SERVICE_BASE_PIPELINE_RS_TRANSACTION_DATA_CALLBACK_MANAGER_H
17 #define RENDER_SERVICE_BASE_PIPELINE_RS_TRANSACTION_DATA_CALLBACK_MANAGER_H
18 
19 #include <functional>
20 #include <map>
21 #include <utility>
22 #include <mutex>
23 #include <shared_mutex>
24 #include <utility>
25 #include <vector>
26 
27 #include "refbase.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 
32 class RSITransactionDataCallback;
33 
34 class RSB_EXPORT RSTransactionDataCallbackManager {
35 public:
36     void RegisterTransactionDataCallback(uint64_t token, uint64_t timeStamp,
37         sptr<RSITransactionDataCallback> callback);
38     void TriggerTransactionDataCallback(uint64_t token, uint64_t timeStamp);
39 
40     static RSTransactionDataCallbackManager& Instance();
41 private:
42     RSTransactionDataCallbackManager() = default;
43     ~RSTransactionDataCallbackManager() noexcept = default;
44 
45     RSTransactionDataCallbackManager(const RSTransactionDataCallbackManager&) = delete;
46     RSTransactionDataCallbackManager(RSTransactionDataCallbackManager&&) = delete;
47     RSTransactionDataCallbackManager& operator=(const RSTransactionDataCallbackManager&) = delete;
48     RSTransactionDataCallbackManager& operator=(RSTransactionDataCallbackManager&&) = delete;
49 
50     sptr<RSITransactionDataCallback> PopTransactionDataCallback(uint64_t token, uint64_t timeStamp);
51     bool PushTransactionDataCallback(uint64_t token, uint64_t timeStamp,
52         sptr<RSITransactionDataCallback> callback);
53 
54     std::map<std::pair<uint64_t, uint64_t>, sptr<RSITransactionDataCallback>> transactionDataCallbacks_;
55     std::mutex transactionDataCbMutex_;
56 };
57 } // namespace Rosen
58 } // namespace OHOS
59 
60 #endif // RENDER_SERVICE_BASE_PIPELINE_RS_TRANSACTION_DATA_CALLBACK_MANAGER_H