1 /* 2 * Copyright (c) 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 "window_drawing_content_info.h" 17 #include "window_manager_hilog.h" 18 19 namespace OHOS::Rosen { 20 namespace { 21 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowDrawingContentInfo"}; 22 } 23 Marshalling(Parcel & parcel) const24bool WindowDrawingContentInfo::Marshalling(Parcel& parcel) const 25 { 26 return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) && 27 parcel.WriteInt32(uid_) && parcel.WriteUint32(static_cast<uint32_t>(drawingContentState_)) && 28 parcel.WriteUint32(static_cast<uint32_t>(windowType_)); 29 } 30 Unmarshalling(Parcel & parcel)31WindowDrawingContentInfo* WindowDrawingContentInfo::Unmarshalling(Parcel& parcel) 32 { 33 auto windowDrawingContentInfo = new (std::nothrow) WindowDrawingContentInfo(); 34 if (windowDrawingContentInfo == nullptr) { 35 WLOGFE("window visibility info is nullptr."); 36 return nullptr; 37 } 38 39 uint32_t drawingContentState = 0; 40 bool res = parcel.ReadUint32(windowDrawingContentInfo->windowId_) && 41 parcel.ReadInt32(windowDrawingContentInfo->pid_) && parcel.ReadInt32(windowDrawingContentInfo->uid_) && 42 parcel.ReadUint32(drawingContentState); 43 if (!res) { 44 delete windowDrawingContentInfo; 45 return nullptr; 46 } 47 windowDrawingContentInfo->drawingContentState_ = static_cast<bool>(drawingContentState); 48 windowDrawingContentInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32()); 49 return windowDrawingContentInfo; 50 } 51 } // namespace OHOS::Rosen 52