diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 955ca7fdf1..d4f9ef7eda 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -124,6 +124,8 @@ public: virtual sptr GetScreenGroupInfoById(ScreenId screenId); virtual DMError GetAllScreenInfos(std::vector>& screenInfos); virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, ScreenId& screenGroupId); + virtual DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, DMRect mainScreenRegion, + ScreenId& screenGroupId); virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode); virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 29eb836744..551aa4570d 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -478,13 +478,21 @@ void BaseAdapter::Clear() } DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, - ScreenId& screenGroupId) + ScreenId& screenGroupId) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); } +DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, screenGroupId); +} + DMError ScreenManagerAdapter::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) { @@ -873,4 +881,4 @@ std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshotWithOp INIT_PROXY_CHECK_RETURN(nullptr); return displayManagerServiceProxy_->GetDisplaySnapshotWithOption(captureOption, errorCode); } -} // namespace OHOS::Rosen \ No newline at end of file +} // namespace OHOS::Rosen diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index 6b28c599fa..66fe5475c0 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -486,7 +486,20 @@ DMError ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector m return DMError::DM_ERROR_INVALID_PARAM; } DMError ret = SingletonContainer::Get().MakeMirror(mainScreenId, mirrorScreenId, - screenGroupId); + screenGroupId); + if (screenGroupId == SCREEN_ID_INVALID) { + WLOGFE("create mirror failed"); + } + return ret; +} + +DMError ScreenManager::MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, DMRect mainScreenRegion, + ScreenId& screenGroupId) +{ + WLOGFI("Make mirror with region for screen: %{public}" PRIu64",mirrorScreen: %{public}" PRIu64"", + mainScreenId, mirrorScreenId); + DMError ret = SingletonContainer::Get().MakeMirror(mainScreenId, mirrorScreenId, + mainScreenRegion, screenGroupId); if (screenGroupId == SCREEN_ID_INVALID) { WLOGFE("create mirror failed"); } diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index 11988cc871..fcd6435fdf 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -137,6 +137,11 @@ public: virtual DMError GetAllScreenInfos(std::vector>& screenInfos) = 0; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) = 0; + virtual DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) { @@ -253,4 +258,4 @@ public: }; } // namespace OHOS::Rosen -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H \ No newline at end of file +#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 1ccd335c20..2c5dbdfac0 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -57,6 +57,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION, TRANS_ID_SCREENGROUP_BASE = 1100, TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE, + TRANS_ID_SCREEN_MAKE_MIRROR_WITH_REGION, TRANS_ID_MULTI_SCREEN_MODE_SWITCH, TRANS_ID_SET_MULTI_SCREEN_POSITION, TRANS_ID_SCREEN_MAKE_EXPAND, @@ -138,4 +139,4 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_GET_DISPLAY_SNAPSHOT_WITH_OPTION, }; } -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H \ No newline at end of file +#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index 76b57c3995..35dd550b5d 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -112,6 +112,18 @@ public: */ DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, ScreenId& screenGroupId); + /** + * @brief Make screen as mirror-screen for region of main screen. + * + * @param mainScreenId Main screen id. + * @param mirrorScreenId Mirror screen id. + * @param mainScreenRegion Region of main screen. + * @param screenGroupId Screen group id. + * @return DM_OK means make mirror success, others means make mirror failed. + */ + DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, DMRect mainScreenRegion, + ScreenId& screenGroupId); + /** * @brief Make screens as mirror-screen * @@ -382,4 +394,4 @@ private: }; } // namespace OHOS::Rosen -#endif // FOUNDATION_DM_SCREEN_MANAGER_H \ No newline at end of file +#endif // FOUNDATION_DM_SCREEN_MANAGER_H diff --git a/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp b/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp index f13c2f9ccd..ed4ad89446 100644 --- a/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp +++ b/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp @@ -81,6 +81,12 @@ static napi_value MakeMirror(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnMakeMirror(env, info) : nullptr; } +static napi_value MakeMirrorWithRegion(napi_env env, napi_callback_info info) +{ + JsScreenManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnMakeMirrorWithRegion(env, info) : nullptr; +} + static napi_value SetMultiScreenMode(napi_env env, napi_callback_info info) { JsScreenManager* me = CheckParamsAndGetThis(env, info); @@ -447,6 +453,53 @@ napi_value OnMakeMirror(napi_env env, napi_callback_info info) return result; } +napi_value OnMakeMirrorWithRegion(napi_env env, napi_callback_info info) +{ + WLOGI("OnMakeMirrorWithRegion is called"); + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_THREE) { + return NapiThrowError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, "Invalid args count, need 3 args at least!"); + } + + int64_t mainScreenId; + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], mainScreenId)) { + return NapiThrowError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, "Failed to convert parameter to mainScreenId"); + } + + int64_t mirrorScreenId; + if (!ConvertFromJsValue(env, argv[INDEX_ONE], mirrorScreenId)) { + return NapiThrowError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, + "Failed to convert parameter to mirrorScreenId"); + } + + DMRect mainScreenRegion; + if (GetRectFromJs(env, argv[INDEX_TWO], mainScreenRegion) == -1) { + return NapiThrowError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, + "Failed to convert parameter to mainScreenRegion"); + } + + napi_value lastParam = nullptr; + napi_value result = nullptr; + std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); + auto asyncTask = [mainScreenId, mirrorScreenId, mainScreenRegion, env, task = napiAsyncTask.get()]() { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsScreenManager::OnMakeMirrorWithRegion"); + ScreenId screenGroupId = INVALID_SCREEN_ID; + DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at( + SingletonContainer::Get().MakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, + screenGroupId)); + if (ret == DmErrorCode::DM_OK) { + task->Resolve(env, CreateJsValue(env, static_cast(screenGroupId))); + } else { + task->Reject(env, + CreateJsError(env, static_cast(ret), "JsScreenManager::OnMakeMirrorWithRegion failed.")); + } + }; + NapiSendDmsEvent(env, asyncTask, napiAsyncTask); + return result; +} + napi_value OnSetMultiScreenMode(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; @@ -741,6 +794,40 @@ static int32_t GetMultiScreenPositionOptionsFromJs(napi_env env, napi_value opti return 0; } +static int32_t GetRectFromJs(napi_env env, napi_value optionObject, DMRect& rect) +{ + napi_value leftValue = nullptr; + napi_value topValue = nullptr; + napi_value widthValue = nullptr; + napi_value heightValue = nullptr; + int32_t left; + int32_t top; + uint32_t width; + uint32_t height; + napi_get_named_property(env, optionObject, "left", &leftValue); + napi_get_named_property(env, optionObject, "top", &topValue); + napi_get_named_property(env, optionObject, "width", &widthValue); + napi_get_named_property(env, optionObject, "height", &heightValue); + if (!ConvertFromJsValue(env, leftValue, left)) { + WLOGFE("Failed to convert leftValue to callbackType"); + return -1; + } + if (!ConvertFromJsValue(env, topValue, top)) { + WLOGFE("Failed to convert topValue to callbackType"); + return -1; + } + if (!ConvertFromJsValue(env, widthValue, width)) { + WLOGFE("Failed to convert widthValue to callbackType"); + return -1; + } + if (!ConvertFromJsValue(env, heightValue, height)) { + WLOGFE("Failed to convert heightValue to callbackType"); + return -1; + } + rect = {left, top, width, height}; + return 0; +} + napi_value OnCreateVirtualScreen(napi_env env, napi_callback_info info) { WLOGI("JsScreenManager::OnCreateVirtualScreen is called"); @@ -1233,6 +1320,7 @@ napi_value JsScreenManagerInit(napi_env env, napi_value exportObj) BindNativeFunction(env, exportObj, "on", moduleName, JsScreenManager::RegisterScreenManagerCallback); BindNativeFunction(env, exportObj, "off", moduleName, JsScreenManager::UnregisterScreenMangerCallback); BindNativeFunction(env, exportObj, "makeMirror", moduleName, JsScreenManager::MakeMirror); + BindNativeFunction(env, exportObj, "makeMirrorWithRegion", moduleName, JsScreenManager::MakeMirrorWithRegion); BindNativeFunction(env, exportObj, "setMultiScreenMode", moduleName, JsScreenManager::SetMultiScreenMode); BindNativeFunction(env, exportObj, "setMultiScreenRelativePosition", moduleName, JsScreenManager::SetMultiScreenRelativePosition); diff --git a/window_scene/screen_session_manager/include/multi_screen_manager.h b/window_scene/screen_session_manager/include/multi_screen_manager.h index 15e578f0c1..01d1013986 100644 --- a/window_scene/screen_session_manager/include/multi_screen_manager.h +++ b/window_scene/screen_session_manager/include/multi_screen_manager.h @@ -32,7 +32,7 @@ public: DMError UniqueSwitch(const std::vector& screenIds); - DMError MirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, + DMError MirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, DMRect mainScreenRegion, ScreenId& screenGroupId); void MultiScreenModeChange(sptr mainSession, sptr secondarySession, @@ -55,9 +55,9 @@ private: std::vector& physicalScreenIds, std::vector& virtualScreenIds); DMError VirtualScreenMirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, - ScreenId& screenGroupId); + DMRect mainScreenRegion, ScreenId& screenGroupId); - DMError PhysicalScreenMirrorSwitch(const std::vector& screenIds); + DMError PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mainScreenRegion); DMError PhysicalScreenUniqueSwitch(const std::vector& screenIds); 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 57a57923ce..1c68f2d2f7 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -109,6 +109,8 @@ public: DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; + virtual DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) override; virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) override; virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, @@ -164,7 +166,8 @@ public: bool HandleFoldScreenSessionCreate(ScreenId screenId); void ChangeScreenGroup(sptr group, const std::vector& screens, - const std::vector& startPoints, bool filterScreen, ScreenCombination combination); + const std::vector& startPoints, bool filterScreen, ScreenCombination combination, + DMRect mainScreenRegion = DMRect::NONE()); bool RemoveChildFromGroup(sptr screen, sptr screenGroup); @@ -173,7 +176,7 @@ public: std::map& removeChildResMap); bool CheckScreenInScreenGroup(sptr screen) const; - DMError SetMirror(ScreenId screenId, std::vector screens); + DMError SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion); DMError StopScreens(const std::vector& screenIds, ScreenCombination stopCombination); void NotifyScreenConnected(sptr screenInfo); @@ -372,6 +375,8 @@ private: void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type); void NotifyCaptureStatusChanged(); + DMError DoMakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, + DMRect mainScreenRegion, ScreenId& screenGroupId); bool OnMakeExpand(std::vector screenId, std::vector startPoint); bool OnRemoteDied(const sptr& agent); std::string TransferTypeToString(ScreenType type) const; diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h index cecbefa7c9..c40a98fd84 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h @@ -109,6 +109,8 @@ public: virtual DMError GetAllScreenInfos(std::vector>& screenInfos) override { return DMError::DM_OK; } virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override { return DMError::DM_OK; } + virtual DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) override { return DMError::DM_OK; } virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) override { return DMError::DM_OK; } virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h index a2b12faf73..7244204048 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h @@ -85,6 +85,8 @@ public: virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; + virtual DMError MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) override; virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) override; virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, @@ -193,4 +195,4 @@ private: } // namespace Rosen } // namespace OHOS -#endif // OHOS_ROSEN_SCREEN_SESSION_MANAGER_PROXY_H \ No newline at end of file +#endif // OHOS_ROSEN_SCREEN_SESSION_MANAGER_PROXY_H diff --git a/window_scene/screen_session_manager/src/multi_screen_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_manager.cpp index 3a1b67165b..6db2b57403 100644 --- a/window_scene/screen_session_manager/src/multi_screen_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_manager.cpp @@ -63,7 +63,7 @@ void MultiScreenManager::FilterPhysicalAndVirtualScreen(const std::vector& screenIds, ScreenId& screenGroupId) + const std::vector& screenIds, DMRect mainScreenRegion, ScreenId& screenGroupId) { TLOGI(WmsLogTag::DMS, "enter size: %{public}u", static_cast(screenIds.size())); @@ -73,7 +73,7 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI TLOGE(WmsLogTag::DMS, "screen session null fail mainScreenId: %{public}" PRIu64, mainScreenId); return DMError::DM_ERROR_INVALID_PARAM; } - DMError ret = ScreenSessionManager::GetInstance().SetMirror(mainScreenId, screenIds); + DMError ret = ScreenSessionManager::GetInstance().SetMirror(mainScreenId, screenIds, mainScreenRegion); if (ret != DMError::DM_OK) { TLOGE(WmsLogTag::DMS, "error: %{public}d", ret); return ret; @@ -88,7 +88,7 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI return ret; } -DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vector& screenIds) +DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vector& screenIds, DMRect mirrorRegion) { sptr defaultSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); if (defaultSession == nullptr) { @@ -110,6 +110,8 @@ DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vectorRemoveFromTree(); } screenSession->ReleaseDisplayNode(); + screenSession->SetMirrorScreenRegion(defaultSession->GetRSScreenId(), mirrorRegion); + screenSession->SetIsPhysicalMirrorSwitch(true); RSDisplayNodeConfig config = { screenSession->screenId_, true, nodeId, true }; screenSession->CreateDisplayNode(config); } @@ -210,7 +212,7 @@ DMError MultiScreenManager::UniqueSwitch(const std::vector& screenIds) } DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std::vector& screenIds, - ScreenId& screenGroupId) + DMRect mainScreenRegion, ScreenId& screenGroupId) { DMError switchStatus = DMError::DM_OK; std::vector virtualScreenIds; @@ -223,12 +225,12 @@ DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std: FilterPhysicalAndVirtualScreen(screenIds, physicalScreenIds, virtualScreenIds); if (!virtualScreenIds.empty()) { - switchStatus = VirtualScreenMirrorSwitch(mainScreenId, virtualScreenIds, screenGroupId); + switchStatus = VirtualScreenMirrorSwitch(mainScreenId, virtualScreenIds, mainScreenRegion, screenGroupId); TLOGI(WmsLogTag::DMS, "virtual screen switch to mirror result: %{public}d", switchStatus); } if (!physicalScreenIds.empty()) { screenGroupId = 1; - switchStatus = PhysicalScreenMirrorSwitch(physicalScreenIds); + switchStatus = PhysicalScreenMirrorSwitch(physicalScreenIds, mainScreenRegion); TLOGI(WmsLogTag::DMS, "physical screen switch to mirror result: %{public}d", switchStatus); } TLOGI(WmsLogTag::DMS, "end switchStatus: %{public}d", switchStatus); @@ -576,4 +578,4 @@ void MultiScreenManager::ExternalScreenDisconnectChange(sptr inte return; } } -} // namespace OHOS::Rosen \ No newline at end of file +} // namespace OHOS::Rosen 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 e298db0d20..5812a93dfe 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -3290,8 +3290,8 @@ void ScreenSessionManager::MirrorSwitchNotify(ScreenId screenId) } } -DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) +DMError ScreenSessionManager::DoMakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, + DMRect mainScreenRegion, ScreenId& screenGroupId) { TLOGI(WmsLogTag::DMS, "enter!"); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { @@ -3319,7 +3319,7 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, + ScreenId& screenGroupId) +{ + return DoMakeMirror(mainScreenId, mirrorScreenIds, DMRect::NONE(), screenGroupId); +} + +DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, ScreenId mirrorScreenId, + DMRect mainScreenRegion, ScreenId& screenGroupId) +{ + std::vector screenIds; + screenIds.emplace_back(mirrorScreenId); + return DoMakeMirror(mainScreenId, screenIds, mainScreenRegion, screenGroupId); +} + void ScreenSessionManager::RegisterCastObserver(std::vector& mirrorScreenIds) { mirrorScreenIds_ = mirrorScreenIds; @@ -4020,7 +4034,7 @@ bool ScreenSessionManager::RemoveChildFromGroup(sptr screen, sptr return true; } -DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector screens) +DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector screens, DMRect mainScreenRegion) { TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64"", screenId); sptr screen = GetScreenSession(screenId); @@ -4044,7 +4058,8 @@ DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector bool filterMirroredScreen = group->combination_ == ScreenCombination::SCREEN_MIRROR && group->mirrorScreenId_ == screen->screenId_; group->mirrorScreenId_ = screen->screenId_; - ChangeScreenGroup(group, screens, startPoints, filterMirroredScreen, ScreenCombination::SCREEN_MIRROR); + ChangeScreenGroup(group, screens, startPoints, filterMirroredScreen, ScreenCombination::SCREEN_MIRROR, + mainScreenRegion); TLOGI(WmsLogTag::DMS, "success"); return DMError::DM_OK; } @@ -4078,7 +4093,7 @@ bool ScreenSessionManager::CheckScreenInScreenGroup(sptr screen) } void ScreenSessionManager::ChangeScreenGroup(sptr group, const std::vector& screens, - const std::vector& startPoints, bool filterScreen, ScreenCombination combination) + const std::vector& startPoints, bool filterScreen, ScreenCombination combination, DMRect mainScreenRegion) { std::map removeChildResMap; std::vector addScreens; @@ -4094,7 +4109,16 @@ void ScreenSessionManager::ChangeScreenGroup(sptr group, con TLOGI(WmsLogTag::DMS, "Screen->groupSmsId_: %{public}" PRIu64"", screen->groupSmsId_); screen->groupSmsId_ = 1; if (filterScreen && screen->groupSmsId_ == group->screenId_ && group->HasChild(screen->screenId_)) { - continue; + //该screen已经在该分组中了 + if (combination != ScreenCombination::SCREEN_MIRROR || + screen->GetMirrorScreenRegion().second == mainScreenRegion) { + continue; + } + //镜像模式且镜像区域变化,需要重新创建镜像 + TLOGI(WmsLogTag::DMS, "Screen: %{public}" PRIu64 + ", apply new region, x:%{public}d y:%{public}d w:%{public}u h:%{public}u", + screenId, mainScreenRegion.posX_, mainScreenRegion.posY_, + mainScreenRegion.width_, mainScreenRegion.height_); } if (CheckScreenInScreenGroup(screen)) { NotifyDisplayDestroy(screenId); @@ -4103,6 +4127,20 @@ void ScreenSessionManager::ChangeScreenGroup(sptr group, con addChildPos.emplace_back(startPoints[i]); removeChildResMap[screenId] = originGroup != nullptr; addScreens.emplace_back(screenId); + if (combination == ScreenCombination::SCREEN_MIRROR) { + auto mirrorScreenId = group->mirrorScreenId_; + ScreenId rsScreenId = SCREEN_ID_INVALID; + if (!ConvertScreenIdToRsScreenId(screenId, rsScreenId)) { + TLOGE(WmsLogTag::DMS, "Screen: %{public}" PRIu64" convert to rs id failed", mirrorScreenId); + } else { + screen->SetMirrorScreenRegion(rsScreenId, mainScreenRegion); + screen->SetIsPhysicalMirrorSwitch(false); + TLOGI(WmsLogTag::DMS, "Screen: %{public}" PRIu64" mirror to %{public}" + PRIu64" with region, x:%{public}d y:%{public}d w:%{public}u h:%{public}u", + screenId, mirrorScreenId, mainScreenRegion.posX_, mainScreenRegion.posY_, + mainScreenRegion.width_, mainScreenRegion.height_); + } + } } group->combination_ = combination; AddScreenToGroup(group, addScreens, addChildPos, removeChildResMap); diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp index 7423e9e3d7..ca8e3d2c14 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -1271,6 +1271,44 @@ DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId, return ret; } +DMError ScreenSessionManagerProxy::MakeMirror(ScreenId mainScreenId, + ScreenId mirrorScreenId, DMRect mainScreenRegion, ScreenId& screenGroupId) +{ + WLOGFW("ScreenSessionManagerProxy::MakeMirror: ENTER"); + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("ScreenSessionManagerProxy::MakeMirror: create mirror fail: remote is null"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("ScreenSessionManagerProxy::MakeMirror: create mirror fail: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + bool res = data.WriteUint64(static_cast(mainScreenId)) && + data.WriteUint64(static_cast(mirrorScreenId)); + if (!res) { + WLOGFE("ScreenSessionManagerProxy::MakeMirror: create mirror fail: write screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(mainScreenRegion.posX_) || !data.WriteInt32(mainScreenRegion.posY_) || + !data.WriteUint32(mainScreenRegion.width_) || !data.WriteUint32(mainScreenRegion.height_)) { + WLOGFE("ScreenSessionManagerProxy::MakeMirror: Write mainScreenRegion failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR_WITH_REGION), + data, reply, option) != ERR_NONE) { + WLOGFW("ScreenSessionManagerProxy::MakeMirror: create mirror fail: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + screenGroupId = static_cast(reply.ReadUint64()); + return ret; +} + DMError ScreenSessionManagerProxy::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode) { diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp index c5c58fd6d4..727b01ace5 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp @@ -269,6 +269,20 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& static_cast(reply.WriteUint64(static_cast(screenGroupId))); break; } + case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR_WITH_REGION: { + ScreenId mainScreenId = static_cast(data.ReadUint64()); + ScreenId mirrorScreenId = static_cast(data.ReadUint64()); + int32_t posX = data.ReadInt32(); + int32_t posY = data.ReadInt32(); + uint32_t width = data.ReadUint32(); + uint32_t height = data.ReadUint32(); + DMRect mainScreenRegion = { posX, posY, width, height }; + ScreenId screenGroupId = INVALID_SCREEN_ID; + DMError ret = MakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, screenGroupId); + static_cast(reply.WriteInt32(static_cast(ret))); + static_cast(reply.WriteUint64(static_cast(screenGroupId))); + break; + } case DisplayManagerMessage::TRANS_ID_MULTI_SCREEN_MODE_SWITCH: { ScreenId mainScreenId = static_cast(data.ReadUint64()); ScreenId secondaryScreenId = static_cast(data.ReadUint64()); diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 505324ef98..8cd8f5807f 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -174,6 +174,8 @@ public: bool IsScreenRotationLocked(); void SetTouchEnabledFromJs(bool isTouchEnabled); bool IsTouchEnabled(); + void SetIsPhysicalMirrorSwitch(bool isPhysicalMirrorSwitch); + bool GetIsPhysicalMirrorSwitch(); void UpdateToInputManager(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode); void UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode); @@ -248,6 +250,8 @@ public: Rotation ConvertIntToRotation(int rotation); void SetPhysicalRotation(int rotation, FoldStatus foldStatus); void SetStartPosition(uint32_t startX, uint32_t startY); + void SetMirrorScreenRegion(ScreenId screenId, DMRect screenRegion); + std::pair GetMirrorScreenRegion(); void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName); void SuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus); @@ -260,6 +264,7 @@ private: VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT }; bool hasPrivateWindowForeground_ = false; bool isFakeInUse_ = false; + bool isPhysicalMirrorSwitch_ = false; mutable std::shared_mutex displayNodeMutex_; std::atomic touchEnabled_ { true }; std::function updateToInputManagerCallback_ = nullptr; @@ -270,10 +275,12 @@ private: std::vector hdrFormats_; std::vector colorSpaces_; MirrorScreenType mirrorScreenType_ { MirrorScreenType::VIRTUAL_MIRROR }; + std::pair mirrorScreenRegion_ = std::make_pair(INVALID_SCREEN_ID, DMRect::NONE()); SetScreenSceneDpiFunc setScreenSceneDpiCallback_ = nullptr; DestroyScreenSceneFunc destroyScreenSceneCallback_ = nullptr; void ReportNotifyModeChange(DisplayOrientation displayOrientation); sptr fakeScreenSession_ = nullptr; + void EnableMirrorScreenRegion(); }; class ScreenSessionGroup : public ScreenSession { diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 57aa48808d..e2ee7cc0ca 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -96,6 +96,9 @@ void ScreenSession::CreateDisplayNode(const Rosen::RSDisplayNodeConfig& config) property_.GetBounds().rect_.width_, property_.GetBounds().rect_.height_); displayNode_->SetBounds(property_.GetBounds().rect_.left_, property_.GetBounds().rect_.top_, property_.GetBounds().rect_.width_, property_.GetBounds().rect_.height_); + if (config.isMirrored) { + EnableMirrorScreenRegion(); + } } else { TLOGE(WmsLogTag::DMS, "Failed to create displayNode, displayNode is null!"); } @@ -214,6 +217,41 @@ void ScreenSession::UnregisterScreenChangeListener(IScreenChangeListener* screen screenChangeListenerList_.end()); } +void ScreenSession::SetMirrorScreenRegion(ScreenId screenId, DMRect screenRegion) +{ + mirrorScreenRegion_ = std::make_pair(screenId, screenRegion); +} + +std::pair ScreenSession::GetMirrorScreenRegion() +{ + return mirrorScreenRegion_; +} + +void ScreenSession::EnableMirrorScreenRegion() +{ + auto& rect = mirrorScreenRegion_.second; + if (rect == DMRect::NONE()) { + return; + } + ScreenId screenId = INVALID_SCREEN_ID; + if (isPhysicalMirrorSwitch_) { + screenId = screenId_; + } else { + screenId = rsId_; + } + auto ret = RSInterfaces::GetInstance().SetMirrorScreenVisibleRect(screenId, + { rect.posX_, rect.posY_, rect.width_, rect.height_ }); + if (ret != StatusCode::SUCCESS) { + WLOGE("ScreenSession::EnableMirrorScreenRegion fail! rsId %{public}" PRIu64", ret:%{public}d," PRIu64 + ", x:%{public}d y:%{public}d w:%{public}u h:%{public}u", screenId, ret, + rect.posX_, rect.posY_, rect.width_, rect.height_); + } else { + WLOGE("ScreenSession::EnableMirrorScreenRegion success! rsId %{public}" PRIu64", ret:%{public}d," PRIu64 + ", x:%{public}d y:%{public}d w:%{public}u h:%{public}u", screenId, ret, + rect.posX_, rect.posY_, rect.width_, rect.height_); + } +} + sptr ScreenSession::ConvertToDisplayInfo() { sptr displayInfo = new(std::nothrow) DisplayInfo(); @@ -1239,6 +1277,9 @@ void ScreenSession::InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startP 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(); + } auto transactionProxy = RSTransactionProxy::GetInstance(); if (transactionProxy != nullptr) { transactionProxy->FlushImplicitTransaction(); @@ -1541,4 +1582,14 @@ void ScreenSession::SuperFoldStatusChange(ScreenId screenId, SuperFoldStatus sup listener->OnSuperFoldStatusChange(screenId, superFoldStatus); } } + +void ScreenSession::SetIsPhysicalMirrorSwitch(bool isPhysicalMirrorSwitch) +{ + isPhysicalMirrorSwitch_ = isPhysicalMirrorSwitch; +} + +bool ScreenSession::GetIsPhysicalMirrorSwitch() +{ + return isPhysicalMirrorSwitch_; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp index 0690f2960d..aa8359d131 100644 --- a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp +++ b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp @@ -111,7 +111,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch01, Function | SmallTe ScreenId mainScreenId = 1; std::vector ScreenIds = {2, 3}; ScreenId screenGroupId; - MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, DMRect::NONE(), + screenGroupId); EXPECT_EQ(screenGroupId, 0); } @@ -127,7 +128,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch02, Function | SmallTe ScreenId screenGroupId; sptr session = new ScreenSession(); ScreenSessionManager::GetInstance().screenSessionMap_[mainScreenId] = session; - auto ret = MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + auto ret = MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, + DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -148,7 +150,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch03, Function | SmallTe ScreenCombination combination = ScreenCombination::SCREEN_ALONE; sptr sessiongroup = new ScreenSessionGroup(mainScreenId, rsId, name, combination); ScreenSessionManager::GetInstance().smsScreenGroupMap_[mainScreenId] = sessiongroup; - auto ret = MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + auto ret = MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, DMRect::NONE(), + screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -162,7 +165,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch04, Function | SmallTe ScreenId mainScreenId = 1003; std::vector ScreenIds = {2, 3}; ScreenId screenGroupId; - MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, DMRect::NONE(), + screenGroupId); EXPECT_EQ(screenGroupId, 0); } @@ -176,7 +180,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch05, Function | SmallTe ScreenId mainScreenId = 101; std::vector ScreenIds = {1, 2}; ScreenId screenGroupId; - MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, DMRect::NONE(), + screenGroupId); EXPECT_EQ(screenGroupId, 0); } @@ -190,7 +195,8 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch06, Function | SmallTe ScreenId mainScreenId = 102; std::vector ScreenIds = {1, 3}; ScreenId screenGroupId; - MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, screenGroupId); + MultiScreenManager::GetInstance().VirtualScreenMirrorSwitch(mainScreenId, ScreenIds, DMRect::NONE(), + screenGroupId); EXPECT_EQ(screenGroupId, 0); } @@ -202,7 +208,7 @@ HWTEST_F(MultiScreenManagerTest, VirtualScreenMirrorSwitch06, Function | SmallTe HWTEST_F(MultiScreenManagerTest, PhysicalScreenMirrorSwitch01, Function | SmallTest | Level1) { std::vector screenIds = {2, 3}; - DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds); + DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds, DMRect::NONE()); EXPECT_EQ(ret, DMError::DM_ERROR_NULLPTR); } @@ -217,7 +223,7 @@ HWTEST_F(MultiScreenManagerTest, PhysicalScreenMirrorSwitch02, Function | SmallT sptr session = new ScreenSession(); ScreenSessionManager::GetInstance().screenSessionMap_[ ScreenSessionManager::GetInstance().defaultScreenId_] = session; - DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds); + DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds, DMRect::NONE()); EXPECT_EQ(ret, DMError::DM_OK); } @@ -234,7 +240,7 @@ HWTEST_F(MultiScreenManagerTest, PhysicalScreenMirrorSwitch03, Function | SmallT ScreenSessionManager::GetInstance().defaultScreenId_] = session; sptr session1 = new ScreenSession(); ScreenSessionManager::GetInstance().screenSessionMap_[1002] = session1; - DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds); + DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds, DMRect::NONE()); EXPECT_EQ(ret, DMError::DM_OK); } @@ -249,7 +255,7 @@ HWTEST_F(MultiScreenManagerTest, PhysicalScreenMirrorSwitch04, Function | SmallT sptr session = new ScreenSession(); ScreenSessionManager::GetInstance().screenSessionMap_[ ScreenSessionManager::GetInstance().defaultScreenId_] = session; - DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds); + DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds, DMRect::NONE()); EXPECT_EQ(ret, DMError::DM_OK); } @@ -267,7 +273,7 @@ HWTEST_F(MultiScreenManagerTest, PhysicalScreenMirrorSwitch05, Function | SmallT ScreenSessionManager::GetInstance().defaultScreenId_] = session; sptr session1 = new ScreenSession(); ScreenSessionManager::GetInstance().screenSessionMap_[12] = session1; - DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds); + DMError ret = MultiScreenManager::GetInstance().PhysicalScreenMirrorSwitch(screenIds, DMRect::NONE()); EXPECT_EQ(ret, DMError::DM_OK); } @@ -538,7 +544,7 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch, Function | SmallTest | Level1) { std::vector screenIds = {}; ScreenId screenGroupId = 0; - DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); + DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -551,7 +557,7 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch01, Function | SmallTest | Level1) { std::vector screenIds = {1001, 1002}; ScreenId screenGroupId = 0; - DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); + DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -564,7 +570,7 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch02, Function | SmallTest | Level1) { std::vector screenIds = {2, 3}; ScreenId screenGroupId = 0; - DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); + DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -577,7 +583,7 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch03, Function | SmallTest | Level1) { std::vector screenIds = {1003, 1002}; ScreenId screenGroupId = 0; - DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); + DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -590,7 +596,7 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch04, Function | SmallTest | Level1) { std::vector screenIds = {1003, 2}; ScreenId screenGroupId = 0; - DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); + DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, DMRect::NONE(), screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } @@ -1860,4 +1866,4 @@ HWTEST_F(MultiScreenManagerTest, ExternalScreenDisconnectChange05, Function | Sm } } } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 f08aab132e..5f4ea20cd5 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -1540,8 +1540,8 @@ HWTEST_F(ScreenSessionManagerTest, SetMirror, Function | SmallTest | Level3) ssm_->screenSessionMap_ = screenSessionMap_; auto screen = ssm_->GetScreenSession(2); screen->GetScreenProperty().SetScreenType(ScreenType::REAL); - ASSERT_EQ(DMError::DM_OK, ssm_->SetMirror(2, screens)); - ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->SetMirror(9, screens)); + ASSERT_EQ(DMError::DM_OK, ssm_->SetMirror(2, screens, DMRect::NONE())); + ASSERT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->SetMirror(9, screens, DMRect::NONE())); ssm_->DestroyVirtualScreen(screenId); }