1 /*
2  * Copyright (c) 2022 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 "screen_manager/rs_virtual_screen_resolution.h"
17 
18 namespace OHOS {
19 namespace Rosen {
RSVirtualScreenResolution(uint32_t width,uint32_t height)20 RSVirtualScreenResolution::RSVirtualScreenResolution(uint32_t width, uint32_t height)
21     : width_(width), height_(height)
22 {
23 }
24 
RSVirtualScreenResolution(const RSVirtualScreenResolution & other)25 RSVirtualScreenResolution::RSVirtualScreenResolution(const RSVirtualScreenResolution& other)
26     : width_(other.width_), height_(other.height_)
27 {
28 }
29 
operator =(const RSVirtualScreenResolution & other)30 RSVirtualScreenResolution& RSVirtualScreenResolution::operator=(const RSVirtualScreenResolution& other)
31 {
32     width_ = other.width_;
33     height_ = other.height_;
34     return *this;
35 }
36 
Marshalling(Parcel & parcel) const37 bool RSVirtualScreenResolution::Marshalling(Parcel& parcel) const
38 {
39     return parcel.WriteUint32(width_) && parcel.WriteUint32(height_);
40 }
41 
Unmarshalling(Parcel & parcel)42 RSVirtualScreenResolution* RSVirtualScreenResolution::Unmarshalling(Parcel& parcel)
43 {
44     uint32_t width;
45     uint32_t height;
46     if (!(parcel.ReadUint32(width) && parcel.ReadUint32(height))) {
47         return nullptr;
48     }
49 
50     RSVirtualScreenResolution* virtualScreenResolution = new RSVirtualScreenResolution(width, height);
51     return virtualScreenResolution;
52 }
53 
GetVirtualScreenWidth() const54 uint32_t RSVirtualScreenResolution::GetVirtualScreenWidth() const
55 {
56     return width_;
57 }
58 
GetVirtualScreenHeight() const59 uint32_t RSVirtualScreenResolution::GetVirtualScreenHeight() const
60 {
61     return height_;
62 }
63 
SetVirtualScreenWidth(uint32_t width)64 void RSVirtualScreenResolution::SetVirtualScreenWidth(uint32_t width)
65 {
66     width_ = width;
67 }
68 
SetVirtualScreenHeight(uint32_t height)69 void RSVirtualScreenResolution::SetVirtualScreenHeight(uint32_t height)
70 {
71     height_ = height;
72 }
73 } // namespace Rosen
74 } // namespace OHOS