From 59903eea6fb4a8bbd2cfdce81c40b552216cef96 Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Mon, 1 Aug 2022 18:21:52 +0800 Subject: [PATCH] bugfix for -270->0 rotate Signed-off-by: chyyy0213 Change-Id: I5e4298493c2b6115c3cb86eb0981d1d2bc70992f Signed-off-by: chyyy0213 --- dmserver/src/abstract_screen_controller.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 46ba2b25..8383a3f4 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -655,6 +655,17 @@ void AbstractScreenController::SetScreenRotateAnimation( x = (h - w) / 2; // 2: used to calculate offset to center display node y = (w - h) / 2; // 2: used to calculate offset to center display node } + auto displayNode = GetRSDisplayNodeByScreenId(screenId); + if (displayNode == nullptr) { + return; + } + if (rotationAfter == Rotation::ROTATION_0 && screen->rotation_ == Rotation::ROTATION_270) { + // avoid animation 270, 240, 210 ... 30, 0, should play from 90->0 + displayNode->SetRotation(90.f); + } else if (rotationAfter == Rotation::ROTATION_270 && screen->rotation_ == Rotation::ROTATION_0) { + // avoid animation 0, 30, 60 ... 270, should play from 360->270 + displayNode->SetRotation(-360.f); + } std::weak_ptr weakNode = GetRSDisplayNodeByScreenId(screenId); static const RSAnimationTimingProtocol timingProtocol(600); // animation time static const RSAnimationTimingCurve curve_ = @@ -665,7 +676,7 @@ void AbstractScreenController::SetScreenRotateAnimation( WLOGFE("SetScreenRotateAnimation error, cannot get DisplayNode"); return; } - displayNode->SetRotation(-90.0f * static_cast(rotationAfter)); // 90.f is base degree + displayNode->SetRotation(-90.f * static_cast(rotationAfter)); // 90.f is base degree displayNode->SetFrame(x, y, w, h); displayNode->SetBounds(x, y, w, h); });