• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_props.h"
17 #include "platform/common/rs_log.h"
18 
19 namespace OHOS {
20 namespace Rosen {
RSScreenProps(std::string propName,uint32_t propId,uint64_t value)21 RSScreenProps::RSScreenProps(std::string propName, uint32_t propId, uint64_t value)
22     : propName_(propName), propId_(propId), value_(value)
23 {
24 }
25 
SetPropertyName(const std::string & propName)26 void RSScreenProps::SetPropertyName(const std::string& propName)
27 {
28     propName_ = propName;
29 }
30 
SetPropId(uint32_t propId)31 void RSScreenProps::SetPropId(uint32_t propId)
32 {
33     propId_ = propId;
34 }
35 
SetValue(uint64_t value)36 void RSScreenProps::SetValue(uint64_t value)
37 {
38     value_ = value;
39 }
40 
GetPropertyName() const41 const std::string& RSScreenProps::GetPropertyName() const
42 {
43     return propName_;
44 }
45 
GetPropId() const46 uint32_t RSScreenProps::GetPropId() const
47 {
48     return propId_;
49 }
50 
GetValue() const51 uint64_t RSScreenProps::GetValue() const
52 {
53     return value_;
54 }
55 
Marshalling(Parcel & parcel) const56 bool RSScreenProps::Marshalling(Parcel &parcel) const
57 {
58     if (!parcel.WriteString(propName_)) {
59         ROSEN_LOGE("RSScreenProps::Marshalling WriteString failed");
60         return false;
61     }
62     if (!parcel.WriteUint32(propId_)) {
63         ROSEN_LOGE("RSScreenProps::Marshalling WriteUint32 failed");
64         return false;
65     }
66     if (!parcel.WriteUint64(value_)) {
67         ROSEN_LOGE("RSScreenProps::Marshalling WriteUint64 failed");
68         return false;
69     }
70     return true;
71 }
72 
Unmarshalling(Parcel & parcel)73 RSScreenProps* RSScreenProps::Unmarshalling(Parcel &parcel)
74 {
75     std::string propName;
76     uint32_t propId;
77     uint64_t value;
78     if (!parcel.ReadString(propName)) {
79         ROSEN_LOGE("RSScreenProps::Unmarshalling ReadString failed");
80         return nullptr;
81     }
82     if (!parcel.ReadUint32(propId)) {
83         ROSEN_LOGE("RSScreenProps::Unmarshalling ReadUint32 failed");
84         return nullptr;
85     }
86     if (!parcel.ReadUint64(value)) {
87         ROSEN_LOGE("RSScreenProps::Unmarshalling ReadUint64 failed");
88         return nullptr;
89     }
90     RSScreenProps* screenProps = new RSScreenProps(propName, propId, value);
91     return screenProps;
92 }
93 }
94 }
95