1 /* 2 * Copyright (c) 2021 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 ROSEN_RENDER_SERVICE_BASE_RS_TRANSACTION_DATA_H 17 #define ROSEN_RENDER_SERVICE_BASE_RS_TRANSACTION_DATA_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "command/rs_command.h" 23 #include "pipeline/rs_context.h" 24 25 #ifdef ROSEN_OHOS 26 #include <parcel.h> 27 #endif 28 29 namespace OHOS { 30 namespace Rosen { 31 #ifdef ROSEN_OHOS 32 class RSTransactionData : public Parcelable { 33 #else 34 class RSTransactionData { 35 #endif 36 public: 37 RSTransactionData() = default; RSTransactionData(RSTransactionData && other)38 RSTransactionData(RSTransactionData&& other) : commands_(std::move(other.commands_)) {} 39 ~RSTransactionData() noexcept; 40 41 #ifdef ROSEN_OHOS 42 static RSTransactionData* Unmarshalling(Parcel& parcel); 43 bool Marshalling(Parcel& parcel) const override; 44 #endif 45 GetCommandCount()46 int GetCommandCount() const 47 { 48 return commands_.size(); 49 } 50 IsEmpty()51 bool IsEmpty() const 52 { 53 return commands_.empty(); 54 } 55 56 void Process(RSContext& context); 57 58 void Clear(); 59 60 private: 61 void AddCommand(std::unique_ptr<RSCommand>& command); 62 void AddCommand(std::unique_ptr<RSCommand>&& command); 63 64 #ifdef ROSEN_OHOS 65 bool UnmarshallingCommand(Parcel& parcel); 66 #endif 67 68 std::vector<std::unique_ptr<RSCommand>> commands_; 69 70 friend class RSTransactionProxy; 71 friend class RSMessageProcessor; 72 }; 73 74 } // namespace Rosen 75 } // namespace OHOS 76 77 #endif // ROSEN_RENDER_SERVICE_BASE_RS_TRANSACTION_DATA_H 78