• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_WINDOW_SCENE_SCREEN_SESSION_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SCREEN_SESSION_H
18 
19 #include <mutex>
20 #include <vector>
21 
22 #include <refbase.h>
23 #include <screen_manager/screen_types.h>
24 #include <shared_mutex>
25 #include <ui/rs_display_node.h>
26 #include <ui/rs_ui_director.h>
27 
28 #include "screen_property.h"
29 #include "dm_common.h"
30 #include "display_info.h"
31 #include "screen.h"
32 #include "screen_info.h"
33 #include "screen_group.h"
34 #include "screen_group_info.h"
35 #include "event_handler.h"
36 #include "screen_session_manager/include/screen_rotation_property.h"
37 
38 namespace OHOS::Rosen {
39 using SetScreenSceneDpiFunc = std::function<void(float density)>;
40 using DestroyScreenSceneFunc = std::function<void()>;
41 
42 class IScreenChangeListener {
43 public:
OnConnect(ScreenId screenId)44     virtual void OnConnect(ScreenId screenId) {}
OnDisconnect(ScreenId screenId)45     virtual void OnDisconnect(ScreenId screenId) {}
OnPropertyChange(const ScreenProperty & newProperty,ScreenPropertyChangeReason reason,ScreenId screenId)46     virtual void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
47         ScreenId screenId) {}
OnPowerStatusChange(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)48     virtual void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
49         PowerStateChangeReason reason) {}
OnSensorRotationChange(float sensorRotation,ScreenId screenId)50     virtual void OnSensorRotationChange(float sensorRotation, ScreenId screenId) {}
OnScreenOrientationChange(float screenOrientation,ScreenId screenId)51     virtual void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) {}
OnScreenRotationLockedChange(bool isLocked,ScreenId screenId)52     virtual void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) {}
OnScreenExtendChange(ScreenId mainScreenId,ScreenId extendScreenId)53     virtual void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) {}
OnHoverStatusChange(int32_t hoverStatus,bool needRotate,ScreenId extendScreenId)54     virtual void OnHoverStatusChange(int32_t hoverStatus, bool needRotate, ScreenId extendScreenId) {}
OnScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)55     virtual void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) {}
OnCameraBackSelfieChange(bool isCameraBackSelfie,ScreenId screenId)56     virtual void OnCameraBackSelfieChange(bool isCameraBackSelfie, ScreenId screenId) {}
OnSuperFoldStatusChange(ScreenId screenId,SuperFoldStatus superFoldStatus)57     virtual void OnSuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus) {}
OnSecondaryReflexionChange(ScreenId screenId,bool isSecondaryReflexion)58     virtual void OnSecondaryReflexionChange(ScreenId screenId, bool isSecondaryReflexion) {}
OnExtendScreenConnectStatusChange(ScreenId screenId,ExtendScreenConnectStatus extendScreenConnectStatus)59     virtual void OnExtendScreenConnectStatusChange(ScreenId screenId,
60         ExtendScreenConnectStatus extendScreenConnectStatus) {}
OnBeforeScreenPropertyChange(FoldStatus foldStatus)61     virtual void OnBeforeScreenPropertyChange(FoldStatus foldStatus) {}
OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent)62     virtual void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) {}
63 };
64 
65 enum class MirrorScreenType : int32_t {
66     PHYSICAL_MIRROR = 0,
67     VIRTUAL_MIRROR = 1,
68 };
69 
70 enum class ScreenState : int32_t {
71     INIT,
72     CONNECTION,
73     DISCONNECTION,
74 };
75 
76 struct ScreenSessionConfig {
77     ScreenId screenId {0};
78     ScreenId rsId {0};
79     ScreenId defaultScreenId {0};
80     ScreenId mirrorNodeId {0};
81     std::string name = "UNKNOWN";
82     std::string innerName = "UNKNOWN";
83     ScreenProperty property;
84     std::shared_ptr<RSDisplayNode> displayNode;
85 };
86 
87 enum class ScreenSessionReason : int32_t {
88     CREATE_SESSION_FOR_CLIENT,
89     CREATE_SESSION_FOR_VIRTUAL,
90     CREATE_SESSION_FOR_MIRROR,
91     CREATE_SESSION_FOR_REAL,
92     CREATE_SESSION_WITHOUT_DISPLAY_NODE,
93     INVALID,
94 };
95 
96 class ScreenSession : public RefBase {
97 public:
98     ScreenSession() = default;
99     ScreenSession(const ScreenSessionConfig& config, ScreenSessionReason reason);
100     ScreenSession(ScreenId screenId, ScreenId rsId, const std::string& name,
101         const ScreenProperty& property, const std::shared_ptr<RSDisplayNode>& displayNode);
102     ScreenSession(ScreenId screenId, const ScreenProperty& property, ScreenId defaultScreenId);
103     ScreenSession(ScreenId screenId, const ScreenProperty& property, NodeId nodeId, ScreenId defaultScreenId);
104     ScreenSession(const std::string& name, ScreenId smsId, ScreenId rsId, ScreenId defaultScreenId);
105     virtual ~ScreenSession();
106 
107     void CreateDisplayNode(const Rosen::RSDisplayNodeConfig& config);
108     void ReuseDisplayNode(const RSDisplayNodeConfig& config);
109     void SetDisplayNodeScreenId(ScreenId screenId);
110     void RegisterScreenChangeListener(IScreenChangeListener* screenChangeListener);
111     void UnregisterScreenChangeListener(IScreenChangeListener* screenChangeListener);
112 
113     sptr<DisplayInfo> ConvertToDisplayInfo();
114     sptr<DisplayInfo> ConvertToRealDisplayInfo();
115     sptr<ScreenInfo> ConvertToScreenInfo() const;
116     sptr<SupportedScreenModes> GetActiveScreenMode() const;
117     ScreenSourceMode GetSourceMode() const;
118     void SetScreenCombination(ScreenCombination combination);
119     ScreenCombination GetScreenCombination() const;
120 
121     void SetBounds(RRect screenBounds);
122     void SetHorizontalRotation();
123     Orientation GetOrientation() const;
124     void SetOrientation(Orientation orientation);
125     Rotation GetRotation() const;
126     void SetRotation(Rotation rotation);
127     void SetRotationAndScreenRotationOnly(Rotation rotation);
128     void SetScreenRequestedOrientation(Orientation orientation);
129     Orientation GetScreenRequestedOrientation() const;
130     void SetUpdateToInputManagerCallback(std::function<void(float)> updateToInputManagerCallback);
131     void SetUpdateScreenPivotCallback(std::function<void(float, float)>&& updateScreenPivotCallback);
132 
133     void SetVirtualPixelRatio(float virtualPixelRatio);
134     void SetScreenSceneDpiChangeListener(const SetScreenSceneDpiFunc& func);
135     void SetScreenSceneDpi(float density);
136     void SetDensityInCurResolution(float densityInCurResolution);
137     float GetDensityInCurResolution();
138     void SetDefaultDensity(float defaultDensity);
139     void UpdateVirtualPixelRatio(const RRect& bounds);
140     void SetScreenType(ScreenType type);
141 
142     void SetScreenSceneDestroyListener(const DestroyScreenSceneFunc& func);
143     void DestroyScreenScene();
144 
145     void SetScreenScale(float scaleX, float scaleY, float pivotX, float pivotY, float translateX, float translateY);
146 
147     std::string GetName();
148     std::string GetInnerName();
149     ScreenId GetScreenId();
150     ScreenId GetRSScreenId();
151     ScreenProperty GetScreenProperty() const;
152     void SetFakeScreenSession(sptr<ScreenSession> screenSession);
153     sptr<ScreenSession> GetFakeScreenSession() const;
154     void UpdatePropertyByActiveMode();
155     std::shared_ptr<RSDisplayNode> GetDisplayNode() const;
156     void ReleaseDisplayNode();
157 
158     Rotation CalcRotation(Orientation orientation, FoldDisplayMode foldDisplayMode) const;
159     DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const;
160     DisplayOrientation CalcDeviceOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const;
161     DisplayOrientation CalcDeviceOrientationWithBounds(Rotation rotation,
162         FoldDisplayMode foldDisplayMode, const RRect& bounds) const;
163     void FillScreenInfo(sptr<ScreenInfo> info) const;
164     void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint, bool isExtend = false,
165         float positionX = 0, float positionY = 0);
166 
167     DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts);
168     DMError GetScreenColorGamut(ScreenColorGamut& colorGamut);
169     DMError SetScreenColorGamut(int32_t colorGamutIdx);
170     DMError GetScreenGamutMap(ScreenGamutMap& gamutMap);
171     DMError SetScreenGamutMap(ScreenGamutMap gamutMap);
172     DMError SetScreenColorTransform();
173 
174     DMError GetPixelFormat(GraphicPixelFormat& pixelFormat);
175     DMError SetPixelFormat(GraphicPixelFormat pixelFormat);
176     DMError GetSupportedHDRFormats(std::vector<ScreenHDRFormat>& hdrFormats);
177     DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat);
178     DMError SetScreenHDRFormat(int32_t modeIdx);
179     DMError GetSupportedColorSpaces(std::vector<GraphicCM_ColorSpaceType>& colorSpaces);
180     DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace);
181     DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace);
182 
183     void HandleSensorRotation(float sensorRotation);
184     void HandleHoverStatusChange(int32_t hoverStatus, bool needRotate = true);
185     void HandleCameraBackSelfieChange(bool isCameraBackSelfie);
186     float ConvertRotationToFloat(Rotation sensorRotation);
187 
188     bool HasPrivateSessionForeground() const;
189     void SetPrivateSessionForeground(bool hasPrivate);
190     void SetDisplayBoundary(const RectF& rect, const uint32_t& offsetY);
191     void SetExtendProperty(RRect bounds, bool isCurrentOffScreenRendering);
192     void SetScreenRotationLocked(bool isLocked);
193     void SetScreenRotationLockedFromJs(bool isLocked);
194     bool IsScreenRotationLocked();
195     void SetTouchEnabledFromJs(bool isTouchEnabled);
196     bool IsTouchEnabled();
197     void SetIsPhysicalMirrorSwitch(bool isPhysicalMirrorSwitch);
198     bool GetIsPhysicalMirrorSwitch();
199     void UpdateTouchBoundsAndOffset();
200     void UpdateToInputManager(RRect bounds, int rotation, int deviceRotation, FoldDisplayMode foldDisplayMode);
201     void UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode);
202     void UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode);
203     void UpdateRotationOrientation(int rotation, FoldDisplayMode foldDisplayMode, const RRect& bounds);
204     void UpdatePropertyByFakeInUse(bool isFakeInUse);
205     ScreenProperty UpdatePropertyByFoldControl(const ScreenProperty& updatedProperty,
206         FoldDisplayMode foldDisplayMode = FoldDisplayMode::UNKNOWN);
207     void UpdateDisplayState(DisplayState displayState);
208     void UpdateRefreshRate(uint32_t refreshRate);
209     uint32_t GetRefreshRate();
210     void UpdatePropertyByResolution(uint32_t width, uint32_t height);
211     void UpdatePropertyByFakeBounds(uint32_t width, uint32_t height);
212     void SetName(std::string name);
213     void SetInnerName(std::string innerName);
214     void Resize(uint32_t width, uint32_t height, bool isFreshBoundsSync = true);
215     void SetFrameGravity(Gravity gravity);
216 
217     void SetHdrFormats(std::vector<uint32_t>&& hdrFormats);
218     std::vector<uint32_t> GetHdrFormats();
219     void SetColorSpaces(std::vector<uint32_t>&& colorSpaces);
220     std::vector<uint32_t> GetColorSpaces();
221     void SetSupportedRefreshRate(std::vector<uint32_t>&& supportedRefreshRate);
222     std::vector<uint32_t> GetSupportedRefreshRate() const;
223     void SetForceCloseHdr(bool isForceCloseHdr);
224 
225     VirtualScreenFlag GetVirtualScreenFlag();
226     void SetVirtualScreenFlag(VirtualScreenFlag screenFlag);
227     void SetSecurity(bool isSecurity);
228 
229     std::string name_ { "UNKNOWN" };
230     ScreenId screenId_ {};
231     ScreenId rsId_ {};
232     ScreenId defaultScreenId_ = SCREEN_ID_INVALID;
233 
234     void SetIsExtend(bool isExtend);
235     bool GetIsExtend() const;
236     void SetIsInternal(bool isInternal);
237     void SetIsRealScreen(bool isReal);
238     bool GetIsRealScreen();
239     void SetIsPcUse(bool isPcUse);
240     bool GetIsPcUse();
241     void SetIsFakeSession(bool isFakeSession);
242     bool GetIsInternal() const;
243     void SetIsCurrentInUse(bool isInUse);
244     bool GetIsCurrentInUse() const;
245     void SetIsFakeInUse(bool isFakeInUse);
246     bool GetIsFakeInUse() const;
247     void SetIsBScreenHalf(bool isBScreenHalf);
248     bool GetIsBScreenHalf() const;
249     void SetIsExtendVirtual(bool isExtendVirtual);
250     bool GetIsExtendVirtual() const;
251     void SetSerialNumber(std::string serialNumber);
252     std::string GetSerialNumber() const;
253     ScreenShape GetScreenShape() const;
254     void SetValidHeight(uint32_t validHeight);
255     void SetValidWidth(uint32_t validWidth);
256     uint32_t GetValidHeight() const;
257     uint32_t GetValidWidth() const;
SetRealHeight(uint32_t realHeight)258     void SetRealHeight(uint32_t realHeight) { property_.SetScreenRealHeight(realHeight); }
SetRealWidth(uint32_t realWidth)259     void SetRealWidth(uint32_t realWidth) { property_.SetScreenRealWidth(realWidth); }
260 
261     void SetPointerActiveWidth(uint32_t pointerActiveWidth);
262     uint32_t GetPointerActiveWidth();
263     void SetPointerActiveHeight(uint32_t pointerActiveHeight);
264     uint32_t GetPointerActiveHeight();
265     float GetSensorRotation() const;
266     DisplaySourceMode GetDisplaySourceMode() const;
267     void SetXYPosition(int32_t x, int32_t y);
268 
269     bool isPrimary_ { false };
270     bool isInternal_ { false };
271     bool isExtended_ { false };
272     bool isInUse_ { false };
273     bool isReal_ { false };
274     bool isPcUse_ { false };
275     bool isFakeSession_ { false };
276 
277     NodeId nodeId_ {};
278 
279     int32_t activeIdx_ { 0 };
280     std::vector<sptr<SupportedScreenModes>> modes_ = {};
281 
282     bool isScreenGroup_ { false };
283     ScreenId groupSmsId_ { SCREEN_ID_INVALID };
284     ScreenId lastGroupSmsId_ { SCREEN_ID_INVALID };
285     std::atomic<bool> isScreenLocked_ = true;
286 
287     void Connect();
288     void Disconnect();
289     void PropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason);
290     void PowerStatusChange(DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason);
291     // notify scb
292     void SensorRotationChange(Rotation sensorRotation);
293     void SensorRotationChange(float sensorRotation);
294     float GetValidSensorRotation();
295     void HoverStatusChange(int32_t hoverStatus, bool needRotate = true);
296     void CameraBackSelfieChange(bool isCameraBackSelfie);
297     void ScreenOrientationChange(Orientation orientation, FoldDisplayMode foldDisplayMode);
298     void ScreenOrientationChange(float orientation);
299     void ScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId);
300     DMRect GetAvailableArea();
301     DMRect GetExpandAvailableArea();
302     void SetAvailableArea(DMRect area);
303     bool UpdateAvailableArea(DMRect area);
304     bool UpdateExpandAvailableArea(DMRect area);
305     void SetFoldScreen(bool isFold);
306     void UpdateRotationAfterBoot(bool foldToExpand);
307     void UpdateValidRotationToScb();
308     std::shared_ptr<Media::PixelMap> GetScreenSnapshot(float scaleX, float scaleY);
309     void SetDefaultDeviceRotationOffset(uint32_t defaultRotationOffset);
310 
311     void SetMirrorScreenType(MirrorScreenType mirrorType);
312     MirrorScreenType GetMirrorScreenType();
313     Rotation ConvertIntToRotation(int rotation);
314     void SetPhysicalRotation(int rotation);
315     void SetScreenComponentRotation(int rotation);
316     void SetStartPosition(uint32_t startX, uint32_t startY);
317     void SetMirrorScreenRegion(ScreenId screenId, DMRect screenRegion);
318     std::pair<ScreenId, DMRect> GetMirrorScreenRegion();
319     void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName);
320     void SuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus);
321     void SecondaryReflexionChange(ScreenId screenId, bool isSecondaryReflexion);
322     void EnableMirrorScreenRegion();
323     void ExtendScreenConnectStatusChange(ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus);
324     void SetIsEnableRegionRotation(bool isEnableRegionRotation);
325     bool GetIsEnableRegionRotation();
326     void SetIsEnableCanvasRotation(bool isEnableCanvasRotation);
327     bool GetIsEnableCanvasRotation();
328     void UpdateDisplayNodeRotation(int rotation);
329     void BeforeScreenPropertyChange(FoldStatus foldStatus);
330     void ScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent);
331     void FreezeScreen(bool isFreeze);
332     std::shared_ptr<Media::PixelMap> GetScreenSnapshotWithAllWindows(float scaleX, float scaleY,
333         bool isNeedCheckDrmAndSurfaceLock);
334 
335     DisplayId GetDisplayId();
336 
337     std::vector<sptr<SupportedScreenModes>> GetScreenModes();
338     void SetScreenModes(const std::vector<sptr<SupportedScreenModes>>& modes);
339 
340     int32_t GetActiveId();
341     void SetActiveId(int32_t activeIdx);
342 
343     void SetScreenId(ScreenId screenId);
344     void SetRSScreenId(ScreenId rsId);
345 
346     void SetDisplayNode(std::shared_ptr<RSDisplayNode> displayNode);
347     void SetScreenOffScreenRendering();
348     void SetScreenOffScreenRenderingInner();
349     void SetScreenProperty(ScreenProperty property);
350 
351     void SetScreenAvailableStatus(bool isScreenAvailable);
352     bool IsScreenAvailable() const;
353 
354     void SetIsAvailableAreaNeedNotify(bool isAvailableAreaNeedNotify);
355     bool GetIsAvailableAreaNeedNotify() const;
356     uint64_t GetSessionId() const;
357 
358     /*
359      * RS Client Multi Instance
360      */
361     std::shared_ptr<RSUIDirector> GetRSUIDirector() const;
362     std::shared_ptr<RSUIContext> GetRSUIContext() const;
363 
364     /*
365      * Display Group Info
366      */
367     void SetDisplayGroupId(DisplayGroupId displayGroupId);
368     DisplayGroupId GetDisplayGroupId() const;
369     void SetMainDisplayIdOfGroup(ScreenId screenId);
370     ScreenId GetMainDisplayIdOfGroup() const;
371     void SetScreenAreaOffsetX(uint32_t screenAreaOffsetX);
372     uint32_t GetScreenAreaOffsetX() const;
373     void SetScreenAreaOffsetY(uint32_t screenAreaOffsetY);
374     uint32_t GetScreenAreaOffsetY() const;
375     void SetScreenAreaWidth(uint32_t screenAreaWidth);
376     uint32_t GetScreenAreaWidth() const;
377     void SetScreenAreaHeight(uint32_t screenAreaHeight);
378     uint32_t GetScreenAreaHeight() const;
379 
380     void UpdateMirrorWidth(uint32_t mirrorWidth);
381     void UpdateMirrorHeight(uint32_t mirrorHeight);
382 
383 private:
384     ScreenProperty property_;
385     mutable std::mutex propertyMutex_; // above guarded by clientProxyMutex_
386     std::shared_ptr<RSDisplayNode> displayNode_;
387     ScreenState screenState_ { ScreenState::INIT };
388     std::vector<IScreenChangeListener*> screenChangeListenerList_;
389     std::mutex screenChangeListenerListMutex_;
390     ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
391     mutable std::mutex combinationMutex_; // above guarded by clientProxyMutex_
392     VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT };
393     bool hasPrivateWindowForeground_ = false;
394     bool isFakeInUse_ = false;  // is fakeScreenSession can be used
395     bool isBScreenHalf_ = false;
396     bool isPhysicalMirrorSwitch_ = false;
397     bool isScreenAvailable_ = true;
398     bool isExtendVirtual_ {false};
399     mutable std::shared_mutex displayNodeMutex_;
400     std::atomic<bool> touchEnabled_ { true };
401     std::function<void(float)> updateToInputManagerCallback_ = nullptr;
402     std::function<void(float, float)> updateScreenPivotCallback_ = nullptr;
403     bool isFold_ = false;
404     float currentSensorRotation_ { -1.0f };
405     float currentValidSensorRotation_ { -1.0f };
406     mutable std::shared_mutex hdrFormatsMutex_;
407     std::vector<uint32_t> hdrFormats_;
408     mutable std::shared_mutex colorSpacesMutex_;
409     std::vector<uint32_t> colorSpaces_;
410     mutable std::shared_mutex supportedRefreshRateMutex_;
411     std::vector<uint32_t> supportedRefreshRate_;
412     MirrorScreenType mirrorScreenType_ { MirrorScreenType::VIRTUAL_MIRROR };
413     std::string serialNumber_;
414     std::pair<ScreenId, DMRect> mirrorScreenRegion_ = std::make_pair(INVALID_SCREEN_ID, DMRect::NONE());
415     SetScreenSceneDpiFunc setScreenSceneDpiCallback_ = nullptr;
416     DestroyScreenSceneFunc destroyScreenSceneCallback_ = nullptr;
417     void ReportNotifyModeChange(DisplayOrientation displayOrientation);
418     sptr<ScreenSession> fakeScreenSession_ = nullptr;
419     int32_t GetApiVersion();
420     void SetScreenSnapshotRect(RSSurfaceCaptureConfig& config);
421     bool IsWidthHeightMatch(float width, float height, float targetWidth, float targetHeight);
422     std::mutex mirrorScreenRegionMutex_;
423     std::string innerName_ {"UNKOWN"};
424     bool isEnableRegionRotation_ = false;
425     bool isEnableCanvasRotation_ = false;
426     std::mutex isEnableRegionRotationMutex_;
427     std::mutex isEnableCanvasRotationMutex_;
428     std::shared_mutex availableAreaMutex_;
429     bool isAvailableAreaNeedNotify_ = false;
430     bool isSecurity_ = true;
431     uint64_t sessionId_;
432     bool lastCloseHdrStatus_ = false;
433     mutable std::shared_mutex modesMutex_;
434 
435     /*
436      * RS Client Multi Instance
437      */
438     std::shared_ptr<RSUIDirector> rsUIDirector_;
439 
440     inline static std::atomic<uint64_t> sessionIdGenerator_ { 0 };
441 };
442 
443 class ScreenSessionGroup : public ScreenSession {
444 public:
445     ScreenSessionGroup(ScreenId smsId, ScreenId rsId, std::string name, ScreenCombination combination);
446     ScreenSessionGroup() = delete;
447     WM_DISALLOW_COPY_AND_MOVE(ScreenSessionGroup);
448     ~ScreenSessionGroup();
449 
450     bool AddChild(sptr<ScreenSession>& smsScreen, Point& startPoint);
451     bool AddChild(sptr<ScreenSession>& smsScreen, Point& startPoint,
452         sptr<ScreenSession> defaultScreenSession, bool isExtend = false);
453     bool AddChildren(std::vector<sptr<ScreenSession>>& smsScreens, std::vector<Point>& startPoints);
454     bool RemoveChild(sptr<ScreenSession>& smsScreen);
455     bool HasChild(ScreenId childScreen) const;
456     std::vector<sptr<ScreenSession>> GetChildren() const;
457     std::vector<Point> GetChildrenPosition() const;
458     Point GetChildPosition(ScreenId screenId) const;
459     size_t GetChildCount() const;
460     sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
461     ScreenCombination GetScreenCombination() const;
462 
463     ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
464     ScreenId mirrorScreenId_ { SCREEN_ID_INVALID };
465 
466 private:
467     bool GetRSDisplayNodeConfig(sptr<ScreenSession>& screenSession, struct RSDisplayNodeConfig& config,
468         sptr<ScreenSession> defaultScreenSession);
469 
470     std::map<ScreenId, std::pair<sptr<ScreenSession>, Point>> screenSessionMap_;
471     mutable std::shared_mutex screenSessionMapMutex_;
472 };
473 
474 } // namespace OHOS::Rosen
475 
476 #endif // OHOS_ROSEN_WINDOW_SCENE_SCREEN_SESSION_H
477