1 /* 2 * Copyright (c) 2022-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 #include "transaction/rs_occlusion_data.h" 17 #include "platform/common/rs_log.h" 18 19 namespace OHOS { 20 namespace Rosen { ~RSOcclusionData()21RSOcclusionData::~RSOcclusionData() noexcept 22 { 23 } 24 Unmarshalling(Parcel & parcel)25RSOcclusionData* RSOcclusionData::Unmarshalling(Parcel& parcel) 26 { 27 auto data = new RSOcclusionData(); 28 auto size = parcel.ReadUint32(); 29 size_t readableSize = parcel.GetReadableBytes() / sizeof(uint64_t); 30 size_t len = static_cast<size_t>(size); 31 if (len > readableSize || len > data->visibleData_.max_size()) { 32 RS_LOGE("RSOcclusionData Unmarshalling Failed read vector, size:%zu, readableSize:%zu", len, readableSize); 33 return data; 34 } 35 for (uint32_t i = 0; i < size; i++) { 36 uint64_t id = parcel.ReadUint64(); 37 data->visibleData_.emplace_back(id); 38 } 39 return data; 40 } 41 Marshalling(Parcel & parcel) const42bool RSOcclusionData::Marshalling(Parcel& parcel) const 43 { 44 parcel.WriteUint32(visibleData_.size()); 45 for (auto& data : visibleData_) { 46 parcel.WriteUint64(data); 47 } 48 49 return true; 50 } 51 } // namespace Rosen 52 } // namespace OHOS 53