1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#include "window_drawing_content_info.h"
17e0dac50fSopenharmony_ci#include "window_manager_hilog.h"
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_cinamespace OHOS::Rosen {
20e0dac50fSopenharmony_cinamespace {
21e0dac50fSopenharmony_ciconstexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowDrawingContentInfo"};
22e0dac50fSopenharmony_ci}
23e0dac50fSopenharmony_ci
24e0dac50fSopenharmony_cibool WindowDrawingContentInfo::Marshalling(Parcel& parcel) const
25e0dac50fSopenharmony_ci{
26e0dac50fSopenharmony_ci    return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) &&
27e0dac50fSopenharmony_ci           parcel.WriteInt32(uid_) && parcel.WriteUint32(static_cast<uint32_t>(drawingContentState_)) &&
28e0dac50fSopenharmony_ci           parcel.WriteUint32(static_cast<uint32_t>(windowType_));
29e0dac50fSopenharmony_ci}
30e0dac50fSopenharmony_ci
31e0dac50fSopenharmony_ciWindowDrawingContentInfo* WindowDrawingContentInfo::Unmarshalling(Parcel& parcel)
32e0dac50fSopenharmony_ci{
33e0dac50fSopenharmony_ci    auto windowDrawingContentInfo = new (std::nothrow) WindowDrawingContentInfo();
34e0dac50fSopenharmony_ci    if (windowDrawingContentInfo == nullptr) {
35e0dac50fSopenharmony_ci        WLOGFE("window visibility info is nullptr.");
36e0dac50fSopenharmony_ci        return nullptr;
37e0dac50fSopenharmony_ci    }
38e0dac50fSopenharmony_ci
39e0dac50fSopenharmony_ci    uint32_t drawingContentState = 0;
40e0dac50fSopenharmony_ci    bool res = parcel.ReadUint32(windowDrawingContentInfo->windowId_) &&
41e0dac50fSopenharmony_ci        parcel.ReadInt32(windowDrawingContentInfo->pid_) && parcel.ReadInt32(windowDrawingContentInfo->uid_) &&
42e0dac50fSopenharmony_ci        parcel.ReadUint32(drawingContentState);
43e0dac50fSopenharmony_ci    if (!res) {
44e0dac50fSopenharmony_ci        delete windowDrawingContentInfo;
45e0dac50fSopenharmony_ci        return nullptr;
46e0dac50fSopenharmony_ci    }
47e0dac50fSopenharmony_ci    windowDrawingContentInfo->drawingContentState_ = static_cast<bool>(drawingContentState);
48e0dac50fSopenharmony_ci    windowDrawingContentInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32());
49e0dac50fSopenharmony_ci    return windowDrawingContentInfo;
50e0dac50fSopenharmony_ci}
51e0dac50fSopenharmony_ci} // namespace OHOS::Rosen
52