mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-26 02:35:54 +00:00
蓝黄同步
Signed-off-by: lpf <liaopengfei@h-partners.com>
This commit is contained in:
parent
e849c3b85d
commit
bf5ba780a3
@ -2081,7 +2081,7 @@ public:
|
||||
*
|
||||
* @return Value of PixelRatio obtained from displayInfo.
|
||||
*/
|
||||
virtual float GetVirtualPixelRatio() { return 0.0f; }
|
||||
virtual float GetVirtualPixelRatio() { return 1.0f; }
|
||||
|
||||
/**
|
||||
* @brief Hide None Secure Windows.
|
||||
|
@ -296,7 +296,7 @@ public:
|
||||
virtual void SetDensity(float density) = 0;
|
||||
virtual WMError SetDefaultDensityEnabled(bool enabled) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
|
||||
virtual bool GetDefaultDensityEnabled() { return false; }
|
||||
virtual float GetVirtualPixelRatio() { return 0.0f; }
|
||||
virtual float GetVirtualPixelRatio() { return 1.0f; }
|
||||
virtual void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type);
|
||||
virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) = 0;
|
||||
virtual void SetContentInfoCallback(const ContentInfoCallback& callback) = 0;
|
||||
|
@ -686,7 +686,7 @@ WMError WindowImpl::SetUIContentInner(const std::string& contentInfo, napi_env e
|
||||
|
||||
float WindowImpl::GetVirtualPixelRatio()
|
||||
{
|
||||
float vpr = 0.0f; // This is an abnormal value, which is used to identify abnormal scenarios.
|
||||
float vpr = 1.0f; // This is an abnormal value, which is used to identify abnormal scenarios.
|
||||
auto display = SingletonContainer::IsDestroyed() ? nullptr :
|
||||
SingletonContainer::Get<DisplayManager>().GetDisplayById(property_->GetDisplayId());
|
||||
if (display == nullptr) {
|
||||
|
@ -702,6 +702,22 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionImpl::UpdateVirtualPixelRatio(const sptr<Display>& display)
|
||||
{
|
||||
if (display == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "display is null when rotation!");
|
||||
return;
|
||||
}
|
||||
sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
|
||||
if (displayInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "displayInfo is null when rotation!");
|
||||
return;
|
||||
}
|
||||
virtualPixelRatio_ = GetVirtualPixelRatio(displayInfo);
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "virtualPixelRatio: %{public}f", virtualPixelRatio_);
|
||||
}
|
||||
|
||||
void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& preRect,
|
||||
WindowSizeChangeReason wmReason, const SceneAnimationConfig& config)
|
||||
{
|
||||
@ -711,6 +727,9 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
auto display = SingletonContainer::Get<DisplayManager>().GetDisplayById(window->property_->GetDisplayId());
|
||||
sptr<DisplayInfo> displayInfo = display ? display->GetDisplayInfo() : nullptr;
|
||||
window->UpdateVirtualPixelRatio(display);
|
||||
const std::shared_ptr<RSTransaction>& rsTransaction = config.rsTransaction_;
|
||||
if (rsTransaction) {
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
@ -735,7 +754,7 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr
|
||||
window->NotifySizeChange(wmRect, wmReason);
|
||||
window->lastSizeChangeReason_ = wmReason;
|
||||
}
|
||||
window->UpdateViewportConfig(wmRect, wmReason, rsTransaction);
|
||||
window->UpdateViewportConfig(wmRect, wmReason, rsTransaction, displayInfo);
|
||||
RSNode::CloseImplicitAnimation();
|
||||
if (rsTransaction) {
|
||||
rsTransaction->Commit();
|
||||
@ -1057,20 +1076,11 @@ WSError WindowSessionImpl::UpdateWindowMode(WindowMode mode)
|
||||
return WSError::WS_OK;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
float WindowSessionImpl::GetVirtualPixelRatio()
|
||||
{
|
||||
float vpr = 0.0f; // This is an abnormal value, which is used to identify abnormal scenarios.
|
||||
auto display = SingletonContainer::Get<DisplayManager>().GetDisplayById(property_->GetDisplayId());
|
||||
if (display == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "display is null!");
|
||||
return vpr;
|
||||
}
|
||||
sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
|
||||
if (displayInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "displayInfo is null!");
|
||||
return vpr;
|
||||
}
|
||||
return GetVirtualPixelRatio(displayInfo);
|
||||
TLOGD(WmsLogTag::WMS_LAYOUT, "virtualPixelRatio: %{public}f", virtualPixelRatio_);
|
||||
return virtualPixelRatio_;
|
||||
}
|
||||
|
||||
float WindowSessionImpl::GetVirtualPixelRatio(sptr<DisplayInfo> displayInfo)
|
||||
|
@ -1414,14 +1414,14 @@ HWTEST_F(WindowImplTest5, GetVirtualPixelRatio01, Function | SmallTest | Level1)
|
||||
window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
|
||||
float vpr = -1.0f;
|
||||
float vpr = 0.0f;
|
||||
window->property_->SetDisplayId(-1);
|
||||
vpr = window->GetVirtualPixelRatio();
|
||||
ASSERT_EQ(vpr, 0.0f);
|
||||
ASSERT_EQ(vpr, 1.0f);
|
||||
|
||||
window->property_->SetDisplayId(0);
|
||||
vpr = window->GetVirtualPixelRatio();
|
||||
ASSERT_NE(vpr, 0.0f);
|
||||
ASSERT_NE(vpr, 1.0f);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
@ -1396,6 +1396,32 @@ HWTEST_F(WindowSessionImplTest4, NotifyWindowVisibility01, Function | SmallTest
|
||||
window->UnregisterWindowVisibilityChangeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateVirtualPixelRatio
|
||||
* @tc.desc: test UpdateVirtualPixelRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowSessionImplTest4, UpdateVirtualPixelRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio start";
|
||||
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
|
||||
option->SetWindowName("UpdateVirtualPixelRatio");
|
||||
sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
|
||||
window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
|
||||
window->property_->SetDisplayId(-1);
|
||||
sptr<Display> display = nullptr;
|
||||
window->UpdateVirtualPixelRatio(display);
|
||||
ASSERT_EQ(window->virtualPixelRatio_, 1.0f);
|
||||
|
||||
window->property_->SetDisplayId(0);
|
||||
display = SingletonContainer::Get<DisplayManager>().GetDisplayById(window->property_->GetDisplayId());
|
||||
window->UpdateVirtualPixelRatio(display);
|
||||
ASSERT_NE(window->virtualPixelRatio_, 1.0f);
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NotifyMainWindowClose01
|
||||
* @tc.desc: NotifyMainWindowClose
|
||||
@ -1643,31 +1669,6 @@ HWTEST_F(WindowSessionImplTest4, UpdateSubWindowStateAndNotify01, Function | Sma
|
||||
EXPECT_EQ(WMError::WM_OK, window->Destroy(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetVirtualPixelRatio
|
||||
* @tc.desc: test GetVirtualPixelRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowSessionImplTest4, GetVirtualPixelRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetVirtualPixelRatio start";
|
||||
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
|
||||
option->SetWindowName("GetVirtualPixelRatio");
|
||||
sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
|
||||
window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
|
||||
float vpr = -1.0f;
|
||||
window->property_->SetDisplayId(-1);
|
||||
vpr = window->GetVirtualPixelRatio();
|
||||
ASSERT_EQ(vpr, 0.0f);
|
||||
|
||||
window->property_->SetDisplayId(0);
|
||||
vpr = window->GetVirtualPixelRatio();
|
||||
ASSERT_NE(vpr, 0.0f);
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetVirtualPixelRatio end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NotifyRotationAnimationEnd
|
||||
* @tc.desc: test NotifyRotationAnimationEnd
|
||||
|
Loading…
x
Reference in New Issue
Block a user