From 58c4692f137a1ac72aaaeb4d984bd9e8e8a88edb Mon Sep 17 00:00:00 2001 From: hejunfei Date: Fri, 29 Aug 2025 14:20:08 +0800 Subject: [PATCH 1/5] add screen trans to display Signed-off-by: hejunfei --- dmserver/include/abstract_screen.h | 3 + dmserver/include/display_manager_service.h | 1 + dmserver/src/abstract_screen.cpp | 79 +++++++++++++++++++ dmserver/src/display_manager_service.cpp | 21 ++++- .../display_runtime/js_display_manager.cpp | 3 - utils/include/display_info.h | 2 +- 6 files changed, 104 insertions(+), 5 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 54ec30d80d..3acd821eb4 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -31,6 +31,7 @@ #include "screen_group.h" #include "screen_group_info.h" #include "screen_info.h" +#include "display_info.h" namespace OHOS::Rosen { class AbstractScreenGroup; @@ -62,6 +63,8 @@ public: void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void UpdateRSDisplayNode(Point startPoint, const sptr& absScreen); ScreenId GetScreenGroupId() const; + sptr ScreenInfoConvertToDisplayInfo(sptr info); + void FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info); // colorspace, gamut DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts); diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index ac93c4ffc8..08061a197e 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -104,6 +104,7 @@ public: DMError StopExpand(const std::vector& expandScreenIds); void RemoveVirtualScreenFromGroup(std::vector screens); sptr GetScreenInfoById(ScreenId screenId); + sptr GetDisplayInfoByScreenId(ScreenId screenId); sptr GetScreenGroupInfoById(ScreenId screenId); ScreenId GetScreenGroupIdByScreenId(ScreenId screenId); DMError GetAllScreenInfos(std::vector>& screenInfos); diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 0bf600ec5f..efb337209e 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -21,6 +21,7 @@ #include "dm_common.h" #include "rs_adapter.h" #include "window_manager_hilog.h" +#include "screen_rotation_controller.h" namespace OHOS::Rosen { namespace { @@ -72,6 +73,44 @@ sptr AbstractScreen::ConvertToScreenInfo() const return info; } +sptr AbstractScreen::ScreenInfoConvertToDisplayInfo(sptr info) +{ + sptr displayInfo = new(std::nothrow) DisplayInfo(); + if (displayInfo == nullptr) { + return nullptr; + } + FillDisplayInfoByScreenInfo(displayInfo, info); + return displayInfo; +} + +void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info) +{ + if (displayInfo == nullptr || info == nullptr) { + TLOGE(WmsLogTag::DMS, "displayInfo is nullptr"); + return; + } + sptr abstractScreenModes = GetActiveScreenMode(); + if (abstractScreenModes != nullptr) { + displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); + std::vector supportedRefreshRate; + supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); + displayInfo->SetSupportedRefreshRate(supportedRefreshRate); + } + + displayInfo->SetName(info->name_); + displayInfo->SetDisplayId(info->id_); + displayInfo->SetWidth(info->virtualWidth_); + displayInfo->SetHeight(info->virtualHeight_); + displayInfo->SetScreenId(info->id_); + displayInfo->SetVirtualPixelRatio(info->virtualPixelRatio_); + displayInfo->SetDpi(info->virtualPixelRatio_ * DOT_PER_INCH); + displayInfo->SetRotation(info->rotation_); + displayInfo->SetOrientation(info->orientation_); + displayInfo->SetDisplayOrientation( + ScreenRotationController::ConvertRotationToDisplayOrientation(info->rotation_)); + displayInfo->SetDisplaySourceMode(GetDisplaySourceMode()); +} + void AbstractScreen::UpdateRSTree(std::shared_ptr& surfaceNode, bool isAdd, bool needToUpdate) { if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) { @@ -712,4 +751,44 @@ ScreenCombination AbstractScreenGroup::GetScreenCombination() const { return combination_; } + +DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const +{ + sptr abstractScreenGroup = GetGroup(); + TLOGI(WmsLogTag::DMS, "in"); + if (abstractScreenGroup == nullptr || screenController_ == nullptr) { + TLOGE(WmsLogTag::DMS, "default NONE"); + return DisplaySourceMode::NONE; + } + ScreenId defaultId = screenController_->GetDefaultAbstractScreenId(); + if (dmsId_ == defaultId) { + TLOGE(WmsLogTag::DMS, "err MAIN"); + return DisplaySourceMode::MAIN; + } + ScreenCombination combination = abstractScreenGroup->GetScreenCombination(); + switch (combination) { + case ScreenCombination::SCREEN_MAIN: { + return DisplaySourceMode::MAIN; + } + case ScreenCombination::SCREEN_MIRROR: { + return DisplaySourceMode::MIRROR; + } + case ScreenCombination::SCREEN_EXPAND: { + return DisplaySourceMode::EXTEND; + } + case ScreenCombination::SCREEN_EXTEND: { + return DisplaySourceMode::EXTEND; + } + case ScreenCombination::SCREEN_UNIQUE: { + return DisplaySourceMode::ALONE; + } + case ScreenCombination::SCREEN_ALONE: { + return DisplaySourceMode::NONE; + } + default: { + TLOGE(WmsLogTag::DMS, "default NONE"); + return DisplaySourceMode::NONE; + } + } +} } // namespace OHOS::Rosen diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 2fab87697c..02b13e080d 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -184,7 +184,12 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) { sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { - TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); + TLOGI(WmsLogTag::DMS, "fail to get displayInfo by id: %{public}" PRIu64" invalid display", displayId); + sptr displayInfo = GetDisplayInfoByScreenId(displayId); + if (displayInfo != nullptr) { + return displayInfo; + } + TLOGW(WmsLogTag::DMS, "fail to get displayInfo by screen id: %{public}" PRIu64" invalid screen", displayId); return nullptr; } return display->ConvertToDisplayInfo(); @@ -646,6 +651,20 @@ sptr DisplayManagerService::GetScreenInfoById(ScreenId screenId) return screen->ConvertToScreenInfo(); } +sptr DisplayManagerService::GetDisplayInfoByScreenId(ScreenId screenId) +{ + auto screen = abstractScreenController_->GetAbstractScreen(screenId); + if (screen == nullptr) { + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64, screenId); + return nullptr; + } + sptr screenInfo = screen->ConvertToScreenInfo(); + if (screenInfo == nullptr) { + return nullptr; + } + return screen->ScreenInfoConvertToDisplayInfo(screenInfo); +} + sptr DisplayManagerService::GetScreenGroupInfoById(ScreenId screenId) { auto screenGroup = abstractScreenController_->GetAbstractScreenGroup(screenId); diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 27690e7eed..9c95de72f4 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -950,9 +950,6 @@ napi_value CreateJsCreaseRectsArrayObject(napi_env env, std::vector crea napi_value OnCreateVirtualScreen(napi_env env, napi_callback_info info) { TLOGI(WmsLogTag::DMS, "called"); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - return NapiThrowError(env, DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT, "Device not support."); - } DmErrorCode errCode = DmErrorCode::DM_OK; VirtualScreenOption option; size_t argc = 4; diff --git a/utils/include/display_info.h b/utils/include/display_info.h index fdad57e343..79be7416da 100644 --- a/utils/include/display_info.h +++ b/utils/include/display_info.h @@ -36,7 +36,7 @@ public: virtual bool Marshalling(Parcel& parcel) const override; static DisplayInfo *Unmarshalling(Parcel& parcel); - DEFINE_VAR_DEFAULT_FUNC_GET(std::string, Name, name, ""); + DEFINE_VAR_DEFAULT_FUNC_GET_SET(std::string, Name, name, ""); DEFINE_VAR_DEFAULT_FUNC_GET_SET(DisplayId, DisplayId, id, DISPLAY_ID_INVALID); DEFINE_VAR_DEFAULT_FUNC_GET_SET(DisplayType, DisplayType, type, DisplayType::DEFAULT); DEFINE_VAR_DEFAULT_FUNC_GET_SET(int32_t, Width, width, 0); -- Gitee From 8855c286d6a16d6f3e037a46e8a5daf0cd924d5d Mon Sep 17 00:00:00 2001 From: hejunfei Date: Fri, 29 Aug 2025 17:57:29 +0800 Subject: [PATCH 2/5] fix review Signed-off-by: hejunfei --- dmserver/src/abstract_screen.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index efb337209e..def499ec6c 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -757,12 +757,12 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const sptr abstractScreenGroup = GetGroup(); TLOGI(WmsLogTag::DMS, "in"); if (abstractScreenGroup == nullptr || screenController_ == nullptr) { - TLOGE(WmsLogTag::DMS, "default NONE"); + TLOGW(WmsLogTag::DMS, "default NONE"); return DisplaySourceMode::NONE; } ScreenId defaultId = screenController_->GetDefaultAbstractScreenId(); if (dmsId_ == defaultId) { - TLOGE(WmsLogTag::DMS, "err MAIN"); + TLOGW(WmsLogTag::DMS, "err MAIN"); return DisplaySourceMode::MAIN; } ScreenCombination combination = abstractScreenGroup->GetScreenCombination(); @@ -773,9 +773,7 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const case ScreenCombination::SCREEN_MIRROR: { return DisplaySourceMode::MIRROR; } - case ScreenCombination::SCREEN_EXPAND: { - return DisplaySourceMode::EXTEND; - } + case ScreenCombination::SCREEN_EXPAND: case ScreenCombination::SCREEN_EXTEND: { return DisplaySourceMode::EXTEND; } @@ -786,7 +784,7 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const return DisplaySourceMode::NONE; } default: { - TLOGE(WmsLogTag::DMS, "default NONE"); + TLOGW(WmsLogTag::DMS, "default NONE"); return DisplaySourceMode::NONE; } } -- Gitee From 9afb13070e4d1d23a659b0902b5351474d1d26bb Mon Sep 17 00:00:00 2001 From: hejunfei Date: Sat, 30 Aug 2025 17:46:59 +0800 Subject: [PATCH 3/5] modify review Signed-off-by: hejunfei --- dmserver/include/abstract_screen.h | 4 ++-- dmserver/include/display_manager_service.h | 2 +- dmserver/src/abstract_screen.cpp | 6 +++--- dmserver/src/display_manager_service.cpp | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 3acd821eb4..86ac942058 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -63,8 +63,8 @@ public: void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void UpdateRSDisplayNode(Point startPoint, const sptr& absScreen); ScreenId GetScreenGroupId() const; - sptr ScreenInfoConvertToDisplayInfo(sptr info); - void FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info); + sptr ConvertScreenInfoToDisplayInfo(const sptr& info) const; + void FillDisplayInfoByScreenInfo(sptr displayInfo, const sptr& info) const; // colorspace, gamut DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts); diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index 08061a197e..4af351d689 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -104,7 +104,7 @@ public: DMError StopExpand(const std::vector& expandScreenIds); void RemoveVirtualScreenFromGroup(std::vector screens); sptr GetScreenInfoById(ScreenId screenId); - sptr GetDisplayInfoByScreenId(ScreenId screenId); + sptr GetDisplayInfoByScreenId(ScreenId screenId) const; sptr GetScreenGroupInfoById(ScreenId screenId); ScreenId GetScreenGroupIdByScreenId(ScreenId screenId); DMError GetAllScreenInfos(std::vector>& screenInfos); diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index def499ec6c..43e7b6d11c 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -73,9 +73,9 @@ sptr AbstractScreen::ConvertToScreenInfo() const return info; } -sptr AbstractScreen::ScreenInfoConvertToDisplayInfo(sptr info) +sptr AbstractScreen::ConvertScreenInfoToDisplayInfo(const sptr& info) const { - sptr displayInfo = new(std::nothrow) DisplayInfo(); + sptr displayInfo = sptr::MakeSptr(); if (displayInfo == nullptr) { return nullptr; } @@ -83,7 +83,7 @@ sptr AbstractScreen::ScreenInfoConvertToDisplayInfo(sptr displayInfo, sptr info) +void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, const sptr& info) const { if (displayInfo == nullptr || info == nullptr) { TLOGE(WmsLogTag::DMS, "displayInfo is nullptr"); diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 02b13e080d..6d130a8fc7 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -651,7 +651,7 @@ sptr DisplayManagerService::GetScreenInfoById(ScreenId screenId) return screen->ConvertToScreenInfo(); } -sptr DisplayManagerService::GetDisplayInfoByScreenId(ScreenId screenId) +sptr DisplayManagerService::GetDisplayInfoByScreenId(ScreenId screenId) const { auto screen = abstractScreenController_->GetAbstractScreen(screenId); if (screen == nullptr) { @@ -660,9 +660,10 @@ sptr DisplayManagerService::GetDisplayInfoByScreenId(ScreenId scree } sptr screenInfo = screen->ConvertToScreenInfo(); if (screenInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "cannot get screenInfo: %{public}" PRIu64, screenId); return nullptr; } - return screen->ScreenInfoConvertToDisplayInfo(screenInfo); + return screen->ConvertScreenInfoToDisplayInfo(screenInfo); } sptr DisplayManagerService::GetScreenGroupInfoById(ScreenId screenId) -- Gitee From 6bd4052a606492cf0670344dd073be254b1b9e9e Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 1 Sep 2025 15:12:14 +0800 Subject: [PATCH 4/5] modify review Signed-off-by: hejunfei --- dmserver/include/abstract_screen.h | 2 +- dmserver/src/abstract_screen.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 86ac942058..07d253f86f 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -26,12 +26,12 @@ #include #include +#include "display_info.h" #include "noncopyable.h" #include "screen.h" #include "screen_group.h" #include "screen_group_info.h" #include "screen_info.h" -#include "display_info.h" namespace OHOS::Rosen { class AbstractScreenGroup; diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 43e7b6d11c..99f06e8486 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -20,8 +20,8 @@ #include "display_manager_service.h" #include "dm_common.h" #include "rs_adapter.h" -#include "window_manager_hilog.h" #include "screen_rotation_controller.h" +#include "window_manager_hilog.h" namespace OHOS::Rosen { namespace { @@ -89,11 +89,11 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, TLOGE(WmsLogTag::DMS, "displayInfo is nullptr"); return; } - sptr abstractScreenModes = GetActiveScreenMode(); - if (abstractScreenModes != nullptr) { - displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); + sptr abstractScreenMode = GetActiveScreenMode(); + if (abstractScreenMode != nullptr) { + displayInfo->SetRefreshRate(abstractScreenMode->refreshRate_); std::vector supportedRefreshRate; - supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); + supportedRefreshRate.push_back(abstractScreenMode->refreshRate_); displayInfo->SetSupportedRefreshRate(supportedRefreshRate); } -- Gitee From 1761472b570727eddc44cea745de70617e3e9e3e Mon Sep 17 00:00:00 2001 From: hejunfei Date: Mon, 1 Sep 2025 15:17:22 +0800 Subject: [PATCH 5/5] mod review Signed-off-by: hejunfei --- dmserver/include/abstract_screen.h | 1 + dmserver/src/abstract_screen.cpp | 2 +- dmserver/src/display_manager_service.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 07d253f86f..25b2b3913d 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -19,6 +19,7 @@ #include #include + #include #include #include diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 99f06e8486..91591ecbd5 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -754,8 +754,8 @@ ScreenCombination AbstractScreenGroup::GetScreenCombination() const DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const { - sptr abstractScreenGroup = GetGroup(); TLOGI(WmsLogTag::DMS, "in"); + sptr abstractScreenGroup = GetGroup(); if (abstractScreenGroup == nullptr || screenController_ == nullptr) { TLOGW(WmsLogTag::DMS, "default NONE"); return DisplaySourceMode::NONE; diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 6d130a8fc7..adc690f4e4 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -184,12 +184,12 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) { sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { - TLOGI(WmsLogTag::DMS, "fail to get displayInfo by id: %{public}" PRIu64" invalid display", displayId); + TLOGI(WmsLogTag::DMS, "fail to get displayInfo by id: %{public}" PRIu64 " invalid display", displayId); sptr displayInfo = GetDisplayInfoByScreenId(displayId); if (displayInfo != nullptr) { return displayInfo; } - TLOGW(WmsLogTag::DMS, "fail to get displayInfo by screen id: %{public}" PRIu64" invalid screen", displayId); + TLOGW(WmsLogTag::DMS, "fail to get displayInfo by screen id: %{public}" PRIu64 " invalid screen", displayId); return nullptr; } return display->ConvertToDisplayInfo(); -- Gitee