已合并
窗口支持RS多实例 #18781
朱春杰创建于 4月17日
窗口支持RS多实例 #18781
已合并
共 71 个文件变更+1302-270
| @@ -39,7 +39,11 @@ class AbstractScreenGroup; | |||
| 39 | class AbstractScreenController; | 39 | class AbstractScreenController; |
| 40 | class AbstractScreen : public RefBase { | 40 | class AbstractScreen : public RefBase { |
| 41 | public: | 41 | public: |
| 42 | - AbstractScreen(sptr<AbstractScreenController>, const std::string& name, ScreenId dmsId, ScreenId rsId); | 42 | + AbstractScreen(sptr<AbstractScreenController>, |
| 43 | + const std::string& name, | ||
| 44 | + ScreenId dmsId, | ||
| 45 | + ScreenId rsId, | ||
| 46 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 43 | AbstractScreen() = delete; | 47 | AbstractScreen() = delete; |
| 44 | WM_DISALLOW_COPY_AND_MOVE(AbstractScreen); | 48 | WM_DISALLOW_COPY_AND_MOVE(AbstractScreen); |
| 45 | ~AbstractScreen(); | 49 | ~AbstractScreen(); |
| @@ -79,6 +83,7 @@ public: | |||
| 79 | void SetPhyHeight(uint32_t phyHeight); | 83 | void SetPhyHeight(uint32_t phyHeight); |
| 80 | uint32_t GetPhyWidth() const; | 84 | uint32_t GetPhyWidth() const; |
| 81 | uint32_t GetPhyHeight() const; | 85 | uint32_t GetPhyHeight() const; |
| 86 | + sptr<IRemoteObject> GetConnectToRenderToken() const; | ||
| 82 | 87 | ||
| 83 | /* | 88 | /* |
| 84 | * RS Client Multi Instance | 89 | * RS Client Multi Instance |
| @@ -116,6 +121,7 @@ private: | |||
| 116 | uint32_t phyWidth_ { UINT32_MAX }; | 121 | uint32_t phyWidth_ { UINT32_MAX }; |
| 117 | uint32_t phyHeight_ { UINT32_MAX }; | 122 | uint32_t phyHeight_ { UINT32_MAX }; |
| 118 | mutable std::recursive_mutex mutex_; | 123 | mutable std::recursive_mutex mutex_; |
| 124 | + sptr<IRemoteObject> connectToRenderToken_; | ||
| 119 | 125 | ||
| 120 | /* | 126 | /* |
| 121 | * RS Client Multi Instance | 127 | * RS Client Multi Instance |
| @@ -125,8 +131,12 @@ private: | |||
| 125 | 131 | ||
| 126 | class AbstractScreenGroup : public AbstractScreen { | 132 | class AbstractScreenGroup : public AbstractScreen { |
| 127 | public: | 133 | public: |
| 128 | - AbstractScreenGroup(sptr<AbstractScreenController>, ScreenId dmsId, ScreenId rsId, std::string name, | 134 | + AbstractScreenGroup(sptr<AbstractScreenController>, |
| 129 | - ScreenCombination combination); | 135 | + ScreenId dmsId, |
| 136 | + ScreenId rsId, | ||
| 137 | + std::string name, | ||
| 138 | + ScreenCombination combination, | ||
| 139 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 130 | AbstractScreenGroup() = delete; | 140 | AbstractScreenGroup() = delete; |
| 131 | WM_DISALLOW_COPY_AND_MOVE(AbstractScreenGroup); | 141 | WM_DISALLOW_COPY_AND_MOVE(AbstractScreenGroup); |
| 132 | ~AbstractScreenGroup(); | 142 | ~AbstractScreenGroup(); |
| @@ -94,11 +94,13 @@ private: | |||
| 94 | void SetScreenRotateAnimation(sptr<AbstractScreen>& screen, ScreenId screenId, | 94 | void SetScreenRotateAnimation(sptr<AbstractScreen>& screen, ScreenId screenId, |
| 95 | Rotation rotationAfter, bool withAnimation); | 95 | Rotation rotationAfter, bool withAnimation); |
| 96 | void RegisterRsScreenConnectionChangeListener(); | 96 | void RegisterRsScreenConnectionChangeListener(); |
| 97 | - void OnRsScreenConnectionChange(ScreenId rsScreenId, ScreenEvent screenEvent); | 97 | + void OnRsScreenConnectionChange(ScreenId rsScreenId, |
| 98 | + ScreenEvent screenEvent, | ||
| 99 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 98 | bool OnRemoteDied(const sptr<IRemoteObject>& agent); | 100 | bool OnRemoteDied(const sptr<IRemoteObject>& agent); |
| 99 | - void ProcessScreenConnected(ScreenId rsScreenId); | 101 | + void ProcessScreenConnected(ScreenId rsScreenId, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 100 | void ProcessDefaultScreenReconnected(ScreenId rsScreenId); | 102 | void ProcessDefaultScreenReconnected(ScreenId rsScreenId); |
| 101 | - sptr<AbstractScreen> InitAndGetScreen(ScreenId rsScreenId); | 103 | + sptr<AbstractScreen> InitAndGetScreen(ScreenId rsScreenId, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 102 | void ProcessScreenDisconnected(ScreenId rsScreenId); | 104 | void ProcessScreenDisconnected(ScreenId rsScreenId); |
| 103 | bool InitAbstractScreenModesInfo(sptr<AbstractScreen>& absScreen); | 105 | bool InitAbstractScreenModesInfo(sptr<AbstractScreen>& absScreen); |
| 104 | sptr<AbstractScreen> InitVirtualScreen(ScreenId dmsScreenId, ScreenId rsId, VirtualScreenOption option); | 106 | sptr<AbstractScreen> InitVirtualScreen(ScreenId dmsScreenId, ScreenId rsId, VirtualScreenOption option); |
| @@ -121,10 +121,14 @@ std::shared_ptr<Media::PixelMap> AbstractDisplayController::GetScreenSnapshot(Di | |||
| 121 | } | 121 | } |
| 122 | ScreenId dmsScreenId = abstractDisplay->GetAbstractScreenId(); | 122 | ScreenId dmsScreenId = abstractDisplay->GetAbstractScreenId(); |
| 123 | std::shared_ptr<RSDisplayNode> displayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(dmsScreenId); | 123 | std::shared_ptr<RSDisplayNode> displayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(dmsScreenId); |
| 124 | + if (displayNode == nullptr || displayNode->GetRSUIContext() == nullptr) { | ||
| 125 | + TLOGE(WmsLogTag::DMS, "GetScreenSnapshot: displayNode or rsUIContext is nullptr"); | ||
| 126 | + return nullptr; | ||
| 127 | + } | ||
| 124 | 128 | ||
| 125 | std::lock_guard<std::recursive_mutex> lock(mutex_); | 129 | std::lock_guard<std::recursive_mutex> lock(mutex_); |
| 126 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); | 130 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); |
| 127 | - rsInterface_.TakeSurfaceCapture(displayNode, callback); | 131 | + displayNode->GetRSUIContext()->GetRSRenderInterface()->TakeSurfaceCapture(displayNode, callback); |
| 128 | std::shared_ptr<Media::PixelMap> screenshot = callback->GetResult(2000); // wait for <= 2000ms | 132 | std::shared_ptr<Media::PixelMap> screenshot = callback->GetResult(2000); // wait for <= 2000ms |
| 129 | if (screenshot == nullptr) { | 133 | if (screenshot == nullptr) { |
| 130 | TLOGE(WmsLogTag::DMS, "Failed to get pixelmap from RS, return nullptr!"); | 134 | TLOGE(WmsLogTag::DMS, "Failed to get pixelmap from RS, return nullptr!"); |
| @@ -29,12 +29,13 @@ constexpr float MAX_ZORDER = 100000.0f; | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | AbstractScreen::AbstractScreen(sptr<AbstractScreenController> screenController, const std::string& name, ScreenId dmsId, | 31 | AbstractScreen::AbstractScreen(sptr<AbstractScreenController> screenController, const std::string& name, ScreenId dmsId, |
| 32 | - ScreenId rsId) : dmsId_(dmsId), rsId_(rsId), screenController_(screenController) | 32 | + ScreenId rsId, sptr<IRemoteObject> connectToRenderToken) |
| 33 | + : dmsId_(dmsId), rsId_(rsId), screenController_(screenController), connectToRenderToken_(connectToRenderToken) | ||
| 33 | { | 34 | { |
| 34 | if (name != "") { | 35 | if (name != "") { |
| 35 | name_ = name; | 36 | name_ = name; |
| 36 | } | 37 | } |
| 37 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 38 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, connectToRenderToken_); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | AbstractScreen::~AbstractScreen() | 41 | AbstractScreen::~AbstractScreen() |
| @@ -144,6 +145,11 @@ void AbstractScreen::UpdateRSTree(std::shared_ptr<RSSurfaceNode>& surfaceNode, b | |||
| 144 | } | 145 | } |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 148 | +sptr<IRemoteObject> AbstractScreen::GetConnectToRenderToken() const | ||
| 149 | +{ | ||
| 150 | + return connectToRenderToken_; | ||
| 151 | +} | ||
| 152 | + | ||
| 147 | DMError AbstractScreen::AddSurfaceNode(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool onTop, bool needToRecord) | 153 | DMError AbstractScreen::AddSurfaceNode(std::shared_ptr<RSSurfaceNode>& surfaceNode, bool onTop, bool needToRecord) |
| 148 | { | 154 | { |
| 149 | if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) { | 155 | if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) { |
| @@ -538,9 +544,13 @@ std::shared_ptr<RSUIContext> AbstractScreen::GetRSUIContext() const | |||
| 538 | return rsUIContext; | 544 | return rsUIContext; |
| 539 | } | 545 | } |
| 540 | 546 | ||
| 541 | -AbstractScreenGroup::AbstractScreenGroup(sptr<AbstractScreenController> screenController, ScreenId dmsId, ScreenId rsId, | 547 | +AbstractScreenGroup::AbstractScreenGroup(sptr<AbstractScreenController> screenController, |
| 542 | - std::string name, ScreenCombination combination) : AbstractScreen(screenController, name, dmsId, rsId), | 548 | + ScreenId dmsId, |
| 543 | - combination_(combination) | 549 | + ScreenId rsId, |
| 550 | + std::string name, | ||
| 551 | + ScreenCombination combination, | ||
| 552 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 553 | + : AbstractScreen(screenController, name, dmsId, rsId, connectToRenderToken), combination_(combination) | ||
| 544 | { | 554 | { |
| 545 | type_ = ScreenType::UNDEFINED; | 555 | type_ = ScreenType::UNDEFINED; |
| 546 | isScreenGroup_ = true; | 556 | isScreenGroup_ = true; |
| @@ -63,12 +63,15 @@ void AbstractScreenController::RegisterRsScreenConnectionChangeListener() | |||
| 63 | { | 63 | { |
| 64 | TLOGI(WmsLogTag::DMS, "RegisterRsScreenConnectionChangeListener"); | 64 | TLOGI(WmsLogTag::DMS, "RegisterRsScreenConnectionChangeListener"); |
| 65 | auto res = rsInterface_.SetScreenChangeCallback( | 65 | auto res = rsInterface_.SetScreenChangeCallback( |
| 66 | - [this](ScreenId rsScreenId, ScreenEvent screenEvent, ScreenChangeReason reason) { | 66 | + [this](ScreenId rsScreenId, |
| 67 | + ScreenEvent screenEvent, | ||
| 68 | + ScreenChangeReason reason, | ||
| 69 | + sptr<IRemoteObject> connectToRenderToken) { | ||
| 67 | if (reason == ScreenChangeReason::HWCDEAD) { | 70 | if (reason == ScreenChangeReason::HWCDEAD) { |
| 68 | TLOGE(WmsLogTag::DMS, "hwcdead, ignore"); | 71 | TLOGE(WmsLogTag::DMS, "hwcdead, ignore"); |
| 69 | return; | 72 | return; |
| 70 | } | 73 | } |
| 71 | - OnRsScreenConnectionChange(rsScreenId, screenEvent); | 74 | + OnRsScreenConnectionChange(rsScreenId, screenEvent, connectToRenderToken); |
| 72 | }); | 75 | }); |
| 73 | if (res != StatusCode::SUCCESS) { | 76 | if (res != StatusCode::SUCCESS) { |
| 74 | auto task = [this] { | 77 | auto task = [this] { |
| @@ -240,13 +243,14 @@ void AbstractScreenController::RegisterAbstractScreenCallback(sptr<AbstractScree | |||
| 240 | } | 243 | } |
| 241 | } | 244 | } |
| 242 | 245 | ||
| 243 | -void AbstractScreenController::OnRsScreenConnectionChange(ScreenId rsScreenId, ScreenEvent screenEvent) | 246 | +void AbstractScreenController::OnRsScreenConnectionChange( |
| 247 | + ScreenId rsScreenId, ScreenEvent screenEvent, sptr<IRemoteObject> connectToRenderToken) | ||
| 244 | { | 248 | { |
| 245 | TLOGI(WmsLogTag::DMS, "RS screen event. rsScreenId:%{public}" PRIu64", defaultRsScreenId_:%{public}" PRIu64", " | 249 | TLOGI(WmsLogTag::DMS, "RS screen event. rsScreenId:%{public}" PRIu64", defaultRsScreenId_:%{public}" PRIu64", " |
| 246 | "event:%{public}u", rsScreenId, static_cast<uint64_t>(defaultRsScreenId_), static_cast<uint32_t>(screenEvent)); | 250 | "event:%{public}u", rsScreenId, static_cast<uint64_t>(defaultRsScreenId_), static_cast<uint32_t>(screenEvent)); |
| 247 | if (screenEvent == ScreenEvent::CONNECTED) { | 251 | if (screenEvent == ScreenEvent::CONNECTED) { |
| 248 | - auto task = [this, rsScreenId] { | 252 | + auto task = [this, rsScreenId, connectToRenderToken] { |
| 249 | - ProcessScreenConnected(rsScreenId); | 253 | + ProcessScreenConnected(rsScreenId, connectToRenderToken); |
| 250 | }; | 254 | }; |
| 251 | controllerHandler_->PostTask(task, "wms:OnRsScreenConnectionChange", 0, AppExecFwk::EventQueue::Priority::HIGH); | 255 | controllerHandler_->PostTask(task, "wms:OnRsScreenConnectionChange", 0, AppExecFwk::EventQueue::Priority::HIGH); |
| 252 | } else if (screenEvent == ScreenEvent::DISCONNECTED) { | 256 | } else if (screenEvent == ScreenEvent::DISCONNECTED) { |
| @@ -306,7 +310,7 @@ void AbstractScreenController::ProcessDefaultScreenReconnected(ScreenId rsScreen | |||
| 306 | } | 310 | } |
| 307 | } | 311 | } |
| 308 | 312 | ||
| 309 | -void AbstractScreenController::ProcessScreenConnected(ScreenId rsScreenId) | 313 | +void AbstractScreenController::ProcessScreenConnected(ScreenId rsScreenId, sptr<IRemoteObject> connectToRenderToken) |
| 310 | { | 314 | { |
| 311 | TLOGI(WmsLogTag::DMS, "start"); | 315 | TLOGI(WmsLogTag::DMS, "start"); |
| 312 | std::lock_guard<std::recursive_mutex> lock(mutex_); | 316 | std::lock_guard<std::recursive_mutex> lock(mutex_); |
| @@ -315,7 +319,7 @@ void AbstractScreenController::ProcessScreenConnected(ScreenId rsScreenId) | |||
| 315 | ProcessDefaultScreenReconnected(rsScreenId); | 319 | ProcessDefaultScreenReconnected(rsScreenId); |
| 316 | return; | 320 | return; |
| 317 | } | 321 | } |
| 318 | - auto absScreen = InitAndGetScreen(rsScreenId); | 322 | + auto absScreen = InitAndGetScreen(rsScreenId, connectToRenderToken); |
| 319 | if (absScreen == nullptr) { | 323 | if (absScreen == nullptr) { |
| 320 | return; | 324 | return; |
| 321 | } | 325 | } |
| @@ -354,15 +358,16 @@ void AbstractScreenController::ProcessScreenConnected(ScreenId rsScreenId) | |||
| 354 | } | 358 | } |
| 355 | } | 359 | } |
| 356 | 360 | ||
| 357 | -sptr<AbstractScreen> AbstractScreenController::InitAndGetScreen(ScreenId rsScreenId) | 361 | +sptr<AbstractScreen> AbstractScreenController::InitAndGetScreen( |
| 362 | + ScreenId rsScreenId, sptr<IRemoteObject> connectToRenderToken) | ||
| 358 | { | 363 | { |
| 359 | ScreenId dmsScreenId = screenIdManager_.CreateAndGetNewScreenId(rsScreenId); | 364 | ScreenId dmsScreenId = screenIdManager_.CreateAndGetNewScreenId(rsScreenId); |
| 360 | RSScreenCapability screenCapability = rsInterface_.GetScreenCapability(rsScreenId); | 365 | RSScreenCapability screenCapability = rsInterface_.GetScreenCapability(rsScreenId); |
| 361 | TLOGI(WmsLogTag::DMS, "Screen name is %{public}s, phyWidth is %{public}u, phyHeight is %{public}u", | 366 | TLOGI(WmsLogTag::DMS, "Screen name is %{public}s, phyWidth is %{public}u, phyHeight is %{public}u", |
| 362 | screenCapability.GetName().c_str(), screenCapability.GetPhyWidth(), screenCapability.GetPhyHeight()); | 367 | screenCapability.GetName().c_str(), screenCapability.GetPhyWidth(), screenCapability.GetPhyHeight()); |
| 363 | 368 | ||
| 364 | - sptr<AbstractScreen> absScreen = | 369 | + sptr<AbstractScreen> absScreen = new(std::nothrow) AbstractScreen(this, screenCapability.GetName(), |
| 365 | - new(std::nothrow) AbstractScreen(this, screenCapability.GetName(), dmsScreenId, rsScreenId); | 370 | + dmsScreenId, rsScreenId, connectToRenderToken); |
| 366 | if (absScreen == nullptr) { | 371 | if (absScreen == nullptr) { |
| 367 | TLOGE(WmsLogTag::DMS, "new AbstractScreen failed."); | 372 | TLOGE(WmsLogTag::DMS, "new AbstractScreen failed."); |
| 368 | screenIdManager_.DeleteScreenId(dmsScreenId); | 373 | screenIdManager_.DeleteScreenId(dmsScreenId); |
| @@ -805,23 +805,6 @@ struct ScreenDirectionInfo { | |||
| 805 | int32_t phyRotation_; | 805 | int32_t phyRotation_; |
| 806 | }; | 806 | }; |
| 807 | 807 | ||
| 808 | -/** | ||
| 809 | - * @brief Session option when connect | ||
| 810 | - */ | ||
| 811 | -struct SessionOption { | ||
| 812 | - ScreenId rsId_; | ||
| 813 | - std::string name_; | ||
| 814 | - bool isExtend_; | ||
| 815 | - std::string innerName_; | ||
| 816 | - ScreenId screenId_; | ||
| 817 | - std::unordered_map<FoldDisplayMode, int32_t> rotationCorrectionMap_; | ||
| 818 | - bool supportsFocus_ {true}; | ||
| 819 | - bool isRotationLocked_; | ||
| 820 | - int32_t rotation_; | ||
| 821 | - std::map<int32_t, int32_t> rotationOrientationMap_; | ||
| 822 | - bool isBooting_ { false }; | ||
| 823 | -}; | ||
| 824 | - | ||
| 825 | /** | 808 | /** |
| 826 | * @brief Device state | 809 | * @brief Device state |
| 827 | */ | 810 | */ |
| @@ -1057,9 +1057,12 @@ public: | |||
| 1057 | * @param identityToken identity token of sceneSession | 1057 | * @param identityToken identity token of sceneSession |
| 1058 | * @return sptr<Window> If create window success, return window instance; Otherwise, return nullptr | 1058 | * @return sptr<Window> If create window success, return window instance; Otherwise, return nullptr |
| 1059 | */ | 1059 | */ |
| 1060 | - static sptr<Window> Create(sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context, | 1060 | + static sptr<Window> Create(sptr<WindowOption>& option, |
| 1061 | - const sptr<IRemoteObject>& iSession, WMError& errCode = DefaultCreateErrCode, | 1061 | + const std::shared_ptr<AbilityRuntime::Context>& context, |
| 1062 | - const std::string& identityToken = "", bool isModuleAbilityHookEnd = false); | 1062 | + const sptr<IRemoteObject>& iSession, WMError& errCode = DefaultCreateErrCode, |
| 1063 | + const std::string& identityToken = "", | ||
| 1064 | + bool isModuleAbilityHookEnd = false, | ||
| 1065 | + sptr<IRemoteObject> renderSession = nullptr); | ||
| 1063 | 1066 | ||
| 1064 | /** | 1067 | /** |
| 1065 | * @brief get and verify windowType, include sub_window/system_window | 1068 | * @brief get and verify windowType, include sub_window/system_window |
| @@ -66,9 +66,14 @@ public: | |||
| 66 | * @param identityToken identity token of sceneSession | 66 | * @param identityToken identity token of sceneSession |
| 67 | * @return the error code of window | 67 | * @return the error code of window |
| 68 | */ | 68 | */ |
| 69 | - WMError Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context, | 69 | + WMError Init(DisplayId displayId, |
| 70 | - sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option, const sptr<IRemoteObject>& iSession, | 70 | + const std::shared_ptr<AbilityRuntime::Context>& context, |
| 71 | - const std::string& identityToken = "", bool isModuleAbilityHookEnd = false); | 71 | + sptr<IWindowLifeCycle>& listener, |
| 72 | + sptr<WindowOption> option, | ||
| 73 | + const sptr<IRemoteObject>& iSession, | ||
| 74 | + const std::string& identityToken = "", | ||
| 75 | + bool isModuleAbilityHookEnd = false, | ||
| 76 | + sptr<IRemoteObject> renderSession = nullptr); | ||
| 72 | 77 | ||
| 73 | /** | 78 | /** |
| 74 | * Create a window instance based on the parameters windowName and option. | 79 | * Create a window instance based on the parameters windowName and option. |
| @@ -263,6 +263,12 @@ public: | |||
| 263 | WMError SetFloatNavigationAvoidAreaEnabled(bool enable) override; | 263 | WMError SetFloatNavigationAvoidAreaEnabled(bool enable) override; |
| 264 | WMError GetFloatNavigationAvoidAreaEnabled(bool& enable) const override; | 264 | WMError GetFloatNavigationAvoidAreaEnabled(bool& enable) const override; |
| 265 | 265 | ||
| 266 | + /* | ||
| 267 | + * RS Client Multi Instance | ||
| 268 | + */ | ||
| 269 | + std::shared_ptr<RSUIContext> GetRSUIContext() const override; | ||
| 270 | + std::shared_ptr<RSUIDirector> GetRSUIDirector() const override { return rsUIDirector_; } | ||
| 271 | + | ||
| 266 | private: | 272 | private: |
| 267 | static sptr<Window> FindWindowById(uint32_t windowId); | 273 | static sptr<Window> FindWindowById(uint32_t windowId); |
| 268 | template<typename T1, typename T2, typename Ret> | 274 | template<typename T1, typename T2, typename Ret> |
| @@ -349,6 +355,11 @@ private: | |||
| 349 | { AvoidAreaType::TYPE_NAVIGATION_INDICATOR, new AvoidArea() }, | 355 | { AvoidAreaType::TYPE_NAVIGATION_INDICATOR, new AvoidArea() }, |
| 350 | }; | 356 | }; |
| 351 | std::atomic<bool> floatNavigationAvoidAreaEnabled_ = false; | 357 | std::atomic<bool> floatNavigationAvoidAreaEnabled_ = false; |
| 358 | + | ||
| 359 | + /* | ||
| 360 | + * RS Client Multi Instance | ||
| 361 | + */ | ||
| 362 | + std::shared_ptr<RSUIDirector> rsUIDirector_; | ||
| 352 | }; | 363 | }; |
| 353 | } // namespace Rosen | 364 | } // namespace Rosen |
| 354 | } // namespace OHOS | 365 | } // namespace OHOS |
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 27 | namespace OHOS { | 28 | namespace OHOS { |
| 28 | namespace Rosen { | 29 | namespace Rosen { |
| @@ -46,6 +47,7 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option) | |||
| 46 | } else { | 47 | } else { |
| 47 | name_ = "main_window"; | 48 | name_ = "main_window"; |
| 48 | } | 49 | } |
| 50 | + rsUIDirector_ = RSUIDirector::Create(nullptr); | ||
| 49 | WLOGFI("WindowImpl constructorCnt: %{public}d", | 51 | WLOGFI("WindowImpl constructorCnt: %{public}d", |
| 50 | ++constructorCnt); | 52 | ++constructorCnt); |
| 51 | } | 53 | } |
| @@ -63,7 +65,7 @@ void WindowImpl::CreateSurfaceNode(const std::string name, const SendRenderDataC | |||
| 63 | struct RSSurfaceNodeConfig rsSurfaceNodeConfig; | 65 | struct RSSurfaceNodeConfig rsSurfaceNodeConfig; |
| 64 | rsSurfaceNodeConfig.SurfaceNodeName = name; | 66 | rsSurfaceNodeConfig.SurfaceNodeName = name; |
| 65 | rsSurfaceNodeConfig.additionalData = reinterpret_cast<void*>(callback); | 67 | rsSurfaceNodeConfig.additionalData = reinterpret_cast<void*>(callback); |
| 66 | - surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig); | 68 | + surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig, true, GetRSUIContext()); |
| 67 | if (surfaceNode_ != nullptr) { | 69 | if (surfaceNode_ != nullptr) { |
| 68 | vsyncStation_ = std::make_shared<VsyncStation>(surfaceNode_->GetId()); | 70 | vsyncStation_ = std::make_shared<VsyncStation>(surfaceNode_->GetId()); |
| 69 | } | 71 | } |
| @@ -101,6 +103,13 @@ sptr<Window> WindowImpl::FindWindowById(uint32_t windowId) | |||
| 101 | return nullptr; | 103 | return nullptr; |
| 102 | } | 104 | } |
| 103 | 105 | ||
| 106 | +std::shared_ptr<RSUIContext> WindowImpl::GetRSUIContext() const | ||
| 107 | +{ | ||
| 108 | + auto rsUIContext = rsUIDirector_ ? rsUIDirector_->GetRSUIContext() : nullptr; | ||
| 109 | + WLOGFE("GetRSUIContext uicontext is %{public}d", rsUIContext != nullptr); | ||
| 110 | + return rsUIContext; | ||
| 111 | +} | ||
| 112 | + | ||
| 104 | sptr<Window> WindowImpl::GetTopWindowWithId(uint32_t mainWinId) | 113 | sptr<Window> WindowImpl::GetTopWindowWithId(uint32_t mainWinId) |
| 105 | { | 114 | { |
| 106 | return FindWindowById(mainWinId); | 115 | return FindWindowById(mainWinId); |
| @@ -71,7 +71,11 @@ public: | |||
| 71 | MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level)); | 71 | MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level)); |
| 72 | MOCK_METHOD1(SetAppWindowTitle, void(const std::string& title)); | 72 | MOCK_METHOD1(SetAppWindowTitle, void(const std::string& title)); |
| 73 | MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr<Media::PixelMap>& pixelMap)); | 73 | MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr<Media::PixelMap>& pixelMap)); |
| 74 | - MOCK_METHOD3(PreInitializeForm, void(OHOS::Rosen::Window* window, const std::string& url, napi_value storage)); | 74 | + MOCK_METHOD4(PreInitializeForm, |
| 75 | + void(OHOS::Rosen::Window* window, | ||
| 76 | + const std::string& url, | ||
| 77 | + napi_value storage, | ||
| 78 | + sptr<IRemoteObject> connectorToRender)); | ||
| 75 | MOCK_METHOD0(RunFormPage, void()); | 79 | MOCK_METHOD0(RunFormPage, void()); |
| 76 | MOCK_METHOD0(GetFormRootNode, std::shared_ptr<Rosen::RSSurfaceNode>()); | 80 | MOCK_METHOD0(GetFormRootNode, std::shared_ptr<Rosen::RSSurfaceNode>()); |
| 77 | MOCK_METHOD1(UpdateFormData, void(const std::string& data)); | 81 | MOCK_METHOD1(UpdateFormData, void(const std::string& data)); |
| @@ -27,6 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | + | ||
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | do { \ | 33 | do { \ |
| @@ -174,10 +175,8 @@ private: | |||
| 174 | class RSAdapterUtil { | 175 | class RSAdapterUtil { |
| 175 | public: | 176 | public: |
| 176 | static bool IsClientMultiInstanceEnabled(); | 177 | static bool IsClientMultiInstanceEnabled(); |
| 177 | - static void InitRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector, | 178 | + static void InitRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector, sptr<IRemoteObject> connectToRenderToken, |
| 178 | - bool shouldCreateRenderThread = true, | 179 | + const std::shared_ptr<RSUIContext>& rsUiContext = nullptr); |
| 179 | - bool isMultiInstance = false, | ||
| 180 | - const std::shared_ptr<RSUIContext>& rsUiContext = nullptr); | ||
| 181 | static void SetRSUIContext(const std::shared_ptr<RSNode>& rsNode, | 180 | static void SetRSUIContext(const std::shared_ptr<RSNode>& rsNode, |
| 182 | const std::shared_ptr<RSUIContext>& rsUIContext, | 181 | const std::shared_ptr<RSUIContext>& rsUIContext, |
| 183 | bool skipCheckInMultiInstance = false); | 182 | bool skipCheckInMultiInstance = false); |
| @@ -476,7 +476,7 @@ AllowInMultiThreadGuard::~AllowInMultiThreadGuard() | |||
| 476 | bool RSAdapterUtil::IsClientMultiInstanceEnabled() | 476 | bool RSAdapterUtil::IsClientMultiInstanceEnabled() |
| 477 | { | 477 | { |
| 478 | static bool enabled = [] { | 478 | static bool enabled = [] { |
| 479 | - bool value = system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "0") != "0"; | 479 | + bool value = system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "1") != "0"; |
| 480 | TLOGNI(WmsLogTag::WMS_SCB, "RS multi-instance enabled: %{public}d", value); | 480 | TLOGNI(WmsLogTag::WMS_SCB, "RS multi-instance enabled: %{public}d", value); |
| 481 | return value; | 481 | return value; |
| 482 | }(); | 482 | }(); |
| @@ -484,8 +484,7 @@ bool RSAdapterUtil::IsClientMultiInstanceEnabled() | |||
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | void RSAdapterUtil::InitRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector, | 486 | void RSAdapterUtil::InitRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector, |
| 487 | - bool shouldCreateRenderThread, bool isMultiInstance, | 487 | + sptr<IRemoteObject> connectToRenderToken, const std::shared_ptr<RSUIContext>& rsUiContext) |
| 488 | - const std::shared_ptr<RSUIContext>& rsUiContext) | ||
| 489 | { | 488 | { |
| 490 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(); | 489 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(); |
| 491 | if (rsUIDirector) { | 490 | if (rsUIDirector) { |
| @@ -493,9 +492,8 @@ void RSAdapterUtil::InitRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector | |||
| 493 | "RSUIDirector already exists: %{public}s", RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str()); | 492 | "RSUIDirector already exists: %{public}s", RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str()); |
| 494 | return; | 493 | return; |
| 495 | } | 494 | } |
| 496 | - rsUIDirector = RSUIDirector::Create(); | 495 | + rsUIDirector = RSUIDirector::Create(connectToRenderToken, rsUiContext); |
| 497 | if (rsUIDirector) { | 496 | if (rsUIDirector) { |
| 498 | - rsUIDirector->Init(shouldCreateRenderThread, isMultiInstance, rsUiContext); | ||
| 499 | TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", | 497 | TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s, rsUIContext: %{public}s", |
| 500 | RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str(), | 498 | RSAdapterUtil::RSUIDirectorToStr(rsUIDirector).c_str(), |
| 501 | RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str()); | 499 | RSAdapterUtil::RSUIContextToStr(rsUiContext).c_str()); |
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 22 | 23 | ||
| 23 | 24 | ||
| 24 | 25 | ||
| @@ -561,7 +562,7 @@ bool SurfaceDraw::GetSurfaceSnapshot(const std::shared_ptr<RSSurfaceNode> surfac | |||
| 561 | std::shared_ptr<Media::PixelMap>&pixelMap, int32_t timeoutMs, float scaleW, float scaleH) | 562 | std::shared_ptr<Media::PixelMap>&pixelMap, int32_t timeoutMs, float scaleW, float scaleH) |
| 562 | { | 563 | { |
| 563 | if (surfaceNode == nullptr) { | 564 | if (surfaceNode == nullptr) { |
| 564 | - WLOGFE("surfaceNode is null"); | 565 | + WLOGFE("surfaceNode or rsUIContext is null"); |
| 565 | return false; | 566 | return false; |
| 566 | } | 567 | } |
| 567 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SurfaceDraw:GetSurfaceSnapshot(%llu)", surfaceNode->GetId()); | 568 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SurfaceDraw:GetSurfaceSnapshot(%llu)", surfaceNode->GetId()); |
| @@ -570,7 +571,12 @@ bool SurfaceDraw::GetSurfaceSnapshot(const std::shared_ptr<RSSurfaceNode> surfac | |||
| 570 | .scaleX = scaleW, | 571 | .scaleX = scaleW, |
| 571 | .scaleY = scaleH, | 572 | .scaleY = scaleH, |
| 572 | }; | 573 | }; |
| 573 | - if (RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode, callback, config)) { | 574 | + auto rsUICtx = surfaceNode->GetRSUIContext(); |
| 575 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 576 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 577 | + return false; | ||
| 578 | + } | ||
| 579 | + if (rsUICtx->GetRSRenderInterface()->TakeSurfaceCapture(surfaceNode, callback, config)) { | ||
| 574 | pixelMap = callback->GetResult(timeoutMs); // get pixelmap time out ms | 580 | pixelMap = callback->GetResult(timeoutMs); // get pixelmap time out ms |
| 575 | } | 581 | } |
| 576 | if (pixelMap == nullptr) { | 582 | if (pixelMap == nullptr) { |
| @@ -31,8 +31,7 @@ public: | |||
| 31 | { | 31 | { |
| 32 | rsClientMultiInstanceEnabled_ = RSAdapterUtil::IsClientMultiInstanceEnabled(); | 32 | rsClientMultiInstanceEnabled_ = RSAdapterUtil::IsClientMultiInstanceEnabled(); |
| 33 | if (rsClientMultiInstanceEnabled_) { | 33 | if (rsClientMultiInstanceEnabled_) { |
| 34 | - rsUIDirector_ = RSUIDirector::Create(); | 34 | + rsUIDirector_ = RSUIDirector::Create(nullptr); |
| 35 | - rsUIDirector_->Init(true, true); | ||
| 36 | rsUIContext_ = rsUIDirector_->GetRSUIContext(); | 35 | rsUIContext_ = rsUIDirector_->GetRSUIContext(); |
| 37 | } | 36 | } |
| 38 | struct RSSurfaceNodeConfig config; | 37 | struct RSSurfaceNodeConfig config; |
| @@ -325,7 +324,7 @@ HWTEST_F(RSAdapterTest, AllowInMultiThreadGuardLifecycle, Function | SmallTest | | |||
| 325 | HWTEST_F(RSAdapterTest, RSAdapterUtilInitRSUIDirectorTest, Function | SmallTest | Level1) | 324 | HWTEST_F(RSAdapterTest, RSAdapterUtilInitRSUIDirectorTest, Function | SmallTest | Level1) |
| 326 | { | 325 | { |
| 327 | std::shared_ptr<RSUIDirector> rsUIDirector; | 326 | std::shared_ptr<RSUIDirector> rsUIDirector; |
| 328 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector, true, true); | 327 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector, nullptr, nullptr); |
| 329 | if (rsClientMultiInstanceEnabled_) { | 328 | if (rsClientMultiInstanceEnabled_) { |
| 330 | EXPECT_NE(rsUIDirector, nullptr); | 329 | EXPECT_NE(rsUIDirector, nullptr); |
| 331 | } else { | 330 | } else { |
| @@ -426,6 +426,7 @@ struct SessionInfo { | |||
| 426 | uint32_t windowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW | 426 | uint32_t windowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW |
| 427 | sptr<IRemoteObject> callerToken_ = nullptr; | 427 | sptr<IRemoteObject> callerToken_ = nullptr; |
| 428 | sptr<IRemoteObject> rootToken_ = nullptr; | 428 | sptr<IRemoteObject> rootToken_ = nullptr; |
| 429 | + sptr<IRemoteObject> connectToRenderToken_ = nullptr; | ||
| 429 | uint64_t screenId_ = -1ULL; // -1ULL:SCREEN_ID_INVALID | 430 | uint64_t screenId_ = -1ULL; // -1ULL:SCREEN_ID_INVALID |
| 430 | bool isPersistentRecover_ = false; | 431 | bool isPersistentRecover_ = false; |
| 431 | AtomicServiceInfo atomicServiceInfo_; | 432 | AtomicServiceInfo atomicServiceInfo_; |
| @@ -72,6 +72,7 @@ ohos_shared_library("scenesessionmanagerani_kit") { | |||
| 72 | "ace_engine:ace_uicontent", | 72 | "ace_engine:ace_uicontent", |
| 73 | "c_utils:utils", | 73 | "c_utils:utils", |
| 74 | "graphic_2d:librender_service_client", | 74 | "graphic_2d:librender_service_client", |
| 75 | + "graphic_2d:librender_service_base", | ||
| 75 | "hilog:libhilog", | 76 | "hilog:libhilog", |
| 76 | "hitrace:hitrace_meter", | 77 | "hitrace:hitrace_meter", |
| 77 | "runtime_core:ani", | 78 | "runtime_core:ani", |
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | + | ||
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | 31 | ||
| @@ -130,6 +131,7 @@ public: | |||
| 130 | std::vector<uint64_t> FilterMissionIdsBySurfaceNodeIds(const std::vector<uint64_t>& missionIds, | 131 | std::vector<uint64_t> FilterMissionIdsBySurfaceNodeIds(const std::vector<uint64_t>& missionIds, |
| 131 | const std::vector<uint64_t>& surfaceNodeIds); | 132 | const std::vector<uint64_t>& surfaceNodeIds); |
| 132 | void SetVirtualScreenUser(sptr<ScreenSession> screenSession, int32_t userId); | 133 | void SetVirtualScreenUser(sptr<ScreenSession> screenSession, int32_t userId); |
| 134 | + ScreenId GetAssociatedScreenId(); | ||
| 133 | virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) override; | 135 | virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) override; |
| 134 | DMError AddVirtualScreenBlockList(const std::vector<int32_t>& persistentIds) override; | 136 | DMError AddVirtualScreenBlockList(const std::vector<int32_t>& persistentIds) override; |
| 135 | DMError RemoveVirtualScreenBlockList(const std::vector<int32_t>& persistentIds) override; | 137 | DMError RemoveVirtualScreenBlockList(const std::vector<int32_t>& persistentIds) override; |
| @@ -214,7 +216,8 @@ public: | |||
| 214 | bool isCaptureFullOfScreen = false, const std::vector<NodeId>& surfaceNodesList = {}, | 216 | bool isCaptureFullOfScreen = false, const std::vector<NodeId>& surfaceNodesList = {}, |
| 215 | SnapshotScaleInfo scaleInfo = { DEFAULT_SNAPSHOT_SCALE, DEFAULT_SNAPSHOT_SCALE, {} }); | 217 | SnapshotScaleInfo scaleInfo = { DEFAULT_SNAPSHOT_SCALE, DEFAULT_SNAPSHOT_SCALE, {} }); |
| 216 | 218 | ||
| 217 | - sptr<ScreenSession> InitVirtualScreen(ScreenId smsScreenId, ScreenId rsId, VirtualScreenOption option); | 219 | + sptr<ScreenSession> InitVirtualScreen(ScreenId smsScreenId, ScreenId rsId, VirtualScreenOption option, |
| 220 | + ScreenId associatedScreenId); | ||
| 218 | sptr<ScreenSession> InitAndGetScreen(ScreenId rsScreenId); | 221 | sptr<ScreenSession> InitAndGetScreen(ScreenId rsScreenId); |
| 219 | bool InitAbstractScreenModesInfo(sptr<ScreenSession>& absScreen); | 222 | bool InitAbstractScreenModesInfo(sptr<ScreenSession>& absScreen); |
| 220 | std::vector<ScreenId> GetAllValidScreenIds(const std::vector<ScreenId>& screenIds) const; | 223 | std::vector<ScreenId> GetAllValidScreenIds(const std::vector<ScreenId>& screenIds) const; |
| @@ -305,8 +308,9 @@ public: | |||
| 305 | 308 | ||
| 306 | void DisablePowerOffRenderControl(ScreenId screenId) override; | 309 | void DisablePowerOffRenderControl(ScreenId screenId) override; |
| 307 | bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) override; | 310 | bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) override; |
| 308 | - sptr<ScreenSession> GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession); | 311 | + sptr<ScreenSession> GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession, |
| 309 | - void InitFakeScreenSession(sptr<ScreenSession> screenSession); | 312 | + sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 313 | + void InitFakeScreenSession(sptr<ScreenSession> screenSession, sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 310 | 314 | ||
| 311 | // Fold Screen | 315 | // Fold Screen |
| 312 | void SetFoldDisplayMode(const FoldDisplayMode displayMode) override; | 316 | void SetFoldDisplayMode(const FoldDisplayMode displayMode) override; |
| @@ -495,11 +499,13 @@ public: | |||
| 495 | const std::string& secondaryScreenMode); | 499 | const std::string& secondaryScreenMode); |
| 496 | void SwitchScrollParam(FoldDisplayMode displayMode); | 500 | void SwitchScrollParam(FoldDisplayMode displayMode); |
| 497 | void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent, | 501 | void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent, |
| 498 | - ScreenChangeReason reason = ScreenChangeReason::DEFAULT); | 502 | + ScreenChangeReason reason = ScreenChangeReason::DEFAULT, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 499 | void OnScreenChangeInner(ScreenId screenId, ScreenEvent screenEvent, | 503 | void OnScreenChangeInner(ScreenId screenId, ScreenEvent screenEvent, |
| 500 | - ScreenChangeReason reason = ScreenChangeReason::DEFAULT); | 504 | + ScreenChangeReason reason = ScreenChangeReason::DEFAULT, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 501 | - void OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason); | 505 | + void OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 502 | - void OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason); | 506 | + sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 507 | + void OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, | ||
| 508 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 503 | void OnFoldScreenChange(sptr<ScreenSession>& screenSession); | 509 | void OnFoldScreenChange(sptr<ScreenSession>& screenSession); |
| 504 | void OnFoldStatusChange(bool isSwitching); | 510 | void OnFoldStatusChange(bool isSwitching); |
| 505 | void SetCoordinationFlag(bool isCoordinationFlag); | 511 | void SetCoordinationFlag(bool isCoordinationFlag); |
| @@ -557,8 +563,9 @@ public: | |||
| 557 | 563 | ||
| 558 | sptr<ScreenSession> GetPhysicalScreenSession(ScreenId screenId) const; | 564 | sptr<ScreenSession> GetPhysicalScreenSession(ScreenId screenId) const; |
| 559 | sptr<ScreenSession> GetPhysicalScreenSession(ScreenId screenId, | 565 | sptr<ScreenSession> GetPhysicalScreenSession(ScreenId screenId, |
| 560 | - ScreenId defScreenId, ScreenProperty property); | 566 | + ScreenId defScreenId, ScreenProperty property, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 561 | - sptr<ScreenSession> GetPhysicalScreenSessionInner(ScreenId screenId, ScreenProperty property); | 567 | + sptr<ScreenSession> GetPhysicalScreenSessionInner(ScreenId screenId, ScreenProperty property, |
| 568 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 562 | sptr<ScreenSession> GetScreenSessionByRsId(ScreenId rsScreenId); | 569 | sptr<ScreenSession> GetScreenSessionByRsId(ScreenId rsScreenId); |
| 563 | void NotifyExtendScreenCreateFinish() override; | 570 | void NotifyExtendScreenCreateFinish() override; |
| 564 | void NotifyExtendScreenDestroyFinish() override; | 571 | void NotifyExtendScreenDestroyFinish() override; |
| @@ -676,12 +683,14 @@ protected: | |||
| 676 | ScreenId GenerateSmsScreenId(ScreenId rsScreenId); | 683 | ScreenId GenerateSmsScreenId(ScreenId rsScreenId); |
| 677 | EventTracker screenEventTracker_; | 684 | EventTracker screenEventTracker_; |
| 678 | sptr<ScreenSession> GetInternalScreenSession(); | 685 | sptr<ScreenSession> GetInternalScreenSession(); |
| 679 | - sptr<ScreenSession> GetScreenSessionInner(ScreenId screenId, ScreenProperty property); | 686 | + sptr<ScreenSession> GetScreenSessionInner(ScreenId screenId, ScreenProperty property, |
| 687 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 680 | std::mutex screenChangeMutex_; | 688 | std::mutex screenChangeMutex_; |
| 681 | std::mutex hasPrivateWindowForegroundMutex_; | 689 | std::mutex hasPrivateWindowForegroundMutex_; |
| 682 | - sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId); | 690 | + sptr<ScreenSession> GetOrCreateScreenSession(ScreenId screenId, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 683 | void AdaptSuperHorizonalBoot(sptr<ScreenSession> screenSession, ScreenId screenId); | 691 | void AdaptSuperHorizonalBoot(sptr<ScreenSession> screenSession, ScreenId screenId); |
| 684 | - sptr<ScreenSession> GetOrCreatePhysicalScreenSession(ScreenId screenId); | 692 | + sptr<ScreenSession> GetOrCreatePhysicalScreenSession(ScreenId screenId, |
| 693 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 685 | void DestroyExtendVirtualScreen(); | 694 | void DestroyExtendVirtualScreen(); |
| 686 | void HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent); | 695 | void HandleScreenDisconnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent); |
| 687 | void HandleScreenConnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent); | 696 | void HandleScreenConnectEvent(sptr<ScreenSession> screenSession, ScreenId screenId, ScreenEvent screenEvent); |
| @@ -739,12 +748,14 @@ private: | |||
| 739 | bool HasExtendVirtualScreen(); | 748 | bool HasExtendVirtualScreen(); |
| 740 | void InitExtendScreenProperty(ScreenId screenId, sptr<ScreenSession> session, ScreenProperty property); | 749 | void InitExtendScreenProperty(ScreenId screenId, sptr<ScreenSession> session, ScreenProperty property); |
| 741 | sptr<ScreenSession> CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId, | 750 | sptr<ScreenSession> CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId, |
| 742 | - ScreenProperty property); | 751 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 752 | + std::shared_ptr<RSUIContext> GetRsUIContextByScreenId(ScreenId screenId); | ||
| 743 | 753 | ||
| 744 | - /* physical screen session */ | 754 | +/* physical screen session */ |
| 745 | sptr<ScreenSession> CreateFakePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId, | 755 | sptr<ScreenSession> CreateFakePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defaultScreenId, |
| 746 | - ScreenProperty property); | 756 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken = nullptr); |
| 747 | - sptr<ScreenSession> GetFakePhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, ScreenProperty property); | 757 | + sptr<ScreenSession> GetFakePhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, ScreenProperty property, |
| 758 | + sptr<IRemoteObject> connectToRenderToken = nullptr); | ||
| 748 | virtual void FreeDisplayMirrorNodeInner(const sptr<ScreenSession> mirrorSession); | 759 | virtual void FreeDisplayMirrorNodeInner(const sptr<ScreenSession> mirrorSession); |
| 749 | void MirrorSwitchNotify(ScreenId screenId); | 760 | void MirrorSwitchNotify(ScreenId screenId); |
| 750 | ScreenId GetDefaultScreenId(); | 761 | ScreenId GetDefaultScreenId(); |
| @@ -0,0 +1,44 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +namespace OHOS::Rosen { | ||
| 27 | + | ||
| 28 | +struct SessionOption { | ||
| 29 | + ScreenId rsId_; | ||
| 30 | + std::string name_; | ||
| 31 | + bool isExtend_; | ||
| 32 | + std::string innerName_; | ||
| 33 | + ScreenId screenId_; | ||
| 34 | + std::unordered_map<FoldDisplayMode, int32_t> rotationCorrectionMap_; | ||
| 35 | + bool supportsFocus_ {true}; | ||
| 36 | + bool isRotationLocked_; | ||
| 37 | + int32_t rotation_; | ||
| 38 | + std::map<int32_t, int32_t> rotationOrientationMap_; | ||
| 39 | + bool isBooting_ { false }; | ||
| 40 | + sptr<IRemoteObject> connectToRenderToken_ = nullptr; | ||
| 41 | +}; | ||
| 42 | + | ||
| 43 | +} | ||
| 44 | + | ||
Mwindow_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp+1-0
| @@ -625,6 +625,7 @@ void SecondaryDisplayFoldPolicy::SetStatusFullActiveRectAndTpFeature(const sptr< | |||
| 625 | if (isNeedToSetSwitch) { | 625 | if (isNeedToSetSwitch) { |
| 626 | RSInterfaces::GetInstance().NotifyScreenSwitched(); | 626 | RSInterfaces::GetInstance().NotifyScreenSwitched(); |
| 627 | } | 627 | } |
| 628 | + RSInterfaces::GetInstance().NotifyScreenSwitched(); | ||
| 628 | auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); | 629 | auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); |
| 629 | TLOGI(WmsLogTag::DMS, "rs response is %{public}ld", static_cast<long>(response)); | 630 | TLOGI(WmsLogTag::DMS, "rs response is %{public}ld", static_cast<long>(response)); |
| 630 | } | 631 | } |
| @@ -420,6 +420,7 @@ void MultiScreenChangeUtils::ScreenConnectionChange(sptr<IScreenSessionManagerCl | |||
| 420 | .innerName_ = screenSession->GetInnerName(), | 420 | .innerName_ = screenSession->GetInnerName(), |
| 421 | .screenId_ = screenSession->GetScreenId(), | 421 | .screenId_ = screenSession->GetScreenId(), |
| 422 | .supportsFocus_ = screenSession->GetSupportsFocus(), | 422 | .supportsFocus_ = screenSession->GetSupportsFocus(), |
| 423 | + .connectToRenderToken_ = screenSession->GetRenderSession(), | ||
| 423 | }; | 424 | }; |
| 424 | ssmClient->OnScreenConnectionChanged(option, screenEvent); | 425 | ssmClient->OnScreenConnectionChanged(option, screenEvent); |
| 425 | } | 426 | } |
| @@ -306,7 +306,7 @@ void MultiScreenModeChangeManager::NotifyClientCreateExtendSessionOnly(sptr<IScr | |||
| 306 | MultiScreenChangeUtils::CreateExtendSession(screenSession); | 306 | MultiScreenChangeUtils::CreateExtendSession(screenSession); |
| 307 | 307 | ||
| 308 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), | 308 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), |
| 309 | - screenSession->GetName(), screenSession->GetIsExtend()); | 309 | + screenSession->GetName(), screenSession->GetRenderSession(), screenSession->GetIsExtend()); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | void MultiScreenModeChangeManager::NotifyClientCreateMirrorSessionOnly(sptr<IScreenSessionManagerClient>& ssmClient, | 312 | void MultiScreenModeChangeManager::NotifyClientCreateMirrorSessionOnly(sptr<IScreenSessionManagerClient>& ssmClient, |
| @@ -321,7 +321,7 @@ void MultiScreenModeChangeManager::NotifyClientCreateMirrorSessionOnly(sptr<IScr | |||
| 321 | MultiScreenChangeUtils::CreateMirrorSession(mainSession, screenSession); | 321 | MultiScreenChangeUtils::CreateMirrorSession(mainSession, screenSession); |
| 322 | 322 | ||
| 323 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), | 323 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), |
| 324 | - screenSession->GetName(), screenSession->GetIsExtend()); | 324 | + screenSession->GetName(), screenSession->GetRenderSession(), screenSession->GetIsExtend()); |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | void MultiScreenModeChangeManager::ScreenChangeToMirrorMode(sptr<IScreenSessionManagerClient> ssmClient, | 327 | void MultiScreenModeChangeManager::ScreenChangeToMirrorMode(sptr<IScreenSessionManagerClient> ssmClient, |
| @@ -218,7 +218,7 @@ void MultiScreenPowerChangeManager::NotifyClientCreateSessionOnly(sptr<IScreenSe | |||
| 218 | { | 218 | { |
| 219 | screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); | 219 | screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); |
| 220 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), | 220 | ssmClient->OnCreateScreenSessionOnly(screenSession->GetScreenId(), screenSession->GetRSScreenId(), |
| 221 | - screenSession->GetName(), true); | 221 | + screenSession->GetName(), screenSession->GetRenderSession(), true); |
| 222 | TLOGW(WmsLogTag::DMS, "notify client create session end."); | 222 | TLOGW(WmsLogTag::DMS, "notify client create session end."); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| @@ -473,7 +473,7 @@ DMError MultiScreenPowerChangeManager::HandleRecoveryInnerMainExternalExtendChan | |||
| 473 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "%s", __func__); | 473 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "%s", __func__); |
| 474 | CreateExternalScreenDisplayNodeOnly(innerScreen, externalScreen, ScreenCombination::SCREEN_EXTEND); | 474 | CreateExternalScreenDisplayNodeOnly(innerScreen, externalScreen, ScreenCombination::SCREEN_EXTEND); |
| 475 | bool changeRet = ssmClient->OnCreateScreenSessionOnly(innerScreen->GetScreenId(), innerScreen->GetRSScreenId(), | 475 | bool changeRet = ssmClient->OnCreateScreenSessionOnly(innerScreen->GetScreenId(), innerScreen->GetRSScreenId(), |
| 476 | - innerScreen->GetName(), innerScreen->GetIsExtend()); | 476 | + innerScreen->GetName(), innerScreen->GetRenderSession(), innerScreen->GetIsExtend()); |
| 477 | if (!changeRet) { | 477 | if (!changeRet) { |
| 478 | TLOGE(WmsLogTag::DMS, "create screenSession failed."); | 478 | TLOGE(WmsLogTag::DMS, "create screenSession failed."); |
| 479 | return DMError::DM_ERROR_REMOTE_CREATE_FAILED; | 479 | return DMError::DM_ERROR_REMOTE_CREATE_FAILED; |
| @@ -582,7 +582,7 @@ DMError MultiScreenPowerChangeManager::HandleRecoveryInnerExtendExternalMainChan | |||
| 582 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "%s", __func__); | 582 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "%s", __func__); |
| 583 | CreateExternalScreenDisplayNodeOnly(innerScreen, externalScreen, ScreenCombination::SCREEN_EXTEND); | 583 | CreateExternalScreenDisplayNodeOnly(innerScreen, externalScreen, ScreenCombination::SCREEN_EXTEND); |
| 584 | bool changeRet = ssmClient->OnCreateScreenSessionOnly(innerScreen->GetScreenId(), innerScreen->GetRSScreenId(), | 584 | bool changeRet = ssmClient->OnCreateScreenSessionOnly(innerScreen->GetScreenId(), innerScreen->GetRSScreenId(), |
| 585 | - innerScreen->GetName(), innerScreen->GetIsExtend()); | 585 | + innerScreen->GetName(), innerScreen->GetRenderSession(), innerScreen->GetIsExtend()); |
| 586 | if (!changeRet) { | 586 | if (!changeRet) { |
| 587 | TLOGE(WmsLogTag::DMS, "create screenSession failed."); | 587 | TLOGE(WmsLogTag::DMS, "create screenSession failed."); |
| 588 | return DMError::DM_ERROR_REMOTE_CREATE_FAILED; | 588 | return DMError::DM_ERROR_REMOTE_CREATE_FAILED; |
| @@ -994,8 +994,9 @@ void ScreenSessionManager::RegisterScreenChangeListener() | |||
| 994 | { | 994 | { |
| 995 | TLOGNFI(WmsLogTag::DMS, "start"); | 995 | TLOGNFI(WmsLogTag::DMS, "start"); |
| 996 | auto res = rsInterface_.SetScreenChangeCallback( | 996 | auto res = rsInterface_.SetScreenChangeCallback( |
| 997 | - DmUtils::wrap_callback([this](ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) { | 997 | + DmUtils::wrap_callback([this](ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 998 | - OnScreenChange(screenId, screenEvent, reason); | 998 | + sptr<IRemoteObject> connectToRenderToken) { |
| 999 | + OnScreenChange(screenId, screenEvent, reason, connectToRenderToken); | ||
| 999 | }) | 1000 | }) |
| 1000 | ); | 1001 | ); |
| 1001 | if (res != StatusCode::SUCCESS) { | 1002 | if (res != StatusCode::SUCCESS) { |
| @@ -1281,7 +1282,17 @@ void ScreenSessionManager::SetScreenCorrection() | |||
| 1281 | int32_t phyOffset = static_cast<int32_t>(std::stoi(phyOffsets[0])); | 1282 | int32_t phyOffset = static_cast<int32_t>(std::stoi(phyOffsets[0])); |
| 1282 | screenRotation = ConvertOffsetToCorrectRotation(phyOffset); | 1283 | screenRotation = ConvertOffsetToCorrectRotation(phyOffset); |
| 1283 | } | 1284 | } |
| 1284 | - auto correctionRet = rsInterface_.SetLogicalCameraRotationCorrection(screenId, | 1285 | + auto rsUIContext = GetRsUIContextByScreenId(screenId); |
| 1286 | + if (rsUIContext == nullptr) { | ||
| 1287 | + TLOGNFI(WmsLogTag::DMS, "rsUIContext is nullptr"); | ||
| 1288 | + return; | ||
| 1289 | + } | ||
| 1290 | + auto rsRenderInterface = rsUIContext->GetRSRenderInterface(); | ||
| 1291 | + if (rsRenderInterface == nullptr) { | ||
| 1292 | + TLOGNFI(WmsLogTag::DMS, "rsRenderInterface is nullptr"); | ||
| 1293 | + return; | ||
| 1294 | + } | ||
| 1295 | + auto correctionRet = rsRenderInterface->SetLogicalCameraRotationCorrection(screenId, | ||
| 1285 | static_cast<ScreenRotation>(GetCurrentConfigCorrection())); | 1296 | static_cast<ScreenRotation>(GetCurrentConfigCorrection())); |
| 1286 | auto ret = rsInterface_.SetScreenCorrection(screenId, screenRotation); | 1297 | auto ret = rsInterface_.SetScreenCorrection(screenId, screenRotation); |
| 1287 | oss << "screenRotation: " << static_cast<int32_t>(screenRotation) << " ret value: " << ret; | 1298 | oss << "screenRotation: " << static_cast<int32_t>(screenRotation) << " ret value: " << ret; |
| @@ -1332,22 +1343,23 @@ void ScreenSessionManager::SetRogToRs(ScreenId screenId, const RogResolution& ro | |||
| 1332 | } | 1343 | } |
| 1333 | } | 1344 | } |
| 1334 | 1345 | ||
| 1335 | -void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | 1346 | +void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 1347 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 1336 | { | 1348 | { |
| 1337 | if (screenEvent == ScreenEvent::DISCONNECTED) { | 1349 | if (screenEvent == ScreenEvent::DISCONNECTED) { |
| 1338 | auto screenSession = GetScreenSessionByRsId(screenId); | 1350 | auto screenSession = GetScreenSessionByRsId(screenId); |
| 1339 | if (screenSession != nullptr && screenSession->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR) { | 1351 | if (screenSession != nullptr && screenSession->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR) { |
| 1340 | - OnScreenChangeInner(screenId, screenEvent, reason); | 1352 | + OnScreenChangeInner(screenId, screenEvent, reason, connectToRenderToken); |
| 1341 | return; | 1353 | return; |
| 1342 | } | 1354 | } |
| 1343 | } | 1355 | } |
| 1344 | if (!IsDefaultMirrorMode(screenId)) { | 1356 | if (!IsDefaultMirrorMode(screenId)) { |
| 1345 | - OnScreenChangeInner(screenId, screenEvent, reason); | 1357 | + OnScreenChangeInner(screenId, screenEvent, reason, connectToRenderToken); |
| 1346 | return; | 1358 | return; |
| 1347 | } | 1359 | } |
| 1348 | auto task = [=] { | 1360 | auto task = [=] { |
| 1349 | screenConnectTaskStage_ = SCREEN_CONNECT_STAGE_DEFAULT; | 1361 | screenConnectTaskStage_ = SCREEN_CONNECT_STAGE_DEFAULT; |
| 1350 | - OnScreenChangeInner(screenId, screenEvent, reason); | 1362 | + OnScreenChangeInner(screenId, screenEvent, reason, connectToRenderToken); |
| 1351 | if (screenConnectTaskStage_ == SCREEN_CONNECT_STAGE_DEFAULT) { | 1363 | if (screenConnectTaskStage_ == SCREEN_CONNECT_STAGE_DEFAULT) { |
| 1352 | TLOGNFW(WmsLogTag::DMS, "Screen connect task is interrupted"); | 1364 | TLOGNFW(WmsLogTag::DMS, "Screen connect task is interrupted"); |
| 1353 | screenConnectTaskGroup_->FinishTask(); | 1365 | screenConnectTaskGroup_->FinishTask(); |
| @@ -1356,7 +1368,8 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE | |||
| 1356 | screenConnectTaskGroup_->AddTask(task); | 1368 | screenConnectTaskGroup_->AddTask(task); |
| 1357 | } | 1369 | } |
| 1358 | 1370 | ||
| 1359 | -void ScreenSessionManager::OnScreenChangeInner(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | 1371 | +void ScreenSessionManager::OnScreenChangeInner(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 1372 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 1360 | { | 1373 | { |
| 1361 | if (reason == ScreenChangeReason::HWCDEAD && screenEvent == ScreenEvent::DISCONNECTED) { | 1374 | if (reason == ScreenChangeReason::HWCDEAD && screenEvent == ScreenEvent::DISCONNECTED) { |
| 1362 | TLOGNFW(WmsLogTag::DMS, "composer dead, ignore"); | 1375 | TLOGNFW(WmsLogTag::DMS, "composer dead, ignore"); |
| @@ -1376,13 +1389,14 @@ void ScreenSessionManager::OnScreenChangeInner(ScreenId screenId, ScreenEvent sc | |||
| 1376 | return; | 1389 | return; |
| 1377 | } | 1390 | } |
| 1378 | if (g_isPcDevice) { | 1391 | if (g_isPcDevice) { |
| 1379 | - OnScreenChangeForPC(screenId, screenEvent, reason); | 1392 | + OnScreenChangeForPC(screenId, screenEvent, reason, connectToRenderToken); |
| 1380 | } else { | 1393 | } else { |
| 1381 | - OnScreenChangeDefault(screenId, screenEvent, reason); | 1394 | + OnScreenChangeDefault(screenId, screenEvent, reason, connectToRenderToken); |
| 1382 | } | 1395 | } |
| 1383 | } | 1396 | } |
| 1384 | 1397 | ||
| 1385 | -void ScreenSessionManager::OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | 1398 | +void ScreenSessionManager::OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 1399 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 1386 | { | 1400 | { |
| 1387 | std::lock_guard<std::mutex> lock(screenChangeMutex_); | 1401 | std::lock_guard<std::mutex> lock(screenChangeMutex_); |
| 1388 | std::ostringstream oss; | 1402 | std::ostringstream oss; |
| @@ -1392,14 +1406,14 @@ void ScreenSessionManager::OnScreenChangeForPC(ScreenId screenId, ScreenEvent sc | |||
| 1392 | TLOGNFW(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenEvent: %{public}d", | 1406 | TLOGNFW(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenEvent: %{public}d", |
| 1393 | screenId, static_cast<int>(screenEvent)); | 1407 | screenId, static_cast<int>(screenEvent)); |
| 1394 | SetScreenCorrection(); | 1408 | SetScreenCorrection(); |
| 1395 | - sptr<ScreenSession> screenSession = GetOrCreateScreenSession(screenId); | 1409 | + sptr<ScreenSession> screenSession = GetOrCreateScreenSession(screenId, connectToRenderToken); |
| 1396 | if (!screenSession) { | 1410 | if (!screenSession) { |
| 1397 | TLOGNFE(WmsLogTag::DMS, "screenSession is nullptr"); | 1411 | TLOGNFE(WmsLogTag::DMS, "screenSession is nullptr"); |
| 1398 | return; | 1412 | return; |
| 1399 | } | 1413 | } |
| 1400 | AdaptSuperHorizonalBoot(screenSession, screenId); | 1414 | AdaptSuperHorizonalBoot(screenSession, screenId); |
| 1401 | if (g_isPcDevice) { | 1415 | if (g_isPcDevice) { |
| 1402 | - auto physicalScreenSession = GetOrCreatePhysicalScreenSession(screenId); | 1416 | + auto physicalScreenSession = GetOrCreatePhysicalScreenSession(screenId, connectToRenderToken); |
| 1403 | if (!physicalScreenSession) { | 1417 | if (!physicalScreenSession) { |
| 1404 | TLOGNFE(WmsLogTag::DMS, "physicalScreenSession is nullptr"); | 1418 | TLOGNFE(WmsLogTag::DMS, "physicalScreenSession is nullptr"); |
| 1405 | return; | 1419 | return; |
| @@ -1419,7 +1433,8 @@ void ScreenSessionManager::OnScreenChangeForPC(ScreenId screenId, ScreenEvent sc | |||
| 1419 | NotifyScreenModeChange(); | 1433 | NotifyScreenModeChange(); |
| 1420 | } | 1434 | } |
| 1421 | 1435 | ||
| 1422 | -void ScreenSessionManager::OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | 1436 | +void ScreenSessionManager::OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason, |
| 1437 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 1423 | { | 1438 | { |
| 1424 | std::ostringstream oss; | 1439 | std::ostringstream oss; |
| 1425 | oss << "OnScreenChange triggered. screenId: " << static_cast<int32_t>(screenId) | 1440 | oss << "OnScreenChange triggered. screenId: " << static_cast<int32_t>(screenId) |
| @@ -1428,12 +1443,12 @@ void ScreenSessionManager::OnScreenChangeDefault(ScreenId screenId, ScreenEvent | |||
| 1428 | TLOGNFW(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenEvent: %{public}d", | 1443 | TLOGNFW(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenEvent: %{public}d", |
| 1429 | screenId, static_cast<int>(screenEvent)); | 1444 | screenId, static_cast<int>(screenEvent)); |
| 1430 | SetScreenCorrection(); | 1445 | SetScreenCorrection(); |
| 1431 | - auto screenSession = GetOrCreateScreenSession(screenId); | 1446 | + auto screenSession = GetOrCreateScreenSession(screenId, connectToRenderToken); |
| 1432 | if (!screenSession) { | 1447 | if (!screenSession) { |
| 1433 | TLOGNFE(WmsLogTag::DMS, "screenSession is nullptr"); | 1448 | TLOGNFE(WmsLogTag::DMS, "screenSession is nullptr"); |
| 1434 | return; | 1449 | return; |
| 1435 | } | 1450 | } |
| 1436 | - if (g_isPcDevice || IS_SUPPORT_PC_MODE) { | 1451 | + if (g_isPcDevice) { |
| 1437 | auto physicalScreenSession = GetOrCreatePhysicalScreenSession(screenId); | 1452 | auto physicalScreenSession = GetOrCreatePhysicalScreenSession(screenId); |
| 1438 | if (!physicalScreenSession) { | 1453 | if (!physicalScreenSession) { |
| 1439 | TLOGNFE(WmsLogTag::DMS, "physicalScreenSession is nullptr"); | 1454 | TLOGNFE(WmsLogTag::DMS, "physicalScreenSession is nullptr"); |
| @@ -4260,7 +4275,7 @@ DMError ScreenSessionManager::SetScreenColorTransform(ScreenId screenId) | |||
| 4260 | } | 4275 | } |
| 4261 | 4276 | ||
| 4262 | sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, | 4277 | sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, |
| 4263 | - ScreenProperty property) | 4278 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken) |
| 4264 | { | 4279 | { |
| 4265 | sptr<ScreenSession> screenSession = nullptr; | 4280 | sptr<ScreenSession> screenSession = nullptr; |
| 4266 | ScreenSessionConfig config; | 4281 | ScreenSessionConfig config; |
| @@ -4270,6 +4285,7 @@ sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSession(ScreenId scre | |||
| 4270 | .rsId = screenId, | 4285 | .rsId = screenId, |
| 4271 | .defaultScreenId = defScreenId, | 4286 | .defaultScreenId = defScreenId, |
| 4272 | .property = property, | 4287 | .property = property, |
| 4288 | + .renderSession = connectToRenderToken, | ||
| 4273 | }; | 4289 | }; |
| 4274 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL); | 4290 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL); |
| 4275 | } else { | 4291 | } else { |
| @@ -4286,6 +4302,7 @@ sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSession(ScreenId scre | |||
| 4286 | .defaultScreenId = defScreenId, | 4302 | .defaultScreenId = defScreenId, |
| 4287 | .mirrorNodeId = nodeId, | 4303 | .mirrorNodeId = nodeId, |
| 4288 | .property = property, | 4304 | .property = property, |
| 4305 | + .renderSession = connectToRenderToken, | ||
| 4289 | }; | 4306 | }; |
| 4290 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR); | 4307 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR); |
| 4291 | screenSession->SetIsPhysicalMirrorSwitch(true); | 4308 | screenSession->SetIsPhysicalMirrorSwitch(true); |
| @@ -4303,7 +4320,7 @@ sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSession(ScreenId scre | |||
| 4303 | } | 4320 | } |
| 4304 | 4321 | ||
| 4305 | sptr<ScreenSession> ScreenSessionManager::CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defScreenId, | 4322 | sptr<ScreenSession> ScreenSessionManager::CreatePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defScreenId, |
| 4306 | - ScreenProperty property) | 4323 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken) |
| 4307 | { | 4324 | { |
| 4308 | 4325 | ||
| 4309 | sptr<ScreenSession> screenSession = nullptr; | 4326 | sptr<ScreenSession> screenSession = nullptr; |
| @@ -4311,7 +4328,7 @@ sptr<ScreenSession> ScreenSessionManager::CreatePhysicalMirrorSessionInner(Scree | |||
| 4311 | TLOGNFW(WmsLogTag::DMS, "mirror disabled by edm!"); | 4328 | TLOGNFW(WmsLogTag::DMS, "mirror disabled by edm!"); |
| 4312 | return screenSession; | 4329 | return screenSession; |
| 4313 | } | 4330 | } |
| 4314 | - screenSession = GetPhysicalScreenSession(screenId, defScreenId, property); | 4331 | + screenSession = GetPhysicalScreenSession(screenId, defScreenId, property, connectToRenderToken); |
| 4315 | if (!screenSession) { | 4332 | if (!screenSession) { |
| 4316 | TLOGNFE(WmsLogTag::DMS, "screenSession is null"); | 4333 | TLOGNFE(WmsLogTag::DMS, "screenSession is null"); |
| 4317 | return nullptr; | 4334 | return nullptr; |
| @@ -4346,13 +4363,14 @@ sptr<ScreenSession> ScreenSessionManager::CreatePhysicalMirrorSessionInner(Scree | |||
| 4346 | 4363 | ||
| 4347 | } | 4364 | } |
| 4348 | 4365 | ||
| 4349 | -sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenId, ScreenProperty property) | 4366 | +sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenId, ScreenProperty property, |
| 4367 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 4350 | { | 4368 | { |
| 4351 | ScreenId defScreenId = GetDefaultScreenId(); | 4369 | ScreenId defScreenId = GetDefaultScreenId(); |
| 4352 | TLOGNFW(WmsLogTag::DMS, "screenId:%{public}" PRIu64 "", screenId); | 4370 | TLOGNFW(WmsLogTag::DMS, "screenId:%{public}" PRIu64 "", screenId); |
| 4353 | if (IsDefaultMirrorMode(screenId)) { | 4371 | if (IsDefaultMirrorMode(screenId)) { |
| 4354 | 4372 | ||
| 4355 | - return CreatePhysicalMirrorSessionInner(screenId, defScreenId, property); | 4373 | + return CreatePhysicalMirrorSessionInner(screenId, defScreenId, property, connectToRenderToken); |
| 4356 | 4374 | ||
| 4357 | return nullptr; | 4375 | return nullptr; |
| 4358 | 4376 | ||
| @@ -4373,6 +4391,7 @@ sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenI | |||
| 4373 | .defaultScreenId = defScreenId, | 4391 | .defaultScreenId = defScreenId, |
| 4374 | .name = screenName, | 4392 | .name = screenName, |
| 4375 | .property = property, | 4393 | .property = property, |
| 4394 | + .renderSession = connectToRenderToken, | ||
| 4376 | }; | 4395 | }; |
| 4377 | sptr<ScreenSession> screenSession = nullptr; | 4396 | sptr<ScreenSession> screenSession = nullptr; |
| 4378 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL); | 4397 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL); |
| @@ -4383,7 +4402,7 @@ sptr<ScreenSession> ScreenSessionManager::GetScreenSessionInner(ScreenId screenI | |||
| 4383 | screenSession->SetIsCurrentInUse(true); | 4402 | screenSession->SetIsCurrentInUse(true); |
| 4384 | screenSession->SetIsPcUse(g_isPcDevice ? true : false); | 4403 | screenSession->SetIsPcUse(g_isPcDevice ? true : false); |
| 4385 | if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { | 4404 | if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { |
| 4386 | - InitFakeScreenSession(screenSession); | 4405 | + InitFakeScreenSession(screenSession, connectToRenderToken); |
| 4387 | } | 4406 | } |
| 4388 | return screenSession; | 4407 | return screenSession; |
| 4389 | } | 4408 | } |
| @@ -4855,7 +4874,8 @@ void ScreenSessionManager::InitExtendScreenDensity(sptr<ScreenSession> session, | |||
| 4855 | return; | 4874 | return; |
| 4856 | } | 4875 | } |
| 4857 | 4876 | ||
| 4858 | -sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId screenId) | 4877 | +sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId screenId, |
| 4878 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 4859 | { | 4879 | { |
| 4860 | TLOGNFW(WmsLogTag::DMS, "ENTER. ScreenId: %{public}" PRIu64 "", screenId); | 4880 | TLOGNFW(WmsLogTag::DMS, "ENTER. ScreenId: %{public}" PRIu64 "", screenId); |
| 4861 | sptr<ScreenSession> screenSession = GetScreenSession(screenId); | 4881 | sptr<ScreenSession> screenSession = GetScreenSession(screenId); |
| @@ -4887,7 +4907,7 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre | |||
| 4887 | return nullptr; | 4907 | return nullptr; |
| 4888 | } | 4908 | } |
| 4889 | 4909 | ||
| 4890 | - sptr<ScreenSession> session = GetScreenSessionInner(screenId, property); | 4910 | + sptr<ScreenSession> session = GetScreenSessionInner(screenId, property, connectToRenderToken); |
| 4891 | if (session == nullptr) { | 4911 | if (session == nullptr) { |
| 4892 | TLOGNFE(WmsLogTag::DMS, "get screen session fail ScreenId: %{public}" PRIu64, screenId); | 4912 | TLOGNFE(WmsLogTag::DMS, "get screen session fail ScreenId: %{public}" PRIu64, screenId); |
| 4893 | return session; | 4913 | return session; |
| @@ -5018,7 +5038,17 @@ DMError ScreenSessionManager::GetBrightnessInfo(DisplayId displayId, ScreenBrigh | |||
| 5018 | return DMError::DM_ERROR_ILLEGAL_PARAM; | 5038 | return DMError::DM_ERROR_ILLEGAL_PARAM; |
| 5019 | } | 5039 | } |
| 5020 | BrightnessInfo rsBrightnessInfo; | 5040 | BrightnessInfo rsBrightnessInfo; |
| 5021 | - auto status = rsInterface_.GetBrightnessInfo(screenSession->GetPhyScreenId(), rsBrightnessInfo); | 5041 | + auto rsUIContext = screenSession->GetRSUIContext(); |
| 5042 | + if (rsUIContext == nullptr) { | ||
| 5043 | + TLOGNFE(WmsLogTag::DMS, "rsUIContext is nullptr"); | ||
| 5044 | + return DMError::DM_ERROR_ILLEGAL_PARAM;; | ||
| 5045 | + } | ||
| 5046 | + auto rsRenderInterface = rsUIContext->GetRSRenderInterface(); | ||
| 5047 | + if (rsRenderInterface == nullptr) { | ||
| 5048 | + TLOGNFE(WmsLogTag::DMS, "rsRenderInterface is nullptr"); | ||
| 5049 | + return DMError::DM_ERROR_ILLEGAL_PARAM;; | ||
| 5050 | + } | ||
| 5051 | + auto status = rsRenderInterface->GetBrightnessInfo(screenSession->GetPhyScreenId(), rsBrightnessInfo); | ||
| 5022 | if (static_cast<StatusCode>(status) != StatusCode::SUCCESS) { | 5052 | if (static_cast<StatusCode>(status) != StatusCode::SUCCESS) { |
| 5023 | TLOGNFE(WmsLogTag::DMS, "get screen brightness info failed! status code:%{public}d", status); | 5053 | TLOGNFE(WmsLogTag::DMS, "get screen brightness info failed! status code:%{public}d", status); |
| 5024 | return DMError::DM_ERROR_ILLEGAL_PARAM; | 5054 | return DMError::DM_ERROR_ILLEGAL_PARAM; |
| @@ -7528,9 +7558,11 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, | |||
| 7528 | clientProxy->OnGetSurfaceNodeIdsFromMissionIdsChanged(option.missionIds_, surfaceNodeIds); | 7558 | clientProxy->OnGetSurfaceNodeIdsFromMissionIdsChanged(option.missionIds_, surfaceNodeIds); |
| 7529 | option.missionIds_ = FilterMissionIdsBySurfaceNodeIds(option.missionIds_, surfaceNodeIds); | 7559 | option.missionIds_ = FilterMissionIdsBySurfaceNodeIds(option.missionIds_, surfaceNodeIds); |
| 7530 | } | 7560 | } |
| 7531 | - TLOGNFI(WmsLogTag::DMS, "missionID size:%{public}ud", static_cast<uint32_t>(option.missionIds_.size())); | 7561 | + ScreenId associatedScreenId = GetAssociatedScreenId(); |
| 7562 | + TLOGNFI(WmsLogTag::DMS, "missionID size:%{public}ud, associatedScreenId: %{public}" PRIu64, | ||
| 7563 | + static_cast<uint32_t>(option.missionIds_.size()), associatedScreenId); | ||
| 7532 | ScreenId rsId = rsInterface_.CreateVirtualScreen(option.name_, option.width_, | 7564 | ScreenId rsId = rsInterface_.CreateVirtualScreen(option.name_, option.width_, |
| 7533 | - option.height_, option.surface_, SCREEN_ID_INVALID, option.flags_, option.missionIds_); | 7565 | + option.height_, option.surface_, associatedScreenId, option.flags_, option.missionIds_); |
| 7534 | if (rsId == SCREEN_ID_INVALID) { | 7566 | if (rsId == SCREEN_ID_INVALID) { |
| 7535 | TLOGNFI(WmsLogTag::DMS, "rsId is invalid"); | 7567 | TLOGNFI(WmsLogTag::DMS, "rsId is invalid"); |
| 7536 | return SCREEN_ID_INVALID; | 7568 | return SCREEN_ID_INVALID; |
| @@ -7555,7 +7587,7 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, | |||
| 7555 | } else { | 7587 | } else { |
| 7556 | screenIdManager_.CreateScreenId(smsScreenId, rsId); | 7588 | screenIdManager_.CreateScreenId(smsScreenId, rsId); |
| 7557 | } | 7589 | } |
| 7558 | - auto screenSession = InitVirtualScreen(smsScreenId, rsId, option); | 7590 | + auto screenSession = InitVirtualScreen(smsScreenId, rsId, option, associatedScreenId); |
| 7559 | if (screenSession == nullptr) { | 7591 | if (screenSession == nullptr) { |
| 7560 | TLOGNFW(WmsLogTag::DMS, "screenSession is nullptr"); | 7592 | TLOGNFW(WmsLogTag::DMS, "screenSession is nullptr"); |
| 7561 | screenIdManager_.DeleteScreenId(smsScreenId); | 7593 | screenIdManager_.DeleteScreenId(smsScreenId); |
| @@ -7591,6 +7623,47 @@ ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, | |||
| 7591 | return smsScreenId; | 7623 | return smsScreenId; |
| 7592 | } | 7624 | } |
| 7593 | 7625 | ||
| 7626 | +ScreenId ScreenSessionManager::GetAssociatedScreenId() | ||
| 7627 | +{ | ||
| 7628 | + if (!IsConcurrentUser()) { | ||
| 7629 | + TLOGNFI(WmsLogTag::DMS, "not support mulyi-screen nulti-user"); | ||
| 7630 | + return MAIN_SCREEN_ID_DEFAULT; | ||
| 7631 | + } | ||
| 7632 | + auto userId = GetUserIdByCallingUid(); | ||
| 7633 | + std::shared_ptr<UserInfo> userInfo = nullptr; | ||
| 7634 | + if (userId == INVALID_USER_ID) { | ||
| 7635 | + userId = GetForegroundConcurrentUser(CONTROL_PANEL_PHYSICAL_ID); | ||
| 7636 | + const auto displayUserMap = GetDisplayConcurrentUserMap(); | ||
| 7637 | + auto displayIt = displayUserMap.find(CONTROL_PANEL_PHYSICAL_ID); | ||
| 7638 | + if (displayIt == displayUserMap.end()) { | ||
| 7639 | + TLOGNFE(WmsLogTag::DMS, "Can not find CONTROL_PANEL_PHYSICAL_ID in displayConcurrentUserMap"); | ||
| 7640 | + return MAIN_SCREEN_ID_DEFAULT; | ||
| 7641 | + } | ||
| 7642 | + const auto &userMap = displayIt->second; | ||
| 7643 | + auto userIt = userMap.find(userId); | ||
| 7644 | + if (userIt == userMap.end()) { | ||
| 7645 | + TLOGNFE(WmsLogTag::DMS, "Can not find userId: %{public}" PRId32, userId); | ||
| 7646 | + return MAIN_SCREEN_ID_DEFAULT; | ||
| 7647 | + } | ||
| 7648 | + userInfo = std::make_shared<UserInfo>(userIt->second); | ||
| 7649 | + } else { | ||
| 7650 | + GetForegroundConcurrentUser(userId, userInfo); | ||
| 7651 | + } | ||
| 7652 | + if (userInfo == nullptr || !userInfo->isForeground) { | ||
| 7653 | + TLOGNFE(WmsLogTag::DMS, "userInfo is nullptr or is not foreground"); | ||
| 7654 | + return MAIN_SCREEN_ID_DEFAULT; | ||
| 7655 | + } | ||
| 7656 | + DisplayId displayid = GetUserDisplayId(userId); | ||
| 7657 | + auto displayInfo = GetDisplayInfoById(displayid); | ||
| 7658 | + if (displayInfo == nullptr) { | ||
| 7659 | + TLOGNFE(WmsLogTag::DMS, "displayInfo is nullptr"); | ||
| 7660 | + return MAIN_SCREEN_ID_DEFAULT; | ||
| 7661 | + } | ||
| 7662 | + auto associatedScreenId = screenIdManager_.ConvertToRsScreenId(displayInfo->GetScreenId()); | ||
| 7663 | + TLOGNFI(WmsLogTag::DMS, "associatedScreenId: %{public}" PRIu64, associatedScreenId); | ||
| 7664 | + return associatedScreenId; | ||
| 7665 | +} | ||
| 7666 | + | ||
| 7594 | // filter valid missionIds, by dynamic whitelist | 7667 | // filter valid missionIds, by dynamic whitelist |
| 7595 | std::vector<uint64_t> ScreenSessionManager::FilterMissionIdsBySurfaceNodeIds(const std::vector<uint64_t>& missionIds, | 7668 | std::vector<uint64_t> ScreenSessionManager::FilterMissionIdsBySurfaceNodeIds(const std::vector<uint64_t>& missionIds, |
| 7596 | const std::vector<uint64_t>& surfaceNodeIds) | 7669 | const std::vector<uint64_t>& surfaceNodeIds) |
| @@ -8698,14 +8771,20 @@ bool ScreenSessionManager::ScreenIdManager::HasRsScreenId(ScreenId smsScreenId) | |||
| 8698 | } | 8771 | } |
| 8699 | 8772 | ||
| 8700 | sptr<ScreenSession> ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId, ScreenId rsId, | 8773 | sptr<ScreenSession> ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId, ScreenId rsId, |
| 8701 | - VirtualScreenOption option) | 8774 | + VirtualScreenOption option, ScreenId associatedScreenId) |
| 8702 | { | 8775 | { |
| 8703 | TLOGNFI(WmsLogTag::DMS, "Enter"); | 8776 | TLOGNFI(WmsLogTag::DMS, "Enter"); |
| 8777 | + auto associatedScreenSession = GetScreenSession(associatedScreenId); | ||
| 8778 | + if (associatedScreenSession == nullptr) { | ||
| 8779 | + TLOGE(WmsLogTag::DMS, "Get screenSession of screenId: %{public}" PRIu64 "failed", associatedScreenId); | ||
| 8780 | + return nullptr; | ||
| 8781 | + } | ||
| 8704 | ScreenSessionConfig config = { | 8782 | ScreenSessionConfig config = { |
| 8705 | .screenId = smsScreenId, | 8783 | .screenId = smsScreenId, |
| 8706 | .rsId = rsId, | 8784 | .rsId = rsId, |
| 8707 | .defaultScreenId = GetDefaultScreenId(), | 8785 | .defaultScreenId = GetDefaultScreenId(), |
| 8708 | .name = option.name_, | 8786 | .name = option.name_, |
| 8787 | + .renderSession = associatedScreenSession->GetRenderSession(), | ||
| 8709 | }; | 8788 | }; |
| 8710 | sptr<ScreenSession> screenSession = | 8789 | sptr<ScreenSession> screenSession = |
| 8711 | new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); | 8790 | new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); |
| @@ -9287,7 +9366,8 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenSnapshot(Display | |||
| 9287 | } | 9366 | } |
| 9288 | TLOGNFW(WmsLogTag::DMS, "dma=%{public}d, displayId:%{public}" PRIu64, isUseDma, realDisplayId); | 9367 | TLOGNFW(WmsLogTag::DMS, "dma=%{public}d, displayId:%{public}" PRIu64, isUseDma, realDisplayId); |
| 9289 | std::shared_ptr<RSDisplayNode> displayNode = GetDisplayNodeByDisplayId(realDisplayId); | 9368 | std::shared_ptr<RSDisplayNode> displayNode = GetDisplayNodeByDisplayId(realDisplayId); |
| 9290 | - if (displayNode == nullptr) { | 9369 | + if (displayNode == nullptr || displayNode->GetRSUIContext() == nullptr || |
| 9370 | + displayNode->GetRSUIContext()->GetRSRenderInterface() == nullptr) { | ||
| 9291 | TLOGNFE(WmsLogTag::DMS, "displayNode is null!"); | 9371 | TLOGNFE(WmsLogTag::DMS, "displayNode is null!"); |
| 9292 | return nullptr; | 9372 | return nullptr; |
| 9293 | } | 9373 | } |
| @@ -9310,7 +9390,7 @@ std::shared_ptr<Media::PixelMap> ScreenSessionManager::GetScreenSnapshot(Display | |||
| 9310 | TLOGNFI(WmsLogTag::DMS, "Snapshot filtering surfaceNodesList surfaceNodes, size:%{public}ud", | 9390 | TLOGNFI(WmsLogTag::DMS, "Snapshot filtering surfaceNodesList surfaceNodes, size:%{public}ud", |
| 9311 | static_cast<uint32_t>(surfaceNodesList.size())); | 9391 | static_cast<uint32_t>(surfaceNodesList.size())); |
| 9312 | } | 9392 | } |
| 9313 | - bool ret = rsInterface_.TakeSurfaceCapture(displayNode, callback, config); | 9393 | + bool ret = displayNode->GetRSUIContext()->GetRSRenderInterface()->TakeSurfaceCapture(displayNode, callback, config); |
| 9314 | if (!ret) { | 9394 | if (!ret) { |
| 9315 | TLOGNFE(WmsLogTag::DMS, "TakeSurfaceCapture failed"); | 9395 | TLOGNFE(WmsLogTag::DMS, "TakeSurfaceCapture failed"); |
| 9316 | return nullptr; | 9396 | return nullptr; |
| @@ -9344,7 +9424,8 @@ std::vector<std::shared_ptr<Media::PixelMap>> ScreenSessionManager::GetScreenHDR | |||
| 9344 | } | 9424 | } |
| 9345 | 9425 | ||
| 9346 | std::shared_ptr<RSDisplayNode> displayNode = GetDisplayNodeByDisplayId(realDisplayId); | 9426 | std::shared_ptr<RSDisplayNode> displayNode = GetDisplayNodeByDisplayId(realDisplayId); |
| 9347 | - if (displayNode == nullptr) { | 9427 | + if (displayNode == nullptr || displayNode->GetRSUIContext() == nullptr || |
| 9428 | + displayNode->GetRSUIContext()->GetRSRenderInterface() == nullptr) { | ||
| 9348 | TLOGNFE(WmsLogTag::DMS, "displayNode is null!"); | 9429 | TLOGNFE(WmsLogTag::DMS, "displayNode is null!"); |
| 9349 | return {nullptr, nullptr}; | 9430 | return {nullptr, nullptr}; |
| 9350 | } | 9431 | } |
| @@ -9365,7 +9446,7 @@ std::vector<std::shared_ptr<Media::PixelMap>> ScreenSessionManager::GetScreenHDR | |||
| 9365 | if (surfaceNodesList.size() > 0) { | 9446 | if (surfaceNodesList.size() > 0) { |
| 9366 | TLOGNFI(WmsLogTag::DMS, "Snapshot filter, size:%{public}ud", static_cast<uint32_t>(surfaceNodesList.size())); | 9447 | TLOGNFI(WmsLogTag::DMS, "Snapshot filter, size:%{public}ud", static_cast<uint32_t>(surfaceNodesList.size())); |
| 9367 | } | 9448 | } |
| 9368 | - bool ret = rsInterface_.TakeSurfaceCapture(displayNode, callback, config); | 9449 | + bool ret = displayNode->GetRSUIContext()->GetRSRenderInterface()->TakeSurfaceCapture(displayNode, callback, config); |
| 9369 | if (!ret) { | 9450 | if (!ret) { |
| 9370 | TLOGNFE(WmsLogTag::DMS, "TakeSurfaceCapture failed"); | 9451 | TLOGNFE(WmsLogTag::DMS, "TakeSurfaceCapture failed"); |
| 9371 | return {nullptr, nullptr}; | 9452 | return {nullptr, nullptr}; |
| @@ -13387,7 +13468,8 @@ bool ScreenSessionManager::SetVirtualScreenStatus(ScreenId screenId, VirtualScre | |||
| 13387 | return rsInterface_.SetVirtualScreenStatus(rsScreenId, screenStatus); | 13468 | return rsInterface_.SetVirtualScreenStatus(rsScreenId, screenStatus); |
| 13388 | } | 13469 | } |
| 13389 | 13470 | ||
| 13390 | -sptr<ScreenSession> ScreenSessionManager::GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession) | 13471 | +sptr<ScreenSession> ScreenSessionManager::GetOrCreateFakeScreenSession(sptr<ScreenSession> screenSession, |
| 13472 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 13391 | { | 13473 | { |
| 13392 | sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession(); | 13474 | sptr<ScreenSession> fakeScreenSession = screenSession->GetFakeScreenSession(); |
| 13393 | if (fakeScreenSession != nullptr) { | 13475 | if (fakeScreenSession != nullptr) { |
| @@ -13399,6 +13481,7 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateFakeScreenSession(sptr<Scre | |||
| 13399 | .screenId = SCREEN_ID_FAKE, | 13481 | .screenId = SCREEN_ID_FAKE, |
| 13400 | .defaultScreenId = SCREEN_ID_INVALID, | 13482 | .defaultScreenId = SCREEN_ID_INVALID, |
| 13401 | .property = screenProperty, | 13483 | .property = screenProperty, |
| 13484 | + .renderSession = connectToRenderToken, | ||
| 13402 | }; | 13485 | }; |
| 13403 | fakeScreenSession = | 13486 | fakeScreenSession = |
| 13404 | new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); | 13487 | new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); |
| @@ -13408,13 +13491,14 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreateFakeScreenSession(sptr<Scre | |||
| 13408 | return fakeScreenSession; | 13491 | return fakeScreenSession; |
| 13409 | } | 13492 | } |
| 13410 | 13493 | ||
| 13411 | -void ScreenSessionManager::InitFakeScreenSession(sptr<ScreenSession> screenSession) | 13494 | +void ScreenSessionManager::InitFakeScreenSession(sptr<ScreenSession> screenSession, |
| 13495 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 13412 | { | 13496 | { |
| 13413 | if (screenSession == nullptr) { | 13497 | if (screenSession == nullptr) { |
| 13414 | TLOGNFE(WmsLogTag::DMS, "screen session is null"); | 13498 | TLOGNFE(WmsLogTag::DMS, "screen session is null"); |
| 13415 | return; | 13499 | return; |
| 13416 | } | 13500 | } |
| 13417 | - sptr<ScreenSession> fakeScreenSession = GetOrCreateFakeScreenSession(screenSession); | 13501 | + sptr<ScreenSession> fakeScreenSession = GetOrCreateFakeScreenSession(screenSession, connectToRenderToken); |
| 13418 | if (fakeScreenSession == nullptr) { | 13502 | if (fakeScreenSession == nullptr) { |
| 13419 | TLOGNFE(WmsLogTag::DMS, "get or create fake screen session failed"); | 13503 | TLOGNFE(WmsLogTag::DMS, "get or create fake screen session failed"); |
| 13420 | return; | 13504 | return; |
| @@ -14297,7 +14381,8 @@ SessionOption ScreenSessionManager::GetSessionOption(sptr<ScreenSession> screenS | |||
| 14297 | .screenId_ = screenSession->GetScreenId(), | 14381 | .screenId_ = screenSession->GetScreenId(), |
| 14298 | .rotationCorrectionMap_ = screenSession->GetRotationCorrectionMap(), | 14382 | .rotationCorrectionMap_ = screenSession->GetRotationCorrectionMap(), |
| 14299 | .supportsFocus_ = screenSession->GetSupportsFocus(), | 14383 | .supportsFocus_ = screenSession->GetSupportsFocus(), |
| 14300 | - .isBooting_ = IsOnBootAnimation() | 14384 | + .isBooting_ = IsOnBootAnimation(), |
| 14385 | + .connectToRenderToken_ = screenSession->GetRenderSession(), | ||
| 14301 | }; | 14386 | }; |
| 14302 | return option; | 14387 | return option; |
| 14303 | } | 14388 | } |
| @@ -14598,7 +14683,7 @@ void ScreenSessionManager::SetExtendScreenIndepDpi() | |||
| 14598 | } | 14683 | } |
| 14599 | 14684 | ||
| 14600 | sptr<ScreenSession> ScreenSessionManager::GetFakePhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, | 14685 | sptr<ScreenSession> ScreenSessionManager::GetFakePhysicalScreenSession(ScreenId screenId, ScreenId defScreenId, |
| 14601 | - ScreenProperty property) | 14686 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken) |
| 14602 | { | 14687 | { |
| 14603 | sptr<ScreenSession> screenSession = nullptr; | 14688 | sptr<ScreenSession> screenSession = nullptr; |
| 14604 | ScreenSessionConfig config; | 14689 | ScreenSessionConfig config; |
| @@ -14608,6 +14693,7 @@ sptr<ScreenSession> ScreenSessionManager::GetFakePhysicalScreenSession(ScreenId | |||
| 14608 | .rsId = screenId, | 14693 | .rsId = screenId, |
| 14609 | .defaultScreenId = defScreenId, | 14694 | .defaultScreenId = defScreenId, |
| 14610 | .property = property, | 14695 | .property = property, |
| 14696 | + .renderSession = connectToRenderToken, | ||
| 14611 | }; | 14697 | }; |
| 14612 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); | 14698 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); |
| 14613 | } | 14699 | } |
| @@ -14615,7 +14701,7 @@ sptr<ScreenSession> ScreenSessionManager::GetFakePhysicalScreenSession(ScreenId | |||
| 14615 | } | 14701 | } |
| 14616 | 14702 | ||
| 14617 | sptr<ScreenSession> ScreenSessionManager::CreateFakePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defScreenId, | 14703 | sptr<ScreenSession> ScreenSessionManager::CreateFakePhysicalMirrorSessionInner(ScreenId screenId, ScreenId defScreenId, |
| 14618 | - ScreenProperty property) | 14704 | + ScreenProperty property, sptr<IRemoteObject> connectToRenderToken) |
| 14619 | { | 14705 | { |
| 14620 | 14706 | ||
| 14621 | sptr<ScreenSession> screenSession = nullptr; | 14707 | sptr<ScreenSession> screenSession = nullptr; |
| @@ -14651,13 +14737,14 @@ sptr<ScreenSession> ScreenSessionManager::CreateFakePhysicalMirrorSessionInner(S | |||
| 14651 | 14737 | ||
| 14652 | } | 14738 | } |
| 14653 | 14739 | ||
| 14654 | -sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSessionInner(ScreenId screenId, ScreenProperty property) | 14740 | +sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSessionInner(ScreenId screenId, ScreenProperty property, |
| 14741 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 14655 | { | 14742 | { |
| 14656 | ScreenId defScreenId = GetDefaultScreenId(); | 14743 | ScreenId defScreenId = GetDefaultScreenId(); |
| 14657 | TLOGNFW(WmsLogTag::DMS, "screenId:%{public}" PRIu64, screenId); | 14744 | TLOGNFW(WmsLogTag::DMS, "screenId:%{public}" PRIu64, screenId); |
| 14658 | if (IsDefaultMirrorMode(screenId)) { | 14745 | if (IsDefaultMirrorMode(screenId)) { |
| 14659 | 14746 | ||
| 14660 | - return CreateFakePhysicalMirrorSessionInner(screenId, defScreenId, property); | 14747 | + return CreateFakePhysicalMirrorSessionInner(screenId, defScreenId, property, connectToRenderToken); |
| 14661 | 14748 | ||
| 14662 | return nullptr; | 14749 | return nullptr; |
| 14663 | 14750 | ||
| @@ -14678,6 +14765,7 @@ sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSessionInner(ScreenId | |||
| 14678 | .defaultScreenId = defScreenId, | 14765 | .defaultScreenId = defScreenId, |
| 14679 | .name = screenName, | 14766 | .name = screenName, |
| 14680 | .property = property, | 14767 | .property = property, |
| 14768 | + .renderSession = connectToRenderToken, | ||
| 14681 | }; | 14769 | }; |
| 14682 | sptr<ScreenSession> screenSession = nullptr; | 14770 | sptr<ScreenSession> screenSession = nullptr; |
| 14683 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); | 14771 | screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE); |
| @@ -14690,7 +14778,8 @@ sptr<ScreenSession> ScreenSessionManager::GetPhysicalScreenSessionInner(ScreenId | |||
| 14690 | return screenSession; | 14778 | return screenSession; |
| 14691 | } | 14779 | } |
| 14692 | 14780 | ||
| 14693 | -sptr<ScreenSession> ScreenSessionManager::GetOrCreatePhysicalScreenSession(ScreenId screenId) | 14781 | +sptr<ScreenSession> ScreenSessionManager::GetOrCreatePhysicalScreenSession(ScreenId screenId, |
| 14782 | + sptr<IRemoteObject> connectToRenderToken) | ||
| 14694 | { | 14783 | { |
| 14695 | TLOGNFW(WmsLogTag::DMS, "ENTER. ScreenId: %{public}" PRIu64, screenId); | 14784 | TLOGNFW(WmsLogTag::DMS, "ENTER. ScreenId: %{public}" PRIu64, screenId); |
| 14696 | sptr<ScreenSession> screenSession = GetPhysicalScreenSession(screenId); | 14785 | sptr<ScreenSession> screenSession = GetPhysicalScreenSession(screenId); |
| @@ -14703,7 +14792,7 @@ sptr<ScreenSession> ScreenSessionManager::GetOrCreatePhysicalScreenSession(Scree | |||
| 14703 | CreateScreenProperty(screenId, property); | 14792 | CreateScreenProperty(screenId, property); |
| 14704 | TLOGNFW(WmsLogTag::DMS, "create screen property end"); | 14793 | TLOGNFW(WmsLogTag::DMS, "create screen property end"); |
| 14705 | 14794 | ||
| 14706 | - sptr<ScreenSession> session = GetPhysicalScreenSessionInner(screenId, property); | 14795 | + sptr<ScreenSession> session = GetPhysicalScreenSessionInner(screenId, property, connectToRenderToken); |
| 14707 | if (session == nullptr) { | 14796 | if (session == nullptr) { |
| 14708 | TLOGNFE(WmsLogTag::DMS, "get physical screen fail ScreenId: %{public}" PRIu64, screenId); | 14797 | TLOGNFE(WmsLogTag::DMS, "get physical screen fail ScreenId: %{public}" PRIu64, screenId); |
| 14709 | return session; | 14798 | return session; |
| @@ -16178,5 +16267,15 @@ void ScreenSessionManager::ProcessVirtualScreenDestroy(ScreenId screenId, Screen | |||
| 16178 | TLOGNFW(WmsLogTag::DMS, "destroy success, sid: %{public}" PRIu64 ", rsId: %{public}" PRIu64, screenId, rsScreenId); | 16267 | TLOGNFW(WmsLogTag::DMS, "destroy success, sid: %{public}" PRIu64 ", rsId: %{public}" PRIu64, screenId, rsScreenId); |
| 16179 | } | 16268 | } |
| 16180 | } | 16269 | } |
| 16270 | + | ||
| 16271 | +std::shared_ptr<RSUIContext> ScreenSessionManager::GetRsUIContextByScreenId(ScreenId screenId) | ||
| 16272 | +{ | ||
| 16273 | + auto screenSession = GetScreenSession(screenId); | ||
| 16274 | + if (screenSession == nullptr) { | ||
| 16275 | + TLOGNFE(WmsLogTag::DMS, "screenSession is null, screenId: %{public}" PRIu64, screenId); | ||
| 16276 | + return nullptr; | ||
| 16277 | + } | ||
| 16278 | + return screenSession->GetRSUIContext(); | ||
| 16279 | +} | ||
| 16181 | // LCOV_EXCL_STOP | 16280 | // LCOV_EXCL_STOP |
| 16182 | } // namespace OHOS::Rosen | 16281 | } // namespace OHOS::Rosen |
| @@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | + | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | 32 | ||
| @@ -126,7 +127,7 @@ public: | |||
| 126 | float translateY); | 127 | float translateY); |
| 127 | bool OnExtendDisplayNodeChange(ScreenId firstId, ScreenId secondId) override; | 128 | bool OnExtendDisplayNodeChange(ScreenId firstId, ScreenId secondId) override; |
| 128 | bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, | 129 | bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, |
| 129 | - const std::string& name, bool isExtend) override; | 130 | + const std::string& name, sptr<IRemoteObject> renderSession, bool isExtend) override; |
| 130 | bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) override; | 131 | bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) override; |
| 131 | void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, | 132 | void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, |
| 132 | ScreenCombination extendCombination) override; | 133 | ScreenCombination extendCombination) override; |
| @@ -158,6 +159,7 @@ public: | |||
| 158 | */ | 159 | */ |
| 159 | std::shared_ptr<RSUIDirector> GetRSUIDirector(ScreenId screenId); | 160 | std::shared_ptr<RSUIDirector> GetRSUIDirector(ScreenId screenId); |
| 160 | std::shared_ptr<RSUIContext> GetRSUIContext(ScreenId screenId); | 161 | std::shared_ptr<RSUIContext> GetRSUIContext(ScreenId screenId); |
| 162 | + sptr<IRemoteObject> GetRenderSessionToken(); | ||
| 161 | bool GetSupportsFocus(DisplayId displayId); | 163 | bool GetSupportsFocus(DisplayId displayId); |
| 162 | 164 | ||
| 163 | protected: | 165 | protected: |
Mwindow_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h+2-1
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | + | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | namespace OHOS::Rosen { | 27 | namespace OHOS::Rosen { |
| @@ -103,7 +104,7 @@ public: | |||
| 103 | ExtendScreenConnectStatus extendScreenConnectStatus) = 0; | 104 | ExtendScreenConnectStatus extendScreenConnectStatus) = 0; |
| 104 | virtual bool OnExtendDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId) = 0; | 105 | virtual bool OnExtendDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId) = 0; |
| 105 | virtual bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, | 106 | virtual bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, |
| 106 | - const std::string& name, bool isExtend) = 0; | 107 | + const std::string& name, sptr<IRemoteObject> renderSession, bool isExtend) = 0; |
| 107 | virtual bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) = 0; | 108 | virtual bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) = 0; |
| 108 | virtual void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, | 109 | virtual void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, |
| 109 | ScreenCombination extendCombination) = 0; | 110 | ScreenCombination extendCombination) = 0; |
| @@ -61,7 +61,7 @@ public: | |||
| 61 | ExtendScreenConnectStatus extendScreenConnectStatus) override; | 61 | ExtendScreenConnectStatus extendScreenConnectStatus) override; |
| 62 | bool OnExtendDisplayNodeChange(ScreenId firstId, ScreenId secondId) override; | 62 | bool OnExtendDisplayNodeChange(ScreenId firstId, ScreenId secondId) override; |
| 63 | bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, const std::string& name, | 63 | bool OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, const std::string& name, |
| 64 | - bool isExtend) override; | 64 | + sptr<IRemoteObject> renderSession, bool isExtend) override; |
| 65 | bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) override; | 65 | bool OnMainDisplayNodeChange(ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId) override; |
| 66 | void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, | 66 | void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, |
| 67 | ScreenCombination extendCombination) override; | 67 | ScreenCombination extendCombination) override; |
| @@ -911,6 +911,22 @@ std::shared_ptr<RSUIContext> ScreenSessionManagerClient::GetRSUIContext(ScreenId | |||
| 911 | return rsUIContext; | 911 | return rsUIContext; |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | +sptr<IRemoteObject> ScreenSessionManagerClient::GetRenderSessionToken() | ||
| 915 | +{ | ||
| 916 | + auto screenSession = GetScreenSession(GetDefaultScreenId()); | ||
| 917 | + if (!screenSession) { | ||
| 918 | + TLOGE(WmsLogTag::DMS, "ScreenSession is null"); | ||
| 919 | + return nullptr; | ||
| 920 | + } | ||
| 921 | + auto renderSession = screenSession->GetRenderSession(); | ||
| 922 | + if (!renderSession) { | ||
| 923 | + TLOGE(WmsLogTag::DMS, "RenderSession is null"); | ||
| 924 | + return nullptr; | ||
| 925 | + } | ||
| 926 | + TLOGI(WmsLogTag::DMS, "Get renderSession success"); | ||
| 927 | + return renderSession; | ||
| 928 | +} | ||
| 929 | + | ||
| 914 | ScreenId ScreenSessionManagerClient::GetDefaultScreenId() | 930 | ScreenId ScreenSessionManagerClient::GetDefaultScreenId() |
| 915 | { | 931 | { |
| 916 | std::lock_guard<std::mutex> lock(screenSessionMapMutex_); | 932 | std::lock_guard<std::mutex> lock(screenSessionMapMutex_); |
| @@ -1147,6 +1163,7 @@ bool ScreenSessionManagerClient::HandleScreenConnection(SessionOption option) | |||
| 1147 | .rsId = option.rsId_, | 1163 | .rsId = option.rsId_, |
| 1148 | .name = option.name_, | 1164 | .name = option.name_, |
| 1149 | .innerName = option.innerName_, | 1165 | .innerName = option.innerName_, |
| 1166 | + .renderSession = option.connectToRenderToken_, | ||
| 1150 | }; | 1167 | }; |
| 1151 | config.property = screenSessionManager_->GetScreenProperty(option.screenId_); | 1168 | config.property = screenSessionManager_->GetScreenProperty(option.screenId_); |
| 1152 | TLOGW(WmsLogTag::DMS, "width:%{public}f, height=%{public}f", | 1169 | TLOGW(WmsLogTag::DMS, "width:%{public}f, height=%{public}f", |
| @@ -1202,13 +1219,14 @@ bool ScreenSessionManagerClient::HandleScreenDisconnection(SessionOption option) | |||
| 1202 | } | 1219 | } |
| 1203 | 1220 | ||
| 1204 | bool ScreenSessionManagerClient::OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, | 1221 | bool ScreenSessionManagerClient::OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, |
| 1205 | - const std::string& name, bool isExtend) | 1222 | + const std::string& name, sptr<IRemoteObject> renderSession, bool isExtend) |
| 1206 | { | 1223 | { |
| 1207 | sptr<ScreenSession> screenSession = nullptr; | 1224 | sptr<ScreenSession> screenSession = nullptr; |
| 1208 | ScreenSessionConfig config = { | 1225 | ScreenSessionConfig config = { |
| 1209 | .screenId = screenId, | 1226 | .screenId = screenId, |
| 1210 | .rsId = rsId, | 1227 | .rsId = rsId, |
| 1211 | .name = name, | 1228 | .name = name, |
| 1229 | + .renderSession = renderSession, | ||
| 1212 | }; | 1230 | }; |
| 1213 | { | 1231 | { |
| 1214 | std::lock_guard<std::mutex> lock(screenSessionMapMutex_); | 1232 | std::lock_guard<std::mutex> lock(screenSessionMapMutex_); |
| @@ -1298,10 +1316,16 @@ sptr<ScreenSession> ScreenSessionManagerClient::CreateTempScreenSession( | |||
| 1298 | TLOGE(WmsLogTag::DMS, "Failed to create temp screen session, screenSessionManager_ is null"); | 1316 | TLOGE(WmsLogTag::DMS, "Failed to create temp screen session, screenSessionManager_ is null"); |
| 1299 | return nullptr; | 1317 | return nullptr; |
| 1300 | } | 1318 | } |
| 1319 | + auto screenSession = GetScreenSession(screenId); | ||
| 1320 | + if (screenSession == nullptr) { | ||
| 1321 | + TLOGE(WmsLogTag::DMS, "screenSession is null"); | ||
| 1322 | + return nullptr; | ||
| 1323 | + } | ||
| 1301 | ScreenSessionConfig config = { | 1324 | ScreenSessionConfig config = { |
| 1302 | .screenId = screenId, | 1325 | .screenId = screenId, |
| 1303 | .rsId = rsId, | 1326 | .rsId = rsId, |
| 1304 | .displayNode = displayNode, | 1327 | .displayNode = displayNode, |
| 1328 | + .renderSession = screenSession->GetRenderSession(), | ||
| 1305 | }; | 1329 | }; |
| 1306 | config.property = screenSessionManager_->GetScreenProperty(screenId); | 1330 | config.property = screenSessionManager_->GetScreenProperty(screenId); |
| 1307 | TLOGW(WmsLogTag::DMS, "CreateTempScreenSession width:%{public}f, height=%{public}f", | 1331 | TLOGW(WmsLogTag::DMS, "CreateTempScreenSession width:%{public}f, height=%{public}f", |
| @@ -33,6 +33,18 @@ void ScreenSessionManagerClientProxy::OnScreenConnectionChanged(SessionOption Se | |||
| 33 | if (!ScreenConnectWriteParam(SessionOption, screenEvent, data)) { | 33 | if (!ScreenConnectWriteParam(SessionOption, screenEvent, data)) { |
| 34 | return; | 34 | return; |
| 35 | } | 35 | } |
| 36 | + auto renderSession = SessionOption.connectToRenderToken_; | ||
| 37 | + if (renderSession) { | ||
| 38 | + if (!data.WriteBool(true) || !data.WriteRemoteObject(renderSession)) { | ||
| 39 | + TLOGE(WmsLogTag::DMS, "Write bool or renderSession failed"); | ||
| 40 | + return; | ||
| 41 | + } else { | ||
| 42 | + if (!data.WriteBool(false)) { | ||
| 43 | + TLOGE(WmsLogTag::DMS, "Write boolbool failed"); | ||
| 44 | + return; | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + } | ||
| 36 | if (remote->SendRequest( | 48 | if (remote->SendRequest( |
| 37 | static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED), | 49 | static_cast<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED), |
| 38 | data, reply, option) != ERR_NONE) { | 50 | data, reply, option) != ERR_NONE) { |
| @@ -919,7 +931,7 @@ void ScreenSessionManagerClientProxy::OnSecondaryReflexionChanged(ScreenId scree | |||
| 919 | } | 931 | } |
| 920 | 932 | ||
| 921 | bool ScreenSessionManagerClientProxy::OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, | 933 | bool ScreenSessionManagerClientProxy::OnCreateScreenSessionOnly(ScreenId screenId, ScreenId rsId, |
| 922 | - const std::string& name, bool isExtend) | 934 | + const std::string& name, sptr<IRemoteObject> renderSession, bool isExtend) |
| 923 | { | 935 | { |
| 924 | sptr<IRemoteObject> remote = Remote(); | 936 | sptr<IRemoteObject> remote = Remote(); |
| 925 | if (remote == nullptr) { | 937 | if (remote == nullptr) { |
| @@ -934,7 +946,7 @@ bool ScreenSessionManagerClientProxy::OnCreateScreenSessionOnly(ScreenId screenI | |||
| 934 | return false; | 946 | return false; |
| 935 | } | 947 | } |
| 936 | if (!data.WriteUint64(screenId) || !data.WriteUint64(rsId) || !data.WriteString(name) || | 948 | if (!data.WriteUint64(screenId) || !data.WriteUint64(rsId) || !data.WriteString(name) || |
| 937 | - !data.WriteBool(isExtend)) { | 949 | + !data.WriteRemoteObject(renderSession) || !data.WriteBool(isExtend)) { |
| 938 | TLOGE(WmsLogTag::DMS, "Write parameters failed"); | 950 | TLOGE(WmsLogTag::DMS, "Write parameters failed"); |
| 939 | return false; | 951 | return false; |
| 940 | } | 952 | } |
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 20 | namespace OHOS::Rosen { | 21 | namespace OHOS::Rosen { |
| 21 | 22 | ||
| @@ -235,6 +236,14 @@ int ScreenSessionManagerClientStub::HandleOnScreenConnectionChanged(MessageParce | |||
| 235 | return ERR_INVALID_DATA; | 236 | return ERR_INVALID_DATA; |
| 236 | } | 237 | } |
| 237 | 238 | ||
| 239 | + bool hasRemoteObj = false; | ||
| 240 | + sptr<IRemoteObject> connectToRenderToken; | ||
| 241 | + if (data.ReadBool(hasRemoteObj)) { | ||
| 242 | + if (hasRemoteObj) { | ||
| 243 | + connectToRenderToken = data.ReadRemoteObject(); | ||
| 244 | + } | ||
| 245 | + } | ||
| 246 | + | ||
| 238 | SessionOption option = { | 247 | SessionOption option = { |
| 239 | .rsId_ = rsId, | 248 | .rsId_ = rsId, |
| 240 | .name_ = name, | 249 | .name_ = name, |
| @@ -246,7 +255,8 @@ int ScreenSessionManagerClientStub::HandleOnScreenConnectionChanged(MessageParce | |||
| 246 | .isRotationLocked_ = rotationOptions.isRotationLocked_, | 255 | .isRotationLocked_ = rotationOptions.isRotationLocked_, |
| 247 | .rotation_ = rotationOptions.rotation_, | 256 | .rotation_ = rotationOptions.rotation_, |
| 248 | .rotationOrientationMap_ = rotationOrientationMap, | 257 | .rotationOrientationMap_ = rotationOrientationMap, |
| 249 | - .isBooting_ = isBooting | 258 | + .isBooting_ = isBooting, |
| 259 | + .connectToRenderToken_ = connectToRenderToken, | ||
| 250 | }; | 260 | }; |
| 251 | TLOGD(WmsLogTag::DMS, | 261 | TLOGD(WmsLogTag::DMS, |
| 252 | "ClientStub received callback parameters, isRotationLocked: %{public}d, rotation: %{public}d, " | 262 | "ClientStub received callback parameters, isRotationLocked: %{public}d, rotation: %{public}d, " |
| @@ -588,8 +598,9 @@ int ScreenSessionManagerClientStub::HandleOnCreateScreenSessionOnly(MessageParce | |||
| 588 | auto screenId = static_cast<ScreenId>(data.ReadUint64()); | 598 | auto screenId = static_cast<ScreenId>(data.ReadUint64()); |
| 589 | auto rsId = static_cast<ScreenId>(data.ReadUint64()); | 599 | auto rsId = static_cast<ScreenId>(data.ReadUint64()); |
| 590 | auto name = data.ReadString(); | 600 | auto name = data.ReadString(); |
| 601 | + sptr<IRemoteObject> renderSession = data.ReadRemoteObject(); | ||
| 591 | bool isExtend = data.ReadBool(); | 602 | bool isExtend = data.ReadBool(); |
| 592 | - bool refreshStatus = OnCreateScreenSessionOnly(screenId, rsId, name, isExtend); | 603 | + bool refreshStatus = OnCreateScreenSessionOnly(screenId, rsId, name, renderSession, isExtend); |
| 593 | reply.WriteBool(refreshStatus); | 604 | reply.WriteBool(refreshStatus); |
| 594 | return ERR_NONE; | 605 | return ERR_NONE; |
| 595 | } | 606 | } |
| @@ -133,6 +133,7 @@ private: | |||
| 133 | WMError IsLandscape(uint64_t screenId, bool& isLandscape); | 133 | WMError IsLandscape(uint64_t screenId, bool& isLandscape); |
| 134 | void PrintRectsInfo(const std::vector<Rect>& rects, const std::string& infoTag); | 134 | void PrintRectsInfo(const std::vector<Rect>& rects, const std::string& infoTag); |
| 135 | CallingWindowInfoData callingWindowInfoData_; | 135 | CallingWindowInfoData callingWindowInfoData_; |
| 136 | + std::shared_ptr<RSUIContext> syncTransRSUIContext_ = nullptr; | ||
| 136 | }; | 137 | }; |
| 137 | } // namespace OHOS::Rosen | 138 | } // namespace OHOS::Rosen |
| 138 | 139 | ||
| @@ -797,12 +797,10 @@ void KeyboardSession::OpenKeyboardSyncTransaction() | |||
| 797 | TLOGNI(WmsLogTag::WMS_KEYBOARD, "Keyboard sync transaction is already open"); | 797 | TLOGNI(WmsLogTag::WMS_KEYBOARD, "Keyboard sync transaction is already open"); |
| 798 | return WSError::WS_OK; | 798 | return WSError::WS_OK; |
| 799 | } | 799 | } |
| 800 | - TLOGNI(WmsLogTag::WMS_KEYBOARD, "Open keyboard sync"); | 800 | + TLOGNI(WmsLogTag::WMS_KEYBOARD, "Open keyboard sync, screenId:%{public}" PRIu64, session->GetScreenId()); |
| 801 | session->isKeyboardSyncTransactionOpen_ = true; | 801 | session->isKeyboardSyncTransactionOpen_ = true; |
| 802 | - auto transactionController = RSSyncTransactionController::GetInstance(); | 802 | + session->syncTransRSUIContext_ = session->GetRSUIContext(); |
| 803 | - if (transactionController) { | 803 | + RSSyncTransactionAdapter::OpenSyncTransaction(session->syncTransRSUIContext_, session->GetEventHandler()); |
| 804 | - transactionController->OpenSyncTransaction(session->GetEventHandler()); | ||
| 805 | - } | ||
| 806 | session->PostKeyboardAnimationSyncTimeoutTask(); | 804 | session->PostKeyboardAnimationSyncTimeoutTask(); |
| 807 | return WSError::WS_OK; | 805 | return WSError::WS_OK; |
| 808 | }; | 806 | }; |
| @@ -884,10 +882,9 @@ void KeyboardSession::CloseRSTransaction() | |||
| 884 | TLOGI(WmsLogTag::WMS_KEYBOARD, "cancelled"); | 882 | TLOGI(WmsLogTag::WMS_KEYBOARD, "cancelled"); |
| 885 | handler->RemoveTask(KEYBOARD_ANIM_SYNC_EVENT_NAME); | 883 | handler->RemoveTask(KEYBOARD_ANIM_SYNC_EVENT_NAME); |
| 886 | } | 884 | } |
| 887 | - auto transactionController = RSSyncTransactionController::GetInstance(); | 885 | + TLOGI(WmsLogTag::WMS_KEYBOARD, "Close keyboard sync, screenId: %{public}" PRIu64, GetScreenId()); |
| 888 | - if (transactionController) { | 886 | + RSSyncTransactionAdapter::CloseSyncTransaction(syncTransRSUIContext_, handler); |
| 889 | - transactionController->CloseSyncTransaction(GetEventHandler()); | 887 | + syncTransRSUIContext_ = nullptr; |
| 890 | - } | ||
| 891 | } | 888 | } |
| 892 | 889 | ||
| 893 | std::shared_ptr<RSTransaction> KeyboardSession::GetRSTransaction() | 890 | std::shared_ptr<RSTransaction> KeyboardSession::GetRSTransaction() |
| @@ -52,7 +52,8 @@ SCBSystemSession::SCBSystemSession(const SessionInfo& info, const sptr<SpecificS | |||
| 52 | break; | 52 | break; |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | - surfaceNode_ = Rosen::RSSurfaceNode::Create(config, Rosen::RSSurfaceNodeType::APP_WINDOW_NODE); | 55 | + surfaceNode_ = Rosen::RSSurfaceNode::Create( |
| 56 | + config, Rosen::RSSurfaceNodeType::APP_WINDOW_NODE, true, false, GetRSUIContext()); | ||
| 56 | shadowSurfaceNode_ = RSAdapterUtil::IsClientMultiInstanceEnabled() && surfaceNode_ ? | 57 | shadowSurfaceNode_ = RSAdapterUtil::IsClientMultiInstanceEnabled() && surfaceNode_ ? |
| 57 | surfaceNode_->CreateShadowSurfaceNode() : nullptr; | 58 | surfaceNode_->CreateShadowSurfaceNode() : nullptr; |
| 58 | RSAdapterUtil::SetRSUIContext(surfaceNode_, GetRSUIContext(), true); | 59 | RSAdapterUtil::SetRSUIContext(surfaceNode_, GetRSUIContext(), true); |
| @@ -3174,13 +3174,18 @@ std::shared_ptr<Media::PixelMap> Session::Snapshot(bool runInFfrt, float scalePa | |||
| 3174 | .useCurWindow = useCurWindow, | 3174 | .useCurWindow = useCurWindow, |
| 3175 | .backGroundColor = GetBackgroundColor(), | 3175 | .backGroundColor = GetBackgroundColor(), |
| 3176 | }; | 3176 | }; |
| 3177 | + auto rsUICtx = surfaceNode->GetRSUIContext(); | ||
| 3178 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 3179 | + TLOGE(WmsLogTag::WMS_PATTERN, "rsUIContext is null"); | ||
| 3180 | + return nullptr; | ||
| 3181 | + } | ||
| 3177 | bool ret = false; | 3182 | bool ret = false; |
| 3178 | if (needBlurSnapshot) { | 3183 | if (needBlurSnapshot) { |
| 3179 | config.backGroundColor = blurBackgroundColor_ == std::numeric_limits<uint32_t>::max() ? | 3184 | config.backGroundColor = blurBackgroundColor_ == std::numeric_limits<uint32_t>::max() ? |
| 3180 | GetBackgroundColor() : blurBackgroundColor_; | 3185 | GetBackgroundColor() : blurBackgroundColor_; |
| 3181 | - ret = RSInterfaces::GetInstance().TakeSurfaceCaptureWithBlur(surfaceNode, callback, config, blurRadius_); | 3186 | + ret = rsUICtx->GetRSRenderInterface()->TakeSurfaceCaptureWithBlur(surfaceNode, callback, config, blurRadius_); |
| 3182 | } else { | 3187 | } else { |
| 3183 | - ret = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode, callback, config); | 3188 | + ret = rsUICtx->GetRSRenderInterface()->TakeSurfaceCapture(surfaceNode, callback, config); |
| 3184 | } | 3189 | } |
| 3185 | if (!ret) { | 3190 | if (!ret) { |
| 3186 | TLOGE(WmsLogTag::WMS_PATTERN, "TakeSurfaceCapture failed %{public}d", persistentId_); | 3191 | TLOGE(WmsLogTag::WMS_PATTERN, "TakeSurfaceCapture failed %{public}d", persistentId_); |
| @@ -5768,7 +5773,13 @@ std::shared_ptr<Media::PixelMap> Session::SetFreezeImmediately(float scale, bool | |||
| 5768 | .isHdrCapture = true, | 5773 | .isHdrCapture = true, |
| 5769 | .needF16WindowCaptureForScRGB = isNeedF16WindowShot, | 5774 | .needF16WindowCaptureForScRGB = isNeedF16WindowShot, |
| 5770 | }; | 5775 | }; |
| 5771 | - bool ret = RSInterfaces::GetInstance().SetWindowFreezeImmediately(surfaceNode, isFreeze, callback, config, blur); | 5776 | + auto rsUICtx = surfaceNode->GetRSUIContext(); |
| 5777 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 5778 | + TLOGE(WmsLogTag::WMS_PATTERN, "rsUIContext is null"); | ||
| 5779 | + return nullptr; | ||
| 5780 | + } | ||
| 5781 | + bool ret = rsUICtx->GetRSRenderInterface()->SetWindowFreezeImmediately( | ||
| 5782 | + surfaceNode, isFreeze, callback, config, blur); | ||
| 5772 | if (!ret) { | 5783 | if (!ret) { |
| 5773 | TLOGE(WmsLogTag::WMS_PATTERN, "failed"); | 5784 | TLOGE(WmsLogTag::WMS_PATTERN, "failed"); |
| 5774 | return nullptr; | 5785 | return nullptr; |
| @@ -6063,7 +6074,7 @@ std::shared_ptr<RSUIContext> Session::GetRSUIContext(const char* caller) | |||
| 6063 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); | 6074 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); |
| 6064 | auto screenId = GetScreenId(); | 6075 | auto screenId = GetScreenId(); |
| 6065 | std::lock_guard<std::mutex> lock(rsUIContextMutex_); | 6076 | std::lock_guard<std::mutex> lock(rsUIContextMutex_); |
| 6066 | - if (screenIdOfRSUIContext_ != screenId) { | 6077 | + if (screenIdOfRSUIContext_ != screenId || screenIdOfRSUIContext_ == SCREEN_ID_INVALID) { |
| 6067 | // Note: For the window corresponding to UIExtAbility, RSUIContext cannot be obtained | 6078 | // Note: For the window corresponding to UIExtAbility, RSUIContext cannot be obtained |
| 6068 | // directly here because its server side is not SceneBoard. The acquisition of RSUIContext | 6079 | // directly here because its server side is not SceneBoard. The acquisition of RSUIContext |
| 6069 | // is deferred to the UIExtensionPattern::OnConnect(ui_extension_pattern.cpp) method, | 6080 | // is deferred to the UIExtensionPattern::OnConnect(ui_extension_pattern.cpp) method, |
| @@ -340,6 +340,8 @@ | |||
| 340 | OHOS::Rosen::ScreenSession::UpdateTouchBoundsAndOffset*; | 340 | OHOS::Rosen::ScreenSession::UpdateTouchBoundsAndOffset*; |
| 341 | OHOS::Rosen::ScreenSession::UpdateValidRotationToScb*; | 341 | OHOS::Rosen::ScreenSession::UpdateValidRotationToScb*; |
| 342 | OHOS::Rosen::ScreenSession::SetRogScreenResolution*; | 342 | OHOS::Rosen::ScreenSession::SetRogScreenResolution*; |
| 343 | + OHOS::Rosen::ScreenSession::GetRenderSession*; | ||
| 344 | + OHOS::Rosen::ScreenSession::SetRenderSession*; | ||
| 343 | OHOS::Rosen::ScreenSessionGroup::AddChild*; | 345 | OHOS::Rosen::ScreenSessionGroup::AddChild*; |
| 344 | OHOS::Rosen::ScreenSessionGroup::ConvertToScreenGroupInfo*; | 346 | OHOS::Rosen::ScreenSessionGroup::ConvertToScreenGroupInfo*; |
| 345 | OHOS::Rosen::ScreenSessionGroup::GetChildCount*; | 347 | OHOS::Rosen::ScreenSessionGroup::GetChildCount*; |
| @@ -86,6 +86,7 @@ struct ScreenSessionConfig { | |||
| 86 | std::string innerName = "UNKNOWN"; | 86 | std::string innerName = "UNKNOWN"; |
| 87 | ScreenProperty property; | 87 | ScreenProperty property; |
| 88 | std::shared_ptr<RSDisplayNode> displayNode; | 88 | std::shared_ptr<RSDisplayNode> displayNode; |
| 89 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 89 | }; | 90 | }; |
| 90 | 91 | ||
| 91 | enum class ScreenSessionReason : int32_t { | 92 | enum class ScreenSessionReason : int32_t { |
| @@ -427,6 +428,8 @@ public: | |||
| 427 | uint32_t GetScreenAreaWidth() const; | 428 | uint32_t GetScreenAreaWidth() const; |
| 428 | void SetScreenAreaHeight(uint32_t screenAreaHeight); | 429 | void SetScreenAreaHeight(uint32_t screenAreaHeight); |
| 429 | uint32_t GetScreenAreaHeight() const; | 430 | uint32_t GetScreenAreaHeight() const; |
| 431 | + void SetRenderSession(sptr<IRemoteObject> renderSession); | ||
| 432 | + sptr<IRemoteObject> GetRenderSession(); | ||
| 430 | 433 | ||
| 431 | void UpdateMirrorWidth(uint32_t mirrorWidth); | 434 | void UpdateMirrorWidth(uint32_t mirrorWidth); |
| 432 | void UpdateMirrorHeight(uint32_t mirrorHeight); | 435 | void UpdateMirrorHeight(uint32_t mirrorHeight); |
| @@ -538,6 +541,7 @@ private: | |||
| 538 | int32_t uniqueRotation_ { 0 }; | 541 | int32_t uniqueRotation_ { 0 }; |
| 539 | mutable std::shared_mutex rotationMapMutex_; | 542 | mutable std::shared_mutex rotationMapMutex_; |
| 540 | std::map<int32_t, int32_t> uniqueRotationOrientationMap_; | 543 | std::map<int32_t, int32_t> uniqueRotationOrientationMap_; |
| 544 | + sptr<IRemoteObject> renderSession_ = nullptr; | ||
| 541 | 545 | ||
| 542 | /* | 546 | /* |
| 543 | * RS Client Multi Instance | 547 | * RS Client Multi Instance |
| @@ -64,7 +64,8 @@ ScreenCache<int32_t, int32_t> g_uidVersionMap(MAP_SIZE, NO_EXIST_UID_VERSION); | |||
| 64 | 64 | ||
| 65 | ScreenSession::ScreenSession(const ScreenSessionConfig& config, ScreenSessionReason reason) | 65 | ScreenSession::ScreenSession(const ScreenSessionConfig& config, ScreenSessionReason reason) |
| 66 | : name_(config.name), screenId_(config.screenId), rsId_(config.rsId), defaultScreenId_(config.defaultScreenId), | 66 | : name_(config.name), screenId_(config.screenId), rsId_(config.rsId), defaultScreenId_(config.defaultScreenId), |
| 67 | - property_(config.property), displayNode_(config.displayNode), innerName_(config.innerName) | 67 | + property_(config.property), displayNode_(config.displayNode), innerName_(config.innerName), |
| 68 | + renderSession_(config.renderSession) | ||
| 68 | { | 69 | { |
| 69 | TLOGI(WmsLogTag::DMS, | 70 | TLOGI(WmsLogTag::DMS, |
| 70 | "[DPNODE]Create Session, reason: %{public}d, screenId: %{public}" PRIu64", rsId: %{public}" PRIu64"", | 71 | "[DPNODE]Create Session, reason: %{public}d, screenId: %{public}" PRIu64", rsId: %{public}" PRIu64"", |
| @@ -73,7 +74,7 @@ ScreenSession::ScreenSession(const ScreenSessionConfig& config, ScreenSessionRea | |||
| 73 | "[DPNODE]Config name: %{public}s, defaultId: %{public}" PRIu64", mirrorNodeId: %{public}" PRIu64"", | 74 | "[DPNODE]Config name: %{public}s, defaultId: %{public}" PRIu64", mirrorNodeId: %{public}" PRIu64"", |
| 74 | name_.c_str(), defaultScreenId_, config.mirrorNodeId); | 75 | name_.c_str(), defaultScreenId_, config.mirrorNodeId); |
| 75 | sessionId_ = sessionIdGenerator_++; | 76 | sessionId_ = sessionIdGenerator_++; |
| 76 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 77 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, config.renderSession); |
| 77 | RSAdapterUtil::SetRSUIContext(displayNode_, GetRSUIContext(), true); | 78 | RSAdapterUtil::SetRSUIContext(displayNode_, GetRSUIContext(), true); |
| 78 | Rosen::RSDisplayNodeConfig rsConfig; | 79 | Rosen::RSDisplayNodeConfig rsConfig; |
| 79 | bool isNeedCreateDisplayNode = true; | 80 | bool isNeedCreateDisplayNode = true; |
| @@ -167,7 +168,7 @@ ScreenSession::ScreenSession(ScreenId screenId, ScreenId rsId, const std::string | |||
| 167 | screenId_); | 168 | screenId_); |
| 168 | sessionId_ = sessionIdGenerator_++; | 169 | sessionId_ = sessionIdGenerator_++; |
| 169 | property_.SetRsId(rsId_); | 170 | property_.SetRsId(rsId_); |
| 170 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 171 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession_); |
| 171 | RSAdapterUtil::SetRSUIContext(displayNode_, GetRSUIContext(), true); | 172 | RSAdapterUtil::SetRSUIContext(displayNode_, GetRSUIContext(), true); |
| 172 | } | 173 | } |
| 173 | 174 | ||
| @@ -175,7 +176,7 @@ ScreenSession::ScreenSession(ScreenId screenId, const ScreenProperty& property, | |||
| 175 | : screenId_(screenId), defaultScreenId_(defaultScreenId), property_(property) | 176 | : screenId_(screenId), defaultScreenId_(defaultScreenId), property_(property) |
| 176 | { | 177 | { |
| 177 | sessionId_ = sessionIdGenerator_++; | 178 | sessionId_ = sessionIdGenerator_++; |
| 178 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 179 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession_); |
| 179 | Rosen::RSDisplayNodeConfig config = { .screenId = screenId_ }; | 180 | Rosen::RSDisplayNodeConfig config = { .screenId = screenId_ }; |
| 180 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); | 181 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); |
| 181 | TLOGD(WmsLogTag::WMS_SCB, | 182 | TLOGD(WmsLogTag::WMS_SCB, |
| @@ -202,7 +203,7 @@ ScreenSession::ScreenSession(ScreenId screenId, const ScreenProperty& property, | |||
| 202 | sessionId_ = sessionIdGenerator_++; | 203 | sessionId_ = sessionIdGenerator_++; |
| 203 | rsId_ = screenId; | 204 | rsId_ = screenId; |
| 204 | property_.SetRsId(rsId_); | 205 | property_.SetRsId(rsId_); |
| 205 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 206 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession_); |
| 206 | Rosen::RSDisplayNodeConfig config = { .screenId = screenId_, .isMirrored = true, .mirrorNodeId = nodeId, | 207 | Rosen::RSDisplayNodeConfig config = { .screenId = screenId_, .isMirrored = true, .mirrorNodeId = nodeId, |
| 207 | .isSync = true}; | 208 | .isSync = true}; |
| 208 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); | 209 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); |
| @@ -228,7 +229,7 @@ ScreenSession::ScreenSession(const std::string& name, ScreenId smsId, ScreenId r | |||
| 228 | sessionId_ = sessionIdGenerator_++; | 229 | sessionId_ = sessionIdGenerator_++; |
| 229 | (void)rsId_; | 230 | (void)rsId_; |
| 230 | property_.SetRsId(rsId_); | 231 | property_.SetRsId(rsId_); |
| 231 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 232 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession_); |
| 232 | // 虚拟屏的screen id和rs id不一致,displayNode的创建应使用rs id | 233 | // 虚拟屏的screen id和rs id不一致,displayNode的创建应使用rs id |
| 233 | Rosen::RSDisplayNodeConfig config = { .screenId = rsId_ }; | 234 | Rosen::RSDisplayNodeConfig config = { .screenId = rsId_ }; |
| 234 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); | 235 | displayNode_ = Rosen::RSDisplayNode::Create(config, GetRSUIContext()); |
| @@ -981,6 +982,11 @@ void ScreenSession::PowerStatusChange(DisplayPowerEvent event, EventStatus statu | |||
| 981 | } | 982 | } |
| 982 | } | 983 | } |
| 983 | 984 | ||
| 985 | +sptr<IRemoteObject> ScreenSession::GetRenderSession() | ||
| 986 | +{ | ||
| 987 | + return renderSession_; | ||
| 988 | +} | ||
| 989 | + | ||
| 984 | void ScreenSession::HandleKeyboardOnPropertyChange(ScreenProperty& screenProperty, int32_t height) | 990 | void ScreenSession::HandleKeyboardOnPropertyChange(ScreenProperty& screenProperty, int32_t height) |
| 985 | { | 991 | { |
| 986 | TLOGI(WmsLogTag::DMS, "Client HandleKeyboardOnPropertyChange"); | 992 | TLOGI(WmsLogTag::DMS, "Client HandleKeyboardOnPropertyChange"); |
| @@ -2714,7 +2720,17 @@ void ScreenSession::SetForceCloseHdr(bool isForceCloseHdr) | |||
| 2714 | DmsXcollie dmsXcollie("DMS:SetForceCloseHdr:GetScreenHDRStatus", XCOLLIE_TIMEOUT_5S); | 2720 | DmsXcollie dmsXcollie("DMS:SetForceCloseHdr:GetScreenHDRStatus", XCOLLIE_TIMEOUT_5S); |
| 2715 | HdrStatus hdrStatus = HdrStatus::NO_HDR; | 2721 | HdrStatus hdrStatus = HdrStatus::NO_HDR; |
| 2716 | TLOGI(WmsLogTag::DMS, "Start get screen status, screenId: %{public}" PRIu64, phyScreenId_); | 2722 | TLOGI(WmsLogTag::DMS, "Start get screen status, screenId: %{public}" PRIu64, phyScreenId_); |
| 2717 | - auto ret = RSInterfaces::GetInstance().GetScreenHDRStatus(phyScreenId_, hdrStatus); | 2723 | + auto rsUIContext = GetRSUIContext(); |
| 2724 | + if (rsUIContext == nullptr) { | ||
| 2725 | + TLOGE(WmsLogTag::DMS, "rsUIContext is null"); | ||
| 2726 | + return; | ||
| 2727 | + } | ||
| 2728 | + auto rsRenderInterface = rsUIContext->GetRSRenderInterface(); | ||
| 2729 | + if (rsRenderInterface == nullptr) { | ||
| 2730 | + TLOGE(WmsLogTag::DMS, "rsRenderInterface is null"); | ||
| 2731 | + return; | ||
| 2732 | + } | ||
| 2733 | + auto ret = rsRenderInterface->GetScreenHDRStatus(phyScreenId_, hdrStatus); | ||
| 2718 | if (ret == StatusCode::SUCCESS && hdrStatus == HdrStatus::NO_HDR) { | 2734 | if (ret == StatusCode::SUCCESS && hdrStatus == HdrStatus::NO_HDR) { |
| 2719 | hdrDuration = DURATION_0MS; | 2735 | hdrDuration = DURATION_0MS; |
| 2720 | } | 2736 | } |
| @@ -2766,14 +2782,6 @@ void ScreenSession::SetScreenSnapshotRect(RSSurfaceCaptureConfig& config) | |||
| 2766 | 2782 | ||
| 2767 | std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshot(float scaleX, float scaleY) | 2783 | std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshot(float scaleX, float scaleY) |
| 2768 | { | 2784 | { |
| 2769 | - { | ||
| 2770 | - std::shared_lock<std::shared_mutex> displayNodeLock(displayNodeMutex_); | ||
| 2771 | - if (displayNode_ == nullptr) { | ||
| 2772 | - TLOGE(WmsLogTag::DMS, "get screen snapshot displayNode_ is null"); | ||
| 2773 | - return nullptr; | ||
| 2774 | - } | ||
| 2775 | - } | ||
| 2776 | - | ||
| 2777 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ss:GetScreenSnapshot"); | 2785 | HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ss:GetScreenSnapshot"); |
| 2778 | auto callback = std::make_shared<SurfaceCaptureFuture>(); | 2786 | auto callback = std::make_shared<SurfaceCaptureFuture>(); |
| 2779 | RSSurfaceCaptureConfig config = { | 2787 | RSSurfaceCaptureConfig config = { |
| @@ -2785,7 +2793,13 @@ std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshot(float scaleX, | |||
| 2785 | { | 2793 | { |
| 2786 | DmsXcollie dmsXcollie("DMS:GetScreenSnapshot:TakeSurfaceCapture", XCOLLIE_TIMEOUT_5S); | 2794 | DmsXcollie dmsXcollie("DMS:GetScreenSnapshot:TakeSurfaceCapture", XCOLLIE_TIMEOUT_5S); |
| 2787 | std::shared_lock<std::shared_mutex> displayNodeLock(displayNodeMutex_); | 2795 | std::shared_lock<std::shared_mutex> displayNodeLock(displayNodeMutex_); |
| 2788 | - bool ret = RSInterfaces::GetInstance().TakeSurfaceCapture(displayNode_, callback, config); | 2796 | + if (displayNode_ == nullptr || displayNode_->GetRSUIContext() == nullptr || |
| 2797 | + displayNode_->GetRSUIContext()->GetRSRenderInterface() == nullptr) { | ||
| 2798 | + TLOGE(WmsLogTag::DMS, "get screen snapshot displayNode or rsUIContext is null"); | ||
| 2799 | + return nullptr; | ||
| 2800 | + } | ||
| 2801 | + bool ret = displayNode_->GetRSUIContext()->GetRSRenderInterface()->TakeSurfaceCapture(displayNode_, callback, | ||
| 2802 | + config); | ||
| 2789 | if (!ret) { | 2803 | if (!ret) { |
| 2790 | TLOGE(WmsLogTag::DMS, "get screen snapshot TakeSurfaceCapture failed"); | 2804 | TLOGE(WmsLogTag::DMS, "get screen snapshot TakeSurfaceCapture failed"); |
| 2791 | return nullptr; | 2805 | return nullptr; |
| @@ -2922,7 +2936,17 @@ void ScreenSession::FreezeScreen(bool isFreeze) | |||
| 2922 | TLOGE(WmsLogTag::DMS, "displayNode is null"); | 2936 | TLOGE(WmsLogTag::DMS, "displayNode is null"); |
| 2923 | return; | 2937 | return; |
| 2924 | } | 2938 | } |
| 2925 | - RSInterfaces::GetInstance().FreezeScreen(displayNode_, isFreeze); | 2939 | + auto rsUIContext = GetRSUIContext(); |
| 2940 | + if (rsUIContext == nullptr) { | ||
| 2941 | + TLOGE(WmsLogTag::DMS, "rsUIContext is null"); | ||
| 2942 | + return; | ||
| 2943 | + } | ||
| 2944 | + auto rsRenderInterface = rsUIContext->GetRSRenderInterface(); | ||
| 2945 | + if (rsRenderInterface == nullptr) { | ||
| 2946 | + TLOGE(WmsLogTag::DMS, "rsRenderInterface is null"); | ||
| 2947 | + return; | ||
| 2948 | + } | ||
| 2949 | + rsRenderInterface->FreezeScreen(displayNode_, isFreeze); | ||
| 2926 | } | 2950 | } |
| 2927 | 2951 | ||
| 2928 | std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshotWithAllWindows(float scaleX, float scaleY, | 2952 | std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshotWithAllWindows(float scaleX, float scaleY, |
| @@ -2943,7 +2967,17 @@ std::shared_ptr<Media::PixelMap> ScreenSession::GetScreenSnapshotWithAllWindows( | |||
| 2943 | .scaleY = scaleY, | 2967 | .scaleY = scaleY, |
| 2944 | }; | 2968 | }; |
| 2945 | SetScreenSnapshotRect(config); | 2969 | SetScreenSnapshotRect(config); |
| 2946 | - bool ret = RSInterfaces::GetInstance().TakeSurfaceCaptureWithAllWindows(displayNode_, callback, config, | 2970 | + auto rsUIContext = GetRSUIContext(); |
| 2971 | + if (rsUIContext == nullptr) { | ||
| 2972 | + TLOGE(WmsLogTag::DMS, "rsUIContext is null"); | ||
| 2973 | + return nullptr; | ||
| 2974 | + } | ||
| 2975 | + auto rsRenderInterface = rsUIContext->GetRSRenderInterface(); | ||
| 2976 | + if (rsRenderInterface == nullptr) { | ||
| 2977 | + TLOGE(WmsLogTag::DMS, "rsRenderInterface is null"); | ||
| 2978 | + return nullptr; | ||
| 2979 | + } | ||
| 2980 | + bool ret = rsRenderInterface->TakeSurfaceCaptureWithAllWindows(displayNode_, callback, config, | ||
| 2947 | isNeedCheckDrmAndSurfaceLock); | 2981 | isNeedCheckDrmAndSurfaceLock); |
| 2948 | if (!ret) { | 2982 | if (!ret) { |
| 2949 | TLOGE(WmsLogTag::DMS, "take surface capture with all windows failed"); | 2983 | TLOGE(WmsLogTag::DMS, "take surface capture with all windows failed"); |
| @@ -245,7 +245,8 @@ public: | |||
| 245 | WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 245 | WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 246 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 246 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 247 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 247 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 248 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) override; | 248 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, |
| 249 | + sptr<IRemoteObject> token = nullptr) override; | ||
| 249 | WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) override; | 250 | WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) override; |
| 250 | WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId, | 251 | WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId, |
| 251 | const sptr<IRemoteObject>& callback) override; | 252 | const sptr<IRemoteObject>& callback) override; |
| @@ -30,7 +30,8 @@ public: | |||
| 30 | WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 30 | WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 31 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 31 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 32 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 32 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 33 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) override; | 33 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, |
| 34 | + sptr<IRemoteObject> token = nullptr) override; | ||
| 34 | WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 35 | WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 35 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 36 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 36 | sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) override; | 37 | sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) override; |
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | namespace OHOS::Rosen { | 29 | namespace OHOS::Rosen { |
| @@ -59,6 +60,7 @@ sptr<AAFwk::SessionInfo> ExtensionSessionManager::SetAbilitySessionInfo(const sp | |||
| 59 | abilitySessionInfo->density = sessionInfo.config_.density_; | 60 | abilitySessionInfo->density = sessionInfo.config_.density_; |
| 60 | abilitySessionInfo->orientation = sessionInfo.config_.orientation_; | 61 | abilitySessionInfo->orientation = sessionInfo.config_.orientation_; |
| 61 | abilitySessionInfo->isDensityFollowHost = sessionInfo.config_.isDensityFollowHost_; | 62 | abilitySessionInfo->isDensityFollowHost = sessionInfo.config_.isDensityFollowHost_; |
| 63 | + abilitySessionInfo->renderSession = sessionInfo.connectToRenderToken_; | ||
| 62 | if (sessionInfo.want != nullptr) { | 64 | if (sessionInfo.want != nullptr) { |
| 63 | abilitySessionInfo->want = sessionInfo.GetWantSafely(); | 65 | abilitySessionInfo->want = sessionInfo.GetWantSafely(); |
| 64 | } | 66 | } |
| @@ -1006,7 +1006,20 @@ void SceneSessionManager::LoadFreeMultiWindowConfig(bool enable) | |||
| 1006 | } | 1006 | } |
| 1007 | } | 1007 | } |
| 1008 | systemConfig_.freeMultiWindowEnable_ = enable; | 1008 | systemConfig_.freeMultiWindowEnable_ = enable; |
| 1009 | - rsInterface_.SetFreeMultiWindowStatus(enable); | 1009 | + auto rootSceneSession = GetRootSceneSession(); |
| 1010 | + if (rootSceneSession == nullptr) { | ||
| 1011 | + TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "rootSceneSession is null"); | ||
| 1012 | + return; | ||
| 1013 | + } | ||
| 1014 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 1015 | + if (rsUICtx == nullptr) { | ||
| 1016 | + TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "rsUICtx is null"); | ||
| 1017 | + return; | ||
| 1018 | + } | ||
| 1019 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 1020 | + TLOGI(WmsLogTag::WMS_MULTI_WINDOW, "enable=%{public}d", enable); | ||
| 1021 | + rsInterface->SetFreeMultiWindowStatus(enable); | ||
| 1022 | + } | ||
| 1010 | } | 1023 | } |
| 1011 | 1024 | ||
| 1012 | const SystemSessionConfig& SceneSessionManager::GetSystemSessionConfig() const | 1025 | const SystemSessionConfig& SceneSessionManager::GetSystemSessionConfig() const |
| @@ -3561,7 +3574,9 @@ sptr<AAFwk::SessionInfo> SceneSessionManager::SetAbilitySessionInfo(const sptr<S | |||
| 3561 | { | 3574 | { |
| 3562 | const auto& sessionInfo = sceneSession->GetSessionInfo(); | 3575 | const auto& sessionInfo = sceneSession->GetSessionInfo(); |
| 3563 | auto abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr(); | 3576 | auto abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr(); |
| 3577 | + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); | ||
| 3564 | abilitySessionInfo->sessionToken = sptr<ISession>(sceneSession)->AsObject(); | 3578 | abilitySessionInfo->sessionToken = sptr<ISession>(sceneSession)->AsObject(); |
| 3579 | + abilitySessionInfo->renderSession = ScreenSessionManagerClient::GetInstance().GetRenderSessionToken(); | ||
| 3565 | abilitySessionInfo->identityToken = std::to_string(std::chrono::time_point_cast<std::chrono::milliseconds>( | 3580 | abilitySessionInfo->identityToken = std::to_string(std::chrono::time_point_cast<std::chrono::milliseconds>( |
| 3566 | std::chrono::system_clock::now()).time_since_epoch().count()); | 3581 | std::chrono::system_clock::now()).time_since_epoch().count()); |
| 3567 | abilitySessionInfo->callerToken = sessionInfo.callerToken_; | 3582 | abilitySessionInfo->callerToken = sessionInfo.callerToken_; |
| @@ -3600,8 +3615,7 @@ sptr<AAFwk::SessionInfo> SceneSessionManager::SetAbilitySessionInfo(const sptr<S | |||
| 3600 | TLOGI(WmsLogTag::WMS_LIFE, "want.appIndex is null, set want.appIndex:%{public}d", sessionInfo.appIndex_); | 3615 | TLOGI(WmsLogTag::WMS_LIFE, "want.appIndex is null, set want.appIndex:%{public}d", sessionInfo.appIndex_); |
| 3601 | abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, sessionInfo.appIndex_); | 3616 | abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, sessionInfo.appIndex_); |
| 3602 | } | 3617 | } |
| 3603 | - abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, | 3618 | + abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, static_cast<int>(displayId)); |
| 3604 | - static_cast<int>(sceneSession->GetSessionProperty()->GetDisplayId())); | ||
| 3605 | abilitySessionInfo->instanceKey = sessionInfo.appInstanceKey_; | 3619 | abilitySessionInfo->instanceKey = sessionInfo.appInstanceKey_; |
| 3606 | if (sessionInfo.callState_ >= static_cast<uint32_t>(AAFwk::CallToState::UNKNOW) && | 3620 | if (sessionInfo.callState_ >= static_cast<uint32_t>(AAFwk::CallToState::UNKNOW) && |
| 3607 | sessionInfo.callState_ <= static_cast<uint32_t>(AAFwk::CallToState::BACKGROUND)) { | 3621 | sessionInfo.callState_ <= static_cast<uint32_t>(AAFwk::CallToState::BACKGROUND)) { |
| @@ -4706,7 +4720,7 @@ void SceneSessionManager::DestroySpecificSession(const sptr<IRemoteObject>& remo | |||
| 4706 | WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 4720 | WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 4707 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 4721 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 4708 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 4722 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 4709 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token) | 4723 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, sptr<IRemoteObject> token) |
| 4710 | { | 4724 | { |
| 4711 | if (!CheckSystemWindowPermission(property) || !CheckModalSubWindowPermission(property)) { | 4725 | if (!CheckSystemWindowPermission(property) || !CheckModalSubWindowPermission(property)) { |
| 4712 | TLOGE(WmsLogTag::WMS_LIFE, "create system window or modal subwindow permission denied!"); | 4726 | TLOGE(WmsLogTag::WMS_LIFE, "create system window or modal subwindow permission denied!"); |
| @@ -4781,7 +4795,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISession | |||
| 4781 | auto pid = IPCSkeleton::GetCallingRealPid(); | 4795 | auto pid = IPCSkeleton::GetCallingRealPid(); |
| 4782 | auto uid = IPCSkeleton::GetCallingUid(); | 4796 | auto uid = IPCSkeleton::GetCallingUid(); |
| 4783 | auto task = [this, sessionStage, eventChannel, surfaceNode, property, &persistentId, &session, &systemConfig, token, | 4797 | auto task = [this, sessionStage, eventChannel, surfaceNode, property, &persistentId, &session, &systemConfig, token, |
| 4784 | - pid, uid, isSystemCalling, initClientDisplayId]() { | 4798 | + &renderSession, pid, uid, isSystemCalling, initClientDisplayId]() { |
| 4785 | if (property == nullptr) { | 4799 | if (property == nullptr) { |
| 4786 | TLOGNE(WmsLogTag::WMS_LIFE, "property is nullptr"); | 4800 | TLOGNE(WmsLogTag::WMS_LIFE, "property is nullptr"); |
| 4787 | return WSError::WS_ERROR_NULLPTR; | 4801 | return WSError::WS_ERROR_NULLPTR; |
| @@ -4819,6 +4833,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr<ISession | |||
| 4819 | 4833 | ||
| 4820 | NotifyCreateSpecificSession(newSession, property, type); | 4834 | NotifyCreateSpecificSession(newSession, property, type); |
| 4821 | session = newSession; | 4835 | session = newSession; |
| 4836 | + renderSession = ScreenSessionManagerClient::GetInstance().GetRenderSessionToken(); | ||
| 4822 | AddClientDeathRecipient(sessionStage, newSession); | 4837 | AddClientDeathRecipient(sessionStage, newSession); |
| 4823 | 4838 | ||
| 4824 | if (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { | 4839 | if (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { |
| @@ -8437,11 +8452,20 @@ void FocusIDChange(int32_t persistentId, const sptr<SceneSession>& sceneSession) | |||
| 8437 | } else { | 8452 | } else { |
| 8438 | focusNodeId = sceneSession->GetSurfaceNode()->GetId(); | 8453 | focusNodeId = sceneSession->GetSurfaceNode()->GetId(); |
| 8439 | } | 8454 | } |
| 8440 | - FocusAppInfo appInfo = { | 8455 | + auto rsUICtx = sceneSession->GetRSUIContext(); |
| 8441 | - sceneSession->GetCallingPid(), sceneSession->GetCallingUid(), | 8456 | + if (rsUICtx == nullptr) { |
| 8442 | - sceneSession->GetSessionInfo().bundleName_, | 8457 | + TLOGE(WmsLogTag::WMS_FOCUS, "rsUICtx is null"); |
| 8443 | - sceneSession->GetSessionInfo().abilityName_, focusNodeId}; | 8458 | + return; |
| 8444 | - RSInterfaces::GetInstance().SetFocusAppInfo(appInfo); | 8459 | + } |
| 8460 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 8461 | + FocusAppInfo appInfo = { | ||
| 8462 | + sceneSession->GetCallingPid(), sceneSession->GetCallingUid(), | ||
| 8463 | + sceneSession->GetSessionInfo().bundleName_, | ||
| 8464 | + sceneSession->GetSessionInfo().abilityName_, focusNodeId}; | ||
| 8465 | + TLOGD(WmsLogTag::WMS_FOCUS, "win=%{public}d, bundleName=%{public}s", | ||
| 8466 | + sceneSession->GetPersistentId(), appInfo.bundleName.c_str()); | ||
| 8467 | + rsInterface->SetFocusAppInfo(appInfo); | ||
| 8468 | + } | ||
| 8445 | } | 8469 | } |
| 8446 | 8470 | ||
| 8447 | // ordered vector by compare func | 8471 | // ordered vector by compare func |
| @@ -9821,7 +9845,12 @@ void SceneSessionManager::RegisterSingleHandContainerNode(const std::string& str | |||
| 9821 | } | 9845 | } |
| 9822 | TLOGI(WmsLogTag::WMS_LAYOUT, "get OneHandModeBox node, id: %{public}" PRIu64, rsNode->GetId()); | 9846 | TLOGI(WmsLogTag::WMS_LAYOUT, "get OneHandModeBox node, id: %{public}" PRIu64, rsNode->GetId()); |
| 9823 | setTopWindowBoundaryByIDFunc_(stringId); | 9847 | setTopWindowBoundaryByIDFunc_(stringId); |
| 9824 | - rsInterface_.SetWindowContainer(rsNode->GetId(), true); | 9848 | + auto rsUICtx = rsNode->GetRSUIContext(); |
| 9849 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 9850 | + TLOGE(WmsLogTag::WMS_LAYOUT, "rsUIContext is null"); | ||
| 9851 | + return; | ||
| 9852 | + } | ||
| 9853 | + rsUICtx->GetRSRenderInterface()->SetWindowContainer(rsNode->GetId(), true); | ||
| 9825 | } | 9854 | } |
| 9826 | 9855 | ||
| 9827 | const SingleHandCompatibleModeConfig& SceneSessionManager::GetSingleHandCompatibleModeConfig() const | 9856 | const SingleHandCompatibleModeConfig& SceneSessionManager::GetSingleHandCompatibleModeConfig() const |
| @@ -11750,7 +11779,12 @@ WMError SceneSessionManager::Snapshot(std::shared_ptr<Media::PixelMap>& pixelMap | |||
| 11750 | .scaleY = config.scaleY, | 11779 | .scaleY = config.scaleY, |
| 11751 | .useCurWindow = config.useCurWindow, | 11780 | .useCurWindow = config.useCurWindow, |
| 11752 | }; | 11781 | }; |
| 11753 | - if (!RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode, callback, rsConfig)) { | 11782 | + auto rsUICtx = surfaceNode->GetRSUIContext(); |
| 11783 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 11784 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 11785 | + return WMError::WM_ERROR_INVALID_OPERATION; | ||
| 11786 | + } | ||
| 11787 | + if (!rsUICtx->GetRSRenderInterface()->TakeSurfaceCapture(surfaceNode, callback, rsConfig)) { | ||
| 11754 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "TakeSurfaceCapture failed: %{public}d", persistentId); | 11788 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "TakeSurfaceCapture failed: %{public}d", persistentId); |
| 11755 | return WMError::WM_ERROR_INVALID_OPERATION; | 11789 | return WMError::WM_ERROR_INVALID_OPERATION; |
| 11756 | } | 11790 | } |
| @@ -13444,8 +13478,23 @@ void SceneSessionManager::InitWithRenderServiceAdded() | |||
| 13444 | auto windowVisibilityChangeCb = [this](std::shared_ptr<RSOcclusionData> occlusiontionData) { | 13478 | auto windowVisibilityChangeCb = [this](std::shared_ptr<RSOcclusionData> occlusiontionData) { |
| 13445 | this->WindowLayerInfoChangeCallback(occlusiontionData); | 13479 | this->WindowLayerInfoChangeCallback(occlusiontionData); |
| 13446 | }; | 13480 | }; |
| 13481 | + auto rootSceneSession = GetRootSceneSession(); | ||
| 13482 | + if (rootSceneSession == nullptr) { | ||
| 13483 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "no rootSession"); | ||
| 13484 | + return; | ||
| 13485 | + } | ||
| 13486 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 13487 | + if (rsUICtx == nullptr) { | ||
| 13488 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "no rsUICtx"); | ||
| 13489 | + return; | ||
| 13490 | + } | ||
| 13491 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 13492 | + if (rsInterface == nullptr) { | ||
| 13493 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsInterface is null"); | ||
| 13494 | + return; | ||
| 13495 | + } | ||
| 13447 | TLOGI(WmsLogTag::DEFAULT, "RegisterWindowVisibilityChangeCallback"); | 13496 | TLOGI(WmsLogTag::DEFAULT, "RegisterWindowVisibilityChangeCallback"); |
| 13448 | - if (rsInterface_.RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) { | 13497 | + if (rsInterface->RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) { |
| 13449 | TLOGE(WmsLogTag::DEFAULT, "RegisterWindowVisibilityChangeCallback failed"); | 13498 | TLOGE(WmsLogTag::DEFAULT, "RegisterWindowVisibilityChangeCallback failed"); |
| 13450 | } | 13499 | } |
| 13451 | } | 13500 | } |
| @@ -13459,10 +13508,22 @@ WMError SceneSessionManager::SetSystemAnimatedScenes(SystemAnimatedSceneType sce | |||
| 13459 | 13508 | ||
| 13460 | auto task = [this, sceneType, isRegularAnimation]() { | 13509 | auto task = [this, sceneType, isRegularAnimation]() { |
| 13461 | TLOGND(WmsLogTag::WMS_PC, "Set system animated scene %{public}d.", sceneType); | 13510 | TLOGND(WmsLogTag::WMS_PC, "Set system animated scene %{public}d.", sceneType); |
| 13462 | - bool ret = rsInterface_.SetSystemAnimatedScenes( | 13511 | + auto rootSceneSession = GetRootSceneSession(); |
| 13463 | - static_cast<SystemAnimatedScenes>(sceneType), isRegularAnimation); | 13512 | + if (rootSceneSession == nullptr) { |
| 13464 | - if (!ret) { | 13513 | + TLOGNE(WmsLogTag::WMS_PC, "no rootSession"); |
| 13465 | - TLOGNE(WmsLogTag::WMS_PC, "Set system animated scene failed."); | 13514 | + return; |
| 13515 | + } | ||
| 13516 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 13517 | + if (rsUICtx == nullptr) { | ||
| 13518 | + TLOGNE(WmsLogTag::WMS_PC, "no rsUICtx"); | ||
| 13519 | + return; | ||
| 13520 | + } | ||
| 13521 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 13522 | + bool ret = rsInterface->SetSystemAnimatedScenes( | ||
| 13523 | + static_cast<SystemAnimatedScenes>(sceneType), isRegularAnimation); | ||
| 13524 | + if (!ret) { | ||
| 13525 | + TLOGNE(WmsLogTag::WMS_PC, "Set system animated scene failed."); | ||
| 13526 | + } | ||
| 13466 | } | 13527 | } |
| 13467 | }; | 13528 | }; |
| 13468 | taskScheduler_->PostAsyncTask(task, "SetSystemAnimatedScenes"); | 13529 | taskScheduler_->PostAsyncTask(task, "SetSystemAnimatedScenes"); |
| @@ -14284,10 +14345,22 @@ void SceneSessionManager::UpdateDarkColorModeToRS() | |||
| 14284 | TLOGE(WmsLogTag::DEFAULT, "app configuration is nullptr"); | 14345 | TLOGE(WmsLogTag::DEFAULT, "app configuration is nullptr"); |
| 14285 | return; | 14346 | return; |
| 14286 | } | 14347 | } |
| 14287 | - std::string colorMode = config->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); | 14348 | + auto rootSceneSession = GetRootSceneSession(); |
| 14288 | - bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); | 14349 | + if (rootSceneSession == nullptr) { |
| 14289 | - bool ret = RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark); | 14350 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rootSceneSession is null"); |
| 14290 | - TLOGI(WmsLogTag::DEFAULT, "colorMode: %{public}s, ret: %{public}d", colorMode.c_str(), ret); | 14351 | + return; |
| 14352 | + } | ||
| 14353 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 14354 | + if (rsUICtx == nullptr) { | ||
| 14355 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUICtx is null"); | ||
| 14356 | + return; | ||
| 14357 | + } | ||
| 14358 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 14359 | + std::string colorMode = config->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); | ||
| 14360 | + bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); | ||
| 14361 | + bool ret = rsInterface->SetGlobalDarkColorMode(isDark); | ||
| 14362 | + TLOGI(WmsLogTag::DEFAULT, "colorMode: %{public}s, ret: %{public}d", colorMode.c_str(), ret); | ||
| 14363 | + } | ||
| 14291 | } | 14364 | } |
| 14292 | 14365 | ||
| 14293 | void SceneSessionManager::SetVirtualPixelRatioChangeListener(const ProcessVirtualPixelRatioChangeFunc& func) | 14366 | void SceneSessionManager::SetVirtualPixelRatioChangeListener(const ProcessVirtualPixelRatioChangeFunc& func) |
| @@ -18629,9 +18702,24 @@ WMError SceneSessionManager::SetWatermarkImageForApp(const std::shared_ptr<Media | |||
| 18629 | watermarkName = ""; | 18702 | watermarkName = ""; |
| 18630 | return WMError::WM_OK; | 18703 | return WMError::WM_OK; |
| 18631 | } | 18704 | } |
| 18705 | + auto rootSceneSession = GetRootSceneSession(); | ||
| 18706 | + if (rootSceneSession == nullptr) { | ||
| 18707 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: rootSceneSession is null", where); | ||
| 18708 | + return WMError::WM_ERROR_SYSTEM_ABNORMALLY; | ||
| 18709 | + } | ||
| 18710 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 18711 | + if (rsUICtx == nullptr) { | ||
| 18712 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: rsUICtx is null", where); | ||
| 18713 | + return WMError::WM_ERROR_SYSTEM_ABNORMALLY; | ||
| 18714 | + } | ||
| 18715 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 18716 | + if (rsInterface == nullptr) { | ||
| 18717 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: rsInterface is null", where); | ||
| 18718 | + return WMError::WM_ERROR_SYSTEM_ABNORMALLY; | ||
| 18719 | + } | ||
| 18632 | std::string newWatermarkName; | 18720 | std::string newWatermarkName; |
| 18633 | auto nodeIds = GetSessionNodeIdsAndWatermarkNameByPid(pid, newWatermarkName); | 18721 | auto nodeIds = GetSessionNodeIdsAndWatermarkNameByPid(pid, newWatermarkName); |
| 18634 | - auto rsErrCode = RSInterfaces::GetInstance().SetSurfaceWatermark(pid, newWatermarkName, pixelMap, nodeIds, | 18722 | + auto rsErrCode = rsInterface->SetSurfaceWatermark(pid, newWatermarkName, pixelMap, nodeIds, |
| 18635 | CUSTOM_WATER_MARK); | 18723 | CUSTOM_WATER_MARK); |
| 18636 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: pid=%{public}d, curWatermark=%{public}s, rsErrCode=%{public}u", | 18724 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: pid=%{public}d, curWatermark=%{public}s, rsErrCode=%{public}u", |
| 18637 | where, pid, newWatermarkName.c_str(), static_cast<uint32_t>(rsErrCode)); | 18725 | where, pid, newWatermarkName.c_str(), static_cast<uint32_t>(rsErrCode)); |
| @@ -18705,9 +18793,27 @@ void SceneSessionManager::SetWatermarkForSession(const sptr<SceneSession>& sessi | |||
| 18705 | where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | 18793 | where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); |
| 18706 | return WSError::WS_ERROR_INVALID_WINDOW; | 18794 | return WSError::WS_ERROR_INVALID_WINDOW; |
| 18707 | } | 18795 | } |
| 18796 | + auto rootSceneSession = GetRootSceneSession(); | ||
| 18797 | + if (rootSceneSession == nullptr) { | ||
| 18798 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rootSession, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18799 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18800 | + return WSError::WS_ERROR_INVALID_WINDOW; | ||
| 18801 | + } | ||
| 18802 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 18803 | + if (rsUICtx == nullptr) { | ||
| 18804 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rsUICtx, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18805 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18806 | + return WSError::WS_ERROR_INVALID_WINDOW; | ||
| 18807 | + } | ||
| 18808 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 18809 | + if (rsInterface == nullptr) { | ||
| 18810 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rsInterface, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18811 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18812 | + return WSError::WS_ERROR_INVALID_WINDOW; | ||
| 18813 | + } | ||
| 18708 | std::vector<NodeId> nodeIds; | 18814 | std::vector<NodeId> nodeIds; |
| 18709 | nodeIds.push_back(surfaceNode->GetId()); | 18815 | nodeIds.push_back(surfaceNode->GetId()); |
| 18710 | - auto rsErrCode = RSInterfaces::GetInstance().SetSurfaceWatermark(pid, watermarkName, nullptr, nodeIds, | 18816 | + auto rsErrCode = rsInterface->SetSurfaceWatermark(pid, watermarkName, nullptr, nodeIds, |
| 18711 | CUSTOM_WATER_MARK); | 18817 | CUSTOM_WATER_MARK); |
| 18712 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: win=[%{public}d, %{public}s], pid=%{public}d, " | 18818 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: win=[%{public}d, %{public}s], pid=%{public}d, " |
| 18713 | "watermark=%{public}s, rsErrCode=%{public}u", where, sceneSession->GetWindowId(), | 18819 | "watermark=%{public}s, rsErrCode=%{public}u", where, sceneSession->GetWindowId(), |
| @@ -18736,9 +18842,27 @@ void SceneSessionManager::ClearWatermarkForSession(const sptr<SceneSession>& ses | |||
| 18736 | where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | 18842 | where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); |
| 18737 | return; | 18843 | return; |
| 18738 | } | 18844 | } |
| 18845 | + auto rootSceneSession = GetRootSceneSession(); | ||
| 18846 | + if (rootSceneSession == nullptr) { | ||
| 18847 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rootSession, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18848 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18849 | + return; | ||
| 18850 | + } | ||
| 18851 | + auto rsUICtx = rootSceneSession->GetRSUIContext(); | ||
| 18852 | + if (rsUICtx == nullptr) { | ||
| 18853 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rsUICtx, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18854 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18855 | + return; | ||
| 18856 | + } | ||
| 18857 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 18858 | + if (rsInterface == nullptr) { | ||
| 18859 | + TLOGNE(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: no rsInterface, win=[%{public}d, %{public}s], pid=%{public}d", | ||
| 18860 | + where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), pid); | ||
| 18861 | + return; | ||
| 18862 | + } | ||
| 18739 | std::vector<NodeId> nodeIds; | 18863 | std::vector<NodeId> nodeIds; |
| 18740 | nodeIds.push_back(surfaceNode->GetId()); | 18864 | nodeIds.push_back(surfaceNode->GetId()); |
| 18741 | - RSInterfaces::GetInstance().ClearSurfaceWatermarkForNodes(pid, watermarkName, nodeIds); | 18865 | + rsInterface->ClearSurfaceWatermarkForNodes(pid, watermarkName, nodeIds); |
| 18742 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: win=[%{public}d, %{public}s], pid=%{public}d, " | 18866 | TLOGNI(WmsLogTag::WMS_ATTRIBUTE, "%{public}s: win=[%{public}d, %{public}s], pid=%{public}d, " |
| 18743 | "watermark=%{public}s", where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), | 18867 | "watermark=%{public}s", where, sceneSession->GetWindowId(), sceneSession->GetWindowName().c_str(), |
| 18744 | pid, watermarkName.c_str()); | 18868 | pid, watermarkName.c_str()); |
| @@ -39,7 +39,7 @@ constexpr DisplayId VIRTUAL_DISPLAY_ID = 999; | |||
| 39 | WSError SceneSessionManagerProxy::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 39 | WSError SceneSessionManagerProxy::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 40 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 40 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 41 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 41 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 42 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token) | 42 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, sptr<IRemoteObject> token) |
| 43 | { | 43 | { |
| 44 | MessageOption option(MessageOption::TF_SYNC); | 44 | MessageOption option(MessageOption::TF_SYNC); |
| 45 | MessageParcel data; | 45 | MessageParcel data; |
| @@ -91,6 +91,12 @@ WSError SceneSessionManagerProxy::CreateAndConnectSpecificSession(const sptr<ISe | |||
| 91 | if (config) { | 91 | if (config) { |
| 92 | systemConfig = *config; | 92 | systemConfig = *config; |
| 93 | } | 93 | } |
| 94 | + sptr<IRemoteObject> renderSessionObject = reply.ReadRemoteObject(); | ||
| 95 | + if (renderSessionObject == nullptr) { | ||
| 96 | + TLOGE(WmsLogTag::WMS_LIFE, "ReadRemoteObject failed"); | ||
| 97 | + return WSError::WS_ERROR_IPC_FAILED; | ||
| 98 | + } | ||
| 99 | + renderSession = renderSessionObject; | ||
| 94 | uint32_t level = 0; | 100 | uint32_t level = 0; |
| 95 | if (!reply.ReadUint32(level)) { | 101 | if (!reply.ReadUint32(level)) { |
| 96 | TLOGE(WmsLogTag::WMS_LIFE, "Read level failed"); | 102 | TLOGE(WmsLogTag::WMS_LIFE, "Read level failed"); |
| @@ -348,14 +348,16 @@ int SceneSessionManagerStub::HandleCreateAndConnectSpecificSession(MessageParcel | |||
| 348 | auto persistentId = INVALID_SESSION_ID; | 348 | auto persistentId = INVALID_SESSION_ID; |
| 349 | sptr<ISession> sceneSession; | 349 | sptr<ISession> sceneSession; |
| 350 | SystemSessionConfig systemConfig; | 350 | SystemSessionConfig systemConfig; |
| 351 | + sptr<IRemoteObject> renderSession; | ||
| 351 | CreateAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, | 352 | CreateAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, |
| 352 | - property, persistentId, sceneSession, systemConfig, token); | 353 | + property, persistentId, sceneSession, systemConfig, renderSession, token); |
| 353 | if (sceneSession== nullptr) { | 354 | if (sceneSession== nullptr) { |
| 354 | return ERR_INVALID_STATE; | 355 | return ERR_INVALID_STATE; |
| 355 | } | 356 | } |
| 356 | reply.WriteInt32(persistentId); | 357 | reply.WriteInt32(persistentId); |
| 357 | reply.WriteRemoteObject(sceneSession->AsObject()); | 358 | reply.WriteRemoteObject(sceneSession->AsObject()); |
| 358 | reply.WriteParcelable(&systemConfig); | 359 | reply.WriteParcelable(&systemConfig); |
| 360 | + reply.WriteRemoteObject(renderSession); | ||
| 359 | reply.WriteUint32(property->GetSubWindowLevel()); | 361 | reply.WriteUint32(property->GetSubWindowLevel()); |
| 360 | reply.WriteUint64(property->GetDisplayId()); | 362 | reply.WriteUint64(property->GetDisplayId()); |
| 361 | reply.WriteUint32(static_cast<uint32_t>(property->GetWindowType())); | 363 | reply.WriteUint32(static_cast<uint32_t>(property->GetWindowType())); |
| @@ -76,7 +76,8 @@ public: | |||
| 76 | (ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus), (override)); | 76 | (ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus), (override)); |
| 77 | MOCK_METHOD(bool, OnExtendDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId), (override)); | 77 | MOCK_METHOD(bool, OnExtendDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId), (override)); |
| 78 | MOCK_METHOD(bool, OnCreateScreenSessionOnly, | 78 | MOCK_METHOD(bool, OnCreateScreenSessionOnly, |
| 79 | - (ScreenId screenId, ScreenId rsId, const std::string& name, bool isExtend), (override)); | 79 | + (ScreenId screenId, ScreenId rsId, const std::string& name, sptr<IRemoteObject> renderSession, |
| 80 | + bool isExtend), (override)); | ||
| 80 | MOCK_METHOD(bool, OnMainDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId), | 81 | MOCK_METHOD(bool, OnMainDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId), |
| 81 | (override)); | 82 | (override)); |
| 82 | MOCK_METHOD(void, SetScreenCombination, | 83 | MOCK_METHOD(void, SetScreenCombination, |
| @@ -53,7 +53,7 @@ int32_t RsMockImpl::SetScreenChangeCallback(const ScreenChangeCallback& callback | |||
| 53 | void RsMockImpl::TriggerScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | 53 | void RsMockImpl::TriggerScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) |
| 54 | { | 54 | { |
| 55 | if (screenChangeCallback_ != nullptr) { | 55 | if (screenChangeCallback_ != nullptr) { |
| 56 | - screenChangeCallback_(screenId, screenEvent, reason); | 56 | + screenChangeCallback_(screenId, screenEvent, reason, nullptr); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -55,7 +55,7 @@ struct EventInfo { | |||
| 55 | std::string description; // the extend description for eventName,e.g."SCENE_APP_START_ANIMATION" | 55 | std::string description; // the extend description for eventName,e.g."SCENE_APP_START_ANIMATION" |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | -using ScreenChangeCallback = std::function<void(ScreenId, ScreenEvent, ScreenChangeReason)>; | 58 | +using ScreenChangeCallback = std::function<void(ScreenId, ScreenEvent, ScreenChangeReason, sptr<IRemoteObject>)>; |
| 59 | using ScreenSwitchingNotifyCallback = std::function<void(bool)>; | 59 | using ScreenSwitchingNotifyCallback = std::function<void(bool)>; |
| 60 | using BrightnessInfoChangeCallback = std::function<void(ScreenId, BrightnessInfo)>; | 60 | using BrightnessInfoChangeCallback = std::function<void(ScreenId, BrightnessInfo)>; |
| 61 | using HgmRefreshRateUpdateCallback = std::function<void(int32_t)>; | 61 | using HgmRefreshRateUpdateCallback = std::function<void(int32_t)>; |
| @@ -0,0 +1,72 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace Rosen { | ||
| 27 | +class RSRenderInterface { | ||
| 28 | + RSRenderInterface(); | ||
| 29 | + ~RSRenderInterface() noexcept; | ||
| 30 | +public: | ||
| 31 | + int32_t SetLogicalCameraRotationCorrection(ScreenId id, ScreenRotation logicalCorrection) | ||
| 32 | + { | ||
| 33 | + return 0; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + int32_t GetBrightnessInfo(ScreenId screenId, BrightnessInfo& brightnessInfo) | ||
| 37 | + { | ||
| 38 | + return 0; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + bool TakeSurfaceCapture(std::shared_ptr<RSSurfaceNode> node, std::shared_ptr<SurfaceCaptureCallback> callback, | ||
| 42 | + RSSurfaceCaptureConfig captureConfig = {}) | ||
| 43 | + { | ||
| 44 | + return false; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + bool TakeSurfaceCapture(std::shared_ptr<RSDisplayNode> node, std::shared_ptr<SurfaceCaptureCallback> callback, | ||
| 48 | + RSSurfaceCaptureConfig captureConfig = {}) | ||
| 49 | + { | ||
| 50 | + return false; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + int32_t GetScreenHDRStatus(ScreenId id, HdrStatus& hdrStatus) | ||
| 54 | + { | ||
| 55 | + return 0; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + bool FreezeScreen(std::shared_ptr<RSDisplayNode> node, bool isFreeze, bool needSync = false) | ||
| 59 | + { | ||
| 60 | + return false; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + bool TakeSurfaceCaptureWithAllWindows(std::shared_ptr<RSDisplayNode> node, | ||
| 64 | + std::shared_ptr<SurfaceCaptureCallback> callback, RSSurfaceCaptureConfig captureConfig, | ||
| 65 | + bool checkDrmAndSurfaceLock) | ||
| 66 | + { | ||
| 67 | + return false; | ||
| 68 | + } | ||
| 69 | +}; | ||
| 70 | +} // namespace Rosen | ||
| 71 | +} // namespace OHOS | ||
| 72 | + | ||
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | + | ||
| 28 | 29 | ||
| 29 | namespace OHOS { | 30 | namespace OHOS { |
| 30 | namespace Rosen { | 31 | namespace Rosen { |
| @@ -65,10 +66,16 @@ public: | |||
| 65 | return nodeMap_; | 66 | return nodeMap_; |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 69 | + std::shared_ptr<RSRenderInterface> GetRSRenderInterface() | ||
| 70 | + { | ||
| 71 | + return rsRenderInterface_; | ||
| 72 | + } | ||
| 73 | + | ||
| 68 | uint64_t token_; | 74 | uint64_t token_; |
| 69 | std::shared_ptr<RSTransactionHandler> rsTransactionHandler_; | 75 | std::shared_ptr<RSTransactionHandler> rsTransactionHandler_; |
| 70 | std::shared_ptr<RSSyncTransactionHandler> rsSyncTransactionHandler_; | 76 | std::shared_ptr<RSSyncTransactionHandler> rsSyncTransactionHandler_; |
| 71 | RSNodeMapV2 nodeMap_; | 77 | RSNodeMapV2 nodeMap_; |
| 78 | + std::shared_ptr<RSRenderInterface> rsRenderInterface_; | ||
| 72 | }; | 79 | }; |
| 73 | 80 | ||
| 74 | } // namespace Rosen | 81 | } // namespace Rosen |
| @@ -19,13 +19,15 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 22 | 23 | ||
| 23 | namespace OHOS { | 24 | namespace OHOS { |
| 24 | namespace Rosen { | 25 | namespace Rosen { |
| 25 | 26 | ||
| 26 | class RSUIDirector final { | 27 | class RSUIDirector final { |
| 27 | public: | 28 | public: |
| 28 | - static std::shared_ptr<RSUIDirector> Create() | 29 | + static std::shared_ptr<RSUIDirector> Create(sptr<IRemoteObject> connectToRenderRemote = nullptr, |
| 30 | + std::shared_ptr<RSUIContext> rsUIContext = nullptr) | ||
| 29 | { | 31 | { |
| 30 | return std::make_shared<RSUIDirector>(); | 32 | return std::make_shared<RSUIDirector>(); |
| 31 | } | 33 | } |
| @@ -32,7 +32,7 @@ public: | |||
| 32 | sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context = nullptr); | 32 | sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context = nullptr); |
| 33 | virtual sptr<Window> CreateWindow(sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context, | 33 | virtual sptr<Window> CreateWindow(sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context, |
| 34 | const sptr<IRemoteObject>& iSession, const std::string& identityToken = "", | 34 | const sptr<IRemoteObject>& iSession, const std::string& identityToken = "", |
| 35 | - bool isModuleAbilityHookEnd = false); | 35 | + bool isModuleAbilityHookEnd = false, sptr<IRemoteObject> renderSession = nullptr); |
| 36 | virtual std::vector<sptr<Window>> GetSubWindow(uint32_t parentId); | 36 | virtual std::vector<sptr<Window>> GetSubWindow(uint32_t parentId); |
| 37 | 37 | ||
| 38 | protected: | 38 | protected: |
| @@ -133,7 +133,7 @@ public: | |||
| 133 | virtual void CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 133 | virtual void CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 134 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 134 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 135 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 135 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 136 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr); | 136 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, sptr<IRemoteObject> token = nullptr); |
| 137 | virtual WMError DestroyAndDisconnectSpecificSession(const int32_t persistentId); | 137 | virtual WMError DestroyAndDisconnectSpecificSession(const int32_t persistentId); |
| 138 | virtual WMError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId, | 138 | virtual WMError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId, |
| 139 | const sptr<IRemoteObject>& callback); | 139 | const sptr<IRemoteObject>& callback); |
| @@ -39,7 +39,7 @@ enum class EnvironmentType { | |||
| 39 | 39 | ||
| 40 | class WindowExtensionSessionImpl : public WindowSessionImpl { | 40 | class WindowExtensionSessionImpl : public WindowSessionImpl { |
| 41 | public: | 41 | public: |
| 42 | - explicit WindowExtensionSessionImpl(const sptr<WindowOption>& option); | 42 | + explicit WindowExtensionSessionImpl(const sptr<WindowOption>& option, sptr<IRemoteObject> renderSession = nullptr); |
| 43 | ~WindowExtensionSessionImpl(); | 43 | ~WindowExtensionSessionImpl(); |
| 44 | 44 | ||
| 45 | WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context, | 45 | WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context, |
| @@ -32,7 +32,7 @@ using OwnSystemBarPropertyPair = std::pair<SystemBarPropertyOwner, PartialSystem | |||
| 32 | class WindowSceneSessionImpl : public WindowSessionImpl { | 32 | class WindowSceneSessionImpl : public WindowSessionImpl { |
| 33 | public: | 33 | public: |
| 34 | explicit WindowSceneSessionImpl(const sptr<WindowOption>& option, | 34 | explicit WindowSceneSessionImpl(const sptr<WindowOption>& option, |
| 35 | - const std::shared_ptr<RSUIContext>& rsUIContext = nullptr); | 35 | + const std::shared_ptr<RSUIContext>& rsUIContext = nullptr, sptr<IRemoteObject> renderSession = nullptr); |
| 36 | ~WindowSceneSessionImpl(); | 36 | ~WindowSceneSessionImpl(); |
| 37 | WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context, | 37 | WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context, |
| 38 | const sptr<Rosen::ISession>& iSession, const std::string& identityToken = "", | 38 | const sptr<Rosen::ISession>& iSession, const std::string& identityToken = "", |
| @@ -401,6 +401,7 @@ public: | |||
| 401 | 401 | ||
| 402 | protected: | 402 | protected: |
| 403 | WMError CreateAndConnectSpecificSession(); | 403 | WMError CreateAndConnectSpecificSession(); |
| 404 | + void PostInitSurfaceNode(sptr<IRemoteObject> renderSession); | ||
| 404 | WMError CreateSystemWindow(WindowType type); | 405 | WMError CreateSystemWindow(WindowType type); |
| 405 | sptr<WindowSessionImpl> FindParentSessionByParentId(uint32_t parentId); | 406 | sptr<WindowSessionImpl> FindParentSessionByParentId(uint32_t parentId); |
| 406 | bool IsSessionMainWindow(uint32_t parentId); | 407 | bool IsSessionMainWindow(uint32_t parentId); |
| @@ -92,7 +92,7 @@ using IKBWillHideListener = IKeyboardWillHideListener; | |||
| 92 | class WindowSessionImpl : public Window, public virtual SessionStageStub { | 92 | class WindowSessionImpl : public Window, public virtual SessionStageStub { |
| 93 | public: | 93 | public: |
| 94 | explicit WindowSessionImpl(const sptr<WindowOption>& option, | 94 | explicit WindowSessionImpl(const sptr<WindowOption>& option, |
| 95 | - const std::shared_ptr<RSUIContext>& rsUIContext = nullptr); | 95 | + const std::shared_ptr<RSUIContext>& rsUIContext = nullptr, sptr<IRemoteObject> renderSession = nullptr); |
| 96 | ~WindowSessionImpl(); | 96 | ~WindowSessionImpl(); |
| 97 | 97 | ||
| 98 | static sptr<Window> Find(const std::string& name); | 98 | static sptr<Window> Find(const std::string& name); |
| @@ -707,6 +707,7 @@ public: | |||
| 707 | WSError UpdateIsShowDecorInFreeMultiWindow(bool isShow) override; | 707 | WSError UpdateIsShowDecorInFreeMultiWindow(bool isShow) override; |
| 708 | 708 | ||
| 709 | protected: | 709 | protected: |
| 710 | + RSSurfaceNodeType GetRSSurfaceNodeType(WindowType type); | ||
| 710 | WMError Connect(); | 711 | WMError Connect(); |
| 711 | bool IsWindowSessionInvalid() const; | 712 | bool IsWindowSessionInvalid() const; |
| 712 | void NotifyWindowAfterUnfocused(); | 713 | void NotifyWindowAfterUnfocused(); |
| @@ -1058,6 +1059,18 @@ protected: | |||
| 1058 | bool isDecorHiddenByApp_ = false; | 1059 | bool isDecorHiddenByApp_ = false; |
| 1059 | bool isMaximizeInvoked_ = false; | 1060 | bool isMaximizeInvoked_ = false; |
| 1060 | 1061 | ||
| 1062 | + /* | ||
| 1063 | + * RS Client Multi Instance | ||
| 1064 | + */ | ||
| 1065 | + std::shared_ptr<RSUIDirector> rsUIDirector_; | ||
| 1066 | + std::shared_ptr<RSUIContext> rsUIContext_; | ||
| 1067 | + | ||
| 1068 | + /** | ||
| 1069 | + * RS Multi Process | ||
| 1070 | + */ | ||
| 1071 | + sptr<IRemoteObject> renderSession_; | ||
| 1072 | + bool needCreateCompleteSurfaceNode_ = false; | ||
| 1073 | + | ||
| 1061 | /** | 1074 | /** |
| 1062 | * Game Prelaunch flag | 1075 | * Game Prelaunch flag |
| 1063 | */ | 1076 | */ |
| @@ -1412,11 +1425,6 @@ private: | |||
| 1412 | void NotifyRotationChangeResult(RotationChangeResult rotationChangeResult) override; | 1425 | void NotifyRotationChangeResult(RotationChangeResult rotationChangeResult) override; |
| 1413 | void NotifyRotationChangeResultInner(const RotationChangeInfo& rotationChangeInfo); | 1426 | void NotifyRotationChangeResultInner(const RotationChangeInfo& rotationChangeInfo); |
| 1414 | DisplayOrientation windowOrientation_ = DisplayOrientation::UNKNOWN; | 1427 | DisplayOrientation windowOrientation_ = DisplayOrientation::UNKNOWN; |
| 1415 | - | ||
| 1416 | - /* | ||
| 1417 | - * RS Client Multi Instance | ||
| 1418 | - */ | ||
| 1419 | - std::shared_ptr<RSUIDirector> rsUIDirector_; | ||
| 1420 | }; | 1428 | }; |
| 1421 | } // namespace Rosen | 1429 | } // namespace Rosen |
| 1422 | } // namespace OHOS | 1430 | } // namespace OHOS |
| @@ -174,9 +174,14 @@ void RootScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configurat | |||
| 174 | continue; | 174 | continue; |
| 175 | } | 175 | } |
| 176 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); | 176 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); |
| 177 | - bool ret = RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark); | 177 | + auto rsUICtx = GetRSUIContext(); |
| 178 | - if (ret == false) { | 178 | + if (rsUICtx == nullptr) { |
| 179 | - TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SetGlobalDarkColorMode fail, colorMode : %{public}s", colorMode.c_str()); | 179 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "no rsUICtx"); |
| 180 | + continue; | ||
| 181 | + } | ||
| 182 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 183 | + bool ret = rsInterface->SetGlobalDarkColorMode(isDark); | ||
| 184 | + TLOGI(WmsLogTag::DEFAULT, "colorMode: %{public}s, ret: %{public}d", colorMode.c_str(), ret); | ||
| 180 | } | 185 | } |
| 181 | } | 186 | } |
| 182 | } | 187 | } |
| @@ -199,9 +204,15 @@ void RootScene::UpdateConfigurationForSpecified(const std::shared_ptr<AppExecFwk | |||
| 199 | GetWindowId(), GetDisplayId()); | 204 | GetWindowId(), GetDisplayId()); |
| 200 | std::string colorMode = configuration->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); | 205 | std::string colorMode = configuration->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); |
| 201 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); | 206 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); |
| 202 | - if (!RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark)) { | 207 | + auto rsUICtx = GetRSUIContext(); |
| 203 | - TLOGE(WmsLogTag::WMS_ATTRIBUTE, "set dark color mode failed, winId: %{public}u, colorMode: %{public}s", | 208 | + if (rsUICtx == nullptr) { |
| 204 | - GetWindowId(), colorMode.c_str()); | 209 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "no rsUICtx"); |
| 210 | + return; | ||
| 211 | + } | ||
| 212 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 213 | + bool ret = rsInterface->SetGlobalDarkColorMode(isDark); | ||
| 214 | + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}u, colorMode: %{public}s, ret: %{public}d", | ||
| 215 | + GetWindowId(), colorMode.c_str(), ret); | ||
| 205 | } | 216 | } |
| 206 | } | 217 | } |
| 207 | 218 | ||
| @@ -168,9 +168,14 @@ void ScreenScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configur | |||
| 168 | } | 168 | } |
| 169 | std::string colorMode = configuration->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); | 169 | std::string colorMode = configuration->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); |
| 170 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); | 170 | bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); |
| 171 | - bool ret = RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark); | 171 | + auto rsUICtx = GetRSUIContext(); |
| 172 | - if (!ret) { | 172 | + if (rsUICtx == nullptr) { |
| 173 | - TLOGI(WmsLogTag::DMS, "SetGlobalDarkColorMode fail with colorMode : %{public}s", colorMode.c_str()); | 173 | + TLOGE(WmsLogTag::DMS, "no rsUICtx"); |
| 174 | + return; | ||
| 175 | + } | ||
| 176 | + if (auto rsInterface = rsUICtx->GetRSRenderInterface()) { | ||
| 177 | + bool ret = rsInterface->SetGlobalDarkColorMode(isDark); | ||
| 178 | + TLOGI(WmsLogTag::DMS, "screen colorMode: %{public}s, ret: %{public}d", colorMode.c_str(), ret); | ||
| 174 | } | 179 | } |
| 175 | } | 180 | } |
| 176 | } | 181 | } |
| @@ -27,10 +27,11 @@ sptr<Window> StaticCall::CreateWindow(const std::string& windowName, | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | sptr<Window> StaticCall::CreateWindow(sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context, | 29 | sptr<Window> StaticCall::CreateWindow(sptr<WindowOption>& option, std::shared_ptr<AbilityRuntime::Context> context, |
| 30 | - const sptr<IRemoteObject>& iSession, const std::string& identityToken, bool isModuleAbilityHookEnd) | 30 | + const sptr<IRemoteObject>& iSession, const std::string& identityToken, bool isModuleAbilityHookEnd, |
| 31 | + sptr<IRemoteObject> renderSession) | ||
| 31 | { | 32 | { |
| 32 | WMError errCode = WMError::WM_OK; | 33 | WMError errCode = WMError::WM_OK; |
| 33 | - return Window::Create(option, context, iSession, errCode, identityToken, isModuleAbilityHookEnd); | 34 | + return Window::Create(option, context, iSession, errCode, identityToken, isModuleAbilityHookEnd, renderSession); |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | std::vector<sptr<Window>> StaticCall::GetSubWindow(uint32_t parentId) | 37 | std::vector<sptr<Window>> StaticCall::GetSubWindow(uint32_t parentId) |
| @@ -27,6 +27,8 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | + | ||
| 31 | + | ||
| 30 | 32 | ||
| 31 | namespace OHOS { | 33 | namespace OHOS { |
| 32 | namespace Rosen { | 34 | namespace Rosen { |
| @@ -37,16 +39,16 @@ constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "Window" | |||
| 37 | static sptr<Window> CreateWindowWithSession(sptr<WindowOption>& option, | 39 | static sptr<Window> CreateWindowWithSession(sptr<WindowOption>& option, |
| 38 | const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, WMError& errCode, | 40 | const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, WMError& errCode, |
| 39 | sptr<ISession> iSession = nullptr, const std::string& identityToken = "", bool isModuleAbilityHookEnd = false, | 41 | sptr<ISession> iSession = nullptr, const std::string& identityToken = "", bool isModuleAbilityHookEnd = false, |
| 40 | - const std::shared_ptr<RSUIContext>& rsUiContext = nullptr) | 42 | + const std::shared_ptr<RSUIContext>& rsUiContext = nullptr, sptr<IRemoteObject> renderSession = nullptr) |
| 41 | { | 43 | { |
| 42 | WLOGFD("in"); | 44 | WLOGFD("in"); |
| 43 | sptr<WindowSessionImpl> windowSessionImpl = nullptr; | 45 | sptr<WindowSessionImpl> windowSessionImpl = nullptr; |
| 44 | auto sessionType = option->GetWindowSessionType(); | 46 | auto sessionType = option->GetWindowSessionType(); |
| 45 | if (sessionType == WindowSessionType::SCENE_SESSION) { | 47 | if (sessionType == WindowSessionType::SCENE_SESSION) { |
| 46 | - windowSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option, rsUiContext); | 48 | + windowSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option, rsUiContext, renderSession); |
| 47 | } else if (sessionType == WindowSessionType::EXTENSION_SESSION) { | 49 | } else if (sessionType == WindowSessionType::EXTENSION_SESSION) { |
| 48 | option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); | 50 | option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); |
| 49 | - windowSessionImpl = sptr<WindowExtensionSessionImpl>::MakeSptr(option); | 51 | + windowSessionImpl = sptr<WindowExtensionSessionImpl>::MakeSptr(option, renderSession); |
| 50 | } | 52 | } |
| 51 | if (windowSessionImpl == nullptr) { | 53 | if (windowSessionImpl == nullptr) { |
| 52 | WLOGFE("malloc windowSessionImpl failed"); | 54 | WLOGFE("malloc windowSessionImpl failed"); |
| @@ -111,7 +113,7 @@ sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& o | |||
| 111 | 113 | ||
| 112 | sptr<Window> Window::Create(sptr<WindowOption>& option, const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, | 114 | sptr<Window> Window::Create(sptr<WindowOption>& option, const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, |
| 113 | const sptr<IRemoteObject>& iSession, WMError& errCode, const std::string& identityToken, | 115 | const sptr<IRemoteObject>& iSession, WMError& errCode, const std::string& identityToken, |
| 114 | - bool isModuleAbilityHookEnd) | 116 | + bool isModuleAbilityHookEnd, sptr<IRemoteObject> renderSession) |
| 115 | { | 117 | { |
| 116 | // create from ability mgr service | 118 | // create from ability mgr service |
| 117 | if (!iSession || !option) { | 119 | if (!iSession || !option) { |
| @@ -138,7 +140,7 @@ sptr<Window> Window::Create(sptr<WindowOption>& option, const std::shared_ptr<OH | |||
| 138 | return nullptr; | 140 | return nullptr; |
| 139 | } | 141 | } |
| 140 | return CreateWindowWithSession(option, context, errCode, | 142 | return CreateWindowWithSession(option, context, errCode, |
| 141 | - iface_cast<Rosen::ISession>(iSession), identityToken, isModuleAbilityHookEnd); | 143 | + iface_cast<Rosen::ISession>(iSession), identityToken, isModuleAbilityHookEnd, nullptr, renderSession); |
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | WMError Window::GetAndVerifyWindowTypeForArkUI(uint32_t parentId, const std::string& windowName, | 146 | WMError Window::GetAndVerifyWindowTypeForArkUI(uint32_t parentId, const std::string& windowName, |
| @@ -1263,14 +1263,14 @@ WMError WindowAdapter::MoveMainWindowToTargetDisplay(DisplayId displayId, int32_ | |||
| 1263 | void WindowAdapter::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 1263 | void WindowAdapter::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 1264 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 1264 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 1265 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 1265 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 1266 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token) | 1266 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, sptr<IRemoteObject> token) |
| 1267 | { | 1267 | { |
| 1268 | INIT_PROXY_CHECK_RETURN(); | 1268 | INIT_PROXY_CHECK_RETURN(); |
| 1269 | 1269 | ||
| 1270 | auto wmsProxy = GetWindowManagerServiceProxy(); | 1270 | auto wmsProxy = GetWindowManagerServiceProxy(); |
| 1271 | CHECK_PROXY_RETURN_IF_NULL(wmsProxy); | 1271 | CHECK_PROXY_RETURN_IF_NULL(wmsProxy); |
| 1272 | wmsProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, | 1272 | wmsProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, |
| 1273 | - surfaceNode, property, persistentId, session, systemConfig, token); | 1273 | + surfaceNode, property, persistentId, session, systemConfig, renderSession, token); |
| 1274 | } | 1274 | } |
| 1275 | 1275 | ||
| 1276 | void WindowAdapter::RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 1276 | void WindowAdapter::RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| @@ -72,7 +72,9 @@ constexpr const char* TRANSPARENT_BACKGROUND_COLOR_HEX = "#00000000"; | |||
| 72 | } \ | 72 | } \ |
| 73 | } while (false) | 73 | } while (false) |
| 74 | 74 | ||
| 75 | -WindowExtensionSessionImpl::WindowExtensionSessionImpl(const sptr<WindowOption>& option) : WindowSessionImpl(option) | 75 | +WindowExtensionSessionImpl::WindowExtensionSessionImpl( |
| 76 | + const sptr<WindowOption>& option, sptr<IRemoteObject> renderSession) | ||
| 77 | + : WindowSessionImpl(option, nullptr, renderSession) | ||
| 76 | { | 78 | { |
| 77 | if (property_->GetUIExtensionUsage() == UIExtensionUsage::MODAL || | 79 | if (property_->GetUIExtensionUsage() == UIExtensionUsage::MODAL || |
| 78 | SessionHelper::IsSecureUIExtension(property_->GetUIExtensionUsage())) { | 80 | SessionHelper::IsSecureUIExtension(property_->GetUIExtensionUsage())) { |
| @@ -1007,6 +1009,7 @@ void WindowExtensionSessionImpl::UpdateRectForRotation(const Rect& wmRect, const | |||
| 1007 | if (needSync) { | 1009 | if (needSync) { |
| 1008 | window->UpdateRotateDuration(wmReason, duration, rsTransaction); | 1010 | window->UpdateRotateDuration(wmReason, duration, rsTransaction); |
| 1009 | RSTransactionAdapter::FlushImplicitTransaction(rsUIContext); | 1011 | RSTransactionAdapter::FlushImplicitTransaction(rsUIContext); |
| 1012 | + RSAdapterUtil::SetRSTransactionHandler(rsTransaction, rsUIContext); | ||
| 1010 | rsTransaction->Begin(); | 1013 | rsTransaction->Begin(); |
| 1011 | } | 1014 | } |
| 1012 | window->rotationAnimationCount_++; | 1015 | window->rotationAnimationCount_++; |
| @@ -147,7 +147,7 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option) | |||
| 147 | } | 147 | } |
| 148 | name_ = option->GetWindowName(); | 148 | name_ = option->GetWindowName(); |
| 149 | 149 | ||
| 150 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true); | 150 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, nullptr, nullptr); |
| 151 | 151 | ||
| 152 | surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), option->GetWindowType()); | 152 | surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), option->GetWindowType()); |
| 153 | if (surfaceNode_ != nullptr) { | 153 | if (surfaceNode_ != nullptr) { |
| @@ -963,11 +963,17 @@ ColorSpace WindowImpl::GetColorSpace() | |||
| 963 | 963 | ||
| 964 | std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot() | 964 | std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot() |
| 965 | { | 965 | { |
| 966 | - if (!IsWindowValid()) { | 966 | + if (!IsWindowValid() || surfaceNode_ == nullptr) { |
| 967 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "invalid window"); | ||
| 967 | return nullptr; | 968 | return nullptr; |
| 968 | } | 969 | } |
| 969 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); | 970 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); |
| 970 | - auto isSucceeded = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode_, callback); | 971 | + auto rsUICtx = surfaceNode_->GetRSUIContext(); |
| 972 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 973 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 974 | + return nullptr; | ||
| 975 | + } | ||
| 976 | + auto isSucceeded = rsUICtx->GetRSRenderInterface()->TakeSurfaceCapture(surfaceNode_, callback); | ||
| 971 | std::shared_ptr<Media::PixelMap> pixelMap; | 977 | std::shared_ptr<Media::PixelMap> pixelMap; |
| 972 | if (isSucceeded) { | 978 | if (isSucceeded) { |
| 973 | pixelMap = callback->GetResult(2000); // wait for <= 2000ms | 979 | pixelMap = callback->GetResult(2000); // wait for <= 2000ms |
| @@ -91,7 +91,7 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRunt | |||
| 91 | 91 | ||
| 92 | WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context, | 92 | WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context, |
| 93 | sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option, const sptr<IRemoteObject>& iSession, | 93 | sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option, const sptr<IRemoteObject>& iSession, |
| 94 | - const std::string& identityToken, bool isModuleAbilityHookEnd) | 94 | + const std::string& identityToken, bool isModuleAbilityHookEnd, sptr<IRemoteObject> renderSession) |
| 95 | { | 95 | { |
| 96 | TLOGI(WmsLogTag::WMS_MAIN, "WindowScene with window session!"); | 96 | TLOGI(WmsLogTag::WMS_MAIN, "WindowScene with window session!"); |
| 97 | if (option == nullptr || iSession == nullptr) { | 97 | if (option == nullptr || iSession == nullptr) { |
| @@ -108,7 +108,7 @@ WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRunt | |||
| 108 | SingletonContainer::Get<WindowManager>().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); | 108 | SingletonContainer::Get<WindowManager>().IsModuleHookOff(isModuleAbilityHookEnd, moduleName); |
| 109 | } | 109 | } |
| 110 | auto mainWindow = SingletonContainer::Get<StaticCall>() | 110 | auto mainWindow = SingletonContainer::Get<StaticCall>() |
| 111 | - .CreateWindow(option, context, iSession, identityToken, isModuleAbilityHookEnd); | 111 | + .CreateWindow(option, context, iSession, identityToken, isModuleAbilityHookEnd, renderSession); |
| 112 | if (mainWindow == nullptr) { | 112 | if (mainWindow == nullptr) { |
| 113 | TLOGE(WmsLogTag::WMS_MAIN, "mainWindow is null after create Window!"); | 113 | TLOGE(WmsLogTag::WMS_MAIN, "mainWindow is null after create Window!"); |
| 114 | return WMError::WM_ERROR_NULLPTR; | 114 | return WMError::WM_ERROR_NULLPTR; |
| @@ -280,7 +280,8 @@ std::mutex WindowSceneSessionImpl::windowAttachStateChangeListenerMutex_; | |||
| 280 | std::atomic<bool> WindowSceneSessionImpl::hasSentCombinedCompatibleConfig_ = false; | 280 | std::atomic<bool> WindowSceneSessionImpl::hasSentCombinedCompatibleConfig_ = false; |
| 281 | 281 | ||
| 282 | WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr<WindowOption>& option, | 282 | WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr<WindowOption>& option, |
| 283 | - const std::shared_ptr<RSUIContext>& rsUIContext) : WindowSessionImpl(option, rsUIContext) | 283 | + const std::shared_ptr<RSUIContext>& rsUIContext, sptr<IRemoteObject> renderSession) |
| 284 | + : WindowSessionImpl(option, rsUIContext, renderSession) | ||
| 284 | { | 285 | { |
| 285 | WLOGFI("[WMSCom] Constructor %{public}s", GetWindowName().c_str()); | 286 | WLOGFI("[WMSCom] Constructor %{public}s", GetWindowName().c_str()); |
| 286 | } | 287 | } |
| @@ -455,6 +456,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 455 | sptr<IWindowEventChannel> eventChannel = sptr<WindowEventChannel>::MakeSptr(iSessionStage); | 456 | sptr<IWindowEventChannel> eventChannel = sptr<WindowEventChannel>::MakeSptr(iSessionStage); |
| 456 | auto persistentId = INVALID_SESSION_ID; | 457 | auto persistentId = INVALID_SESSION_ID; |
| 457 | sptr<Rosen::ISession> session; | 458 | sptr<Rosen::ISession> session; |
| 459 | + sptr<IRemoteObject> renderSession; | ||
| 458 | auto context = GetContext(); | 460 | auto context = GetContext(); |
| 459 | sptr<IRemoteObject> token = context ? context->GetToken() : nullptr; | 461 | sptr<IRemoteObject> token = context ? context->GetToken() : nullptr; |
| 460 | if (token) { | 462 | if (token) { |
| @@ -471,7 +473,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 471 | property_->SetIsUIExtensionAbilityProcess(isUIExtensionAbilityProcess_); | 473 | property_->SetIsUIExtensionAbilityProcess(isUIExtensionAbilityProcess_); |
| 472 | // create sub session by parent session | 474 | // create sub session by parent session |
| 473 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, | 475 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, |
| 474 | - surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); | 476 | + surfaceNode_, property_, persistentId, session, windowSystemConfig_, renderSession, token); |
| 475 | if (!hasToastFlag) { | 477 | if (!hasToastFlag) { |
| 476 | AddSubWindowMapForExtensionWindow(); | 478 | AddSubWindowMapForExtensionWindow(); |
| 477 | } | 479 | } |
| @@ -489,7 +491,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 489 | property_->SetIsPcAppInPad(crossProcessWindowInfo.isPcAppInPad); | 491 | property_->SetIsPcAppInPad(crossProcessWindowInfo.isPcAppInPad); |
| 490 | property_->SetPcAppInpadCompatibleMode(crossProcessWindowInfo.isPcAppInpadCompatibleMode); | 492 | property_->SetPcAppInpadCompatibleMode(crossProcessWindowInfo.isPcAppInpadCompatibleMode); |
| 491 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, | 493 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, |
| 492 | - surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); | 494 | + surfaceNode_, property_, persistentId, session, windowSystemConfig_, renderSession, token); |
| 493 | } else { | 495 | } else { |
| 494 | sptr<WindowSessionImpl> parentSession = nullptr; | 496 | sptr<WindowSessionImpl> parentSession = nullptr; |
| 495 | auto ret = WindowSceneSessionImpl::GetParentSessionAndVerify(hasToastFlag, parentSession); | 497 | auto ret = WindowSceneSessionImpl::GetParentSessionAndVerify(hasToastFlag, parentSession); |
| @@ -504,7 +506,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 504 | property_->SetPcAppInpadCompatibleMode(parentSession->GetProperty()->GetPcAppInpadCompatibleMode()); | 506 | property_->SetPcAppInpadCompatibleMode(parentSession->GetProperty()->GetPcAppInpadCompatibleMode()); |
| 505 | // creat sub session by parent session | 507 | // creat sub session by parent session |
| 506 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, | 508 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, |
| 507 | - surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); | 509 | + surfaceNode_, property_, persistentId, session, windowSystemConfig_, renderSession, token); |
| 508 | { | 510 | { |
| 509 | std::lock_guard<std::recursive_mutex> lock(subWindowSessionMutex_); | 511 | std::lock_guard<std::recursive_mutex> lock(subWindowSessionMutex_); |
| 510 | // update subWindowSessionMap_ | 512 | // update subWindowSessionMap_ |
| @@ -523,7 +525,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 523 | } | 525 | } |
| 524 | PreProcessCreate(); | 526 | PreProcessCreate(); |
| 525 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, | 527 | SingletonContainer::Get<WindowAdapter>().CreateAndConnectSpecificSession(iSessionStage, eventChannel, |
| 526 | - surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); | 528 | + surfaceNode_, property_, persistentId, session, windowSystemConfig_, renderSession, token); |
| 527 | } | 529 | } |
| 528 | property_->SetPersistentId(persistentId); | 530 | property_->SetPersistentId(persistentId); |
| 529 | if (session == nullptr) { | 531 | if (session == nullptr) { |
| @@ -533,6 +535,12 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 533 | WMErrorReason::WM_REASON_SUB_WINDOW_IPC_CREATE_ERR, "sub window create failed when ipc"); | 535 | WMErrorReason::WM_REASON_SUB_WINDOW_IPC_CREATE_ERR, "sub window create failed when ipc"); |
| 534 | return WMError::WM_ERROR_NULLPTR; | 536 | return WMError::WM_ERROR_NULLPTR; |
| 535 | } | 537 | } |
| 538 | + if (renderSession == nullptr) { | ||
| 539 | + TLOGI(WmsLogTag::WMS_LIFE, "create specific failed, renderSession is nullptr, name: %{public}s", | ||
| 540 | + property_->GetWindowName().c_str()); | ||
| 541 | + return WMError::WM_ERROR_NULLPTR; | ||
| 542 | + } | ||
| 543 | + PostInitSurfaceNode(renderSession); | ||
| 536 | { | 544 | { |
| 537 | std::lock_guard<std::mutex> lock(hostSessionMutex_); | 545 | std::lock_guard<std::mutex> lock(hostSessionMutex_); |
| 538 | hostSession_ = session; | 546 | hostSession_ = session; |
| @@ -544,6 +552,19 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() | |||
| 544 | return WMError::WM_OK; | 552 | return WMError::WM_OK; |
| 545 | } | 553 | } |
| 546 | 554 | ||
| 555 | +void WindowSceneSessionImpl::PostInitSurfaceNode(sptr<IRemoteObject> renderSession) | ||
| 556 | +{ | ||
| 557 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession, rsUIContext_); | ||
| 558 | + auto rsUIContext = rsUIDirector_->GetRSUIContext(); | ||
| 559 | + surfaceNode_->SetRSUIContext(rsUIContext); | ||
| 560 | + | ||
| 561 | + struct RSSurfaceNodeConfig rsSurfaceNodeConfig; | ||
| 562 | + rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName(); | ||
| 563 | + RSSurfaceNodeType rsSurfaceNodeType = GetRSSurfaceNodeType(property_->GetWindowType()); | ||
| 564 | + surfaceNode_->SendDataToRender(rsSurfaceNodeConfig, rsSurfaceNodeType, true, property_->IsConstrainedModal()); | ||
| 565 | + TLOGI(WmsLogTag::WMS_LIFE, "post init surfaceNode success, name: %{public}s", property_->GetWindowName().c_str()); | ||
| 566 | +} | ||
| 567 | + | ||
| 547 | WMError WindowSceneSessionImpl::CreateSystemWindow(WindowType type) | 568 | WMError WindowSceneSessionImpl::CreateSystemWindow(WindowType type) |
| 548 | { | 569 | { |
| 549 | if (WindowHelper::IsAppFloatingWindow(type) || WindowHelper::IsPipWindow(type) || | 570 | if (WindowHelper::IsAppFloatingWindow(type) || WindowHelper::IsPipWindow(type) || |
| @@ -331,11 +331,13 @@ bool WindowSessionImpl::isUIExtensionAbilityProcess_ = false; | |||
| 331 | } while (false) | 331 | } while (false) |
| 332 | 332 | ||
| 333 | WindowSessionImpl::WindowSessionImpl(const sptr<WindowOption>& option, | 333 | WindowSessionImpl::WindowSessionImpl(const sptr<WindowOption>& option, |
| 334 | - const std::shared_ptr<RSUIContext>& rsUIContext) | 334 | + const std::shared_ptr<RSUIContext>& rsUIContext, sptr<IRemoteObject> renderSession) |
| 335 | { | 335 | { |
| 336 | WLOGFD("[WMSCom] Constructor"); | 336 | WLOGFD("[WMSCom] Constructor"); |
| 337 | property_ = sptr<WindowSessionProperty>::MakeSptr(); | 337 | property_ = sptr<WindowSessionProperty>::MakeSptr(); |
| 338 | windowOption_ = option; | 338 | windowOption_ = option; |
| 339 | + rsUIContext_ = rsUIContext; | ||
| 340 | + renderSession_ = renderSession; | ||
| 339 | handler_ = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner()); | 341 | handler_ = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner()); |
| 340 | 342 | ||
| 341 | WindowType optionWindowType = option->GetWindowType(); | 343 | WindowType optionWindowType = option->GetWindowType(); |
| @@ -347,11 +349,20 @@ WindowSessionImpl::WindowSessionImpl(const sptr<WindowOption>& option, | |||
| 347 | isIgnoreSafeArea_ = WindowHelper::IsSubWindow(optionWindowType); | 349 | isIgnoreSafeArea_ = WindowHelper::IsSubWindow(optionWindowType); |
| 348 | followCreatorLifecycle_ = option->IsFollowCreatorLifecycle(); | 350 | followCreatorLifecycle_ = option->IsFollowCreatorLifecycle(); |
| 349 | 351 | ||
| 350 | - RSAdapterUtil::InitRSUIDirector(rsUIDirector_, true, true, rsUIContext); | ||
| 351 | if (WindowHelper::IsSubWindow(GetType())) { | 352 | if (WindowHelper::IsSubWindow(GetType())) { |
| 352 | property_->SetDecorEnable(option->GetSubWindowDecorEnable()); | 353 | property_->SetDecorEnable(option->GetSubWindowDecorEnable()); |
| 353 | } | 354 | } |
| 354 | - surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), optionWindowType); | 355 | + TLOGD(WmsLogTag::WMS_LIFE, "renderSession is %{public}p", renderSession.GetRefPtr()); |
| 356 | + if (IsSceneBoardEnabled()) { | ||
| 357 | + if (renderSession) { | ||
| 358 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession, rsUIContext); | ||
| 359 | + } | ||
| 360 | + surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), optionWindowType); | ||
| 361 | + } else { | ||
| 362 | + needCreateCompleteSurfaceNode_ = true; | ||
| 363 | + RSAdapterUtil::InitRSUIDirector(rsUIDirector_, renderSession, rsUIContext); | ||
| 364 | + surfaceNode_ = CreateSurfaceNode(property_->GetWindowName(), optionWindowType); | ||
| 365 | + } | ||
| 355 | if (surfaceNode_ != nullptr) { | 366 | if (surfaceNode_ != nullptr) { |
| 356 | vsyncStation_ = std::make_shared<VsyncStation>(surfaceNode_->GetId()); | 367 | vsyncStation_ = std::make_shared<VsyncStation>(surfaceNode_->GetId()); |
| 357 | } | 368 | } |
| @@ -514,10 +525,8 @@ void WindowSessionImpl::SetSubWindowZLevelToProperty() | |||
| 514 | } | 525 | } |
| 515 | } | 526 | } |
| 516 | 527 | ||
| 517 | -RSSurfaceNode::SharedPtr WindowSessionImpl::CreateSurfaceNode(const std::string& name, WindowType type) | 528 | +RSSurfaceNodeType WindowSessionImpl::GetRSSurfaceNodeType(WindowType type) |
| 518 | { | 529 | { |
| 519 | - struct RSSurfaceNodeConfig rsSurfaceNodeConfig; | ||
| 520 | - rsSurfaceNodeConfig.SurfaceNodeName = name; | ||
| 521 | RSSurfaceNodeType rsSurfaceNodeType = RSSurfaceNodeType::DEFAULT; | 530 | RSSurfaceNodeType rsSurfaceNodeType = RSSurfaceNodeType::DEFAULT; |
| 522 | switch (type) { | 531 | switch (type) { |
| 523 | case WindowType::WINDOW_TYPE_BOOT_ANIMATION: | 532 | case WindowType::WINDOW_TYPE_BOOT_ANIMATION: |
| @@ -545,11 +554,22 @@ RSSurfaceNode::SharedPtr WindowSessionImpl::CreateSurfaceNode(const std::string& | |||
| 545 | rsSurfaceNodeType = RSSurfaceNodeType::DEFAULT; | 554 | rsSurfaceNodeType = RSSurfaceNodeType::DEFAULT; |
| 546 | break; | 555 | break; |
| 547 | } | 556 | } |
| 548 | - auto surfaceNode = RSSurfaceNode::Create( | 557 | + return rsSurfaceNodeType; |
| 549 | - rsSurfaceNodeConfig, rsSurfaceNodeType, true, property_->IsConstrainedModal(), GetRSUIContext()); | 558 | +} |
| 550 | - RSAdapterUtil::SetSkipCheckInMultiInstance(surfaceNode, true); | 559 | + |
| 551 | - TLOGD(WmsLogTag::WMS_SCB, "Create RSSurfaceNode: %{public}s, name: %{public}s", | 560 | +RSSurfaceNode::SharedPtr WindowSessionImpl::CreateSurfaceNode(const std::string& name, WindowType type) |
| 552 | - RSAdapterUtil::RSNodeToStr(surfaceNode).c_str(), name.c_str()); | 561 | +{ |
| 562 | + struct RSSurfaceNodeConfig rsSurfaceNodeConfig; | ||
| 563 | + rsSurfaceNodeConfig.SurfaceNodeName = name; | ||
| 564 | + RSSurfaceNodeType rsSurfaceNodeType = GetRSSurfaceNodeType(type); | ||
| 565 | + auto surfaceNode = (renderSession_ || needCreateCompleteSurfaceNode_) ? RSSurfaceNode::Create(rsSurfaceNodeConfig, | ||
| 566 | + rsSurfaceNodeType, true, property_->IsConstrainedModal(), GetRSUIContext()) | ||
| 567 | + : RSSurfaceNode::CreateSurfaceNode(rsSurfaceNodeConfig, true); | ||
| 568 | + if (renderSession_ || needCreateCompleteSurfaceNode_) { | ||
| 569 | + RSAdapterUtil::SetSkipCheckInMultiInstance(surfaceNode, true); | ||
| 570 | + } | ||
| 571 | + TLOGI(WmsLogTag::WMS_SCB, "Create RSSurfaceNode: %{public}s, name: %{public}s", | ||
| 572 | + RSAdapterUtil::RSNodeToStr(surfaceNode).c_str(), name.c_str()); | ||
| 553 | return surfaceNode; | 573 | return surfaceNode; |
| 554 | } | 574 | } |
| 555 | 575 | ||
| @@ -1517,6 +1537,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& | |||
| 1517 | bool ifNeedCommitRsTransaction = window->CheckIfNeedCommitRsTransaction(wmReason); | 1537 | bool ifNeedCommitRsTransaction = window->CheckIfNeedCommitRsTransaction(wmReason); |
| 1518 | if (rsTransaction && ifNeedCommitRsTransaction) { | 1538 | if (rsTransaction && ifNeedCommitRsTransaction) { |
| 1519 | RSTransactionAdapter::FlushImplicitTransaction(window->GetRSUIContext()); | 1539 | RSTransactionAdapter::FlushImplicitTransaction(window->GetRSUIContext()); |
| 1540 | + RSAdapterUtil::SetRSTransactionHandler(rsTransaction, window->GetRSUIContext()); | ||
| 1520 | rsTransaction->Begin(); | 1541 | rsTransaction->Begin(); |
| 1521 | } | 1542 | } |
| 1522 | if (wmReason == WindowSizeChangeReason::DRAG) { | 1543 | if (wmReason == WindowSizeChangeReason::DRAG) { |
| @@ -4058,8 +4079,22 @@ std::shared_ptr<Media::PixelMap> WindowSessionImpl::Snapshot() | |||
| 4058 | if (IsWindowSessionInvalid()) { | 4079 | if (IsWindowSessionInvalid()) { |
| 4059 | return nullptr; | 4080 | return nullptr; |
| 4060 | } | 4081 | } |
| 4082 | + if (surfaceNode_ == nullptr) { | ||
| 4083 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "surfaceNode is null"); | ||
| 4084 | + return nullptr; | ||
| 4085 | + } | ||
| 4086 | + auto rsUICtx = surfaceNode_->GetRSUIContext(); | ||
| 4087 | + if (rsUICtx == nullptr) { | ||
| 4088 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 4089 | + return nullptr; | ||
| 4090 | + } | ||
| 4091 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 4092 | + if (rsInterface == nullptr) { | ||
| 4093 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsInterface is null"); | ||
| 4094 | + return nullptr; | ||
| 4095 | + } | ||
| 4061 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); | 4096 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); |
| 4062 | - auto isSucceeded = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode_, callback); | 4097 | + auto isSucceeded = rsInterface->TakeSurfaceCapture(surfaceNode_, callback); |
| 4063 | if (!isSucceeded) { | 4098 | if (!isSucceeded) { |
| 4064 | WLOGFE("Failed to TakeSurfaceCapture!"); | 4099 | WLOGFE("Failed to TakeSurfaceCapture!"); |
| 4065 | return nullptr; | 4100 | return nullptr; |
| @@ -4083,8 +4118,22 @@ WMError WindowSessionImpl::Snapshot(std::shared_ptr<Media::PixelMap>& pixelMap) | |||
| 4083 | GetPersistentId(), state_); | 4118 | GetPersistentId(), state_); |
| 4084 | return WMError::WM_ERROR_INVALID_WINDOW; | 4119 | return WMError::WM_ERROR_INVALID_WINDOW; |
| 4085 | } | 4120 | } |
| 4121 | + if (surfaceNode_ == nullptr) { | ||
| 4122 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "surfaceNode is null"); | ||
| 4123 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4124 | + } | ||
| 4125 | + auto rsUICtx = surfaceNode_->GetRSUIContext(); | ||
| 4126 | + if (rsUICtx == nullptr) { | ||
| 4127 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 4128 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4129 | + } | ||
| 4130 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 4131 | + if (rsInterface == nullptr) { | ||
| 4132 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsInterface is null"); | ||
| 4133 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4134 | + } | ||
| 4086 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); | 4135 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); |
| 4087 | - auto isSucceeded = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode_, callback); | 4136 | + auto isSucceeded = rsInterface->TakeSurfaceCapture(surfaceNode_, callback); |
| 4088 | if (!isSucceeded) { | 4137 | if (!isSucceeded) { |
| 4089 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, Failed to TakeSurfaceCapture", GetPersistentId()); | 4138 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "winId: %{public}d, Failed to TakeSurfaceCapture", GetPersistentId()); |
| 4090 | return WMError::WM_ERROR_INVALID_OPERATION; | 4139 | return WMError::WM_ERROR_INVALID_OPERATION; |
| @@ -4104,8 +4153,22 @@ WMError WindowSessionImpl::SnapshotIgnorePrivacy(std::shared_ptr<Media::PixelMap | |||
| 4104 | if (IsWindowSessionInvalid()) { | 4153 | if (IsWindowSessionInvalid()) { |
| 4105 | return WMError::WM_ERROR_INVALID_WINDOW; | 4154 | return WMError::WM_ERROR_INVALID_WINDOW; |
| 4106 | } | 4155 | } |
| 4156 | + if (surfaceNode_ == nullptr) { | ||
| 4157 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "surfaceNode is null"); | ||
| 4158 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4159 | + } | ||
| 4160 | + auto rsUICtx = surfaceNode_->GetRSUIContext(); | ||
| 4161 | + if (rsUICtx == nullptr) { | ||
| 4162 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 4163 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4164 | + } | ||
| 4165 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 4166 | + if (rsInterface == nullptr) { | ||
| 4167 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsInterface is null"); | ||
| 4168 | + return WMError::WM_ERROR_INVALID_WINDOW; | ||
| 4169 | + } | ||
| 4107 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); | 4170 | std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>(); |
| 4108 | - auto isSucceeded = RSInterfaces::GetInstance().TakeSelfSurfaceCapture(surfaceNode_, callback); | 4171 | + auto isSucceeded = rsInterface->TakeSelfSurfaceCapture(surfaceNode_, callback); |
| 4109 | if (!isSucceeded) { | 4172 | if (!isSucceeded) { |
| 4110 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowId:%{public}u, Failed to TakeSelfSurfaceCapture!", GetWindowId()); | 4173 | TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowId:%{public}u, Failed to TakeSelfSurfaceCapture!", GetWindowId()); |
| 4111 | return WMError::WM_ERROR_INVALID_OPERATION; | 4174 | return WMError::WM_ERROR_INVALID_OPERATION; |
| @@ -8145,6 +8208,9 @@ void WindowSessionImpl::NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo | |||
| 8145 | } | 8208 | } |
| 8146 | if (rsTransaction) { | 8209 | if (rsTransaction) { |
| 8147 | RSTransactionAdapter::FlushImplicitTransaction(window->GetRSUIContext()); | 8210 | RSTransactionAdapter::FlushImplicitTransaction(window->GetRSUIContext()); |
| 8211 | + if(auto rsUIContext = window->GetRSUIContext()){ | ||
| 8212 | + rsTransaction->SetTransactionHandler(rsUIContext->GetRSTransaction()); | ||
| 8213 | + } | ||
| 8148 | rsTransaction->Begin(); | 8214 | rsTransaction->Begin(); |
| 8149 | } | 8215 | } |
| 8150 | window->NotifyOccupiedAreaChangeInfoInner(info); | 8216 | window->NotifyOccupiedAreaChangeInfoInner(info); |
| @@ -8310,7 +8376,8 @@ void WindowSessionImpl::NotifyKeyboardAnimationWillBegin(const KeyboardAnimation | |||
| 8310 | } | 8376 | } |
| 8311 | 8377 | ||
| 8312 | if (rsTransaction != nullptr) { | 8378 | if (rsTransaction != nullptr) { |
| 8313 | - RSTransaction::FlushImplicitTransaction(); | 8379 | + RSTransactionAdapter::FlushImplicitTransaction(window->GetRSUIContext()); |
| 8380 | + RSAdapterUtil::SetRSTransactionHandler(rsTransaction, window->GetRSUIContext()); | ||
| 8314 | rsTransaction->Begin(); | 8381 | rsTransaction->Begin(); |
| 8315 | } | 8382 | } |
| 8316 | if (keyboardAnimationInfo.isShow) { | 8383 | if (keyboardAnimationInfo.isShow) { |
| @@ -1253,6 +1253,107 @@ HWTEST_F(WindowSceneSessionImplTest6, ApplyForcibleLimitsMinAlreadySmaller, Test | |||
| 1253 | EXPECT_EQ(vp.minHeight_, 0); | 1253 | EXPECT_EQ(vp.minHeight_, 0); |
| 1254 | } | 1254 | } |
| 1255 | 1255 | ||
| 1256 | +/** | ||
| 1257 | + * @tc.name: PostInitSurfaceNode01 | ||
| 1258 | + * @tc.desc: Test PostInitSurfaceNode with null renderSession | ||
| 1259 | + * @tc.type: FUNC | ||
| 1260 | + */ | ||
| 1261 | +HWTEST_F(WindowSceneSessionImplTest6, PostInitSurfaceNode01, TestSize.Level1) | ||
| 1262 | +{ | ||
| 1263 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 1264 | + option->SetWindowName("PostInitSurfaceNode01"); | ||
| 1265 | + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); | ||
| 1266 | + sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option); | ||
| 1267 | + ASSERT_NE(window, nullptr); | ||
| 1268 | + ASSERT_NE(window->property_, nullptr); | ||
| 1269 | + ASSERT_NE(window->surfaceNode_, nullptr); | ||
| 1270 | + | ||
| 1271 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 1272 | + window->PostInitSurfaceNode(renderSession); | ||
| 1273 | + EXPECT_NE(window->rsUIDirector_, nullptr); | ||
| 1274 | +} | ||
| 1275 | + | ||
| 1276 | +/** | ||
| 1277 | + * @tc.name: PostInitSurfaceNode02 | ||
| 1278 | + * @tc.desc: Test PostInitSurfaceNode with APP_MAIN_WINDOW type | ||
| 1279 | + * @tc.type: FUNC | ||
| 1280 | + */ | ||
| 1281 | +HWTEST_F(WindowSceneSessionImplTest6, PostInitSurfaceNode02, TestSize.Level1) | ||
| 1282 | +{ | ||
| 1283 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 1284 | + option->SetWindowName("PostInitSurfaceNode02"); | ||
| 1285 | + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); | ||
| 1286 | + sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option); | ||
| 1287 | + ASSERT_NE(window, nullptr); | ||
| 1288 | + ASSERT_NE(window->property_, nullptr); | ||
| 1289 | + ASSERT_NE(window->surfaceNode_, nullptr); | ||
| 1290 | + | ||
| 1291 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 1292 | + window->PostInitSurfaceNode(renderSession); | ||
| 1293 | + EXPECT_NE(window->rsUIDirector_, nullptr); | ||
| 1294 | +} | ||
| 1295 | + | ||
| 1296 | +/** | ||
| 1297 | + * @tc.name: PostInitSurfaceNode03 | ||
| 1298 | + * @tc.desc: Test PostInitSurfaceNode with PIP window type | ||
| 1299 | + * @tc.type: FUNC | ||
| 1300 | + */ | ||
| 1301 | +HWTEST_F(WindowSceneSessionImplTest6, PostInitSurfaceNode03, TestSize.Level1) | ||
| 1302 | +{ | ||
| 1303 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 1304 | + option->SetWindowName("PostInitSurfaceNode03"); | ||
| 1305 | + option->SetWindowType(WindowType::WINDOW_TYPE_PIP); | ||
| 1306 | + sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option); | ||
| 1307 | + ASSERT_NE(window, nullptr); | ||
| 1308 | + ASSERT_NE(window->property_, nullptr); | ||
| 1309 | + ASSERT_NE(window->surfaceNode_, nullptr); | ||
| 1310 | + | ||
| 1311 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 1312 | + window->PostInitSurfaceNode(renderSession); | ||
| 1313 | + EXPECT_NE(window->rsUIDirector_, nullptr); | ||
| 1314 | +} | ||
| 1315 | + | ||
| 1316 | +/** | ||
| 1317 | + * @tc.name: PostInitSurfaceNode04 | ||
| 1318 | + * @tc.desc: Test PostInitSurfaceNode with BOOT_ANIMATION type | ||
| 1319 | + * @tc.type: FUNC | ||
| 1320 | + */ | ||
| 1321 | +HWTEST_F(WindowSceneSessionImplTest6, PostInitSurfaceNode04, TestSize.Level1) | ||
| 1322 | +{ | ||
| 1323 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 1324 | + option->SetWindowName("PostInitSurfaceNode04"); | ||
| 1325 | + option->SetWindowType(WindowType::WINDOW_TYPE_BOOT_ANIMATION); | ||
| 1326 | + sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option); | ||
| 1327 | + ASSERT_NE(window, nullptr); | ||
| 1328 | + ASSERT_NE(window->property_, nullptr); | ||
| 1329 | + ASSERT_NE(window->surfaceNode_, nullptr); | ||
| 1330 | + | ||
| 1331 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 1332 | + window->PostInitSurfaceNode(renderSession); | ||
| 1333 | + EXPECT_NE(window->rsUIDirector_, nullptr); | ||
| 1334 | +} | ||
| 1335 | + | ||
| 1336 | +/** | ||
| 1337 | + * @tc.name: PostInitSurfaceNode05 | ||
| 1338 | + * @tc.desc: Test PostInitSurfaceNode with UI_EXTENSION type | ||
| 1339 | + * @tc.type: FUNC | ||
| 1340 | + */ | ||
| 1341 | +HWTEST_F(WindowSceneSessionImplTest6, PostInitSurfaceNode05, TestSize.Level1) | ||
| 1342 | +{ | ||
| 1343 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 1344 | + option->SetWindowName("PostInitSurfaceNode05"); | ||
| 1345 | + option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 1346 | + sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option); | ||
| 1347 | + ASSERT_NE(window, nullptr); | ||
| 1348 | + ASSERT_NE(window->property_, nullptr); | ||
| 1349 | + ASSERT_NE(window->surfaceNode_, nullptr); | ||
| 1350 | + | ||
| 1351 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::MODAL); | ||
| 1352 | + sptr<IRemoteObject> renderSession = nullptr; | ||
| 1353 | + window->PostInitSurfaceNode(renderSession); | ||
| 1354 | + EXPECT_NE(window->rsUIDirector_, nullptr); | ||
| 1355 | +} | ||
| 1356 | + | ||
| 1256 | /** | 1357 | /** |
| 1257 | * @tc.name: ConfigDockAutoHide | 1358 | * @tc.name: ConfigDockAutoHide |
| 1258 | * @tc.desc: ConfigDockAutoHide | 1359 | * @tc.desc: ConfigDockAutoHide |
| @@ -2784,6 +2784,276 @@ HWTEST_F(WindowSessionImplTest5, WindowStatusToString, TestSize.Level1) | |||
| 2784 | EXPECT_EQ(WindowSessionImpl::WindowStatusToString(invalidStatus), "UNKNOWN"); | 2784 | EXPECT_EQ(WindowSessionImpl::WindowStatusToString(invalidStatus), "UNKNOWN"); |
| 2785 | } | 2785 | } |
| 2786 | 2786 | ||
| 2787 | +/** | ||
| 2788 | + * @tc.name: GetRSSurfaceNodeType01 | ||
| 2789 | + * @tc.desc: Test GetRSSurfaceNodeType with BOOT_ANIMATION type | ||
| 2790 | + * @tc.type: FUNC | ||
| 2791 | + */ | ||
| 2792 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType01, TestSize.Level1) | ||
| 2793 | +{ | ||
| 2794 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2795 | + option->SetWindowName("GetRSSurfaceNodeType01"); | ||
| 2796 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2797 | + ASSERT_NE(window, nullptr); | ||
| 2798 | + | ||
| 2799 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_BOOT_ANIMATION); | ||
| 2800 | + EXPECT_EQ(result, RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE); | ||
| 2801 | +} | ||
| 2802 | + | ||
| 2803 | +/** | ||
| 2804 | + * @tc.name: GetRSSurfaceNodeType02 | ||
| 2805 | + * @tc.desc: Test GetRSSurfaceNodeType with POINTER type | ||
| 2806 | + * @tc.type: FUNC | ||
| 2807 | + */ | ||
| 2808 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType02, TestSize.Level1) | ||
| 2809 | +{ | ||
| 2810 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2811 | + option->SetWindowName("GetRSSurfaceNodeType02"); | ||
| 2812 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2813 | + ASSERT_NE(window, nullptr); | ||
| 2814 | + | ||
| 2815 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_POINTER); | ||
| 2816 | + EXPECT_EQ(result, RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE); | ||
| 2817 | +} | ||
| 2818 | + | ||
| 2819 | +/** | ||
| 2820 | + * @tc.name: GetRSSurfaceNodeType03 | ||
| 2821 | + * @tc.desc: Test GetRSSurfaceNodeType with APP_MAIN_WINDOW type | ||
| 2822 | + * @tc.type: FUNC | ||
| 2823 | + */ | ||
| 2824 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType03, TestSize.Level1) | ||
| 2825 | +{ | ||
| 2826 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2827 | + option->SetWindowName("GetRSSurfaceNodeType03"); | ||
| 2828 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2829 | + ASSERT_NE(window, nullptr); | ||
| 2830 | + | ||
| 2831 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); | ||
| 2832 | + EXPECT_EQ(result, RSSurfaceNodeType::APP_WINDOW_NODE); | ||
| 2833 | +} | ||
| 2834 | + | ||
| 2835 | +/** | ||
| 2836 | + * @tc.name: GetRSSurfaceNodeType04 | ||
| 2837 | + * @tc.desc: Test GetRSSurfaceNodeType with PIP type | ||
| 2838 | + * @tc.type: FUNC | ||
| 2839 | + */ | ||
| 2840 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType04, TestSize.Level1) | ||
| 2841 | +{ | ||
| 2842 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2843 | + option->SetWindowName("GetRSSurfaceNodeType04"); | ||
| 2844 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2845 | + ASSERT_NE(window, nullptr); | ||
| 2846 | + | ||
| 2847 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_PIP); | ||
| 2848 | + EXPECT_EQ(result, RSSurfaceNodeType::APP_WINDOW_NODE); | ||
| 2849 | +} | ||
| 2850 | + | ||
| 2851 | +/** | ||
| 2852 | + * @tc.name: GetRSSurfaceNodeType05 | ||
| 2853 | + * @tc.desc: Test GetRSSurfaceNodeType with MAGNIFICATION type | ||
| 2854 | + * @tc.type: FUNC | ||
| 2855 | + */ | ||
| 2856 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType05, TestSize.Level1) | ||
| 2857 | +{ | ||
| 2858 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2859 | + option->SetWindowName("GetRSSurfaceNodeType05"); | ||
| 2860 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2861 | + ASSERT_NE(window, nullptr); | ||
| 2862 | + | ||
| 2863 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_MAGNIFICATION); | ||
| 2864 | + EXPECT_EQ(result, RSSurfaceNodeType::ABILITY_MAGNIFICATION_NODE); | ||
| 2865 | +} | ||
| 2866 | + | ||
| 2867 | +/** | ||
| 2868 | + * @tc.name: GetRSSurfaceNodeType06 | ||
| 2869 | + * @tc.desc: Test GetRSSurfaceNodeType with default type | ||
| 2870 | + * @tc.type: FUNC | ||
| 2871 | + */ | ||
| 2872 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType06, TestSize.Level1) | ||
| 2873 | +{ | ||
| 2874 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2875 | + option->SetWindowName("GetRSSurfaceNodeType06"); | ||
| 2876 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2877 | + ASSERT_NE(window, nullptr); | ||
| 2878 | + | ||
| 2879 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); | ||
| 2880 | + EXPECT_EQ(result, RSSurfaceNodeType::DEFAULT); | ||
| 2881 | + | ||
| 2882 | + result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_DIALOG); | ||
| 2883 | + EXPECT_EQ(result, RSSurfaceNodeType::DEFAULT); | ||
| 2884 | + | ||
| 2885 | + result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_FLOAT); | ||
| 2886 | + EXPECT_EQ(result, RSSurfaceNodeType::DEFAULT); | ||
| 2887 | +} | ||
| 2888 | + | ||
| 2889 | +/** | ||
| 2890 | + * @tc.name: GetRSSurfaceNodeType07 | ||
| 2891 | + * @tc.desc: Test GetRSSurfaceNodeType with UI_EXTENSION common type | ||
| 2892 | + * @tc.type: FUNC | ||
| 2893 | + */ | ||
| 2894 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType07, TestSize.Level1) | ||
| 2895 | +{ | ||
| 2896 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2897 | + option->SetWindowName("GetRSSurfaceNodeType07"); | ||
| 2898 | + option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2899 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2900 | + ASSERT_NE(window, nullptr); | ||
| 2901 | + ASSERT_NE(window->property_, nullptr); | ||
| 2902 | + | ||
| 2903 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::MODAL); | ||
| 2904 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2905 | + EXPECT_EQ(result, RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE); | ||
| 2906 | + | ||
| 2907 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::EMBEDDED); | ||
| 2908 | + result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2909 | + EXPECT_EQ(result, RSSurfaceNodeType::UI_EXTENSION_COMMON_NODE); | ||
| 2910 | +} | ||
| 2911 | + | ||
| 2912 | +/** | ||
| 2913 | + * @tc.name: GetRSSurfaceNodeType08 | ||
| 2914 | + * @tc.desc: Test GetRSSurfaceNodeType with UI_EXTENSION secure type | ||
| 2915 | + * @tc.type: FUNC | ||
| 2916 | + */ | ||
| 2917 | +HWTEST_F(WindowSessionImplTest5, GetRSSurfaceNodeType08, TestSize.Level1) | ||
| 2918 | +{ | ||
| 2919 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2920 | + option->SetWindowName("GetRSSurfaceNodeType08"); | ||
| 2921 | + option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2922 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2923 | + ASSERT_NE(window, nullptr); | ||
| 2924 | + ASSERT_NE(window->property_, nullptr); | ||
| 2925 | + | ||
| 2926 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::CONSTRAINED_EMBEDDED); | ||
| 2927 | + RSSurfaceNodeType result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2928 | + EXPECT_EQ(result, RSSurfaceNodeType::UI_EXTENSION_SECURE_NODE); | ||
| 2929 | + | ||
| 2930 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::PREVIEW_EMBEDDED); | ||
| 2931 | + result = window->GetRSSurfaceNodeType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 2932 | + EXPECT_EQ(result, RSSurfaceNodeType::UI_EXTENSION_SECURE_NODE); | ||
| 2933 | +} | ||
| 2934 | + | ||
| 2935 | +/** | ||
| 2936 | + * @tc.name: CreateSurfaceNode01 | ||
| 2937 | + * @tc.desc: Test CreateSurfaceNode without renderSession | ||
| 2938 | + * @tc.type: FUNC | ||
| 2939 | + */ | ||
| 2940 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode01, TestSize.Level1) | ||
| 2941 | +{ | ||
| 2942 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2943 | + option->SetWindowName("CreateSurfaceNode01"); | ||
| 2944 | + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); | ||
| 2945 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2946 | + ASSERT_NE(window, nullptr); | ||
| 2947 | + ASSERT_NE(window->property_, nullptr); | ||
| 2948 | + | ||
| 2949 | + window->renderSession_ = nullptr; | ||
| 2950 | + auto surfaceNode = window->CreateSurfaceNode("TestNode", WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); | ||
| 2951 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 2952 | +} | ||
| 2953 | + | ||
| 2954 | +/** | ||
| 2955 | + * @tc.name: CreateSurfaceNode02 | ||
| 2956 | + * @tc.desc: Test CreateSurfaceNode with BOOT_ANIMATION type | ||
| 2957 | + * @tc.type: FUNC | ||
| 2958 | + */ | ||
| 2959 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode02, TestSize.Level1) | ||
| 2960 | +{ | ||
| 2961 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2962 | + option->SetWindowName("CreateSurfaceNode02"); | ||
| 2963 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2964 | + ASSERT_NE(window, nullptr); | ||
| 2965 | + ASSERT_NE(window->property_, nullptr); | ||
| 2966 | + | ||
| 2967 | + window->renderSession_ = nullptr; | ||
| 2968 | + auto surfaceNode = window->CreateSurfaceNode("TestBootNode", WindowType::WINDOW_TYPE_BOOT_ANIMATION); | ||
| 2969 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 2970 | +} | ||
| 2971 | + | ||
| 2972 | +/** | ||
| 2973 | + * @tc.name: CreateSurfaceNode03 | ||
| 2974 | + * @tc.desc: Test CreateSurfaceNode with PIP type | ||
| 2975 | + * @tc.type: FUNC | ||
| 2976 | + */ | ||
| 2977 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode03, TestSize.Level1) | ||
| 2978 | +{ | ||
| 2979 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2980 | + option->SetWindowName("CreateSurfaceNode03"); | ||
| 2981 | + option->SetWindowType(WindowType::WINDOW_TYPE_PIP); | ||
| 2982 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 2983 | + ASSERT_NE(window, nullptr); | ||
| 2984 | + ASSERT_NE(window->property_, nullptr); | ||
| 2985 | + | ||
| 2986 | + window->renderSession_ = nullptr; | ||
| 2987 | + auto surfaceNode = window->CreateSurfaceNode("TestPipNode", WindowType::WINDOW_TYPE_PIP); | ||
| 2988 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 2989 | +} | ||
| 2990 | + | ||
| 2991 | +/** | ||
| 2992 | + * @tc.name: CreateSurfaceNode04 | ||
| 2993 | + * @tc.desc: Test CreateSurfaceNode with UI_EXTENSION type | ||
| 2994 | + * @tc.type: FUNC | ||
| 2995 | + */ | ||
| 2996 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode04, TestSize.Level1) | ||
| 2997 | +{ | ||
| 2998 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 2999 | + option->SetWindowName("CreateSurfaceNode04"); | ||
| 3000 | + option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 3001 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 3002 | + ASSERT_NE(window, nullptr); | ||
| 3003 | + ASSERT_NE(window->property_, nullptr); | ||
| 3004 | + | ||
| 3005 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::MODAL); | ||
| 3006 | + window->renderSession_ = nullptr; | ||
| 3007 | + auto surfaceNode = window->CreateSurfaceNode("TestUIExtNode", WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 3008 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3009 | + | ||
| 3010 | + window->property_->SetUIExtensionUsage(UIExtensionUsage::CONSTRAINED_EMBEDDED); | ||
| 3011 | + surfaceNode = window->CreateSurfaceNode("TestUIExtSecureNode", WindowType::WINDOW_TYPE_UI_EXTENSION); | ||
| 3012 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3013 | +} | ||
| 3014 | + | ||
| 3015 | +/** | ||
| 3016 | + * @tc.name: CreateSurfaceNode05 | ||
| 3017 | + * @tc.desc: Test CreateSurfaceNode with MAGNIFICATION type | ||
| 3018 | + * @tc.type: FUNC | ||
| 3019 | + */ | ||
| 3020 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode05, TestSize.Level1) | ||
| 3021 | +{ | ||
| 3022 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 3023 | + option->SetWindowName("CreateSurfaceNode05"); | ||
| 3024 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 3025 | + ASSERT_NE(window, nullptr); | ||
| 3026 | + ASSERT_NE(window->property_, nullptr); | ||
| 3027 | + | ||
| 3028 | + window->renderSession_ = nullptr; | ||
| 3029 | + auto surfaceNode = window->CreateSurfaceNode("TestMagnificationNode", WindowType::WINDOW_TYPE_MAGNIFICATION); | ||
| 3030 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3031 | +} | ||
| 3032 | + | ||
| 3033 | +/** | ||
| 3034 | + * @tc.name: CreateSurfaceNode06 | ||
| 3035 | + * @tc.desc: Test CreateSurfaceNode with default types | ||
| 3036 | + * @tc.type: FUNC | ||
| 3037 | + */ | ||
| 3038 | +HWTEST_F(WindowSessionImplTest5, CreateSurfaceNode06, TestSize.Level1) | ||
| 3039 | +{ | ||
| 3040 | + sptr<WindowOption> option = sptr<WindowOption>::MakeSptr(); | ||
| 3041 | + option->SetWindowName("CreateSurfaceNode06"); | ||
| 3042 | + sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option); | ||
| 3043 | + ASSERT_NE(window, nullptr); | ||
| 3044 | + ASSERT_NE(window->property_, nullptr); | ||
| 3045 | + | ||
| 3046 | + window->renderSession_ = nullptr; | ||
| 3047 | + auto surfaceNode = window->CreateSurfaceNode("TestDialogNode", WindowType::WINDOW_TYPE_DIALOG); | ||
| 3048 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3049 | + | ||
| 3050 | + surfaceNode = window->CreateSurfaceNode("TestFloatNode", WindowType::WINDOW_TYPE_FLOAT); | ||
| 3051 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3052 | + | ||
| 3053 | + surfaceNode = window->CreateSurfaceNode("TestToastNode", WindowType::WINDOW_TYPE_TOAST); | ||
| 3054 | + ASSERT_NE(surfaceNode, nullptr); | ||
| 3055 | +} | ||
| 3056 | + | ||
| 2787 | /** | 3057 | /** |
| 2788 | * @tc.name: RecordLifeCycleExceptionEvent | 3058 | * @tc.name: RecordLifeCycleExceptionEvent |
| 2789 | * @tc.desc: Test RecordLifeCycleExceptionEvent function | 3059 | * @tc.desc: Test RecordLifeCycleExceptionEvent function |
| @@ -262,7 +262,8 @@ public: | |||
| 262 | virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 262 | virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 263 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 263 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 264 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, | 264 | sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, |
| 265 | - SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) { return WSError::WS_OK; } | 265 | + SystemSessionConfig& systemConfig, sptr<IRemoteObject>& renderSession, |
| 266 | + sptr<IRemoteObject> token = nullptr) { return WSError::WS_OK; } | ||
| 266 | virtual WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, | 267 | virtual WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, |
| 267 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, | 268 | const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, |
| 268 | sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) | 269 | sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) |
| @@ -1001,12 +1001,17 @@ void WindowController::RecordBootAnimationEvent() const | |||
| 1001 | std::shared_ptr<Media::PixelMap> WindowController::GetSnapshot(int32_t windowId) | 1001 | std::shared_ptr<Media::PixelMap> WindowController::GetSnapshot(int32_t windowId) |
| 1002 | { | 1002 | { |
| 1003 | auto node = windowRoot_->GetWindowNode(windowId); | 1003 | auto node = windowRoot_->GetWindowNode(windowId); |
| 1004 | - if (node == nullptr) { | 1004 | + if (node == nullptr || node->surfaceNode_ == nullptr) { |
| 1005 | WLOGFE("could not find window"); | 1005 | WLOGFE("could not find window"); |
| 1006 | return nullptr; | 1006 | return nullptr; |
| 1007 | } | 1007 | } |
| 1008 | + auto rsUICtx = node->surfaceNode_->GetRSUIContext(); | ||
| 1009 | + if (rsUICtx == nullptr || rsUICtx->GetRSRenderInterface() == nullptr) { | ||
| 1010 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsUIContext is null"); | ||
| 1011 | + return nullptr; | ||
| 1012 | + } | ||
| 1008 | auto callback = std::make_shared<SurfaceCaptureFuture>(); | 1013 | auto callback = std::make_shared<SurfaceCaptureFuture>(); |
| 1009 | - bool ret = RSInterfaces::GetInstance().TakeSurfaceCapture(node->surfaceNode_, callback); | 1014 | + bool ret = rsUICtx->GetRSRenderInterface()->TakeSurfaceCapture(node->surfaceNode_, callback); |
| 1010 | if (!ret) { | 1015 | if (!ret) { |
| 1011 | WLOGFE("takeSurfaceCapture failed"); | 1016 | WLOGFE("takeSurfaceCapture failed"); |
| 1012 | return nullptr; | 1017 | return nullptr; |
| @@ -205,7 +205,17 @@ void WindowManagerService::InitWithRanderServiceAdded() | |||
| 205 | auto windowVisibilityChangeCb = | 205 | auto windowVisibilityChangeCb = |
| 206 | [this](std::shared_ptr<RSOcclusionData> occlusionData) { this->WindowVisibilityChangeCallback(occlusionData); }; | 206 | [this](std::shared_ptr<RSOcclusionData> occlusionData) { this->WindowVisibilityChangeCallback(occlusionData); }; |
| 207 | WLOGI("RegisterWindowVisibilityChangeCallback"); | 207 | WLOGI("RegisterWindowVisibilityChangeCallback"); |
| 208 | - if (rsInterface_.RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) { | 208 | + auto rsUICtx = rsUiDirector_->GetRSUIContext(); |
| 209 | + if (rsUICtx == nullptr) { | ||
| 210 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "no rsUICtx"); | ||
| 211 | + return; | ||
| 212 | + } | ||
| 213 | + auto rsInterface = rsUICtx->GetRSRenderInterface(); | ||
| 214 | + if (rsInterface == nullptr) { | ||
| 215 | + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "rsInterface is null"); | ||
| 216 | + return; | ||
| 217 | + } | ||
| 218 | + if (rsInterface->RegisterOcclusionChangeCallback(windowVisibilityChangeCb) != WM_OK) { | ||
| 209 | WLOGFE("RegisterWindowVisibilityChangeCallback failed"); | 219 | WLOGFE("RegisterWindowVisibilityChangeCallback failed"); |
| 210 | } | 220 | } |
| 211 | } | 221 | } |
| @@ -1674,7 +1684,7 @@ void WindowManagerService::GetFocusWindowInfo(FocusChangeInfo& focusInfo, Displa | |||
| 1674 | 1684 | ||
| 1675 | void WindowManagerService::InitRSUIDirector() | 1685 | void WindowManagerService::InitRSUIDirector() |
| 1676 | { | 1686 | { |
| 1677 | - rsUiDirector_ = RSUIDirector::Create(); | 1687 | + rsUiDirector_ = RSUIDirector::Create(nullptr); |
| 1678 | if (!rsUiDirector_) { | 1688 | if (!rsUiDirector_) { |
| 1679 | TLOGE(WmsLogTag::WMS_SCB, "Failed to create RSUIDirector"); | 1689 | TLOGE(WmsLogTag::WMS_SCB, "Failed to create RSUIDirector"); |
| 1680 | return; | 1690 | return; |
| @@ -1689,7 +1699,6 @@ void WindowManagerService::InitRSUIDirector() | |||
| 1689 | rsUiDirector_->SetUITaskRunner([this](const std::function<void()>& task, uint32_t delay) { | 1699 | rsUiDirector_->SetUITaskRunner([this](const std::function<void()>& task, uint32_t delay) { |
| 1690 | PostAsyncTask(task, "WindowManagerService:cacheGuard", delay); | 1700 | PostAsyncTask(task, "WindowManagerService:cacheGuard", delay); |
| 1691 | }, instanceId, useMultiInstance); | 1701 | }, instanceId, useMultiInstance); |
| 1692 | - rsUiDirector_->Init(false, useMultiInstance); | ||
| 1693 | TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s", | 1702 | TLOGI(WmsLogTag::WMS_SCB, "Create RSUIDirector: %{public}s", |
| 1694 | RSAdapterUtil::RSUIDirectorToStr(rsUiDirector_).c_str()); | 1703 | RSAdapterUtil::RSUIDirectorToStr(rsUiDirector_).c_str()); |
| 1695 | } | 1704 | } |
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 22 | namespace OHOS { | 23 | namespace OHOS { |
| 23 | namespace Rosen { | 24 | namespace Rosen { |
| @@ -442,16 +443,8 @@ bool WindowNode::GetTouchable() const | |||
| 442 | std::shared_ptr<RSUIContext> WindowNode::GetRSUIContext() const | 443 | std::shared_ptr<RSUIContext> WindowNode::GetRSUIContext() const |
| 443 | { | 444 | { |
| 444 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); | 445 | RETURN_IF_RS_CLIENT_MULTI_INSTANCE_DISABLED(nullptr); |
| 445 | - std::shared_ptr<RSUIContext> rsUIContext; | 446 | + std::shared_ptr<RSUIContext> rsUIContext = WindowInnerManager::GetInstance().GetRSUIContext(); |
| 446 | - for (const auto& node : {surfaceNode_, leashWinSurfaceNode_, startingWinSurfaceNode_, closeWinSurfaceNode_}) { | 447 | + TLOGI(WmsLogTag::WMS_SCB, "%{public}s", |
| 447 | - if (node) { | ||
| 448 | - rsUIContext = node->GetRSUIContext(); | ||
| 449 | - if (rsUIContext) { | ||
| 450 | - break; | ||
| 451 | - } | ||
| 452 | - } | ||
| 453 | - } | ||
| 454 | - TLOGD(WmsLogTag::WMS_SCB, "%{public}s", | ||
| 455 | RSAdapterUtil::RSUIContextToStr(rsUIContext).c_str()); | 448 | RSAdapterUtil::RSUIContextToStr(rsUIContext).c_str()); |
| 456 | return rsUIContext; | 449 | return rsUIContext; |
| 457 | } | 450 | } |
| @@ -981,9 +981,13 @@ void WindowNodeContainer::UpdateFocusStatus(uint32_t id, bool focused) | |||
| 981 | } else { | 981 | } else { |
| 982 | focusNodeId = node->surfaceNode_->GetId(); | 982 | focusNodeId = node->surfaceNode_->GetId(); |
| 983 | } | 983 | } |
| 984 | - FocusAppInfo appInfo = | 984 | + auto rsUICtx = node->GetRSUIContext(); |
| 985 | - { node->GetCallingPid(), node->GetCallingUid(), info.bundleName_, info.abilityName_, focusNodeId }; | 985 | + if (rsUICtx != nullptr && rsUICtx->GetRSRenderInterface() != nullptr) { |
| 986 | - RSInterfaces::GetInstance().SetFocusAppInfo(appInfo); | 986 | + FocusAppInfo appInfo = { node->GetCallingPid(), node->GetCallingUid(), |
| 987 | + info.bundleName_, info.abilityName_, focusNodeId }; | ||
| 988 | + TLOGD(WmsLogTag::WMS_FOCUS, "bundleName=%{public}s", appInfo.bundleName.c_str()); | ||
| 989 | + rsUICtx->GetRSRenderInterface()->SetFocusAppInfo(appInfo); | ||
| 990 | + } | ||
| 987 | } | 991 | } |
| 988 | if (node->GetWindowToken()) { | 992 | if (node->GetWindowToken()) { |
| 989 | node->GetWindowToken()->UpdateFocusStatus(focused); | 993 | node->GetWindowToken()->UpdateFocusStatus(focused); |