1 /*
2 * Copyright (c) 2021-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_screen_mode_info.h"
17
18 namespace OHOS {
19 namespace Rosen {
RSScreenModeInfo(int32_t width,int32_t height,uint32_t refreshRate,int32_t id)20 RSScreenModeInfo::RSScreenModeInfo(int32_t width, int32_t height, uint32_t refreshRate, int32_t id)
21 : width_(width), height_(height), refreshRate_(refreshRate), modeId_(id)
22 {
23 }
24
RSScreenModeInfo(const RSScreenModeInfo & other)25 RSScreenModeInfo::RSScreenModeInfo(const RSScreenModeInfo& other) : width_(other.width_),
26 height_(other.height_), refreshRate_(other.refreshRate_), modeId_(other.modeId_)
27 {
28 }
29
operator =(const RSScreenModeInfo & other)30 RSScreenModeInfo& RSScreenModeInfo::operator=(const RSScreenModeInfo& other)
31 {
32 width_ = other.width_;
33 height_ = other.height_;
34 refreshRate_ = other.refreshRate_;
35 modeId_ = other.modeId_;
36 return *this;
37 }
38
Marshalling(Parcel & parcel) const39 bool RSScreenModeInfo::Marshalling(Parcel& parcel) const
40 {
41 return parcel.WriteInt32(width_) && parcel.WriteInt32(height_) &&
42 parcel.WriteUint32(refreshRate_) && parcel.WriteInt32(modeId_);
43 }
44
Unmarshalling(Parcel & parcel)45 RSScreenModeInfo* RSScreenModeInfo::Unmarshalling(Parcel& parcel)
46 {
47 int32_t width;
48 int32_t height;
49 uint32_t refreshRate;
50 int32_t id;
51 if (!(parcel.ReadInt32(width) && parcel.ReadInt32(height) && parcel.ReadUint32(refreshRate)
52 && parcel.ReadInt32(id))) {
53 return nullptr;
54 }
55
56 RSScreenModeInfo* screenModeInfo = new RSScreenModeInfo(width, height, refreshRate, id);
57 return screenModeInfo;
58 }
59
GetScreenWidth() const60 int32_t RSScreenModeInfo::GetScreenWidth() const
61 {
62 return width_;
63 }
64
GetScreenHeight() const65 int32_t RSScreenModeInfo::GetScreenHeight() const
66 {
67 return height_;
68 }
69
GetScreenRefreshRate() const70 uint32_t RSScreenModeInfo::GetScreenRefreshRate() const
71 {
72 return refreshRate_;
73 }
74
GetScreenModeId() const75 int32_t RSScreenModeInfo::GetScreenModeId() const
76 {
77 return modeId_;
78 }
79
SetScreenWidth(int32_t width)80 void RSScreenModeInfo::SetScreenWidth(int32_t width)
81 {
82 width_ = width;
83 }
84
SetScreenHeight(int32_t height)85 void RSScreenModeInfo::SetScreenHeight(int32_t height)
86 {
87 height_ = height;
88 }
89
SetScreenRefreshRate(uint32_t refreshRate)90 void RSScreenModeInfo::SetScreenRefreshRate(uint32_t refreshRate)
91 {
92 refreshRate_ = refreshRate;
93 }
94
SetScreenModeId(int32_t id)95 void RSScreenModeInfo::SetScreenModeId(int32_t id)
96 {
97 modeId_ = id;
98 }
99 } // namespace Rosen
100 } // namespace OHOS