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 class Display::Impl : public RefBase {
21 public:
Impl(const std::string & name,sptr<DisplayInfo> info)22 Impl(const std::string& name, sptr<DisplayInfo> info)
23 {
24 name_ = name;
25 displayInfo_ = info;
26 }
27 ~Impl() = default;
28 DEFINE_VAR_FUNC_GET_SET(std::string, Name, name);
29 DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo);
30 };
31
Display(const std::string & name,sptr<DisplayInfo> info)32 Display::Display(const std::string& name, sptr<DisplayInfo> info) : pImpl_(new Impl(name, info))
33 {}
34
~Display()35 Display::~Display()
36 {}
37
GetId() const38 DisplayId Display::GetId() const
39 {
40 DisplayId id {0};
41 return id;
42 }
43
GetWidth() const44 int32_t Display::GetWidth() const
45 {
46 return 0;
47 }
48
GetHeight() const49 int32_t Display::GetHeight() const
50 {
51 return 0;
52 }
53
GetRefreshRate() const54 uint32_t Display::GetRefreshRate() const
55 {
56 return 0;
57 }
58
GetScreenId() const59 ScreenId Display::GetScreenId() const
60 {
61 ScreenId id {0};
62 return id;
63 }
64
UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const65 void Display::UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const
66 {
67 if (!displayInfo) {
68 return;
69 }
70 pImpl_->SetDisplayInfo(displayInfo);
71 }
72
GetVirtualPixelRatio() const73 float Display::GetVirtualPixelRatio() const
74 {
75 #ifdef PRODUCT_RK
76 return 1.0f;
77 #else
78 return 2.0f;
79 #endif
80 }
81 } // namespace OHOS::Rosen