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 <mutex> 21 #include <parcel.h> 22 #include <refbase.h> 23 24 #include "common/rs_common_def.h" 25 #include "common/rs_macros.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 static void FlushImplicitTransaction(); 43 void OpenSyncTransaction(); 44 void CloseSyncTransaction(); 45 46 void Begin(); 47 void Commit(); 48 49 private: 50 uint64_t GenerateSyncId(); 51 void ResetSyncTransactionInfo(); 52 bool UnmarshallingParam(Parcel& parcel); 53 54 uint64_t syncId_ { 0 }; 55 std::mutex mutex_; 56 mutable int32_t transactionCount_ { 0 }; 57 58 friend class RSSyncTransactionController; 59 }; 60 61 } // namespace Rosen 62 } // namespace OHOS 63 64 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_TRANSACTION_H 65