• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "platform/common/rs_log.h"
18 
19 namespace OHOS {
20 namespace Rosen {
RSScreenModeInfo(int32_t width,int32_t height,uint32_t refreshRate,int32_t id)21 RSScreenModeInfo::RSScreenModeInfo(int32_t width, int32_t height, uint32_t refreshRate, int32_t id)
22     : width_(width), height_(height), refreshRate_(refreshRate), modeId_(id)
23 {
24 }
25 
RSScreenModeInfo(const RSScreenModeInfo & other)26 RSScreenModeInfo::RSScreenModeInfo(const RSScreenModeInfo& other)
27 {
28     // Tell the compiler there is no alias and to select wider load/store
29     // instructions.
30     int32_t width = other.width_;
31     int32_t height = other.height_;
32     uint32_t refreshRate = other.refreshRate_;
33     int32_t modeId = other.modeId_;
34     width_ = width;
35     height_ = height;
36     refreshRate_ = refreshRate;
37     modeId_ = modeId;
38 }
39 
operator =(const RSScreenModeInfo & other)40 RSScreenModeInfo& RSScreenModeInfo::operator=(const RSScreenModeInfo& other)
41 {
42     // Tell the compiler there is no alias and to select wider load/store
43     // instructions.
44     int32_t width = other.width_;
45     int32_t height = other.height_;
46     uint32_t refreshRate = other.refreshRate_;
47     int32_t modeId = other.modeId_;
48     width_ = width;
49     height_ = height;
50     refreshRate_ = refreshRate;
51     modeId_ = modeId;
52     return *this;
53 }
54 
Marshalling(Parcel & parcel) const55 bool RSScreenModeInfo::Marshalling(Parcel& parcel) const
56 {
57     bool flag = parcel.WriteInt32(width_) && parcel.WriteInt32(height_) &&
58         parcel.WriteUint32(refreshRate_) && parcel.WriteInt32(modeId_);
59     if (!flag) {
60         ROSEN_LOGE("RSScreenModeInfo::Marshalling failed");
61     }
62     return flag;
63 }
64 
Unmarshalling(Parcel & parcel)65 RSScreenModeInfo* RSScreenModeInfo::Unmarshalling(Parcel& parcel)
66 {
67     int32_t width;
68     int32_t height;
69     uint32_t refreshRate;
70     int32_t id;
71     if (!(parcel.ReadInt32(width) && parcel.ReadInt32(height) && parcel.ReadUint32(refreshRate)
72         && parcel.ReadInt32(id))) {
73         ROSEN_LOGE("RSScreenModeInfo::Unmarshalling failed");
74         return nullptr;
75     }
76 
77     RSScreenModeInfo* screenModeInfo = new RSScreenModeInfo(width, height, refreshRate, id);
78     return screenModeInfo;
79 }
80 
GetScreenWidth() const81 int32_t RSScreenModeInfo::GetScreenWidth() const
82 {
83     return width_;
84 }
85 
GetScreenHeight() const86 int32_t RSScreenModeInfo::GetScreenHeight() const
87 {
88     return height_;
89 }
90 
GetScreenRefreshRate() const91 uint32_t RSScreenModeInfo::GetScreenRefreshRate() const
92 {
93     return refreshRate_;
94 }
95 
GetScreenModeId() const96 int32_t RSScreenModeInfo::GetScreenModeId() const
97 {
98     return modeId_;
99 }
100 
SetScreenWidth(int32_t width)101 void RSScreenModeInfo::SetScreenWidth(int32_t width)
102 {
103     width_ = width;
104 }
105 
SetScreenHeight(int32_t height)106 void RSScreenModeInfo::SetScreenHeight(int32_t height)
107 {
108     height_ = height;
109 }
110 
SetScreenRefreshRate(uint32_t refreshRate)111 void RSScreenModeInfo::SetScreenRefreshRate(uint32_t refreshRate)
112 {
113     refreshRate_ = refreshRate;
114 }
115 
SetScreenModeId(int32_t id)116 void RSScreenModeInfo::SetScreenModeId(int32_t id)
117 {
118     modeId_ = id;
119 }
120 } // namespace Rosen
121 } // namespace OHOS
122