• 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 
16 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H
17 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H
18 
19 #include <message_parcel.h>
20 #include <parcel.h>
21 #include <refbase.h>
22 
23 #include "common/rs_common_def.h"
24 #include "common/rs_macros.h"
25 #include "ipc_callbacks/rs_isync_transaction_controller.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 
30 class RSC_EXPORT RSTransaction : public Parcelable {
31 public:
32     RSTransaction() = default;
33     RSTransaction(const RSTransaction&) = delete;
34     RSTransaction(const RSTransaction&&) = delete;
35     RSTransaction& operator=(const RSTransaction&) = delete;
36     RSTransaction& operator=(const RSTransaction&&) = delete;
37     ~RSTransaction() override = default;
38 
39     static RSTransaction* Unmarshalling(Parcel& parcel);
40     bool Marshalling(Parcel& parcel) const override;
41 
42     void MarshallTransactionSyncController(MessageParcel& parcel);
43     void UnmarshallTransactionSyncController(MessageParcel& parcel);
44 
45     static void FlushImplicitTransaction();
46     void OpenSyncTransaction();
47     void CloseSyncTransaction(const uint64_t transactionCount);
48 
49     void Begin();
50     void Commit();
51 
52 private:
53     uint64_t GenerateSyncId();
54     void ResetSyncTransactionInfo();
55     bool UnmarshallingParam(Parcel& parcel);
56     void CallCreateStartCallback();
57     void CallCreateFinishCallback();
58     void CreateTransactionFinish();
59     void SetCreateStartCallback(const std::function<void()>& callback);
60     void SetCreateFinishCallback(const std::function<void()>& callback);
61 
62     uint64_t syncId_ { 0 };
63     std::mutex mutex_;
64     std::vector<sptr<RSISyncTransactionController>> controllers_;
65     std::function<void()> createStartCallback_;
66     std::function<void()> createFinishCallback_;
67 
68     friend class RSSyncTransactionController;
69 };
70 
71 } // namespace Rosen
72 } // namespace OHOS
73 
74 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H
75