1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#include "display.h" 17885b47fbSopenharmony_ci#include "window/window_manager/utils/include/display_info.h" 18885b47fbSopenharmony_ci 19885b47fbSopenharmony_cinamespace OHOS::Rosen { 20885b47fbSopenharmony_cinamespace { 21885b47fbSopenharmony_ci const int32_t HEIGHT_VALUE = 1000; 22885b47fbSopenharmony_ci const int32_t WEIGHT_VALUE = 600; 23885b47fbSopenharmony_ci} // namespace 24885b47fbSopenharmony_ci 25885b47fbSopenharmony_ciclass Display::Impl : public RefBase { 26885b47fbSopenharmony_cipublic: 27885b47fbSopenharmony_ci Impl(const std::string& name, sptr<DisplayInfo> info) 28885b47fbSopenharmony_ci { 29885b47fbSopenharmony_ci name_ = name; 30885b47fbSopenharmony_ci displayInfo_ = info; 31885b47fbSopenharmony_ci } 32885b47fbSopenharmony_ci ~Impl() = default; 33885b47fbSopenharmony_ci DEFINE_VAR_FUNC_GET_SET(std::string, Name, name); 34885b47fbSopenharmony_ci DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo); 35885b47fbSopenharmony_ci}; 36885b47fbSopenharmony_ci 37885b47fbSopenharmony_ciDisplay::Display(const std::string& name, sptr<DisplayInfo> info) : pImpl_(new Impl(name, info)) 38885b47fbSopenharmony_ci{} 39885b47fbSopenharmony_ci 40885b47fbSopenharmony_ciDisplay::~Display() 41885b47fbSopenharmony_ci{} 42885b47fbSopenharmony_ci 43885b47fbSopenharmony_ciDisplayId Display::GetId() const 44885b47fbSopenharmony_ci{ 45885b47fbSopenharmony_ci DisplayId id {0}; 46885b47fbSopenharmony_ci return id; 47885b47fbSopenharmony_ci} 48885b47fbSopenharmony_ci 49885b47fbSopenharmony_ciint32_t Display::GetWidth() const 50885b47fbSopenharmony_ci{ 51885b47fbSopenharmony_ci return WEIGHT_VALUE; 52885b47fbSopenharmony_ci} 53885b47fbSopenharmony_ci 54885b47fbSopenharmony_ciint32_t Display::GetHeight() const 55885b47fbSopenharmony_ci{ 56885b47fbSopenharmony_ci return HEIGHT_VALUE; 57885b47fbSopenharmony_ci} 58885b47fbSopenharmony_ci 59885b47fbSopenharmony_ciuint32_t Display::GetRefreshRate() const 60885b47fbSopenharmony_ci{ 61885b47fbSopenharmony_ci return 0; 62885b47fbSopenharmony_ci} 63885b47fbSopenharmony_ci 64885b47fbSopenharmony_ciScreenId Display::GetScreenId() const 65885b47fbSopenharmony_ci{ 66885b47fbSopenharmony_ci ScreenId id {0}; 67885b47fbSopenharmony_ci return id; 68885b47fbSopenharmony_ci} 69885b47fbSopenharmony_ci 70885b47fbSopenharmony_civoid Display::UpdateDisplayInfo(sptr<DisplayInfo> displayInfo) const 71885b47fbSopenharmony_ci{ 72885b47fbSopenharmony_ci if (!displayInfo) { 73885b47fbSopenharmony_ci return; 74885b47fbSopenharmony_ci } 75885b47fbSopenharmony_ci pImpl_->SetDisplayInfo(displayInfo); 76885b47fbSopenharmony_ci} 77885b47fbSopenharmony_ci 78885b47fbSopenharmony_cifloat Display::GetVirtualPixelRatio() const 79885b47fbSopenharmony_ci{ 80885b47fbSopenharmony_ci#ifdef PRODUCT_RK 81885b47fbSopenharmony_ci return 1.0f; 82885b47fbSopenharmony_ci#else 83885b47fbSopenharmony_ci return 2.0f; 84885b47fbSopenharmony_ci#endif 85885b47fbSopenharmony_ci} 86885b47fbSopenharmony_ci} // namespace OHOS::Rosen