From a58a1767fd5015361cf6290af2670cc2c6c8dd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Thu, 21 Nov 2024 12:02:17 +0800 Subject: [PATCH] fix comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- .../wms/window_layout_integration_test.cpp | 14 ++++---- .../session/host/include/scene_session.h | 6 ++-- window_scene/session/host/include/session.h | 6 ++-- .../session/host/src/scene_session.cpp | 26 +++++++------- .../test/unittest/scene_session_test.cpp | 8 ++--- .../test/unittest/scene_session_test2.cpp | 4 +-- .../test/unittest/scene_session_test5.cpp | 36 +++++++++---------- wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 6 ++-- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/test/systemtest/wms/window_layout_integration_test.cpp b/test/systemtest/wms/window_layout_integration_test.cpp index ef9c91eff0..1bd59443cd 100644 --- a/test/systemtest/wms/window_layout_integration_test.cpp +++ b/test/systemtest/wms/window_layout_integration_test.cpp @@ -727,15 +727,15 @@ HWTEST_F(WindowLayoutTest, ResizeDataRoute, Function | MediumTest | Level3) } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: test FixRectByAspectRatio + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: test AdjustRectByAspectRatio * @tc.type: FUNC */ -HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0) +HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, Function | MediumTest | Level0) { - TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio begin ###"); + TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio begin ###"); sptr option = sptr::MakeSptr(); - option->SetWindowName("FixRectByAspectRatio"); + option->SetWindowName("AdjustRectByAspectRatio"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sptr windowSceneSessionImpl = sptr::MakeSptr(option); @@ -775,12 +775,12 @@ HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0) WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false); EXPECT_EQ(WSError::WS_OK, wsRet2); usleep(WAIT_SERVERAL_FRAMES); - WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "FixRectByAspectRatio", nullptr); + WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "AdjustRectByAspectRatio", nullptr); EXPECT_EQ(WSError::WS_OK, wsRet3); usleep(WAIT_SERVERAL_FRAMES); WSError wsRet4 = session->SetAspectRatio(ratio); EXPECT_EQ(WSError::WS_OK, wsRet4); - TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio end ###"); + TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###"); } } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 24b8acf4ee..8c216f350d 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -532,7 +532,7 @@ public: bool IsDirtyWindow(); bool IsDirtyDragWindow(); void ResetSizeChangeReasonIfDirty(); - void SetRequestNextVsyncFunc(const RequestVsyncFunc&& func); + void SetRequestNextVsyncFunc(RequestVsyncFunc&& func); void OnNextVsyncReceivedWhenDrag(); void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback); bool SetFrameGravity(Gravity gravity); @@ -792,8 +792,8 @@ private: /** * Window Layout */ - void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); - bool FixRectByAspectRatio(WSRect& rect); + void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect); + bool AdjustRectByAspectRatio(WSRect& rect); bool SaveAspectRatio(float ratio); void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason); WSError UpdateRectForDrag(const WSRect& rect); diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 6dc5d0cf2c..523e0d7ee6 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -671,10 +671,10 @@ protected: */ RequestVsyncFunc requestNextVsyncFunc_; WSRect winRect_; - WSRect clientRect_; // rect saved when prelayout or notify client to update rect + WSRect clientRect_; // rect saved when prelayout or notify client to update rect WSRect lastLayoutRect_; // rect saved when go background - WSRect layoutRect_; // rect of root view - WSRect globalRect_; // globalRect include translate + WSRect layoutRect_; // rect of root view + WSRect globalRect_; // globalRect include translate SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; NotifySessionRectChangeFunc sessionRectChangeFunc_; float clientScaleX_ = 1.0f; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index fdca5b12b0..df318a2360 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -338,7 +338,7 @@ WSError SceneSession::Foreground( return ForegroundTask(property); } -void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc&& func) +void SceneSession::SetRequestNextVsyncFunc(RequestVsyncFunc&& func) { if (func == nullptr) { TLOGI(WmsLogTag::DEFAULT, "func is nullptr"); @@ -964,7 +964,7 @@ static WSError CheckAspectRatioValid(const sptr& session, float ra /** @note @window.layout */ WSError SceneSession::SetAspectRatio(float ratio) { - auto task = [weakThis = wptr(this), ratio]() { + auto task = [weakThis = wptr(this), ratio] { auto session = weakThis.promote(); if (!session) { TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); @@ -989,13 +989,13 @@ WSError SceneSession::SetAspectRatio(float ratio) session->moveDragController_->SetAspectRatio(ratio); } session->SaveAspectRatio(session->aspectRatio_); - WSRect fixedRect = session->winRect_; - TLOGI(WmsLogTag::WMS_LAYOUT, "Before fixing, the id:%{public}d, the current rect: %{public}s, " - "ratio: %{public}f", session->GetPersistentId(), fixedRect.ToString().c_str(), ratio); - if (session->FixRectByAspectRatio(fixedRect)) { - TLOGI(WmsLogTag::WMS_LAYOUT, "After fixing, the id:%{public}d, the fixed rect: %{public}s", - session->GetPersistentId(), fixedRect.ToString().c_str()); - session->NotifySessionRectChange(fixedRect, SizeChangeReason::RESIZE); + WSRect adjustedRect = session->winRect_; + TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect: %{public}s, " + "ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio); + if (session->AdjustRectByAspectRatio(adjustedRect)) { + TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect: %{public}s", + session->GetPersistentId(), adjustedRect.ToString().c_str()); + session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE); } return WSError::WS_OK; }; @@ -1007,7 +1007,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::string& updateReason, const std::shared_ptr& rsTransaction) { const char* const funcName = __func__; - auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName]() { + auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName] { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); @@ -2466,7 +2466,7 @@ bool SceneSession::SaveAspectRatio(float ratio) return false; } -void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr) +void SceneSession::AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect) { if (isDecor) { rect.width_ = SessionUtils::ToLayoutWidth(rect.width_, vpr); @@ -2494,7 +2494,7 @@ void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float rati rect.width_ = SessionUtils::ToWinWidth(rect.width_, vpr); } } -bool SceneSession::FixRectByAspectRatio(WSRect& rect) +bool SceneSession::AdjustRectByAspectRatio(WSRect& rect) { const int tolerancePx = 2; // 2: tolerance delta pixel value, unit: px WSRect originalRect = rect; @@ -2536,7 +2536,7 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect) rect.height_ = rect.width_ / aspectRatio_; } } - FixRectByLimits(property->GetWindowLimits(), rect, aspectRatio_, IsDecorEnable(), vpr); + AdjustRectByLimits(property->GetWindowLimits(), aspectRatio_, IsDecorEnable(), vpr, rect); if (std::abs(static_cast(originalRect.width_) - static_cast(rect.width_)) <= tolerancePx && std::abs(static_cast(originalRect.height_) - static_cast(rect.height_)) <= tolerancePx) { rect = originalRect; diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 2cb826a5f7..4a068fc008 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -886,11 +886,11 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: FixRectByAspectRatio + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: AdjustRectByAspectRatio * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest, AdjustRectByAspectRatio, Function | SmallTest | Level2) { SessionInfo info; info.abilityName_ = "Background01"; @@ -904,7 +904,7 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); WSRect originalRect_ = { 0, 0, 0, 0 }; - ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_)); + ASSERT_EQ(false, sceneSession->AdjustRectByAspectRatio(originalRect_)); } /** diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 9e3570f82f..52c52673da 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1648,7 +1648,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level float ratio = 0.0; bool isDecor = true; float vpr = 0.0; - sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr); + sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect); sceneSession->SetPipActionEvent("pointerEvent", 0); auto property = sptr::MakeSptr(); @@ -1660,7 +1660,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level sceneSession->sessionStage_ = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_PIP); property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - sceneSession->FixRectByLimits(limits, rect, ratio, false, vpr); + sceneSession->AdjustRectByLimits(limits, ratio, false, vpr, rect); ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0)); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 31e8cb883b..489cbacd63 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -742,42 +742,42 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2) } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: FixRectByAspectRatio function01 + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: AdjustRectByAspectRatio function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, FixRectByAspectRatio, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "FixRectByAspectRatio"; - info.bundleName_ = "FixRectByAspectRatio"; + info.abilityName_ = "AdjustRectByAspectRatio"; + info.bundleName_ = "AdjustRectByAspectRatio"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); sptr property = sptr::MakeSptr(); session->SetSessionProperty(nullptr); WSRect rect; - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); session->SetSessionProperty(property); property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetWindowType(WindowType::APP_MAIN_WINDOW_END); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect)); } /** - * @tc.name: FixRectByAspectRatio01 - * @tc.desc: FixRectByAspectRatio function01 + * @tc.name: AdjustRectByAspectRatio01 + * @tc.desc: AdjustRectByAspectRatio function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "FixRectByAspectRatio01"; - info.bundleName_ = "FixRectByAspectRatio01"; + info.abilityName_ = "AdjustRectByAspectRatio01"; + info.bundleName_ = "AdjustRectByAspectRatio01"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); @@ -791,14 +791,14 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level systemConfig.isSystemDecorEnable_ = true; systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); - EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect)); systemConfig.isSystemDecorEnable_ = false; - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); systemConfig.isSystemDecorEnable_ = true; session->SetSessionProperty(nullptr); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); } /** @@ -813,7 +813,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2) info.bundleName_ = "OnMoveDragCallback"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); - session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback){}); + session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback) {}); EXPECT_NE(nullptr, session->requestNextVsyncFunc_); session->moveDragController_ = nullptr; SizeChangeReason reason = { SizeChangeReason::DRAG }; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index b89a5e5abf..78e6c49b2a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -420,7 +420,7 @@ protected: /** * Window Layout */ - std::atomic_bool isDragTaskUpdateDone_ = true; + std::atomic_bool isDragTaskPostDone_ = true; void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; void UpdateVirtualPixelRatio(const sptr& display); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 643ad1f82b..e3ab0a378e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -811,7 +811,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } if (wmReason == WindowSizeChangeReason::DRAG) { window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction); - window->isDragTaskUpdateDone_.store(true); + window->isDragTaskPostDone_.store(true); } else { window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); } @@ -820,9 +820,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } }; if (wmReason == WindowSizeChangeReason::DRAG) { - if (isDragTaskUpdateDone_.load()) { + bool isDragTaskPostDone = true; + if (isDragTaskPostDone_.compare_exchange_strong(isDragTaskPostDone, false)) { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); - isDragTaskUpdateDone_.store(false); } } else { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");