• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "dm_virtual_screen_option.h"
17 #include "window_manager_hilog.h"
18 
19 namespace OHOS::Rosen {
DmVirtualScreenOption(VirtualScreenOption option)20 DmVirtualScreenOption::DmVirtualScreenOption(VirtualScreenOption option) : option_(std::move(option))
21 {}
22 
Marshalling(Parcel & parcel) const23 bool DmVirtualScreenOption::Marshalling(Parcel& parcel) const
24 {
25     return parcel.WriteString(option_.name_) && parcel.WriteUint32(option_.width_) &&
26            parcel.WriteUint32(option_.height_) && parcel.WriteFloat(option_.density_) &&
27            parcel.WriteInt32(option_.flags_) && parcel.WriteBool(option_.isForShot_) &&
28            parcel.WriteUInt64Vector(option_.missionIds_);
29 }
30 
Unmarshalling(Parcel & parcel)31 DmVirtualScreenOption* DmVirtualScreenOption::Unmarshalling(Parcel& parcel)
32 {
33     std::string name;
34     uint32_t width;
35     uint32_t height;
36     float density;
37     int32_t flags;
38     bool isForShot;
39     std::vector<uint64_t> missionIds;
40     if (!(parcel.ReadString(name) && parcel.ReadUint32(width) && parcel.ReadUint32(height) &&
41         parcel.ReadFloat(density) && parcel.ReadInt32(flags) && parcel.ReadBool(isForShot) &&
42         parcel.ReadUInt64Vector(&missionIds))) {
43         TLOGE(WmsLogTag::DMS, "read from parcel failed");
44         return nullptr;
45     }
46 
47     auto* virScrOption = new (std::nothrow) DmVirtualScreenOption();
48     if (virScrOption == nullptr) {
49         TLOGE(WmsLogTag::DMS, "new DmVirtualScreenOption failed");
50         return nullptr;
51     }
52 
53     virScrOption->option_.name_ = name;
54     virScrOption->option_.width_ = width;
55     virScrOption->option_.height_ = height;
56     virScrOption->option_.density_ = density;
57     virScrOption->option_.flags_ = flags;
58     virScrOption->option_.isForShot_ = isForShot;
59     virScrOption->option_.missionIds_ = missionIds;
60     return virScrOption;
61 }
62 
GetOption() const63 VirtualScreenOption DmVirtualScreenOption::GetOption() const
64 {
65     return option_;
66 }
67 } // namespace OHOS::Rosen
68