From d94a0d3983ba4aa685857d124e739bf0b8f2ace0 Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 20 Nov 2023 16:31:37 +0800 Subject: [PATCH 1/4] fix fold phone snapshot Signed-off-by: zhangzhicong --- .../session/screen/include/screen_session.h | 5 ++-- .../session/screen/src/screen_session.cpp | 26 ++++++++++++++----- .../src/screen_session_manager.cpp | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index ba213a1270..3f65065ebb 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -87,7 +87,7 @@ public: void ReleaseDisplayNode(); Rotation CalcRotation(Orientation orientation) const; - DisplayOrientation CalcDisplayOrientation(Rotation rotation) const; + DisplayOrientation CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const; void FillScreenInfo(sptr info) const; void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint); @@ -104,7 +104,7 @@ public: void SetScreenRotationLocked(bool isLocked); void SetScreenRotationLockedFromJs(bool isLocked); bool IsScreenRotationLocked(); - void UpdatePropertyAfterRotation(RRect bounds, int rotation); + void UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode); void UpdatePropertyByFoldControl(RRect bounds, RRect phyBounds); void SetName(std::string name); void Resize(uint32_t width, uint32_t height); @@ -133,6 +133,7 @@ public: private: float ConvertRotationToFloat(Rotation sensorRotation); + Rotation ConvertIntToRotation(int rotation); ScreenProperty property_; std::shared_ptr displayNode_; ScreenState screenState_ { ScreenState::INIT }; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index c44c4c65ea..b79d6b3074 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -265,7 +265,7 @@ void ScreenSession::ScreenOrientationChange(float orientation) } } -void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation) +Rotation ScreenSession::ConvertIntToRotation(int rotation); { Rotation targetRotation = Rotation::ROTATION_0; switch (rotation) { @@ -282,19 +282,30 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation) targetRotation = Rotation::ROTATION_0; break; } - DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation); + return targetRotation; +} + +void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) +{ + Rotation targetRotation = ConvertIntToRotation(rotation); + Rotation displayScreenRotation = targetRotation; + if (foldDisplayMode == FoldDisplayMode::FULL) { + displayScreenRotation = ConvertIntToRotation((rotation + 90) % 360); + } + DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation, foldDisplayMode); property_.SetBounds(bounds); property_.SetRotation(static_cast(rotation)); property_.UpdateScreenRotation(targetRotation); property_.SetDisplayOrientation(displayOrientation); - displayNode_->SetScreenRotation(static_cast(targetRotation)); + displayNode_->SetScreenRotation(static_cast(displayScreenRotation)); auto transactionProxy = RSTransactionProxy::GetInstance(); if (transactionProxy != nullptr) { transactionProxy->FlushImplicitTransaction(); } - WLOGFI("bounds:[%{public}f %{public}f %{public}f %{public}f], rotation: %{public}u", + WLOGFI("bounds:[%{public}f %{public}f %{public}f %{public}f],rotation:%{public}d,displayOrientation:%{public}u", property_.GetBounds().rect_.GetLeft(), property_.GetBounds().rect_.GetTop(), - property_.GetBounds().rect_.GetWidth(), property_.GetBounds().rect_.GetHeight(), targetRotation); + property_.GetBounds().rect_.GetWidth(), property_.GetBounds().rect_.GetHeight(), + rotation, displayOrientation); } sptr ScreenSession::GetActiveScreenMode() const @@ -403,7 +414,7 @@ Rotation ScreenSession::CalcRotation(Orientation orientation) const } } -DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation) const +DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const { sptr info = GetActiveScreenMode(); if (info == nullptr) { @@ -411,6 +422,9 @@ DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation) cons } // vertical: phone(Plugin screen); horizontal: pad & external screen bool isVerticalScreen = info->width_ < info->height_; + if (foldDisplayMode != FoldDisplayMode::UNKNOWN) { + isVerticalScreen = info->width_ > info->height_; + } switch (rotation) { case Rotation::ROTATION_0: { return isVerticalScreen ? DisplayOrientation::PORTRAIT : DisplayOrientation::LANDSCAPE; diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index b78681c3db..e4a37b976c 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -883,7 +883,7 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const screenSession->GetScreenProperty().GetRotation() != static_cast(rotation)) { needNotifyAvoidArea = true; } - screenSession->UpdatePropertyAfterRotation(bounds, rotation); + screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode()); sptr displayInfo = screenSession->ConvertToDisplayInfo(); if (displayInfo == nullptr) { WLOGFE("fail to update screen rotation property, displayInfo is nullptr"); -- Gitee From 75a874b04f65e22073162cf2d07875b07ae304c8 Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 20 Nov 2023 16:58:42 +0800 Subject: [PATCH 2/4] fix fold phone snapshot Signed-off-by: zhangzhicong --- window_scene/session/screen/src/screen_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index b79d6b3074..45c1e0a749 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -265,7 +265,7 @@ void ScreenSession::ScreenOrientationChange(float orientation) } } -Rotation ScreenSession::ConvertIntToRotation(int rotation); +Rotation ScreenSession::ConvertIntToRotation(int rotation) { Rotation targetRotation = Rotation::ROTATION_0; switch (rotation) { -- Gitee From f2c048af6a2a42c99d1173021a4d5782c042d141 Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 20 Nov 2023 19:47:41 +0800 Subject: [PATCH 3/4] fix fold phone snapshot Signed-off-by: zhangzhicong --- window_scene/session/screen/src/screen_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 45c1e0a749..d81aaaf0f2 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -290,7 +290,7 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, Fold Rotation targetRotation = ConvertIntToRotation(rotation); Rotation displayScreenRotation = targetRotation; if (foldDisplayMode == FoldDisplayMode::FULL) { - displayScreenRotation = ConvertIntToRotation((rotation + 90) % 360); + displayScreenRotation = ConvertIntToRotation((rotation + 90) % 360); // fold phone need fix 90 degree } DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation, foldDisplayMode); property_.SetBounds(bounds); -- Gitee From 4f2c0f03818a10b7d0723c0b629b0aed02a0d60b Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 20 Nov 2023 20:38:09 +0800 Subject: [PATCH 4/4] fix fold phone snapshot Signed-off-by: zhangzhicong --- window_scene/session/screen/src/screen_session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index d81aaaf0f2..0243cf11ff 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -290,7 +290,8 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, Fold Rotation targetRotation = ConvertIntToRotation(rotation); Rotation displayScreenRotation = targetRotation; if (foldDisplayMode == FoldDisplayMode::FULL) { - displayScreenRotation = ConvertIntToRotation((rotation + 90) % 360); // fold phone need fix 90 degree + // fold phone need fix 90 degree by remainder 360 degree + displayScreenRotation = ConvertIntToRotation((rotation + 90) % 360); } DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation, foldDisplayMode); property_.SetBounds(bounds); -- Gitee