fix comments

Signed-off-by: 白钰胜 <baiyusheng@h-partners.com>
This commit is contained in:
白钰胜 2024-11-21 12:02:17 +08:00
parent a3d93c7822
commit a58a1767fd
9 changed files with 54 additions and 54 deletions

View File

@ -727,15 +727,15 @@ HWTEST_F(WindowLayoutTest, ResizeDataRoute, Function | MediumTest | Level3)
} }
/** /**
* @tc.name: FixRectByAspectRatio * @tc.name: AdjustRectByAspectRatio
* @tc.desc: test FixRectByAspectRatio * @tc.desc: test AdjustRectByAspectRatio
* @tc.type: FUNC * @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<WindowOption> option = sptr<WindowOption>::MakeSptr(); sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
option->SetWindowName("FixRectByAspectRatio"); option->SetWindowName("AdjustRectByAspectRatio");
option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowType(WindowType::APP_WINDOW_BASE);
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
sptr<WindowSceneSessionImpl> windowSceneSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option); sptr<WindowSceneSessionImpl> windowSceneSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option);
@ -775,12 +775,12 @@ HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0)
WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false); WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false);
EXPECT_EQ(WSError::WS_OK, wsRet2); EXPECT_EQ(WSError::WS_OK, wsRet2);
usleep(WAIT_SERVERAL_FRAMES); 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); EXPECT_EQ(WSError::WS_OK, wsRet3);
usleep(WAIT_SERVERAL_FRAMES); usleep(WAIT_SERVERAL_FRAMES);
WSError wsRet4 = session->SetAspectRatio(ratio); WSError wsRet4 = session->SetAspectRatio(ratio);
EXPECT_EQ(WSError::WS_OK, wsRet4); EXPECT_EQ(WSError::WS_OK, wsRet4);
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio end ###"); TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###");
} }
} }

View File

@ -532,7 +532,7 @@ public:
bool IsDirtyWindow(); bool IsDirtyWindow();
bool IsDirtyDragWindow(); bool IsDirtyDragWindow();
void ResetSizeChangeReasonIfDirty(); void ResetSizeChangeReasonIfDirty();
void SetRequestNextVsyncFunc(const RequestVsyncFunc&& func); void SetRequestNextVsyncFunc(RequestVsyncFunc&& func);
void OnNextVsyncReceivedWhenDrag(); void OnNextVsyncReceivedWhenDrag();
void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback); void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback);
bool SetFrameGravity(Gravity gravity); bool SetFrameGravity(Gravity gravity);
@ -792,8 +792,8 @@ private:
/** /**
* Window Layout * Window Layout
*/ */
void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect);
bool FixRectByAspectRatio(WSRect& rect); bool AdjustRectByAspectRatio(WSRect& rect);
bool SaveAspectRatio(float ratio); bool SaveAspectRatio(float ratio);
void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason); void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason);
WSError UpdateRectForDrag(const WSRect& rect); WSError UpdateRectForDrag(const WSRect& rect);

View File

@ -338,7 +338,7 @@ WSError SceneSession::Foreground(
return ForegroundTask(property); return ForegroundTask(property);
} }
void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc&& func) void SceneSession::SetRequestNextVsyncFunc(RequestVsyncFunc&& func)
{ {
if (func == nullptr) { if (func == nullptr) {
TLOGI(WmsLogTag::DEFAULT, "func is nullptr"); TLOGI(WmsLogTag::DEFAULT, "func is nullptr");
@ -964,7 +964,7 @@ static WSError CheckAspectRatioValid(const sptr<SceneSession>& session, float ra
/** @note @window.layout */ /** @note @window.layout */
WSError SceneSession::SetAspectRatio(float ratio) WSError SceneSession::SetAspectRatio(float ratio)
{ {
auto task = [weakThis = wptr(this), ratio]() { auto task = [weakThis = wptr(this), ratio] {
auto session = weakThis.promote(); auto session = weakThis.promote();
if (!session) { if (!session) {
TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); TLOGE(WmsLogTag::WMS_LAYOUT, "session is null");
@ -989,13 +989,13 @@ WSError SceneSession::SetAspectRatio(float ratio)
session->moveDragController_->SetAspectRatio(ratio); session->moveDragController_->SetAspectRatio(ratio);
} }
session->SaveAspectRatio(session->aspectRatio_); session->SaveAspectRatio(session->aspectRatio_);
WSRect fixedRect = session->winRect_; WSRect adjustedRect = session->winRect_;
TLOGI(WmsLogTag::WMS_LAYOUT, "Before fixing, the id:%{public}d, the current rect: %{public}s, " TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect: %{public}s, "
"ratio: %{public}f", session->GetPersistentId(), fixedRect.ToString().c_str(), ratio); "ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio);
if (session->FixRectByAspectRatio(fixedRect)) { if (session->AdjustRectByAspectRatio(adjustedRect)) {
TLOGI(WmsLogTag::WMS_LAYOUT, "After fixing, the id:%{public}d, the fixed rect: %{public}s", TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect: %{public}s",
session->GetPersistentId(), fixedRect.ToString().c_str()); session->GetPersistentId(), adjustedRect.ToString().c_str());
session->NotifySessionRectChange(fixedRect, SizeChangeReason::RESIZE); session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE);
} }
return WSError::WS_OK; 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>& rsTransaction) const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction)
{ {
const char* const funcName = __func__; 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(); auto session = weakThis.promote();
if (!session) { if (!session) {
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
@ -2466,7 +2466,7 @@ bool SceneSession::SaveAspectRatio(float ratio)
return false; 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) { if (isDecor) {
rect.width_ = SessionUtils::ToLayoutWidth(rect.width_, vpr); 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); 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 const int tolerancePx = 2; // 2: tolerance delta pixel value, unit: px
WSRect originalRect = rect; WSRect originalRect = rect;
@ -2536,7 +2536,7 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect)
rect.height_ = rect.width_ / aspectRatio_; rect.height_ = rect.width_ / aspectRatio_;
} }
} }
FixRectByLimits(property->GetWindowLimits(), rect, aspectRatio_, IsDecorEnable(), vpr); AdjustRectByLimits(property->GetWindowLimits(), aspectRatio_, IsDecorEnable(), vpr, rect);
if (std::abs(static_cast<int32_t>(originalRect.width_) - static_cast<int32_t>(rect.width_)) <= tolerancePx && if (std::abs(static_cast<int32_t>(originalRect.width_) - static_cast<int32_t>(rect.width_)) <= tolerancePx &&
std::abs(static_cast<int32_t>(originalRect.height_) - static_cast<int32_t>(rect.height_)) <= tolerancePx) { std::abs(static_cast<int32_t>(originalRect.height_) - static_cast<int32_t>(rect.height_)) <= tolerancePx) {
rect = originalRect; rect = originalRect;

View File

@ -886,11 +886,11 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level
} }
/** /**
* @tc.name: FixRectByAspectRatio * @tc.name: AdjustRectByAspectRatio
* @tc.desc: FixRectByAspectRatio * @tc.desc: AdjustRectByAspectRatio
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) HWTEST_F(SceneSessionTest, AdjustRectByAspectRatio, Function | SmallTest | Level2)
{ {
SessionInfo info; SessionInfo info;
info.abilityName_ = "Background01"; info.abilityName_ = "Background01";
@ -904,7 +904,7 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(sceneSession, nullptr); EXPECT_NE(sceneSession, nullptr);
WSRect originalRect_ = { 0, 0, 0, 0 }; WSRect originalRect_ = { 0, 0, 0, 0 };
ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_)); ASSERT_EQ(false, sceneSession->AdjustRectByAspectRatio(originalRect_));
} }
/** /**

View File

@ -1648,7 +1648,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
float ratio = 0.0; float ratio = 0.0;
bool isDecor = true; bool isDecor = true;
float vpr = 0.0; float vpr = 0.0;
sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr); sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect);
sceneSession->SetPipActionEvent("pointerEvent", 0); sceneSession->SetPipActionEvent("pointerEvent", 0);
auto property = sptr<WindowSessionProperty>::MakeSptr(); auto property = sptr<WindowSessionProperty>::MakeSptr();
@ -1660,7 +1660,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr(); sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
property->SetWindowType(WindowType::WINDOW_TYPE_PIP); property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
property->SetWindowMode(WindowMode::WINDOW_MODE_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)); ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
} }

View File

@ -742,42 +742,42 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2)
} }
/** /**
* @tc.name: FixRectByAspectRatio * @tc.name: AdjustRectByAspectRatio
* @tc.desc: FixRectByAspectRatio function01 * @tc.desc: AdjustRectByAspectRatio function01
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio, Function | SmallTest | Level2) HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2)
{ {
SessionInfo info; SessionInfo info;
info.abilityName_ = "FixRectByAspectRatio"; info.abilityName_ = "AdjustRectByAspectRatio";
info.bundleName_ = "FixRectByAspectRatio"; info.bundleName_ = "AdjustRectByAspectRatio";
info.isSystem_ = false; info.isSystem_ = false;
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr); sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(session, nullptr); EXPECT_NE(session, nullptr);
sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr(); sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
session->SetSessionProperty(nullptr); session->SetSessionProperty(nullptr);
WSRect rect; WSRect rect;
EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
session->SetSessionProperty(property); session->SetSessionProperty(property);
property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); 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->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
property->SetWindowType(WindowType::APP_MAIN_WINDOW_END); 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); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
} }
/** /**
* @tc.name: FixRectByAspectRatio01 * @tc.name: AdjustRectByAspectRatio01
* @tc.desc: FixRectByAspectRatio function01 * @tc.desc: AdjustRectByAspectRatio function01
* @tc.type: FUNC * @tc.type: FUNC
*/ */
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level2) HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2)
{ {
SessionInfo info; SessionInfo info;
info.abilityName_ = "FixRectByAspectRatio01"; info.abilityName_ = "AdjustRectByAspectRatio01";
info.bundleName_ = "FixRectByAspectRatio01"; info.bundleName_ = "AdjustRectByAspectRatio01";
info.isSystem_ = false; info.isSystem_ = false;
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr); sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(session, nullptr); EXPECT_NE(session, nullptr);
@ -791,14 +791,14 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level
systemConfig.isSystemDecorEnable_ = true; systemConfig.isSystemDecorEnable_ = true;
systemConfig.decorWindowModeSupportType_ = 2; systemConfig.decorWindowModeSupportType_ = 2;
session->SetSystemConfig(systemConfig); session->SetSystemConfig(systemConfig);
EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
systemConfig.isSystemDecorEnable_ = false; systemConfig.isSystemDecorEnable_ = false;
EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
systemConfig.isSystemDecorEnable_ = true; systemConfig.isSystemDecorEnable_ = true;
session->SetSessionProperty(nullptr); session->SetSessionProperty(nullptr);
EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
} }
/** /**

View File

@ -420,7 +420,7 @@ protected:
/** /**
* Window Layout * Window Layout
*/ */
std::atomic_bool isDragTaskUpdateDone_ = true; std::atomic_bool isDragTaskPostDone_ = true;
void FlushLayoutSize(int32_t width, int32_t height) override; void FlushLayoutSize(int32_t width, int32_t height) override;
sptr<FutureCallback> layoutCallback_ = nullptr; sptr<FutureCallback> layoutCallback_ = nullptr;
void UpdateVirtualPixelRatio(const sptr<Display>& display); void UpdateVirtualPixelRatio(const sptr<Display>& display);

View File

@ -811,7 +811,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
} }
if (wmReason == WindowSizeChangeReason::DRAG) { if (wmReason == WindowSizeChangeReason::DRAG) {
window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction); window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction);
window->isDragTaskUpdateDone_.store(true); window->isDragTaskPostDone_.store(true);
} else { } else {
window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
} }
@ -820,9 +820,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
} }
}; };
if (wmReason == WindowSizeChangeReason::DRAG) { if (wmReason == WindowSizeChangeReason::DRAG) {
if (isDragTaskUpdateDone_.load()) { bool isDragTaskPostDone = true;
if (isDragTaskPostDone_.compare_exchange_strong(isDragTaskPostDone, false)) {
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");
isDragTaskUpdateDone_.store(false);
} }
} else { } else {
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");