1 /* 2 * Copyright (c) 2024 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 #ifndef OHOS_ROSEN_MULTI_SCREEN_MANAGER_H 17 #define OHOS_ROSEN_MULTI_SCREEN_MANAGER_H 18 19 #include <hitrace_meter.h> 20 #include <transaction/rs_interfaces.h> 21 22 #include "dm_common.h" 23 #include "screen_session_manager.h" 24 #include "wm_single_instance.h" 25 26 namespace OHOS::Rosen { 27 28 class MultiScreenManager { 29 WM_DECLARE_SINGLE_INSTANCE_BASE(MultiScreenManager); 30 public: 31 DMError VirtualScreenUniqueSwitch(sptr<ScreenSession> screenSession, const std::vector<ScreenId>& screenIds); 32 33 DMError UniqueSwitch(const std::vector<ScreenId>& screenIds, std::vector<DisplayId>& displayIds); 34 35 DMError MirrorSwitch(const ScreenId mainScreenId, const std::vector<ScreenId>& screenIds, DMRect mainScreenRegion, 36 ScreenId& screenGroupId); 37 38 void MultiScreenModeChange(sptr<ScreenSession> mainSession, sptr<ScreenSession> secondarySession, 39 const std::string& operateType); 40 41 void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType); 42 43 void SetLastScreenMode(ScreenId mainScreenId, MultiScreenMode secondaryScreenMode); 44 45 void InternalScreenOnChange(sptr<ScreenSession> internalSession, sptr<ScreenSession> externalSession); 46 47 void InternalScreenOffChange(sptr<ScreenSession> internalSession, sptr<ScreenSession> externalSession); 48 49 void ExternalScreenDisconnectChange(sptr<ScreenSession> internalSession, sptr<ScreenSession> externalSession); 50 51 bool AreScreensTouching(sptr<ScreenSession> mainScreenSession, sptr<ScreenSession> secondScreenSession, 52 MultiScreenPositionOptions mainScreenOptions, MultiScreenPositionOptions secondScreenOption); 53 54 void MultiScreenReportDataToRss(std::string multiScreenType, std::string status); 55 private: 56 MultiScreenManager(); 57 ~MultiScreenManager(); 58 59 void FilterPhysicalAndVirtualScreen(const std::vector<ScreenId>& allScreenIds, 60 std::vector<ScreenId>& physicalScreenIds, std::vector<ScreenId>& virtualScreenIds); 61 62 DMError VirtualScreenMirrorSwitch(const ScreenId mainScreenId, const std::vector<ScreenId>& screenIds, 63 DMRect mainScreenRegion, ScreenId& screenGroupId); 64 65 DMError PhysicalScreenMirrorSwitch(const std::vector<ScreenId>& screenIds, DMRect mainScreenRegion); 66 67 DMError PhysicalScreenUniqueSwitch(const std::vector<ScreenId>& screenIds); 68 69 /* pc multi screen switch */ 70 void DoFirstExtendChange(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession, 71 const std::string& operateType); 72 73 void DoFirstMainChangeExtend(sptr<IScreenSessionManagerClient> scbClient, sptr<ScreenSession> firstSession, 74 sptr<ScreenSession> secondarySession); 75 76 void DoFirstMainChangeMirror(sptr<IScreenSessionManagerClient> scbClient, sptr<ScreenSession> firstSession, 77 sptr<ScreenSession> secondarySession); 78 79 void DoFirstMirrorChange(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession, 80 const std::string& operateType); 81 void DoFirstMirrorChangeExtend(sptr<IScreenSessionManagerClient> scbClient, sptr<ScreenSession> firstSession, 82 sptr<ScreenSession> secondarySession); 83 void DoFirstMirrorChangeMirror(sptr<IScreenSessionManagerClient> scbClient, sptr<ScreenSession> firstSession, 84 sptr<ScreenSession> secondarySession); 85 86 void DoFirstMainChange(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession, 87 const std::string& operateType); 88 void DoFirstExtendChangeExtend(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession); 89 void DoFirstExtendChangeMirror(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession); 90 91 std::pair<ScreenId, MultiScreenMode> lastScreenMode_; // main screen id & secondary screen mode 92 }; 93 } // namespace OHOS::Rosen 94 #endif // OHOS_ROSEN_MULTI_SCREEN_MANAGER_H 95