• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "platform/common/rs_log.h"
18 
19 namespace OHOS {
20 namespace Rosen {
RSVirtualScreenResolution(uint32_t width,uint32_t height)21 RSVirtualScreenResolution::RSVirtualScreenResolution(uint32_t width, uint32_t height)
22     : width_(width), height_(height)
23 {
24 }
25 
RSVirtualScreenResolution(const RSVirtualScreenResolution & other)26 RSVirtualScreenResolution::RSVirtualScreenResolution(const RSVirtualScreenResolution& other)
27     : width_(other.width_), height_(other.height_)
28 {
29 }
30 
operator =(const RSVirtualScreenResolution & other)31 RSVirtualScreenResolution& RSVirtualScreenResolution::operator=(const RSVirtualScreenResolution& other)
32 {
33     width_ = other.width_;
34     height_ = other.height_;
35     return *this;
36 }
37 
Marshalling(Parcel & parcel) const38 bool RSVirtualScreenResolution::Marshalling(Parcel& parcel) const
39 {
40     bool flag = parcel.WriteUint32(width_) && parcel.WriteUint32(height_);
41     if (!flag) {
42         ROSEN_LOGE("RSVirtualScreenResolution::Marshalling failed");
43     }
44     return flag;
45 }
46 
Unmarshalling(Parcel & parcel)47 RSVirtualScreenResolution* RSVirtualScreenResolution::Unmarshalling(Parcel& parcel)
48 {
49     uint32_t width;
50     uint32_t height;
51     if (!(parcel.ReadUint32(width) && parcel.ReadUint32(height))) {
52         ROSEN_LOGE("RSVirtualScreenResolution::Unmarshalling failed");
53         return nullptr;
54     }
55 
56     RSVirtualScreenResolution* virtualScreenResolution = new RSVirtualScreenResolution(width, height);
57     return virtualScreenResolution;
58 }
59 
GetVirtualScreenWidth() const60 uint32_t RSVirtualScreenResolution::GetVirtualScreenWidth() const
61 {
62     return width_;
63 }
64 
GetVirtualScreenHeight() const65 uint32_t RSVirtualScreenResolution::GetVirtualScreenHeight() const
66 {
67     return height_;
68 }
69 
SetVirtualScreenWidth(uint32_t width)70 void RSVirtualScreenResolution::SetVirtualScreenWidth(uint32_t width)
71 {
72     width_ = width;
73 }
74 
SetVirtualScreenHeight(uint32_t height)75 void RSVirtualScreenResolution::SetVirtualScreenHeight(uint32_t height)
76 {
77     height_ = height;
78 }
79 } // namespace Rosen
80 } // namespace OHOS