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 "display.h"
17 #include "window/window_manager/utils/include/display_info.h"
18
19 namespace OHOS::Rosen {
20 namespace {
21 const int32_t HEIGHT_VALUE = 1000;
22 const int32_t WEIGHT_VALUE = 600;
23 } // namespace
24
25 class Display::Impl : public RefBase {
26 public:
Impl(const std::string & name,sptr<DisplayInfo> info)27 Impl(const std::string& name, sptr<DisplayInfo> info)
28 {
29 name_ = name;
30 displayInfo_ = info;
31 }
32 ~Impl() = default;
33 DEFINE_VAR_FUNC_GET_SET(std::string, Name, name);
34 DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo);
35 };
36
Display(const std::string & name,sptr<DisplayInfo> info)37 Display::Display(const std::string& name, sptr<DisplayInfo> info) : pImpl_(new Impl(name, info))
38 {}
39
~Display()40 Display::~Display()
41 {}
42
GetId() const43 DisplayId Display::GetId() const
44 {
45 DisplayId id {0};
46 return id;
47 }
48
GetWidth() const49 int32_t Display::GetWidth() const
50 {
51 return WEIGHT_VALUE;
52 }
53
GetHeight() const54 int32_t Display::GetHeight() const
55 {
56 return HEIGHT_VALUE;
57 }
58
GetRefreshRate() const59 uint32_t Display::GetRefreshRate() const
60 {
61 return 0;
62 }
63
GetScreenId() const64 ScreenId Display::GetScreenId() const
65 {
66 ScreenId id {0};
67 return id;
68 }
69
UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const70 void Display::UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const
71 {
72 if (!displayInfo) {
73 return;
74 }
75 pImpl_->SetDisplayInfo(displayInfo);
76 }
77
GetVirtualPixelRatio() const78 float Display::GetVirtualPixelRatio() const
79 {
80 #ifdef PRODUCT_RK
81 return 1.0f;
82 #else
83 return 2.0f;
84 #endif
85 }
86 } // namespace OHOS::Rosen