diff --git a/dm/src/display.cpp b/dm/src/display.cpp index 99073601..e23e6901 100644 --- a/dm/src/display.cpp +++ b/dm/src/display.cpp @@ -21,7 +21,6 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "Display"}; - constexpr int32_t LARGE_SCREEN_WIDTH = 2160; } class Display::Impl : public RefBase { public: @@ -108,12 +107,7 @@ void Display::UpdateDisplayInfo() const float Display::GetVirtualPixelRatio() const { - // Should get from DMS - if ((pImpl_->GetDisplayInfo()->GetWidth() >= LARGE_SCREEN_WIDTH) - || (pImpl_->GetDisplayInfo()->GetHeight() >= LARGE_SCREEN_WIDTH)) { - return 2.0f; - } else { - return 1.0f; - } + UpdateDisplayInfo(); + return pImpl_->GetDisplayInfo()->GetVirtualPixelRatio(); } } // namespace OHOS::Rosen diff --git a/dmserver/src/abstract_display.cpp b/dmserver/src/abstract_display.cpp index e52e0aa8..67f554a4 100644 --- a/dmserver/src/abstract_display.cpp +++ b/dmserver/src/abstract_display.cpp @@ -164,6 +164,7 @@ sptr AbstractDisplay::ConvertToDisplayInfo() const displayInfo->id_ = id_; displayInfo->refreshRate_ = refreshRate_; displayInfo->screenId_ = screenId_; + displayInfo->virtualPixelRatio_ = virtualPixelRatio_; displayInfo->rotation_ = rotation_; displayInfo->orientation_ = orientation_; return displayInfo; diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 8a4f99be..e584dad7 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -54,15 +54,6 @@ void AbstractDisplayController::Init(sptr abstractScre std::placeholders::_2); abstractScreenController_->ScreenConnectionInDisplayInit(abstractScreenCallback_); abstractScreenController->RegisterAbstractScreenCallback(abstractScreenCallback_); - - // Active the code after "rsDisplayNode_->SetScreenId(rsScreenId)" is provided. - /*std::lock_guard lock(mutex_); - if (dummyDisplay_ == nullptr) { - sptr display = new AbstractDisplay(this, displayCount_.fetch_add(1), SCREEN_ID_INVALID, - AbstractDisplay::DEFAULT_WIDTH, AbstractDisplay::DEFAULT_HIGHT, AbstractDisplay::DEFAULT_FRESH_RATE); - abstractDisplayMap_.insert((std::make_pair(display->GetId(), display))); - dummyDisplay_ = display; - }*/ } ScreenId AbstractDisplayController::GetDefaultScreenId() diff --git a/utils/include/display_info.h b/utils/include/display_info.h index d1226fd3..78ecd7d1 100644 --- a/utils/include/display_info.h +++ b/utils/include/display_info.h @@ -39,6 +39,7 @@ public: DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, FreshRate, freshRate, 0); DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, RefreshRate, refreshRate, 0); DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, screenId, SCREEN_ID_INVALID); + DEFINE_VAR_DEFAULT_FUNC_GET(float, VirtualPixelRatio, virtualPixelRatio, 1.0f); DEFINE_VAR_DEFAULT_FUNC_GET(float, XDpi, xDpi, 0.0f); DEFINE_VAR_DEFAULT_FUNC_GET(float, YDpi, yDpi, 0.0f); DEFINE_VAR_DEFAULT_FUNC_GET(Rotation, Rotation, rotation, Rotation::ROTATION_0); diff --git a/utils/src/display_info.cpp b/utils/src/display_info.cpp index e8b894b4..7044eea6 100644 --- a/utils/src/display_info.cpp +++ b/utils/src/display_info.cpp @@ -21,7 +21,7 @@ bool DisplayInfo::Marshalling(Parcel &parcel) const return parcel.WriteUint64(id_) && parcel.WriteUint32(type_) && parcel.WriteInt32(width_) && parcel.WriteInt32(height_) && parcel.WriteUint32(freshRate_) && parcel.WriteUint32(refreshRate_) && parcel.WriteUint64(screenId_) && - parcel.WriteFloat(xDpi_) && parcel.WriteFloat(yDpi_) && + parcel.WriteFloat(virtualPixelRatio_) && parcel.WriteFloat(xDpi_) && parcel.WriteFloat(yDpi_) && parcel.WriteUint32(static_cast(rotation_)) && parcel.WriteUint32(static_cast(orientation_)); } @@ -36,6 +36,7 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel) parcel.ReadInt32(displayInfo->width_) && parcel.ReadInt32(displayInfo->height_) && parcel.ReadUint32(displayInfo->freshRate_) && parcel.ReadUint32(displayInfo->refreshRate_) && parcel.ReadUint64(displayInfo->screenId_) && + parcel.ReadFloat(displayInfo->virtualPixelRatio_) && parcel.ReadFloat(displayInfo->xDpi_) && parcel.ReadFloat(displayInfo->yDpi_) && parcel.ReadUint32(rotation) && parcel.ReadUint32(orientation); if (!res) {