From fb575cf2b6284b83d74b0fac7bad7d37ae960384 Mon Sep 17 00:00:00 2001 From: chenwei Date: Tue, 18 Mar 2025 17:29:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BC=80=E6=9C=BA=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=97=B6=E5=88=87=E5=B1=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- .../src/fold_screen_controller/dual_display_fold_policy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp index 5eb4747d72..094e52f5cc 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp @@ -41,7 +41,6 @@ const std::string MAIN_TP = "0"; const std::string SUB_TP = "1"; const int32_t REMOVE_DISPLAY_NODE = 0; const int32_t ADD_DISPLAY_NODE = 1; -const uint32_t CHANGE_MODE_TASK_NUM = 3; } // namespace DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex, @@ -67,7 +66,7 @@ DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMu void DualDisplayFoldPolicy::SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation) { if (status) { - pengdingTask_ = CHANGE_MODE_TASK_NUM; + pengdingTask_ = isOnBootAnimation ? FOLD_TO_EXPAND_ONBOOTANIMATION_TASK_NUM : FOLD_TO_EXPAND_TASK_NUM; startTimePoint_ = std::chrono::steady_clock::now(); displayModeChangeRunning_ = status; } else { @@ -310,6 +309,7 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr scr ScreenId onScreenId) { if (onBootAnimation_) { + SetdisplayModeChangeStatus(true, true); ChangeScreenDisplayModeOnBootAnimation(screenSession, onScreenId); return; } -- Gitee From 4115b282098fee5e0626cf1dccb6c5532ac53fb1 Mon Sep 17 00:00:00 2001 From: chenwei Date: Mon, 16 Jun 2025 12:31:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?SetDisplayOffset=E6=94=B9SetScreenOffset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- dmserver/include/abstract_screen.h | 2 +- dmserver/src/abstract_display_controller.cpp | 7 ++++- dmserver/src/abstract_screen.cpp | 14 ++++----- dmserver/src/abstract_screen_controller.cpp | 2 +- dmserver/src/display_manager_service.cpp | 10 +++--- .../include/screen_session_manager.h | 1 + .../src/multi_screen_change_utils.cpp | 10 +++--- .../src/multi_screen_power_change_manager.cpp | 2 +- .../src/screen_session_manager.cpp | 31 +++++++++++++------ .../session/screen/include/screen_session.h | 3 +- .../session/screen/src/screen_session.cpp | 20 ++++++------ .../screen_session_manager_test.cpp | 13 ++++++++ 12 files changed, 77 insertions(+), 38 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index fa4e29585f..de655a6a5f 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -59,7 +59,7 @@ public: std::shared_ptr& surfaceNode, std::shared_ptr& parentNode, bool isAdd); void InitRSDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); - void UpdateRSDisplayNode(Point startPoint); + void UpdateRSDisplayNode(Point startPoint, sptr absScreen); ScreenId GetScreenGroupId() const; // colorspace, gamut diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 11c0710c49..2c9299857c 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -251,7 +251,12 @@ DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected( } else { abstractDisplay->SetOffset(0, 0); auto screenId = abstractDisplay->GetAbstractScreenId(); - abstractScreenController_->GetRSDisplayNodeByScreenId(screenId)->SetDisplayOffset(0, 0); + ScreenId rsScreenId = abstractScreenController_->GetRSDisplayNodeByScreenId(screenId)->ConvertToRsScreenId(screenId); + if (rsScreenId == SCREEN_ID_INVALID) { + TLOGE(WmsLogTag::DMS, "rsScreenId is invalid."); + continue; + } + RSInterfaces::GetInstance().SetScreenOffset(rsScreenId, 0, 0); } } return displayId; diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 473fcc7196..723692a890 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -172,8 +172,8 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetDisplayOffset(startPoint.posX_, startPoint.posY_); + TLOGI(WmsLogTag::DMS, "SetScreenOffset: posX:%{public}d, posY:%{public}d", startPoint.posX_, startPoint.posY_); + RSInterfaces::GetInstance().SetScreenOffset(rsId_, startPoint.posX_, startPoint.posY_); uint32_t width = 0; uint32_t height = 0; sptr abstractScreenModes = GetActiveScreenMode(); @@ -187,7 +187,7 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetSecurityDisplay(true); TLOGI(WmsLogTag::DMS, "virtualScreen SetSecurityDisplay success"); } - // If setDisplayOffset is not valid for SetFrame/SetBounds + // If SetScreenOffset is not valid for SetFrame/SetBounds rsDisplayNode->SetFrame(0, 0, width, height); rsDisplayNode->SetBounds(0, 0, width, height); } @@ -248,7 +248,7 @@ void AbstractScreen::InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, TLOGD(WmsLogTag::DMS, "InitRSDefaultDisplayNode success"); } -void AbstractScreen::UpdateRSDisplayNode(Point startPoint) +void AbstractScreen::UpdateRSDisplayNode(Point startPoint, sptr absScreen) { TLOGD(WmsLogTag::DMS, "update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); @@ -258,7 +258,7 @@ void AbstractScreen::UpdateRSDisplayNode(Point startPoint) } startPoint_ = startPoint; - rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); + RSInterfaces::GetInstance().SetScreenOffset(absScreen->rsId_, startPoint.posX_, startPoint.posY_); } ScreenId AbstractScreen::GetScreenGroupId() const @@ -626,7 +626,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) dmsScreen->groupDmsId_ = SCREEN_ID_INVALID; dmsScreen->startPoint_ = Point(); if (dmsScreen->rsDisplayNode_ != nullptr) { - dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); + RSInterfaces::GetInstance().SetScreenOffset(dmsScreen->rsId_, 0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); RSTransactionAdapter::FlushImplicitTransaction(dmsScreen->GetRSUIContext()); dmsScreen->rsDisplayNode_ = nullptr; @@ -645,7 +645,7 @@ bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScr ScreenId screenId = dmsScreen->dmsId_; dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; if (dmsScreen->rsDisplayNode_ != nullptr) { - dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); + RSInterfaces::GetInstance().SetScreenOffset(dmsScreen->rsId_, 0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); RSTransactionAdapter::FlushImplicitTransaction(dmsScreen->GetRSUIContext()); } diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index f2101a82c6..3919011a3b 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -820,7 +820,7 @@ void AbstractScreenController::UpdateScreenGroupLayout(sptr } if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point); + screen->UpdateRSDisplayNode(point, screen); if (abstractScreenCallback_ != nullptr) { abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 543f41272a..fdad24c8e6 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -716,11 +716,13 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, std::shared_ptr rsDisplayNode; std::vector points; for (uint32_t i = 0; i < allExpandScreenIds.size(); i++) { - rsDisplayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(allExpandScreenIds[i]); - points.emplace_back(pointsMap[allExpandScreenIds[i]]); + ScreenId expandScreenId = allExpandScreenIds[i]; + rsDisplayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(expandScreenId); + points.emplace_back(pointsMap[expandScreenId]); if (rsDisplayNode != nullptr) { - rsDisplayNode->SetDisplayOffset(pointsMap[allExpandScreenIds[i]].posX_, - pointsMap[allExpandScreenIds[i]].posY_); + sptr absScreen = abstractScreenController_->GetAbstracetScreen(expandScreenId); + RSInterfaces::GetInstance().SetScreenOffset(absScreen->rsId_, + pointsMap(expandScreenId).posX_, pointsMap(expandScreenId).posY_); } } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand"); diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index f9c75a5050..2bad67468d 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -466,6 +466,7 @@ public: bool GetKeyboardState() override; DMError GetScreenAreaOfDisplayArea(DisplayId displayId, const DMRect& displayArea, ScreenId& screenId, DMRect& screenArea) override; + bool SetScreenOffsetInner(ScreenId screenId, float offsetX, float offsetY); protected: ScreenSessionManager(); diff --git a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp index 8becadec21..76c6a18634 100644 --- a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp @@ -77,9 +77,11 @@ void MultiScreenChangeUtils::ScreenExtendPositionChange(sptr& inn std::shared_ptr innerNode = innerScreen->GetDisplayNode(); std::shared_ptr externalNode = externalScreen->GetDisplayNode(); if (innerNode && externalNode) { - innerNode->SetDisplayOffset(innerScreen->GetScreenProperty().GetStartX(), + ScreenSessionManager::GetInstance().SetScreenOffset(innerScreen->GetScreenId(), + innerScreen->GetScreenProperty().GetStartX(), innerScreen->GetScreenProperty().GetStartY()); - externalNode->SetDisplayOffset(externalScreen->GetScreenProperty().GetStartX(), + ScreenSessionManager::GetInstance().SetScreenOffset(externalScreen->GetScreenId(), + externalScreen->GetScreenProperty().GetStartX(), externalScreen->GetScreenProperty().GetStartY()); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); @@ -126,8 +128,8 @@ void MultiScreenChangeUtils::ScreenMainPositionChange(sptr& inner std::shared_ptr innerNode = innerScreen->GetDisplayNode(); std::shared_ptr externalNode = externalScreen->GetDisplayNode(); if (innerNode && externalNode) { - innerNode->SetDisplayOffset(0, 0); - externalNode->SetDisplayOffset(0, 0); + ScreenSessionManager::GetInstance().SetScreenOffset(innerScreen->GetScreenId(), 0, 0); + ScreenSessionManager::GetInstance().SetScreenOffset(externalScreen->GetScreenId(), 0, 0); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } diff --git a/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp index 6b4e432a65..2b938056eb 100644 --- a/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp @@ -195,7 +195,7 @@ void MultiScreenPowerChangeManager::ScreenDisplayNodeRemove(sptr& TLOGW(WmsLogTag::DMS, "removeNode screenId=%{public}" PRIu64, screenScreen->GetScreenId()); std::shared_ptr displayNode = screenScreen->GetDisplayNode(); if (displayNode != nullptr) { - displayNode->SetDisplayOffset(0, 0); + ScreenSessionManager::GetInstance().SetScreenOffset(screenScreen->GetScreenId(), 0, 0); displayNode->RemoveFromTree(); screenScreen->ReleaseDisplayNode(); } diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 505684ee23..cee119de6e 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1540,11 +1540,11 @@ void ScreenSessionManager::ResetInternalScreenSession(sptr& inner ScreenId externalRSId = externalScreen->GetRSScreenId(); if (mainNode != nullptr) { mainNode->SetScreenId(externalRSId); - mainNode->SetDisplayOffset(0, 0); + SetScreenOffsetInner(externalRSId, 0, 0); } if (extendNode != nullptr) { extendNode->SetScreenId(innerRSId); - extendNode->SetDisplayOffset(0, 0); + SetScreenOffsetInner(innerRSId, 0, 0); } RSTransactionAdapter::FlushImplicitTransaction( {innerScreen->GetRSUIContext(), externalScreen->GetRSUIContext()}); @@ -5303,11 +5303,12 @@ DMError ScreenSessionManager::MakeExpand(std::vector screenId, std::shared_ptr rsDisplayNode; std::vector points; for (uint32_t i = 0; i < allExpandScreenIds.size(); i++) { - rsDisplayNode = GetRSDisplayNodeByScreenId(allExpandScreenIds[i]); - points.emplace_back(pointsMap[allExpandScreenIds[i]]); + ScreenId expandScreenId = allExpandScreenIds[i]; + rsDisplayNode = GetRSDisplayNodeByScreenId(expandScreenId); + points.emplace_back(pointsMap[expandScreenId]); if (rsDisplayNode != nullptr) { - rsDisplayNode->SetDisplayOffset(pointsMap[allExpandScreenIds[i]].posX_, - pointsMap[allExpandScreenIds[i]].posY_); + SetScreenOffsetInner(expandScreenId, pointsMap[allExpandScreenIds[i]].posX_, + pointsMap[allExpandScreenIds[i]].posY_) } } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand"); @@ -9178,8 +9179,8 @@ void ScreenSessionManager::SetMultiScreenRelativePositionInner(sptr firstDisplayNode = firstScreenSession->GetDisplayNode(); std::shared_ptr secondDisplayNode = secondScreenSession->GetDisplayNode(); if (firstDisplayNode && secondDisplayNode) { - firstDisplayNode->SetDisplayOffset(mainScreenOptions.startX_, mainScreenOptions.startY_); - secondDisplayNode->SetDisplayOffset(secondScreenOption.startX_, secondScreenOption.startY_); + SetScreenOffsetInner(firstScreenSession->GetScreenId(), mainScreenOptions.startX_, mainScreenOptions.startY_); + SetScreenOffsetInner(secondScreenSession->GetScreenId(), secondScreenOption.startX_, secondScreenOption.startY_); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } @@ -9205,7 +9206,8 @@ void ScreenSessionManager::SetRelativePositionForDisconnect(MultiScreenPositionO ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); std::shared_ptr defaultDisplayNode = defaultScreenSession->GetDisplayNode(); if (defaultDisplayNode) { - defaultDisplayNode->SetDisplayOffset(defaultScreenOptions.startX_, defaultScreenOptions.startY_); + SetScreenOffsetInner(defaultScreenSession->GetScreenId(), + defaultScreenOptions.startX_, defaultScreenOptions.startY_); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } @@ -10232,4 +10234,15 @@ DMError ScreenSessionManager::SetPrimaryDisplaySystemDpi(float virtualPixelRatio screenSession->SetDensityInCurResolution(virtualPixelRatio); return DMError::DM_OK; } + +bool ScreenSessionManager::SetScreenOffsetInner(ScreenId screenId, float offsetX, float offsetY) +{ + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is null."); + return; + } + RSInterfaces::GetInstance().SetScreenOffset(screenSession->rsId_, offsetX, offsetY); + return true; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index bb205a85c9..400aaa37a2 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -159,7 +159,8 @@ public: DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; DisplayOrientation CalcDeviceOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; void FillScreenInfo(sptr info) const; - void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false); + void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false, + float positionX = 0, float positionY = 0); DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts); DMError GetScreenColorGamut(ScreenColorGamut& colorGamut); diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 70e4f890fb..186dbcb246 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -1750,7 +1750,8 @@ void ScreenSession::SetPrivateSessionForeground(bool hasPrivate) hasPrivateWindowForeground_ = hasPrivate; } -void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend) +void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend, + float positionX = 0, float positionY = 0) { std::unique_lock displayNodeLock(displayNodeMutex_); if (displayNode_ != nullptr) { @@ -1770,8 +1771,8 @@ void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startP TLOGD(WmsLogTag::WMS_RS_CLI_MULTI_INST, "Create RSDisplayNode: %{public}s", RSAdapterUtil::RSNodeToStr(displayNode_).c_str()); } - TLOGI(WmsLogTag::DMS, "SetDisplayOffset: posX:%{public}d, posY:%{public}d", startPoint.posX_, startPoint.posY_); - displayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); + TLOGI(WmsLogTag::DMS, "SetScreenOffset: posX:%{public}d, posY:%{public}d", startPoint.posX_, startPoint.posY_); + RSInterfaces::GetInstance().SetScreenOffset(config.screenId, startPoint.posX_, startPoint.posY_); uint32_t width = 0; uint32_t height = 0; if (isExtend) { @@ -1791,11 +1792,12 @@ void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startP displayNode_->SetSecurityDisplay(isSecurity_); TLOGI(WmsLogTag::DMS, "virtualScreen SetSecurityDisplay success, isSecurity:%{public}d", isSecurity_); } - // If setDisplayOffset is not valid for SetFrame/SetBounds - TLOGI(WmsLogTag::DMS, "InitRSDisplayNode screenId:%{public}" PRIu64" width:%{public}u height:%{public}u", - screenId_, width, height); - displayNode_->SetFrame(0, 0, static_cast(width), static_cast(height)); - displayNode_->SetBounds(0, 0, static_cast(width), static_cast(height)); + // If SetScreenOffset is not valid for SetFrame/SetBounds + TLOGI(WmsLogTag::DMS, "InitRSDisplayNode screenId:%{public}" PRIu64" \ + width:%{public}u height:%{public}u positionX:%{public}f positionY:%{public}f", + screenId_, width, height, positionX, positionY); + displayNode_->SetFrame(positionX, positionY, static_cast(width), static_cast(height)); + displayNode_->SetBounds(positionX, positionY, static_cast(width), static_cast(height)); if (config.isMirrored) { EnableMirrorScreenRegion(); } @@ -1909,7 +1911,7 @@ bool ScreenSessionGroup::RemoveChild(sptr& smsScreen) smsScreen->groupSmsId_ = SCREEN_ID_INVALID; std::shared_ptr displayNode = smsScreen->GetDisplayNode(); if (displayNode != nullptr) { - displayNode->SetDisplayOffset(0, 0); + RSInterfaces::GetInstance().SetScreenOffset(smsScreen->rsId_, 0, 0); displayNode->RemoveFromTree(); smsScreen->ReleaseDisplayNode(); } diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index 8021684559..d553cffbc9 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -6949,6 +6949,19 @@ HWTEST_F(ScreenSessionManagerTest, SetPrimaryDisplaySystemDpi, Function | SmallT DMError ret = ssm_->SetPrimaryDisplaySystemDpi(2.2); EXPECT_EQ(DMError::DM_OK, ret); } + +/** + * @tc.name: SetScreenOffsetInner01 + * @tc.desc: SetScreenOffsetInner + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenOffsetInner01, Function | SmallTest | Level3) +{ + ScreenId screenId = 0; + EXPECT_TRUE(ssm_->SetScreenOffsetInner(screenId, 0, 0)); + screenId = 5; + EXPECT_TRUE(ssm_->SetScreenOffsetInner(screenId, 0, 0)); +} } } // namespace Rosen } // namespace OHOS -- Gitee From 128a60f00c0b9b644d803644b3690d5ef6265f67 Mon Sep 17 00:00:00 2001 From: chenwei Date: Thu, 11 Sep 2025 16:54:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=87=E5=B1=8F=E7=9A=84=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E7=94=B5=E6=94=BE=E5=88=B0=E4=B8=80=E4=B8=AA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- dmserver/include/abstract_screen.h | 2 +- dmserver/src/abstract_display_controller.cpp | 7 +--- dmserver/src/abstract_screen.cpp | 14 ++++---- dmserver/src/abstract_screen_controller.cpp | 2 +- dmserver/src/display_manager_service.cpp | 10 +++--- .../include/screen_session_manager.h | 1 - .../dual_display_fold_policy.cpp | 36 +++++++++---------- .../src/multi_screen_change_utils.cpp | 10 +++--- .../src/multi_screen_power_change_manager.cpp | 2 +- .../src/screen_session_manager.cpp | 31 +++++----------- .../session/screen/include/screen_session.h | 3 +- .../session/screen/src/screen_session.cpp | 20 +++++------ .../screen_session_manager_test.cpp | 13 ------- 13 files changed, 55 insertions(+), 96 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index de655a6a5f..fa4e29585f 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -59,7 +59,7 @@ public: std::shared_ptr& surfaceNode, std::shared_ptr& parentNode, bool isAdd); void InitRSDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); - void UpdateRSDisplayNode(Point startPoint, sptr absScreen); + void UpdateRSDisplayNode(Point startPoint); ScreenId GetScreenGroupId() const; // colorspace, gamut diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 2c9299857c..11c0710c49 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -251,12 +251,7 @@ DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected( } else { abstractDisplay->SetOffset(0, 0); auto screenId = abstractDisplay->GetAbstractScreenId(); - ScreenId rsScreenId = abstractScreenController_->GetRSDisplayNodeByScreenId(screenId)->ConvertToRsScreenId(screenId); - if (rsScreenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "rsScreenId is invalid."); - continue; - } - RSInterfaces::GetInstance().SetScreenOffset(rsScreenId, 0, 0); + abstractScreenController_->GetRSDisplayNodeByScreenId(screenId)->SetDisplayOffset(0, 0); } } return displayId; diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 723692a890..473fcc7196 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -172,8 +172,8 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetDisplayOffset(startPoint.posX_, startPoint.posY_); uint32_t width = 0; uint32_t height = 0; sptr abstractScreenModes = GetActiveScreenMode(); @@ -187,7 +187,7 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetSecurityDisplay(true); TLOGI(WmsLogTag::DMS, "virtualScreen SetSecurityDisplay success"); } - // If SetScreenOffset is not valid for SetFrame/SetBounds + // If setDisplayOffset is not valid for SetFrame/SetBounds rsDisplayNode->SetFrame(0, 0, width, height); rsDisplayNode->SetBounds(0, 0, width, height); } @@ -248,7 +248,7 @@ void AbstractScreen::InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, TLOGD(WmsLogTag::DMS, "InitRSDefaultDisplayNode success"); } -void AbstractScreen::UpdateRSDisplayNode(Point startPoint, sptr absScreen) +void AbstractScreen::UpdateRSDisplayNode(Point startPoint) { TLOGD(WmsLogTag::DMS, "update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); @@ -258,7 +258,7 @@ void AbstractScreen::UpdateRSDisplayNode(Point startPoint, sptr } startPoint_ = startPoint; - RSInterfaces::GetInstance().SetScreenOffset(absScreen->rsId_, startPoint.posX_, startPoint.posY_); + rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); } ScreenId AbstractScreen::GetScreenGroupId() const @@ -626,7 +626,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) dmsScreen->groupDmsId_ = SCREEN_ID_INVALID; dmsScreen->startPoint_ = Point(); if (dmsScreen->rsDisplayNode_ != nullptr) { - RSInterfaces::GetInstance().SetScreenOffset(dmsScreen->rsId_, 0, 0); + dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); RSTransactionAdapter::FlushImplicitTransaction(dmsScreen->GetRSUIContext()); dmsScreen->rsDisplayNode_ = nullptr; @@ -645,7 +645,7 @@ bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScr ScreenId screenId = dmsScreen->dmsId_; dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; if (dmsScreen->rsDisplayNode_ != nullptr) { - RSInterfaces::GetInstance().SetScreenOffset(dmsScreen->rsId_, 0, 0); + dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); RSTransactionAdapter::FlushImplicitTransaction(dmsScreen->GetRSUIContext()); } diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 3919011a3b..f2101a82c6 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -820,7 +820,7 @@ void AbstractScreenController::UpdateScreenGroupLayout(sptr } if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point, screen); + screen->UpdateRSDisplayNode(point); if (abstractScreenCallback_ != nullptr) { abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index fdad24c8e6..543f41272a 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -716,13 +716,11 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, std::shared_ptr rsDisplayNode; std::vector points; for (uint32_t i = 0; i < allExpandScreenIds.size(); i++) { - ScreenId expandScreenId = allExpandScreenIds[i]; - rsDisplayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(expandScreenId); - points.emplace_back(pointsMap[expandScreenId]); + rsDisplayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(allExpandScreenIds[i]); + points.emplace_back(pointsMap[allExpandScreenIds[i]]); if (rsDisplayNode != nullptr) { - sptr absScreen = abstractScreenController_->GetAbstracetScreen(expandScreenId); - RSInterfaces::GetInstance().SetScreenOffset(absScreen->rsId_, - pointsMap(expandScreenId).posX_, pointsMap(expandScreenId).posY_); + rsDisplayNode->SetDisplayOffset(pointsMap[allExpandScreenIds[i]].posX_, + pointsMap[allExpandScreenIds[i]].posY_); } } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand"); diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index 2bad67468d..f9c75a5050 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -466,7 +466,6 @@ public: bool GetKeyboardState() override; DMError GetScreenAreaOfDisplayArea(DisplayId displayId, const DMRect& displayArea, ScreenId& screenId, DMRect& screenArea) override; - bool SetScreenOffsetInner(ScreenId screenId, float offsetX, float offsetY); protected: ScreenSessionManager(); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp index b77f75e878..a0aed48d5b 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp @@ -42,6 +42,7 @@ const std::string MAIN_TP = "0"; const std::string SUB_TP = "1"; const int32_t REMOVE_DISPLAY_NODE = 0; const int32_t ADD_DISPLAY_NODE = 1; +const uint32_t CHANGE_MODE_TASK_NUM = 3; } // namespace DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMutex, @@ -67,7 +68,7 @@ DualDisplayFoldPolicy::DualDisplayFoldPolicy(std::recursive_mutex& displayInfoMu void DualDisplayFoldPolicy::SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation) { if (status) { - pengdingTask_ = isOnBootAnimation ? FOLD_TO_EXPAND_ONBOOTANIMATION_TASK_NUM : FOLD_TO_EXPAND_TASK_NUM; + pengdingTask_ = CHANGE_MODE_TASK_NUM; startTimePoint_ = std::chrono::steady_clock::now(); displayModeChangeRunning_ = status; } else { @@ -310,7 +311,6 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr scr ScreenId onScreenId) { if (onBootAnimation_) { - SetdisplayModeChangeStatus(true, true); ChangeScreenDisplayModeOnBootAnimation(screenSession, onScreenId); return; } @@ -322,34 +322,32 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayModeInner(sptr scr RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, tp.c_str()); #endif ReportFoldStatusChangeBegin((int32_t)SCREEN_ID_MAIN, (int32_t)SCREEN_ID_SUB); - bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn(); - TLOGI(WmsLogTag::DMS, "ChangeScreenDisplayModeToCoordination, isScreenOn= %{public}d", isScreenOn); auto taskScreenOff = [=] { - TLOGNI(WmsLogTag::DMS, "ChangeScreenDisplayMode: off screenId: %{public}" PRIu64 "", offScreenId); + TLOGNI(WmsLogTag::DMS, "ChangeScreenDisplayModeInner: off screenId: %{public}" PRIu64 "", offScreenId); screenId_ = offScreenId; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_OFF); SetdisplayModeChangeStatus(false); - }; - if (screenPowerTaskScheduler_ == nullptr) { - TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter"); - return; - } - screenPowerTaskScheduler_->PostAsyncTask(taskScreenOff, "screenOffTask"); - AddOrRemoveDisplayNodeToTree(offScreenId, REMOVE_DISPLAY_NODE); - auto taskScreenOn = [=] { - TLOGNI(WmsLogTag::DMS, "ChangeScreenDisplayMode: on screenId: %{public}" PRIu64 "", onScreenId); - screenId_ = onScreenId; - if (isScreenOn) { + TLOGNI(WmsLogTag::DMS, "ChangeScreenDisplayModeInner: on screenId: %{public}" PRIu64 "", onScreenId); + bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsFoldScreenOn(); + bool isInCancelSuspendStatus = ScreenSessionManager::GetInstance().GetCancelSuspendStatus(); + TLOGNI(WmsLogTag::DMS, + "ChangeScreenDisplayModeInner, isScreenOn = %{public}d, isInCancelSuspendStatus = %{public}d", + isScreenOn, isInCancelSuspendStatus); + if (isScreenOn || isInCancelSuspendStatus) { ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPowerForFold(ScreenPowerStatus::POWER_STATUS_ON); } else { PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync(); } - SetdisplayModeChangeStatus(false); }; - screenPowerTaskScheduler_->PostAsyncTask(taskScreenOn, "screenOnTask"); + if (screenPowerTaskScheduler_ == nullptr) { + TLOGE(WmsLogTag::DMS, "screenPowerTaskScheduler_ is nullpter"); + return; + } + screenPowerTaskScheduler_->PostAsyncTask(taskScreenOn, "dualScreenOffTask"); + AddOrRemoveDisplayNodeToTree(offScreenId, REMOVE_DISPLAY_NODE); AddOrRemoveDisplayNodeToTree(onScreenId, ADD_DISPLAY_NODE); } @@ -459,7 +457,7 @@ void DualDisplayFoldPolicy::ChangeOnTentMode(FoldStatus currentState) TLOGE(WmsLogTag::DMS, "current state:%{public}d invalid", currentState); } } - + void DualDisplayFoldPolicy::ChangeOffTentMode() { PowerMgr::PowerMgrClient::GetInstance().WakeupDeviceAsync(); diff --git a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp index 76c6a18634..8becadec21 100644 --- a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp @@ -77,11 +77,9 @@ void MultiScreenChangeUtils::ScreenExtendPositionChange(sptr& inn std::shared_ptr innerNode = innerScreen->GetDisplayNode(); std::shared_ptr externalNode = externalScreen->GetDisplayNode(); if (innerNode && externalNode) { - ScreenSessionManager::GetInstance().SetScreenOffset(innerScreen->GetScreenId(), - innerScreen->GetScreenProperty().GetStartX(), + innerNode->SetDisplayOffset(innerScreen->GetScreenProperty().GetStartX(), innerScreen->GetScreenProperty().GetStartY()); - ScreenSessionManager::GetInstance().SetScreenOffset(externalScreen->GetScreenId(), - externalScreen->GetScreenProperty().GetStartX(), + externalNode->SetDisplayOffset(externalScreen->GetScreenProperty().GetStartX(), externalScreen->GetScreenProperty().GetStartY()); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); @@ -128,8 +126,8 @@ void MultiScreenChangeUtils::ScreenMainPositionChange(sptr& inner std::shared_ptr innerNode = innerScreen->GetDisplayNode(); std::shared_ptr externalNode = externalScreen->GetDisplayNode(); if (innerNode && externalNode) { - ScreenSessionManager::GetInstance().SetScreenOffset(innerScreen->GetScreenId(), 0, 0); - ScreenSessionManager::GetInstance().SetScreenOffset(externalScreen->GetScreenId(), 0, 0); + innerNode->SetDisplayOffset(0, 0); + externalNode->SetDisplayOffset(0, 0); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } diff --git a/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp index 2b938056eb..6b4e432a65 100644 --- a/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_power_change_manager.cpp @@ -195,7 +195,7 @@ void MultiScreenPowerChangeManager::ScreenDisplayNodeRemove(sptr& TLOGW(WmsLogTag::DMS, "removeNode screenId=%{public}" PRIu64, screenScreen->GetScreenId()); std::shared_ptr displayNode = screenScreen->GetDisplayNode(); if (displayNode != nullptr) { - ScreenSessionManager::GetInstance().SetScreenOffset(screenScreen->GetScreenId(), 0, 0); + displayNode->SetDisplayOffset(0, 0); displayNode->RemoveFromTree(); screenScreen->ReleaseDisplayNode(); } diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index cee119de6e..505684ee23 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1540,11 +1540,11 @@ void ScreenSessionManager::ResetInternalScreenSession(sptr& inner ScreenId externalRSId = externalScreen->GetRSScreenId(); if (mainNode != nullptr) { mainNode->SetScreenId(externalRSId); - SetScreenOffsetInner(externalRSId, 0, 0); + mainNode->SetDisplayOffset(0, 0); } if (extendNode != nullptr) { extendNode->SetScreenId(innerRSId); - SetScreenOffsetInner(innerRSId, 0, 0); + extendNode->SetDisplayOffset(0, 0); } RSTransactionAdapter::FlushImplicitTransaction( {innerScreen->GetRSUIContext(), externalScreen->GetRSUIContext()}); @@ -5303,12 +5303,11 @@ DMError ScreenSessionManager::MakeExpand(std::vector screenId, std::shared_ptr rsDisplayNode; std::vector points; for (uint32_t i = 0; i < allExpandScreenIds.size(); i++) { - ScreenId expandScreenId = allExpandScreenIds[i]; - rsDisplayNode = GetRSDisplayNodeByScreenId(expandScreenId); - points.emplace_back(pointsMap[expandScreenId]); + rsDisplayNode = GetRSDisplayNodeByScreenId(allExpandScreenIds[i]); + points.emplace_back(pointsMap[allExpandScreenIds[i]]); if (rsDisplayNode != nullptr) { - SetScreenOffsetInner(expandScreenId, pointsMap[allExpandScreenIds[i]].posX_, - pointsMap[allExpandScreenIds[i]].posY_) + rsDisplayNode->SetDisplayOffset(pointsMap[allExpandScreenIds[i]].posX_, + pointsMap[allExpandScreenIds[i]].posY_); } } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand"); @@ -9179,8 +9178,8 @@ void ScreenSessionManager::SetMultiScreenRelativePositionInner(sptr firstDisplayNode = firstScreenSession->GetDisplayNode(); std::shared_ptr secondDisplayNode = secondScreenSession->GetDisplayNode(); if (firstDisplayNode && secondDisplayNode) { - SetScreenOffsetInner(firstScreenSession->GetScreenId(), mainScreenOptions.startX_, mainScreenOptions.startY_); - SetScreenOffsetInner(secondScreenSession->GetScreenId(), secondScreenOption.startX_, secondScreenOption.startY_); + firstDisplayNode->SetDisplayOffset(mainScreenOptions.startX_, mainScreenOptions.startY_); + secondDisplayNode->SetDisplayOffset(secondScreenOption.startX_, secondScreenOption.startY_); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } @@ -9206,8 +9205,7 @@ void ScreenSessionManager::SetRelativePositionForDisconnect(MultiScreenPositionO ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); std::shared_ptr defaultDisplayNode = defaultScreenSession->GetDisplayNode(); if (defaultDisplayNode) { - SetScreenOffsetInner(defaultScreenSession->GetScreenId(), - defaultScreenOptions.startX_, defaultScreenOptions.startY_); + defaultDisplayNode->SetDisplayOffset(defaultScreenOptions.startX_, defaultScreenOptions.startY_); } else { TLOGW(WmsLogTag::DMS, "DisplayNode is null"); } @@ -10234,15 +10232,4 @@ DMError ScreenSessionManager::SetPrimaryDisplaySystemDpi(float virtualPixelRatio screenSession->SetDensityInCurResolution(virtualPixelRatio); return DMError::DM_OK; } - -bool ScreenSessionManager::SetScreenOffsetInner(ScreenId screenId, float offsetX, float offsetY) -{ - sptr screenSession = GetScreenSession(screenId); - if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "screenSession is null."); - return; - } - RSInterfaces::GetInstance().SetScreenOffset(screenSession->rsId_, offsetX, offsetY); - return true; -} } // namespace OHOS::Rosen diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 400aaa37a2..bb205a85c9 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -159,8 +159,7 @@ public: DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; DisplayOrientation CalcDeviceOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; void FillScreenInfo(sptr info) const; - void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false, - float positionX = 0, float positionY = 0); + void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false); DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts); DMError GetScreenColorGamut(ScreenColorGamut& colorGamut); diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 186dbcb246..70e4f890fb 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -1750,8 +1750,7 @@ void ScreenSession::SetPrivateSessionForeground(bool hasPrivate) hasPrivateWindowForeground_ = hasPrivate; } -void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend, - float positionX = 0, float positionY = 0) +void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend) { std::unique_lock displayNodeLock(displayNodeMutex_); if (displayNode_ != nullptr) { @@ -1771,8 +1770,8 @@ void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startP TLOGD(WmsLogTag::WMS_RS_CLI_MULTI_INST, "Create RSDisplayNode: %{public}s", RSAdapterUtil::RSNodeToStr(displayNode_).c_str()); } - TLOGI(WmsLogTag::DMS, "SetScreenOffset: posX:%{public}d, posY:%{public}d", startPoint.posX_, startPoint.posY_); - RSInterfaces::GetInstance().SetScreenOffset(config.screenId, startPoint.posX_, startPoint.posY_); + TLOGI(WmsLogTag::DMS, "SetDisplayOffset: posX:%{public}d, posY:%{public}d", startPoint.posX_, startPoint.posY_); + displayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); uint32_t width = 0; uint32_t height = 0; if (isExtend) { @@ -1792,12 +1791,11 @@ void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startP displayNode_->SetSecurityDisplay(isSecurity_); TLOGI(WmsLogTag::DMS, "virtualScreen SetSecurityDisplay success, isSecurity:%{public}d", isSecurity_); } - // If SetScreenOffset is not valid for SetFrame/SetBounds - TLOGI(WmsLogTag::DMS, "InitRSDisplayNode screenId:%{public}" PRIu64" \ - width:%{public}u height:%{public}u positionX:%{public}f positionY:%{public}f", - screenId_, width, height, positionX, positionY); - displayNode_->SetFrame(positionX, positionY, static_cast(width), static_cast(height)); - displayNode_->SetBounds(positionX, positionY, static_cast(width), static_cast(height)); + // If setDisplayOffset is not valid for SetFrame/SetBounds + TLOGI(WmsLogTag::DMS, "InitRSDisplayNode screenId:%{public}" PRIu64" width:%{public}u height:%{public}u", + screenId_, width, height); + displayNode_->SetFrame(0, 0, static_cast(width), static_cast(height)); + displayNode_->SetBounds(0, 0, static_cast(width), static_cast(height)); if (config.isMirrored) { EnableMirrorScreenRegion(); } @@ -1911,7 +1909,7 @@ bool ScreenSessionGroup::RemoveChild(sptr& smsScreen) smsScreen->groupSmsId_ = SCREEN_ID_INVALID; std::shared_ptr displayNode = smsScreen->GetDisplayNode(); if (displayNode != nullptr) { - RSInterfaces::GetInstance().SetScreenOffset(smsScreen->rsId_, 0, 0); + displayNode->SetDisplayOffset(0, 0); displayNode->RemoveFromTree(); smsScreen->ReleaseDisplayNode(); } diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index d553cffbc9..8021684559 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -6949,19 +6949,6 @@ HWTEST_F(ScreenSessionManagerTest, SetPrimaryDisplaySystemDpi, Function | SmallT DMError ret = ssm_->SetPrimaryDisplaySystemDpi(2.2); EXPECT_EQ(DMError::DM_OK, ret); } - -/** - * @tc.name: SetScreenOffsetInner01 - * @tc.desc: SetScreenOffsetInner - * @tc.type: FUNC - */ -HWTEST_F(ScreenSessionManagerTest, SetScreenOffsetInner01, Function | SmallTest | Level3) -{ - ScreenId screenId = 0; - EXPECT_TRUE(ssm_->SetScreenOffsetInner(screenId, 0, 0)); - screenId = 5; - EXPECT_TRUE(ssm_->SetScreenOffsetInner(screenId, 0, 0)); -} } } // namespace Rosen } // namespace OHOS -- Gitee