mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-21 12:35:22 -04:00
Merge branch 'master' of gitee.com:openharmony/windowmanager
Signed-off-by: xingyanan <xingyanan2@huawei.com> Change-Id: I74264f9b6eeaf49f2c1928c0e0c85ddf89754ba5 Signed-off-by: xingyanan <xingyanan2@huawei.com>
This commit is contained in:
@@ -28,35 +28,34 @@
|
||||
#include "singleton_delegator.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class DMSDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
class BaseAdapter {
|
||||
public:
|
||||
virtual void OnRemoteDied(const wptr<IRemoteObject>& wptrDeath) override;
|
||||
};
|
||||
|
||||
class DisplayManagerAdapter {
|
||||
WM_DECLARE_SINGLE_INSTANCE(DisplayManagerAdapter);
|
||||
public:
|
||||
virtual DisplayId GetDefaultDisplayId();
|
||||
virtual sptr<Display> GetDisplayById(DisplayId displayId);
|
||||
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
virtual bool RequestRotation(ScreenId screenId, Rotation rotation);
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId);
|
||||
|
||||
// colorspace, gamut
|
||||
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
|
||||
virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut);
|
||||
virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx);
|
||||
virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap);
|
||||
virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap);
|
||||
virtual DMError SetScreenColorTransform(ScreenId screenId);
|
||||
|
||||
virtual bool RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
virtual bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type);
|
||||
virtual void Clear();
|
||||
protected:
|
||||
bool InitDMSProxyLocked();
|
||||
std::recursive_mutex mutex_;
|
||||
sptr<IDisplayManager> displayManagerServiceProxy_ = nullptr;
|
||||
sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
|
||||
};
|
||||
|
||||
class DMSDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
DMSDeathRecipient(BaseAdapter& adapter);
|
||||
virtual void OnRemoteDied(const wptr<IRemoteObject>& wptrDeath) override;
|
||||
private:
|
||||
BaseAdapter& adapter_;
|
||||
};
|
||||
|
||||
class DisplayManagerAdapter : public BaseAdapter {
|
||||
WM_DECLARE_SINGLE_INSTANCE(DisplayManagerAdapter);
|
||||
public:
|
||||
virtual DisplayId GetDefaultDisplayId();
|
||||
virtual sptr<Display> GetDisplayById(DisplayId displayId);
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId);
|
||||
virtual bool WakeUpBegin(PowerStateChangeReason reason);
|
||||
virtual bool WakeUpEnd();
|
||||
virtual bool SuspendBegin(PowerStateChangeReason reason);
|
||||
@@ -65,28 +64,45 @@ public:
|
||||
virtual bool SetDisplayState(DisplayState state);
|
||||
virtual DisplayState GetDisplayState(DisplayId displayId);
|
||||
virtual void NotifyDisplayEvent(DisplayEvent event);
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual void Clear();
|
||||
virtual DisplayInfo GetDisplayInfo(DisplayId displayId);
|
||||
virtual sptr<ScreenInfo> GetScreenInfo(ScreenId screenId);
|
||||
virtual sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
virtual sptr<ScreenGroup> GetScreenGroupById(ScreenId screenId);
|
||||
virtual std::vector<sptr<Screen>> GetAllScreens();
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
|
||||
virtual void UpdateDisplayInfo(DisplayId);
|
||||
private:
|
||||
bool InitDMSProxyLocked();
|
||||
sptr<DisplayInfo> GetDisplayInfo(DisplayId displayId);
|
||||
|
||||
static inline SingletonDelegator<DisplayManagerAdapter> delegator;
|
||||
|
||||
std::recursive_mutex mutex_;
|
||||
sptr<IDisplayManager> displayManagerServiceProxy_ = nullptr;
|
||||
sptr<DMSDeathRecipient> dmsDeath_ = nullptr;
|
||||
std::map<DisplayId, sptr<Display>> displayMap_;
|
||||
DisplayId defaultDisplayId_;
|
||||
};
|
||||
|
||||
class ScreenManagerAdapter : public BaseAdapter {
|
||||
WM_DECLARE_SINGLE_INSTANCE(ScreenManagerAdapter);
|
||||
public:
|
||||
virtual bool RequestRotation(ScreenId screenId, Rotation rotation);
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
virtual sptr<Screen> GetScreenById(ScreenId screenId);
|
||||
virtual sptr<ScreenGroup> GetScreenGroupById(ScreenId screenId);
|
||||
virtual std::vector<sptr<Screen>> GetAllScreens();
|
||||
virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
|
||||
virtual bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId);
|
||||
virtual void UpdateScreenInfo(ScreenId);
|
||||
|
||||
// colorspace, gamut
|
||||
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
|
||||
virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut);
|
||||
virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx);
|
||||
virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap);
|
||||
virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap);
|
||||
virtual DMError SetScreenColorTransform(ScreenId screenId);
|
||||
private:
|
||||
sptr<ScreenInfo> GetScreenInfo(ScreenId screenId);
|
||||
|
||||
static inline SingletonDelegator<ScreenManagerAdapter> delegator;
|
||||
|
||||
std::map<ScreenId, sptr<Screen>> screenMap_;
|
||||
std::map<ScreenId, sptr<ScreenGroup>> screenGroupMap_;
|
||||
DisplayId defaultDisplayId_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_H
|
||||
|
||||
+29
-63
@@ -23,90 +23,61 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "Display"};
|
||||
}
|
||||
class Display::Impl : public RefBase {
|
||||
friend class Display;
|
||||
private:
|
||||
void UpdateDisplay(sptr<DisplayInfo> info);
|
||||
|
||||
std::string name_;
|
||||
DisplayId id_ { DISPLAY_ID_INVALD };
|
||||
int32_t width_ { 0 };
|
||||
int32_t height_ { 0 };
|
||||
uint32_t freshRate_ { 0 };
|
||||
ScreenId screenId_ {SCREEN_ID_INVALID};
|
||||
Rotation rotation_ { Rotation::ROTATION_0 };
|
||||
public:
|
||||
Impl(const std::string& name, sptr<DisplayInfo> info)
|
||||
{
|
||||
name_= name;
|
||||
if (info == nullptr) {
|
||||
WLOGFE("DisplayInfo is nullptr.");
|
||||
}
|
||||
displayInfo_ = info;
|
||||
}
|
||||
~Impl() = default;
|
||||
DEFINE_VAR_FUNC_GET_SET(std::string, Name, name);
|
||||
DEFINE_VAR_FUNC_GET_SET(sptr<DisplayInfo>, DisplayInfo, displayInfo);
|
||||
};
|
||||
|
||||
void Display::Impl::UpdateDisplay(sptr<DisplayInfo> info)
|
||||
Display::Display(const std::string& name, sptr<DisplayInfo> info)
|
||||
: pImpl_(new Impl(name, info))
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("info is nullptr.");
|
||||
return;
|
||||
}
|
||||
width_ = info->width_;
|
||||
height_ = info->height_;
|
||||
freshRate_ = info->freshRate_;
|
||||
screenId_ = info->screenId_;
|
||||
rotation_ = info->rotation_;
|
||||
}
|
||||
|
||||
Display::Display(const std::string& name, DisplayInfo* info)
|
||||
: pImpl_(new Impl())
|
||||
{
|
||||
pImpl_->name_ = name;
|
||||
pImpl_->id_ = info->id_;
|
||||
pImpl_->width_ = info->width_;
|
||||
pImpl_->height_ = info->height_;
|
||||
pImpl_->freshRate_ = info->freshRate_;
|
||||
pImpl_->screenId_ = info->screenId_;
|
||||
pImpl_->rotation_ = info->rotation_;
|
||||
}
|
||||
|
||||
DisplayId Display::GetId() const
|
||||
{
|
||||
return pImpl_->id_;
|
||||
return pImpl_->GetDisplayInfo()->GetDisplayId();
|
||||
}
|
||||
|
||||
int32_t Display::GetWidth() const
|
||||
{
|
||||
DisplayInfo info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(pImpl_->id_);
|
||||
pImpl_->UpdateDisplay(&info);
|
||||
return pImpl_->width_;
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().UpdateDisplayInfo(GetId());
|
||||
return pImpl_->GetDisplayInfo()->GetWidth();
|
||||
}
|
||||
|
||||
int32_t Display::GetHeight() const
|
||||
{
|
||||
DisplayInfo info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(pImpl_->id_);
|
||||
pImpl_->UpdateDisplay(&info);
|
||||
return pImpl_->height_;
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().UpdateDisplayInfo(GetId());
|
||||
return pImpl_->GetDisplayInfo()->GetHeight();
|
||||
}
|
||||
|
||||
uint32_t Display::GetFreshRate() const
|
||||
{
|
||||
DisplayInfo info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(pImpl_->id_);
|
||||
pImpl_->UpdateDisplay(&info);
|
||||
return pImpl_->freshRate_;
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().UpdateDisplayInfo(GetId());
|
||||
return pImpl_->GetDisplayInfo()->GetFreshRate();
|
||||
}
|
||||
|
||||
ScreenId Display::GetScreenId() const
|
||||
{
|
||||
DisplayInfo info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(pImpl_->id_);
|
||||
pImpl_->UpdateDisplay(&info);
|
||||
return pImpl_->screenId_;
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().UpdateDisplayInfo(GetId());
|
||||
return pImpl_->GetDisplayInfo()->GetScreenId();
|
||||
}
|
||||
|
||||
void Display::SetWidth(int32_t width)
|
||||
void Display::UpdateDisplayInfo(sptr<DisplayInfo> displayInfo)
|
||||
{
|
||||
pImpl_->width_ = width;
|
||||
}
|
||||
|
||||
void Display::SetHeight(int32_t height)
|
||||
{
|
||||
pImpl_->height_ = height;
|
||||
}
|
||||
|
||||
void Display::SetFreshRate(uint32_t freshRate)
|
||||
{
|
||||
pImpl_->freshRate_ = freshRate;
|
||||
if (displayInfo == nullptr) {
|
||||
WLOGFE("displayInfo is invalid");
|
||||
return;
|
||||
}
|
||||
pImpl_->SetDisplayInfo(displayInfo);
|
||||
}
|
||||
|
||||
float Display::GetVirtualPixelRatio() const
|
||||
@@ -118,9 +89,4 @@ float Display::GetVirtualPixelRatio() const
|
||||
return 2.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Display::SetId(DisplayId id)
|
||||
{
|
||||
pImpl_->id_ = id;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
void OnDisplayCreate(sptr<DisplayInfo> displayInfo) override
|
||||
{
|
||||
if (displayInfo == nullptr || displayInfo->id_ == DISPLAY_ID_INVALD) {
|
||||
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALD) {
|
||||
WLOGFE("OnDisplayCreate, displayInfo is invalid.");
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
return;
|
||||
}
|
||||
for (auto listener : pImpl_->displayListeners_) {
|
||||
listener->OnCreate(displayInfo->id_);
|
||||
listener->OnCreate(displayInfo->GetDisplayId());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
void OnDisplayChange(const sptr<DisplayInfo> displayInfo, DisplayChangeEvent event) override
|
||||
{
|
||||
if (displayInfo == nullptr || displayInfo->id_ == DISPLAY_ID_INVALD) {
|
||||
if (displayInfo == nullptr || displayInfo->GetDisplayId() == DISPLAY_ID_INVALD) {
|
||||
WLOGFE("OnDisplayChange, displayInfo is invalid.");
|
||||
return;
|
||||
}
|
||||
@@ -92,9 +92,9 @@ public:
|
||||
WLOGFE("OnDisplayChange, impl is nullptr.");
|
||||
return;
|
||||
}
|
||||
WLOGD("OnDisplayChange. display %{public}" PRIu64", event %{public}u", displayInfo->id_, event);
|
||||
WLOGD("OnDisplayChange. display %{public}" PRIu64", event %{public}u", displayInfo->GetDisplayId(), event);
|
||||
for (auto listener : pImpl_->displayListeners_) {
|
||||
listener->OnChange(displayInfo->id_, event);
|
||||
listener->OnChange(displayInfo->GetDisplayId(), event);
|
||||
}
|
||||
};
|
||||
private:
|
||||
@@ -380,7 +380,7 @@ void DisplayManager::NotifyDisplayChangedEvent(const sptr<DisplayInfo> info, Dis
|
||||
WLOGI("NotifyDisplayChangedEvent event:%{public}u, size:%{public}zu", event, pImpl_->displayListeners_.size());
|
||||
std::lock_guard<std::recursive_mutex> lock(pImpl_->mutex_);
|
||||
for (auto& listener : pImpl_->displayListeners_) {
|
||||
listener->OnChange(info->id_, event);
|
||||
listener->OnChange(info->GetDisplayId(), event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapter"};
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapter)
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapter)
|
||||
|
||||
DisplayId DisplayManagerAdapter::GetDefaultDisplayId()
|
||||
{
|
||||
@@ -56,35 +57,34 @@ sptr<Display> DisplayManagerAdapter::GetDisplayById(DisplayId displayId)
|
||||
if (iter != displayMap_.end()) {
|
||||
// Update display in map
|
||||
// should be updated automatically
|
||||
DisplayInfo displayInfo = displayManagerServiceProxy_->GetDisplayInfoById(displayId);
|
||||
if (displayInfo.id_ == DISPLAY_ID_INVALD) {
|
||||
auto displayInfo = displayManagerServiceProxy_->GetDisplayInfoById(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
WLOGFE("GetDisplayById: displayInfo is nullptr!");
|
||||
displayMap_.erase(iter);
|
||||
return nullptr;
|
||||
}
|
||||
if (displayInfo->GetDisplayId() == DISPLAY_ID_INVALD) {
|
||||
WLOGFE("GetDisplayById: Get invalid displayInfo!");
|
||||
displayMap_.erase(iter);
|
||||
return nullptr;
|
||||
}
|
||||
sptr<Display> display = iter->second;
|
||||
if (displayInfo.width_ != display->GetWidth()) {
|
||||
display->SetWidth(displayInfo.width_);
|
||||
WLOGFI("GetDisplayById: set new width %{public}d", display->GetWidth());
|
||||
}
|
||||
if (displayInfo.height_ != display->GetHeight()) {
|
||||
display->SetHeight(displayInfo.height_);
|
||||
WLOGFI("GetDisplayById: set new height %{public}d", display->GetHeight());
|
||||
}
|
||||
if (displayInfo.freshRate_ != display->GetFreshRate()) {
|
||||
display->SetFreshRate(displayInfo.freshRate_);
|
||||
WLOGFI("GetDisplayById: set new freshRate %{public}ud", display->GetFreshRate());
|
||||
}
|
||||
display->UpdateDisplayInfo(displayInfo);
|
||||
return iter->second;
|
||||
}
|
||||
DisplayInfo displayInfo = displayManagerServiceProxy_->GetDisplayInfoById(displayId);
|
||||
sptr<Display> display = new Display("", &displayInfo);
|
||||
auto displayInfo = displayManagerServiceProxy_->GetDisplayInfoById(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
WLOGFE("GetDisplayById: displayInfo is nullptr!");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<Display> display = new Display("", displayInfo);
|
||||
if (display->GetId() != DISPLAY_ID_INVALD) {
|
||||
displayMap_[display->GetId()] = display;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::RequestRotation(ScreenId screenId, Rotation rotation)
|
||||
bool ScreenManagerAdapter::RequestRotation(ScreenId screenId, Rotation rotation)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
@@ -109,7 +109,7 @@ std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshot(Displ
|
||||
return dispalySnapshot;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
|
||||
DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
|
||||
std::vector<ScreenColorGamut>& colorGamuts)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
@@ -123,7 +123,7 @@ DMError DisplayManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
|
||||
DMError ScreenManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -136,7 +136,7 @@ DMError DisplayManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColo
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
|
||||
DMError ScreenManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -149,7 +149,7 @@ DMError DisplayManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t co
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
|
||||
DMError ScreenManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -162,7 +162,7 @@ DMError DisplayManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutM
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
|
||||
DMError ScreenManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -175,7 +175,7 @@ DMError DisplayManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutM
|
||||
return ret;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::SetScreenColorTransform(ScreenId screenId)
|
||||
DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
||||
@@ -188,7 +188,7 @@ DMError DisplayManagerAdapter::SetScreenColorTransform(ScreenId screenId)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerAdapter::CreateVirtualScreen(VirtualScreenOption option)
|
||||
ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option)
|
||||
{
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return SCREEN_ID_INVALID;
|
||||
@@ -197,7 +197,7 @@ ScreenId DisplayManagerAdapter::CreateVirtualScreen(VirtualScreenOption option)
|
||||
return displayManagerServiceProxy_->CreateVirtualScreen(option);
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
|
||||
DMError ScreenManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
|
||||
{
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
@@ -206,7 +206,7 @@ DMError DisplayManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
|
||||
return displayManagerServiceProxy_->DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
@@ -215,7 +215,7 @@ DMError DisplayManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<S
|
||||
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
bool BaseAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
@@ -225,7 +225,7 @@ bool DisplayManagerAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManag
|
||||
return displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
bool BaseAdapter::UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
@@ -308,7 +308,7 @@ void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event)
|
||||
displayManagerServiceProxy_->NotifyDisplayEvent(event);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::InitDMSProxyLocked()
|
||||
bool BaseAdapter::InitDMSProxyLocked()
|
||||
{
|
||||
if (!displayManagerServiceProxy_) {
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
@@ -331,7 +331,7 @@ bool DisplayManagerAdapter::InitDMSProxyLocked()
|
||||
return false;
|
||||
}
|
||||
|
||||
dmsDeath_ = new DMSDeathRecipient();
|
||||
dmsDeath_ = new DMSDeathRecipient(*this);
|
||||
if (!dmsDeath_) {
|
||||
WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient");
|
||||
return false;
|
||||
@@ -344,6 +344,10 @@ bool DisplayManagerAdapter::InitDMSProxyLocked()
|
||||
return true;
|
||||
}
|
||||
|
||||
DMSDeathRecipient::DMSDeathRecipient(BaseAdapter& adapter) : adapter_(adapter)
|
||||
{
|
||||
}
|
||||
|
||||
void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
|
||||
{
|
||||
if (wptrDeath == nullptr) {
|
||||
@@ -356,11 +360,11 @@ void DMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
|
||||
WLOGFE("object is null");
|
||||
return;
|
||||
}
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().Clear();
|
||||
adapter_.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
void DisplayManagerAdapter::Clear()
|
||||
void BaseAdapter::Clear()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) {
|
||||
@@ -369,7 +373,7 @@ void DisplayManagerAdapter::Clear()
|
||||
displayManagerServiceProxy_ = nullptr;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
@@ -378,7 +382,7 @@ DMError DisplayManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<Scr
|
||||
return displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId);
|
||||
}
|
||||
|
||||
sptr<ScreenInfo> DisplayManagerAdapter::GetScreenInfo(ScreenId screenId)
|
||||
sptr<ScreenInfo> ScreenManagerAdapter::GetScreenInfo(ScreenId screenId)
|
||||
{
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("screen id is invalid");
|
||||
@@ -396,80 +400,76 @@ sptr<ScreenInfo> DisplayManagerAdapter::GetScreenInfo(ScreenId screenId)
|
||||
return screenInfo;
|
||||
}
|
||||
|
||||
DisplayInfo DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
|
||||
sptr<DisplayInfo> DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId)
|
||||
{
|
||||
if (displayId == DISPLAY_ID_INVALD) {
|
||||
WLOGFE("screen id is invalid");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
return displayManagerServiceProxy_->GetDisplayInfoById(displayId);
|
||||
}
|
||||
|
||||
sptr<Screen> DisplayManagerAdapter::GetScreenById(ScreenId screenId)
|
||||
sptr<Screen> ScreenManagerAdapter::GetScreenById(ScreenId screenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("screen id is invalid");
|
||||
sptr<ScreenInfo> screenInfo = GetScreenInfo(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGFE("screenInfo is null");
|
||||
screenMap_.erase(screenId);
|
||||
return nullptr;
|
||||
}
|
||||
auto iter = screenMap_.find(screenId);
|
||||
if (iter != screenMap_.end()) {
|
||||
WLOGFI("get screen in screen map");
|
||||
iter->second->UpdateScreenInfo(screenInfo);
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenInfo> screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGFE("screenInfo is null");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<Screen> screen = new Screen(screenInfo.GetRefPtr());
|
||||
sptr<Screen> screen = new Screen(screenInfo);
|
||||
screenMap_.insert(std::make_pair(screenId, screen));
|
||||
return screen;
|
||||
}
|
||||
|
||||
sptr<ScreenGroup> DisplayManagerAdapter::GetScreenGroupById(ScreenId screenId)
|
||||
sptr<ScreenGroup> ScreenManagerAdapter::GetScreenGroupById(ScreenId screenId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("screenGroup id is invalid");
|
||||
return nullptr;
|
||||
}
|
||||
auto iter = screenGroupMap_.find(screenId);
|
||||
if (iter != screenGroupMap_.end()) {
|
||||
WLOGFI("get screenGroup in screenGroup map");
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
screenGroupMap_.clear();
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenGroupInfo> screenGroupInfo = displayManagerServiceProxy_->GetScreenGroupInfoById(screenId);
|
||||
if (screenGroupInfo == nullptr) {
|
||||
WLOGFE("screenGroupInfo is null");
|
||||
screenGroupMap_.erase(screenId);
|
||||
return nullptr;
|
||||
}
|
||||
sptr<ScreenGroup> screenGroup = new ScreenGroup(screenGroupInfo.GetRefPtr());
|
||||
auto iter = screenGroupMap_.find(screenId);
|
||||
if (iter != screenGroupMap_.end()) {
|
||||
WLOGFI("get screenGroup in screenGroup map");
|
||||
iter->second->UpdateScreenGroupInfo(screenGroupInfo);
|
||||
return iter->second;
|
||||
}
|
||||
sptr<ScreenGroup> screenGroup = new ScreenGroup(screenGroupInfo);
|
||||
screenGroupMap_.insert(std::make_pair(screenId, screenGroup));
|
||||
return screenGroup;
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> DisplayManagerAdapter::GetAllScreens()
|
||||
std::vector<sptr<Screen>> ScreenManagerAdapter::GetAllScreens()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
std::vector<sptr<Screen>> screens;
|
||||
if (!InitDMSProxyLocked()) {
|
||||
WLOGFE("InitDMSProxyLocked failed!");
|
||||
screenMap_.clear();
|
||||
return screens;
|
||||
}
|
||||
std::vector<sptr<ScreenInfo>> screenInfos = displayManagerServiceProxy_->GetAllScreenInfos();
|
||||
@@ -478,12 +478,24 @@ std::vector<sptr<Screen>> DisplayManagerAdapter::GetAllScreens()
|
||||
WLOGFE("screenInfo is null");
|
||||
continue;
|
||||
}
|
||||
screens.emplace_back(new Screen(info.GetRefPtr()));
|
||||
auto iter = screenMap_.find(info->GetScreenId());
|
||||
if (iter != screenMap_.end()) {
|
||||
WLOGFI("get screen in screen map");
|
||||
iter->second->UpdateScreenInfo(info);
|
||||
screens.emplace_back(iter->second);
|
||||
} else {
|
||||
sptr<Screen> screen = new Screen(info);
|
||||
screens.emplace_back(screen);
|
||||
}
|
||||
}
|
||||
screenMap_.clear();
|
||||
for (auto screen: screens) {
|
||||
screenMap_.insert(std::make_pair(screen->GetId(), screen));
|
||||
}
|
||||
return screens;
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
DMError ScreenManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
@@ -492,7 +504,7 @@ DMError DisplayManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::v
|
||||
return displayManagerServiceProxy_->MakeExpand(screenId, startPoint);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
bool ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
@@ -500,4 +512,30 @@ bool DisplayManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t mode
|
||||
}
|
||||
return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId);
|
||||
}
|
||||
|
||||
void ScreenManagerAdapter::UpdateScreenInfo(ScreenId screenId)
|
||||
{
|
||||
auto screenInfo = GetScreenInfo(screenId);
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGFE("screenInfo is invalid");
|
||||
return;
|
||||
}
|
||||
auto iter = screenMap_.find(screenId);
|
||||
if (iter != screenMap_.end()) {
|
||||
iter->second->UpdateScreenInfo(screenInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManagerAdapter::UpdateDisplayInfo(DisplayId displayId)
|
||||
{
|
||||
auto displayInfo = GetDisplayInfo(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
WLOGFE("displayInfo is invalid");
|
||||
return;
|
||||
}
|
||||
auto iter = displayMap_.find(displayId);
|
||||
if (iter != displayMap_.end()) {
|
||||
iter->second->UpdateDisplayInfo(displayInfo);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
+50
-83
@@ -16,7 +16,6 @@
|
||||
#include "screen.h"
|
||||
|
||||
#include "display_manager_adapter.h"
|
||||
#include "screen_group.h"
|
||||
#include "screen_info.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@@ -25,55 +24,21 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "Screen"};
|
||||
}
|
||||
class Screen::Impl : public RefBase {
|
||||
friend class Screen;
|
||||
public:
|
||||
Impl() = default;
|
||||
Impl(sptr<ScreenInfo> info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("ScreenInfo is nullptr.");
|
||||
}
|
||||
screenInfo_ = info;
|
||||
}
|
||||
~Impl() = default;
|
||||
void UpdateScreen(sptr<ScreenInfo> info);
|
||||
|
||||
ScreenId id_ { SCREEN_ID_INVALID };
|
||||
uint32_t virtualWidth_ { 0 };
|
||||
uint32_t virtualHeight_ { 0 };
|
||||
float virtualPixelRatio_ { 0.0 };
|
||||
ScreenId parent_ { SCREEN_ID_INVALID };
|
||||
bool canHasChild_ { false };
|
||||
uint32_t modeId_ { 0 };
|
||||
std::vector<sptr<SupportedScreenModes>> modes_ {};
|
||||
Rotation rotation_ { Rotation::ROTATION_0 };
|
||||
DEFINE_VAR_FUNC_GET_SET(sptr<ScreenInfo>, ScreenInfo, screenInfo);
|
||||
};
|
||||
|
||||
void Screen::Impl::UpdateScreen(sptr<ScreenInfo> info)
|
||||
Screen::Screen(sptr<ScreenInfo> info)
|
||||
: pImpl_(new Impl(info))
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("info is nullptr.");
|
||||
return;
|
||||
}
|
||||
virtualWidth_ = info->virtualWidth_;
|
||||
virtualHeight_ = info->virtualHeight_;
|
||||
virtualPixelRatio_ = info->virtualPixelRatio_;
|
||||
parent_ = info->parent_;
|
||||
canHasChild_ = info->canHasChild_;
|
||||
modeId_ = info->modeId_;
|
||||
modes_ = info->modes_;
|
||||
rotation_ = info->rotation_;
|
||||
}
|
||||
|
||||
Screen::Screen(const ScreenInfo* info)
|
||||
: pImpl_(new Impl())
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("info is nullptr.");
|
||||
return;
|
||||
}
|
||||
pImpl_->id_ = info->id_;
|
||||
pImpl_->virtualWidth_ = info->virtualWidth_;
|
||||
pImpl_->virtualHeight_ = info->virtualHeight_;
|
||||
pImpl_->virtualPixelRatio_ = info->virtualPixelRatio_;
|
||||
pImpl_->parent_ = info->parent_;
|
||||
pImpl_->canHasChild_ = info->canHasChild_;
|
||||
pImpl_->modeId_ = info->modeId_;
|
||||
pImpl_->modes_ = info->modes_;
|
||||
pImpl_->rotation_ = info->rotation_;
|
||||
}
|
||||
|
||||
Screen::~Screen()
|
||||
@@ -82,22 +47,20 @@ Screen::~Screen()
|
||||
|
||||
bool Screen::IsGroup() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
return pImpl_->canHasChild_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
return pImpl_->GetScreenInfo()->GetCanHasChild();
|
||||
}
|
||||
|
||||
ScreenId Screen::GetId() const
|
||||
{
|
||||
return pImpl_->id_;
|
||||
return pImpl_->GetScreenInfo()->GetScreenId();
|
||||
}
|
||||
|
||||
uint32_t Screen::GetWidth() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
auto modeId = pImpl_->modeId_;
|
||||
auto modes = pImpl_->modes_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
auto modeId = GetModeId();
|
||||
auto modes = GetSupportedModes();
|
||||
if (modeId < 0 || modeId >= modes.size()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -106,10 +69,9 @@ uint32_t Screen::GetWidth() const
|
||||
|
||||
uint32_t Screen::GetHeight() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
auto modeId = pImpl_->modeId_;
|
||||
auto modes = pImpl_->modes_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
auto modeId = GetModeId();
|
||||
auto modes = GetSupportedModes();
|
||||
if (modeId < 0 || modeId >= modes.size()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -118,93 +80,98 @@ uint32_t Screen::GetHeight() const
|
||||
|
||||
uint32_t Screen::GetVirtualWidth() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
return pImpl_->virtualWidth_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
return pImpl_->GetScreenInfo()->GetVirtualWidth();
|
||||
}
|
||||
|
||||
uint32_t Screen::GetVirtualHeight() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
return pImpl_->virtualHeight_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
return pImpl_->GetScreenInfo()->GetVirtualHeight();
|
||||
}
|
||||
|
||||
float Screen::GetVirtualPixelRatio() const
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
return pImpl_->virtualPixelRatio_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
return pImpl_->GetScreenInfo()->GetVirtualPixelRatio();
|
||||
}
|
||||
|
||||
Rotation Screen::GetRotation()
|
||||
{
|
||||
sptr<ScreenInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetScreenInfo(pImpl_->id_);
|
||||
pImpl_->UpdateScreen(info);
|
||||
return pImpl_->rotation_;
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UpdateScreenInfo(GetId());
|
||||
return pImpl_->GetScreenInfo()->GetRotation();
|
||||
}
|
||||
|
||||
bool Screen::RequestRotation(Rotation rotation)
|
||||
{
|
||||
WLOGFD("rotation the screen");
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().RequestRotation(pImpl_->id_, rotation);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().RequestRotation(GetId(), rotation);
|
||||
}
|
||||
|
||||
DMError Screen::GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenSupportedColorGamuts(pImpl_->id_, colorGamuts);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenSupportedColorGamuts(GetId(), colorGamuts);
|
||||
}
|
||||
|
||||
DMError Screen::GetScreenColorGamut(ScreenColorGamut& colorGamut) const
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenColorGamut(pImpl_->id_, colorGamut);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenColorGamut(GetId(), colorGamut);
|
||||
}
|
||||
|
||||
DMError Screen::SetScreenColorGamut(int32_t colorGamutIdx)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenColorGamut(pImpl_->id_, colorGamutIdx);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorGamut(GetId(), colorGamutIdx);
|
||||
}
|
||||
|
||||
DMError Screen::GetScreenGamutMap(ScreenGamutMap& gamutMap) const
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenGamutMap(pImpl_->id_, gamutMap);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGamutMap(GetId(), gamutMap);
|
||||
}
|
||||
|
||||
DMError Screen::SetScreenGamutMap(ScreenGamutMap gamutMap)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenGamutMap(pImpl_->id_, gamutMap);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenGamutMap(GetId(), gamutMap);
|
||||
}
|
||||
|
||||
DMError Screen::SetScreenColorTransform()
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenColorTransform(pImpl_->id_);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorTransform(GetId());
|
||||
}
|
||||
|
||||
ScreenId Screen::GetParentId() const
|
||||
{
|
||||
return pImpl_->parent_;
|
||||
return pImpl_->GetScreenInfo()->GetParentId();
|
||||
}
|
||||
|
||||
uint32_t Screen::GetModeId() const
|
||||
{
|
||||
return pImpl_->modeId_;
|
||||
return pImpl_->GetScreenInfo()->GetModeId();
|
||||
}
|
||||
|
||||
std::vector<sptr<SupportedScreenModes>> Screen::GetSupportedModes() const
|
||||
{
|
||||
return pImpl_->modes_;
|
||||
return pImpl_->GetScreenInfo()->GetModes();
|
||||
}
|
||||
|
||||
bool Screen::SetScreenActiveMode(uint32_t modeId)
|
||||
{
|
||||
ScreenId screenId = pImpl_->id_;
|
||||
if (modeId < 0 || modeId >= pImpl_->modes_.size()) {
|
||||
ScreenId screenId = GetId();
|
||||
if (modeId < 0 || modeId >= GetSupportedModes().size()) {
|
||||
return false;
|
||||
}
|
||||
if (SingletonContainer::Get<DisplayManagerAdapter>().SetScreenActiveMode(screenId, modeId)) {
|
||||
pImpl_->modeId_ = modeId;
|
||||
if (SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(screenId, modeId)) {
|
||||
pImpl_->GetScreenInfo()->SetModeId(modeId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Screen::UpdateScreenInfo(sptr<ScreenInfo> screenInfo)
|
||||
{
|
||||
if (screenInfo == nullptr) {
|
||||
WLOGFE("ScreenInfo is invalid");
|
||||
return;
|
||||
}
|
||||
pImpl_->SetScreenInfo(screenInfo);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
+22
-18
@@ -23,26 +23,30 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "ScreenGroup"};
|
||||
}
|
||||
class ScreenGroup::Impl : public RefBase {
|
||||
friend class ScreenGroup;
|
||||
private:
|
||||
Impl() = default;
|
||||
public:
|
||||
Impl(sptr<ScreenGroupInfo> info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("ScreenGroupInfo is nullptr.");
|
||||
}
|
||||
screenGroupInfo_ = info;
|
||||
}
|
||||
~Impl() = default;
|
||||
|
||||
std::vector<ScreenId> children_;
|
||||
std::vector<Point> position_;
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
DEFINE_VAR_FUNC_GET_SET(sptr<ScreenGroupInfo>, ScreenGroupInfo, screenGroupInfo);
|
||||
};
|
||||
|
||||
ScreenGroup::ScreenGroup(const ScreenGroupInfo* info)
|
||||
: Screen(info), pImpl_(new Impl())
|
||||
ScreenGroup::ScreenGroup(sptr<ScreenGroupInfo> info)
|
||||
: Screen(info), pImpl_(new Impl(info))
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenGroup::UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("info is nullptr.");
|
||||
return;
|
||||
WLOGFE("ScreenGroupInfo is nullptr.");
|
||||
}
|
||||
pImpl_->children_ = info->children_;
|
||||
pImpl_->position_ = info->position_;
|
||||
pImpl_->combination_ = info->combination_;
|
||||
pImpl_->SetScreenGroupInfo(info);
|
||||
}
|
||||
|
||||
ScreenGroup::~ScreenGroup()
|
||||
@@ -51,16 +55,16 @@ ScreenGroup::~ScreenGroup()
|
||||
|
||||
ScreenCombination ScreenGroup::GetCombination() const
|
||||
{
|
||||
return pImpl_->combination_;
|
||||
return pImpl_->GetScreenGroupInfo()->GetCombination();
|
||||
}
|
||||
|
||||
std::vector<ScreenId> ScreenGroup::GetChild() const
|
||||
std::vector<ScreenId> ScreenGroup::GetChildIds() const
|
||||
{
|
||||
return pImpl_->children_;
|
||||
return pImpl_->GetScreenGroupInfo()->GetChildren();
|
||||
}
|
||||
|
||||
std::vector<Point> ScreenGroup::GetChildPosition() const
|
||||
std::vector<Point> ScreenGroup::GetChildPositions() const
|
||||
{
|
||||
return pImpl_->position_;
|
||||
return pImpl_->GetScreenGroupInfo()->GetPosition();
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
+14
-14
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void OnScreenConnect(sptr<ScreenInfo> screenInfo)
|
||||
{
|
||||
if (screenInfo == nullptr || screenInfo->id_ == SCREEN_ID_INVALID) {
|
||||
if (screenInfo == nullptr || screenInfo->GetScreenId() == SCREEN_ID_INVALID) {
|
||||
WLOGFE("OnScreenConnect, screenInfo is invalid.");
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
return;
|
||||
}
|
||||
for (auto listener : pImpl_->screenListeners_) {
|
||||
listener->OnConnect(screenInfo->id_);
|
||||
listener->OnConnect(screenInfo->GetScreenId());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,8 +84,8 @@ public:
|
||||
WLOGFD("OnScreenChange. event %{public}u", event);
|
||||
std::vector<ScreenId> screenIds;
|
||||
for (auto screenInfo : screenInfos) {
|
||||
if (screenInfo->id_ != SCREEN_ID_INVALID) {
|
||||
screenIds.push_back(screenInfo->id_);
|
||||
if (screenInfo->GetScreenId() != SCREEN_ID_INVALID) {
|
||||
screenIds.push_back(screenInfo->GetScreenId());
|
||||
}
|
||||
}
|
||||
for (auto listener: pImpl_->screenListeners_) {
|
||||
@@ -108,17 +108,17 @@ ScreenManager::~ScreenManager()
|
||||
|
||||
sptr<Screen> ScreenManager::GetScreenById(ScreenId screenId)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenById(screenId);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenById(screenId);
|
||||
}
|
||||
|
||||
sptr<ScreenGroup> ScreenManager::GetScreenGroupById(ScreenId screenId)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenGroupById(screenId);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGroupById(screenId);
|
||||
}
|
||||
|
||||
std::vector<sptr<Screen>> ScreenManager::GetAllScreens()
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetAllScreens();
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().GetAllScreens();
|
||||
}
|
||||
|
||||
bool ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
@@ -131,7 +131,7 @@ bool ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
|
||||
pImpl_->screenListeners_.push_back(listener);
|
||||
if (screenManagerListener_ == nullptr) {
|
||||
screenManagerListener_ = new ScreenManagerListener(pImpl_);
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
|
||||
screenManagerListener_,
|
||||
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ bool ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
|
||||
}
|
||||
pImpl_->screenListeners_.erase(iter);
|
||||
if (pImpl_->screenListeners_.empty() && screenManagerListener_ != nullptr) {
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
|
||||
screenManagerListener_,
|
||||
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
|
||||
screenManagerListener_ = nullptr;
|
||||
@@ -172,7 +172,7 @@ ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
|
||||
screenIds.emplace_back(option.screenId_);
|
||||
startPoints.emplace_back(Point(option.startX_, option.startY_));
|
||||
}
|
||||
DMError result = SingletonContainer::Get<DisplayManagerAdapter>().MakeExpand(screenIds, startPoints);
|
||||
DMError result = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenIds, startPoints);
|
||||
if (result != DMError::DM_OK) {
|
||||
return SCREEN_ID_INVALID;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId>
|
||||
{
|
||||
WLOGFI("create mirror for screen: %{public}" PRIu64"", mainScreenId);
|
||||
// TODO: "record screen" should use another function, "MakeMirror" should return group id.
|
||||
DMError result = SingletonContainer::Get<DisplayManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
|
||||
DMError result = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId);
|
||||
if (result == DMError::DM_OK) {
|
||||
WLOGFI("create mirror success");
|
||||
}
|
||||
@@ -193,16 +193,16 @@ ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId>
|
||||
|
||||
ScreenId ScreenManager::CreateVirtualScreen(VirtualScreenOption option)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().CreateVirtualScreen(option);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().CreateVirtualScreen(option);
|
||||
}
|
||||
|
||||
DMError ScreenManager::DestroyVirtualScreen(ScreenId screenId)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().DestroyVirtualScreen(screenId);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError ScreenManager::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetVirtualScreenSurface(screenId, surface);
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -23,25 +23,45 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
class MockDisplayManagerAdapter : public DisplayManagerAdapter {
|
||||
public:
|
||||
MOCK_METHOD0(GetDefaultDisplayId, DisplayId());
|
||||
MOCK_METHOD1(GetDisplayById, sptr<Display>(DisplayId displayId));
|
||||
MOCK_METHOD1(CreateVirtualScreen, ScreenId(VirtualScreenOption option));
|
||||
MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId));
|
||||
MOCK_METHOD1(GetDisplaySnapshot, std::shared_ptr<Media::PixelMap>(DisplayId displayId));
|
||||
MOCK_METHOD0(Clear, void());
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD0(GetDefaultDisplayId, DisplayId());
|
||||
MOCK_METHOD1(GetDisplayById, sptr<Display>(DisplayId displayId));
|
||||
MOCK_METHOD1(GetDisplaySnapshot, std::shared_ptr<Media::PixelMap>(DisplayId displayId));
|
||||
|
||||
MOCK_METHOD1(WakeUpBegin, bool(PowerStateChangeReason reason));
|
||||
MOCK_METHOD0(WakeUpEnd, bool());
|
||||
MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason));
|
||||
MOCK_METHOD0(SuspendEnd, bool());
|
||||
MOCK_METHOD2(SetScreenPowerForAll, bool(DisplayPowerState state, PowerStateChangeReason reason));
|
||||
MOCK_METHOD1(SetDisplayState, bool(DisplayState state));
|
||||
MOCK_METHOD1(GetDisplayState, DisplayState(uint64_t displayId));
|
||||
MOCK_METHOD2(SetScreenActiveMode, bool(ScreenId screenId, uint32_t modeId));
|
||||
MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId));
|
||||
MOCK_METHOD1(NotifyDisplayEvent, void(DisplayEvent event));
|
||||
MOCK_METHOD1(UpdateDisplayInfo, void(DisplayId displayId));
|
||||
};
|
||||
|
||||
class MockScreenManagerAdapter : public ScreenManagerAdapter {
|
||||
public:
|
||||
MOCK_METHOD0(Clear, void());
|
||||
MOCK_METHOD2(RegisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(UnregisterDisplayManagerAgent, bool(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type));
|
||||
MOCK_METHOD2(RequestRotation, bool(ScreenId screenId, Rotation rotation));
|
||||
MOCK_METHOD1(CreateVirtualScreen, ScreenId(VirtualScreenOption option));
|
||||
MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId));
|
||||
MOCK_METHOD2(SetVirtualScreenSurface, DMError(ScreenId screenId, sptr<Surface> surface));
|
||||
MOCK_METHOD1(GetScreenById, sptr<Screen>(ScreenId screenId));
|
||||
MOCK_METHOD1(GetScreenGroupById, sptr<ScreenGroup>(ScreenId screenId));
|
||||
MOCK_METHOD0(GetAllScreens, std::vector<sptr<Screen>>());
|
||||
MOCK_METHOD2(MakeMirror, DMError(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId));
|
||||
MOCK_METHOD2(MakeExpand, DMError(std::vector<ScreenId> screenId, std::vector<Point> startPoint));
|
||||
MOCK_METHOD2(SetScreenActiveMode, bool(ScreenId screenId, uint32_t modeId));
|
||||
MOCK_METHOD1(UpdateScreenInfo, void(ScreenId screenId));
|
||||
|
||||
MOCK_METHOD2(GetScreenSupportedColorGamuts, DMError(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts));
|
||||
MOCK_METHOD2(GetScreenColorGamut, DMError(ScreenId screenId, ScreenColorGamut& colorGamut));
|
||||
MOCK_METHOD2(SetScreenColorGamut, DMError(ScreenId screenId, int32_t colorGamutIdx));
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Mocker = SingletonMocker<DisplayManagerAdapter, MockDisplayManagerAdapter>;
|
||||
using Mocker = SingletonMocker<ScreenManagerAdapter, MockScreenManagerAdapter>;
|
||||
|
||||
sptr<Display> ScreenManagerTest::defaultDisplay_ = nullptr;
|
||||
DisplayId ScreenManagerTest::defaultDisplayId_ = DISPLAY_ID_INVALD;
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using Mocker = SingletonMocker<DisplayManagerAdapter, MockDisplayManagerAdapter>;
|
||||
using Mocker = SingletonMocker<ScreenManagerAdapter, MockScreenManagerAdapter>;
|
||||
|
||||
sptr<Display> ScreenTest::defaultDisplay_ = nullptr;
|
||||
ScreenId ScreenTest::defaultScreenId_ = SCREEN_ID_INVALID;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
constexpr static int32_t DEFAULT_HIGHT = 1280;
|
||||
constexpr static float DEFAULT_VIRTUAL_PIXEL_RATIO = 1.0;
|
||||
constexpr static uint32_t DEFAULT_FRESH_RATE = 60;
|
||||
AbstractDisplay(const DisplayInfo& info);
|
||||
AbstractDisplay(const DisplayInfo* info);
|
||||
AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t freshRate);
|
||||
~AbstractDisplay() = default;
|
||||
static inline bool IsVertical(Rotation rotation)
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
ScreenId GetAbstractScreenId() const;
|
||||
bool BindAbstractScreen(ScreenId dmsScreenId);
|
||||
bool BindAbstractScreen(sptr<AbstractScreen> abstractDisplay);
|
||||
const sptr<DisplayInfo> ConvertToDisplayInfo() const;
|
||||
sptr<DisplayInfo> ConvertToDisplayInfo() const;
|
||||
|
||||
void SetId(DisplayId displayId);
|
||||
void SetWidth(int32_t width);
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
sptr<SupportedScreenModes> GetActiveScreenMode() const;
|
||||
std::vector<sptr<SupportedScreenModes>> GetAbstractScreenModes() const;
|
||||
sptr<AbstractScreenGroup> GetGroup() const;
|
||||
const sptr<ScreenInfo> ConvertToScreenInfo() const;
|
||||
sptr<ScreenInfo> ConvertToScreenInfo() const;
|
||||
void RequestRotation(Rotation rotation);
|
||||
Rotation GetRotation() const;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
std::vector<sptr<AbstractScreen>> GetChildren() const;
|
||||
std::vector<Point> GetChildrenPosition() const;
|
||||
size_t GetChildCount() const;
|
||||
const sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
|
||||
sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
|
||||
bool SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config);
|
||||
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
};
|
||||
|
||||
virtual DisplayId GetDefaultDisplayId() = 0;
|
||||
virtual DisplayInfo GetDisplayInfoById(DisplayId displayId) = 0;
|
||||
virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) = 0;
|
||||
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option) = 0;
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
~DisplayManagerProxy() {};
|
||||
|
||||
DisplayId GetDefaultDisplayId() override;
|
||||
DisplayInfo GetDisplayInfoById(DisplayId displayId) override;
|
||||
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
|
||||
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
|
||||
DisplayId GetDefaultDisplayId() override;
|
||||
DisplayInfo GetDisplayInfoById(DisplayId displayId) override;
|
||||
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
|
||||
bool RequestRotation(ScreenId screenId, Rotation rotation) override;
|
||||
std::shared_ptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
|
||||
ScreenId GetRSScreenId(DisplayId displayId) const;
|
||||
|
||||
@@ -24,12 +24,16 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "AbstractDisplay"};
|
||||
}
|
||||
|
||||
AbstractDisplay::AbstractDisplay(const DisplayInfo& info)
|
||||
: id_(info.id_),
|
||||
width_(info.width_),
|
||||
height_(info.height_),
|
||||
freshRate_(info.freshRate_)
|
||||
AbstractDisplay::AbstractDisplay(const DisplayInfo* info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
WLOGFE("DisplayInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
id_ = info->GetDisplayId();
|
||||
width_ = info->GetWidth();
|
||||
height_ = info->GetHeight();
|
||||
freshRate_ = info->GetHeight();
|
||||
}
|
||||
|
||||
AbstractDisplay::AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t freshRate)
|
||||
@@ -146,7 +150,7 @@ ScreenId AbstractDisplay::GetAbstractScreenId() const
|
||||
return screenId_;
|
||||
}
|
||||
|
||||
const sptr<DisplayInfo> AbstractDisplay::ConvertToDisplayInfo() const
|
||||
sptr<DisplayInfo> AbstractDisplay::ConvertToDisplayInfo() const
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo = new DisplayInfo();
|
||||
displayInfo->width_ = width_;
|
||||
|
||||
@@ -53,7 +53,7 @@ sptr<AbstractScreenGroup> AbstractScreen::GetGroup() const
|
||||
return DisplayManagerService::GetInstance().GetAbstractScreenController()->GetAbstractScreenGroup(groupDmsId_);
|
||||
}
|
||||
|
||||
const sptr<ScreenInfo> AbstractScreen::ConvertToScreenInfo() const
|
||||
sptr<ScreenInfo> AbstractScreen::ConvertToScreenInfo() const
|
||||
{
|
||||
sptr<ScreenInfo> info = new ScreenInfo();
|
||||
FillScreenInfo(info);
|
||||
@@ -215,7 +215,7 @@ AbstractScreenGroup::~AbstractScreenGroup()
|
||||
abstractScreenMap_.clear();
|
||||
}
|
||||
|
||||
const sptr<ScreenGroupInfo> AbstractScreenGroup::ConvertToScreenGroupInfo() const
|
||||
sptr<ScreenGroupInfo> AbstractScreenGroup::ConvertToScreenGroupInfo() const
|
||||
{
|
||||
sptr<ScreenGroupInfo> screenGroupInfo = new ScreenGroupInfo();
|
||||
FillScreenInfo(screenGroupInfo);
|
||||
|
||||
@@ -52,12 +52,12 @@ DisplayId DisplayManagerProxy::GetDefaultDisplayId()
|
||||
return displayId;
|
||||
}
|
||||
|
||||
DisplayInfo DisplayManagerProxy::GetDisplayInfoById(DisplayId displayId)
|
||||
sptr<DisplayInfo> DisplayManagerProxy::GetDisplayInfoById(DisplayId displayId)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("GetDisplayInfoById: remote is nullptr");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@@ -65,23 +65,23 @@ DisplayInfo DisplayManagerProxy::GetDisplayInfoById(DisplayId displayId)
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
if (!data.WriteUint64(displayId)) {
|
||||
WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_GET_DISPLAY_BY_ID, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("GetDisplayInfoById: SendRequest failed");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<DisplayInfo> info = reply.ReadParcelable<DisplayInfo>();
|
||||
if (info == nullptr) {
|
||||
WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr.");
|
||||
return DisplayInfo();
|
||||
return nullptr;
|
||||
}
|
||||
return *info;
|
||||
return info;
|
||||
}
|
||||
|
||||
ScreenId DisplayManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOption)
|
||||
@@ -682,9 +682,10 @@ sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
|
||||
WLOGFW("GetScreenInfoById SendRequest nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
for (int i = 0; i < info->modes_.size(); i++) {
|
||||
auto modes = info->GetModes();
|
||||
for (int i = 0; i < modes.size(); i++) {
|
||||
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
|
||||
info->modes_[i]->width_, info->modes_[i]->height_, info->modes_[i]->freshRate_);
|
||||
modes[i]->width_, modes[i]->height_, modes[i]->freshRate_);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -89,21 +89,14 @@ DisplayId DisplayManagerService::GetDefaultDisplayId()
|
||||
return GetDisplayIdFromScreenId(screenId);
|
||||
}
|
||||
|
||||
DisplayInfo DisplayManagerService::GetDisplayInfoById(DisplayId displayId)
|
||||
sptr<DisplayInfo> DisplayManagerService::GetDisplayInfoById(DisplayId displayId)
|
||||
{
|
||||
DisplayInfo displayInfo;
|
||||
sptr<AbstractDisplay> display = GetDisplayByDisplayId(displayId);
|
||||
if (display == nullptr) {
|
||||
WLOGFE("GetDisplayById: Get invalid display!");
|
||||
return displayInfo;
|
||||
return nullptr;
|
||||
}
|
||||
displayInfo.id_ = displayId;
|
||||
displayInfo.width_ = display->GetWidth();
|
||||
displayInfo.height_ = display->GetHeight();
|
||||
displayInfo.freshRate_ = display->GetFreshRate();
|
||||
displayInfo.screenId_ = display->GetAbstractScreenId();
|
||||
displayInfo.rotation_ = display->GetRotation();
|
||||
return displayInfo;
|
||||
return display->ConvertToDisplayInfo();
|
||||
}
|
||||
|
||||
sptr<AbstractDisplay> DisplayManagerService::GetAbstractDisplay(DisplayId displayId)
|
||||
|
||||
@@ -41,7 +41,7 @@ const sptr<AbstractDisplay> DisplayManagerServiceInner::GetDisplayById(DisplayId
|
||||
{
|
||||
sptr<AbstractDisplay> display = DisplayManagerService::GetInstance().GetAbstractDisplay(displayId);
|
||||
if (display == nullptr) {
|
||||
DisplayInfo displayInfo = DisplayManagerService::GetInstance().GetDisplayInfoById(displayId);
|
||||
auto displayInfo = DisplayManagerService::GetInstance().GetDisplayInfoById(displayId);
|
||||
display = new AbstractDisplay(displayInfo);
|
||||
WLOGFE("GetDisplayById create new!\n");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case TRANS_ID_GET_DISPLAY_BY_ID: {
|
||||
DisplayId displayId = data.ReadUint64();
|
||||
auto info = GetDisplayInfoById(displayId);
|
||||
reply.WriteParcelable(&info);
|
||||
reply.WriteParcelable(info);
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_CREATE_VIRTUAL_SCREEN: {
|
||||
@@ -166,9 +166,10 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case TRANS_ID_GET_SCREEN_INFO_BY_ID: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
auto screenInfo = GetScreenInfoById(screenId);
|
||||
for (int i = 0; i < screenInfo->modes_.size(); i++) {
|
||||
auto modes = screenInfo->GetModes();
|
||||
for (int i = 0; i < modes.size(); i++) {
|
||||
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
|
||||
screenInfo->modes_[i]->width_, screenInfo->modes_[i]->height_, screenInfo->modes_[i]->freshRate_);
|
||||
modes[i]->width_, modes[i]->height_, modes[i]->freshRate_);
|
||||
}
|
||||
reply.WriteStrongParcelable(screenInfo);
|
||||
break;
|
||||
|
||||
@@ -27,23 +27,22 @@ typedef enum DisplayType {
|
||||
} DisplayType;
|
||||
|
||||
class Display : public RefBase {
|
||||
friend class DisplayManagerAdapter;
|
||||
public:
|
||||
Display(const std::string& name, DisplayInfo* info);
|
||||
~Display() = default;
|
||||
|
||||
Display(const Display&) = delete;
|
||||
Display(Display&&) = delete;
|
||||
Display& operator=(const Display&) = delete;
|
||||
Display& operator=(Display&&) = delete;
|
||||
DisplayId GetId() const;
|
||||
int32_t GetWidth() const;
|
||||
int32_t GetHeight() const;
|
||||
uint32_t GetFreshRate() const;
|
||||
ScreenId GetScreenId() const;
|
||||
float GetVirtualPixelRatio() const;
|
||||
|
||||
void SetId(DisplayId displayId);
|
||||
void SetWidth(int32_t width);
|
||||
void SetHeight(int32_t height);
|
||||
void SetFreshRate(uint32_t freshRate);
|
||||
|
||||
private:
|
||||
Display(const std::string& name, sptr<DisplayInfo> info);
|
||||
void UpdateDisplayInfo(sptr<DisplayInfo>);
|
||||
class Impl;
|
||||
sptr<Impl> pImpl_;
|
||||
};
|
||||
|
||||
@@ -57,9 +57,13 @@ struct ExpandOption {
|
||||
};
|
||||
|
||||
class Screen : public RefBase {
|
||||
friend class ScreenManagerAdapter;
|
||||
public:
|
||||
Screen(const ScreenInfo* info);
|
||||
~Screen();
|
||||
Screen(const Screen&) = delete;
|
||||
Screen(Screen&&) = delete;
|
||||
Screen& operator=(const Screen&) = delete;
|
||||
Screen& operator=(Screen&&) = delete;
|
||||
bool IsGroup() const;
|
||||
ScreenId GetId() const;
|
||||
uint32_t GetWidth() const;
|
||||
@@ -81,7 +85,9 @@ public:
|
||||
DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const;
|
||||
DMError SetScreenGamutMap(ScreenGamutMap gamutMap);
|
||||
DMError SetScreenColorTransform();
|
||||
|
||||
protected:
|
||||
Screen(sptr<ScreenInfo> info);
|
||||
void UpdateScreenInfo(sptr<ScreenInfo> screenInfo);
|
||||
private:
|
||||
class Impl;
|
||||
sptr<Impl> pImpl_;
|
||||
|
||||
@@ -29,14 +29,20 @@ enum class ScreenCombination : uint32_t {
|
||||
};
|
||||
|
||||
class ScreenGroup : public Screen {
|
||||
friend class ScreenManagerAdapter;
|
||||
public:
|
||||
ScreenGroup(const ScreenGroupInfo* info);
|
||||
~ScreenGroup();
|
||||
ScreenGroup(const ScreenGroup&) = delete;
|
||||
ScreenGroup(ScreenGroup&&) = delete;
|
||||
ScreenGroup& operator=(const ScreenGroup&) = delete;
|
||||
ScreenGroup& operator=(ScreenGroup&&) = delete;
|
||||
ScreenCombination GetCombination() const;
|
||||
std::vector<ScreenId> GetChild() const;
|
||||
std::vector<Point> GetChildPosition() const;
|
||||
std::vector<ScreenId> GetChildIds() const;
|
||||
std::vector<Point> GetChildPositions() const;
|
||||
|
||||
private:
|
||||
ScreenGroup(sptr<ScreenGroupInfo> info);
|
||||
void UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info);
|
||||
class Impl;
|
||||
sptr<Impl> pImpl_;
|
||||
};
|
||||
|
||||
@@ -138,14 +138,7 @@ struct PointInfo {
|
||||
namespace {
|
||||
constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
|
||||
constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
|
||||
constexpr float DEFAULT_SPLIT_RATIO = 0.5;
|
||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||
constexpr uint32_t INVALID_WINDOW_ID = 0;
|
||||
constexpr uint32_t HOTZONE = 40;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_WIDTH = 240;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_HEIGHT = 426;
|
||||
constexpr uint32_t MIN_VERTICAL_SPLIT_HEIGHT = 426;
|
||||
constexpr uint32_t MIN_HORIZONTAL_SPLIT_WIDTH = 426;
|
||||
}
|
||||
|
||||
struct SystemBarProperty {
|
||||
|
||||
@@ -150,21 +150,21 @@ void WindowManagerDebugCommand::DumpResults(WindowDumpType dumpType)
|
||||
}
|
||||
}
|
||||
switch (dumpType) {
|
||||
case WindowDumpType::ALL: {
|
||||
result_ += (ret == WMError::WM_OK) ? DUMP_ALL_OK_MSG : DUMP_ALL_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
case WindowDumpType::TREE: {
|
||||
result_ += (ret == WMError::WM_OK) ? DUMP_TREE_OK_MSG : DUMP_TREE_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
case WindowDumpType::CLEAR: {
|
||||
result_ += (ret == WMError::WM_OK) ? CLEAR_DUMP_INFO_OK_MSG : CLEAR_DUMP_INFO_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
result_ = " ";
|
||||
}
|
||||
case WindowDumpType::ALL: {
|
||||
result_ += (ret == WMError::WM_OK) ? DUMP_ALL_OK_MSG : DUMP_ALL_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
case WindowDumpType::TREE: {
|
||||
result_ += (ret == WMError::WM_OK) ? DUMP_TREE_OK_MSG : DUMP_TREE_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
case WindowDumpType::CLEAR: {
|
||||
result_ += (ret == WMError::WM_OK) ? CLEAR_DUMP_INFO_OK_MSG : CLEAR_DUMP_INFO_FAIL_MSG;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
result_ = " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing p ermissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_CLASS_VAR_DEFINATION_H
|
||||
#define OHOS_ROSEN_CLASS_VAR_DEFINATION_H
|
||||
namespace OHOS::Rosen {
|
||||
#define DEFINE_VAR(type, memberName) \
|
||||
private: \
|
||||
type memberName##_;
|
||||
|
||||
#define DEFINE_VAR_DEFAULT(type, memberName, defaultValue) \
|
||||
private: \
|
||||
type memberName##_ {defaultValue};
|
||||
|
||||
#define DEFINE_FUNC_GET(type, funcName, memberName) \
|
||||
public: \
|
||||
type Get##funcName() const \
|
||||
{ \
|
||||
return memberName##_; \
|
||||
}
|
||||
|
||||
#define DEFINE_FUNC_SET(type, funcName, memberName) \
|
||||
public: \
|
||||
void Set##funcName(type value) \
|
||||
{ \
|
||||
memberName##_ = value; \
|
||||
}
|
||||
|
||||
#define DEFINE_VAR_FUNC_GET(type, funcName, memberName) \
|
||||
DEFINE_VAR(type, memberName) \
|
||||
DEFINE_FUNC_GET(type, funcName, memberName)
|
||||
|
||||
#define DEFINE_VAR_DEFAULT_FUNC_GET(type, funcName, memberName, defaultValue) \
|
||||
DEFINE_VAR_DEFAULT(type, memberName, defaultValue) \
|
||||
DEFINE_FUNC_GET(type, funcName, memberName)
|
||||
|
||||
#define DEFINE_VAR_FUNC_GET_SET(type, funcName, memberName) \
|
||||
DEFINE_VAR(type, memberName) \
|
||||
DEFINE_FUNC_GET(type, funcName, memberName) \
|
||||
DEFINE_FUNC_SET(type, funcName, memberName)
|
||||
|
||||
#define DEFINE_VAR_DEFAULT_FUNC_GET_SET(type, funcName, memberName, defaultValue) \
|
||||
DEFINE_VAR_DEFAULT(type, memberName, defaultValue) \
|
||||
DEFINE_FUNC_GET(type, funcName, memberName) \
|
||||
DEFINE_FUNC_SET(type, funcName, memberName)
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_CLASS_VAR_DEFINATION_H
|
||||
@@ -18,29 +18,34 @@
|
||||
|
||||
#include <parcel.h>
|
||||
|
||||
#include "class_var_defination.h"
|
||||
#include "display.h"
|
||||
#include "dm_common.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class DisplayInfo : public Parcelable {
|
||||
friend class AbstractDisplay;
|
||||
public:
|
||||
DisplayInfo() = default;
|
||||
~DisplayInfo() = default;
|
||||
|
||||
void Update(DisplayInfo* info);
|
||||
DisplayInfo(const DisplayInfo&) = delete;
|
||||
DisplayInfo(DisplayInfo&&) = delete;
|
||||
DisplayInfo& operator=(const DisplayInfo&) = delete;
|
||||
DisplayInfo& operator=(DisplayInfo&&) = delete;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static DisplayInfo *Unmarshalling(Parcel& parcel);
|
||||
|
||||
DisplayId id_ { DISPLAY_ID_INVALD };
|
||||
DisplayType type_ {DisplayType::DEFAULT };
|
||||
int32_t width_ { 0 };
|
||||
int32_t height_ { 0 };
|
||||
uint32_t freshRate_ { 0 };
|
||||
ScreenId screenId_ { SCREEN_ID_INVALID };
|
||||
float xDpi_ { 0.0 };
|
||||
float yDpi_ { 0.0 };
|
||||
Rotation rotation_ { Rotation::ROTATION_0 };
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayId, DisplayId, id, DISPLAY_ID_INVALD);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(DisplayType, DisplayType, type, DisplayType::DEFAULT);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Width, width, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Height, height, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, FreshRate, freshRate, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, screenId, SCREEN_ID_INVALID);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(float, XDpi, xDpi, 0.0f);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(float, YDpi, yDpi, 0.0f);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(Rotation, Rotation, rotation, Rotation::ROTATION_0);
|
||||
private:
|
||||
DisplayInfo() = default;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DMSERVER_DISPLAY_INFO_H
|
||||
@@ -23,20 +23,23 @@
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenGroupInfo : public ScreenInfo {
|
||||
friend class AbstractScreenGroup;
|
||||
public:
|
||||
ScreenGroupInfo() = default;
|
||||
~ScreenGroupInfo() = default;
|
||||
|
||||
void Update(sptr<ScreenGroupInfo> info);
|
||||
ScreenGroupInfo(const ScreenGroupInfo&) = delete;
|
||||
ScreenGroupInfo(ScreenGroupInfo&&) = delete;
|
||||
ScreenGroupInfo& operator=(const ScreenGroupInfo&) = delete;
|
||||
ScreenGroupInfo& operator=(ScreenGroupInfo&&) = delete;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static ScreenGroupInfo* Unmarshalling(Parcel& parcel);
|
||||
|
||||
std::vector<ScreenId> children_;
|
||||
std::vector<Point> position_;
|
||||
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
|
||||
protected:
|
||||
ScreenGroupInfo* InnerUnmarshalling(Parcel& parcel);
|
||||
DEFINE_VAR_FUNC_GET(std::vector<ScreenId>, Children, children);
|
||||
DEFINE_VAR_FUNC_GET(std::vector<Point>, Position, position);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenCombination, Combination, combination, ScreenCombination::SCREEN_ALONE);
|
||||
private:
|
||||
ScreenGroupInfo() = default;
|
||||
bool InnerUnmarshalling(Parcel& parcel);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DMSERVER_SCREEN_GROUP_INFO_H
|
||||
+17
-13
@@ -18,30 +18,34 @@
|
||||
|
||||
#include <parcel.h>
|
||||
|
||||
#include "class_var_defination.h"
|
||||
#include "screen.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenInfo : public Parcelable {
|
||||
friend class AbstractScreen;
|
||||
public:
|
||||
ScreenInfo() = default;
|
||||
~ScreenInfo() = default;
|
||||
|
||||
void Update(sptr<ScreenInfo> info);
|
||||
ScreenInfo(const ScreenInfo&) = delete;
|
||||
ScreenInfo(ScreenInfo&&) = delete;
|
||||
ScreenInfo& operator=(const ScreenInfo&) = delete;
|
||||
ScreenInfo& operator= (ScreenInfo&&) = delete;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static ScreenInfo* Unmarshalling(Parcel& parcel);
|
||||
|
||||
ScreenId id_ { SCREEN_ID_INVALID };
|
||||
uint32_t virtualWidth_ { 0 };
|
||||
uint32_t virtualHeight_ { 0 };
|
||||
float virtualPixelRatio_ { 0.0 };
|
||||
ScreenId parent_ { 0 };
|
||||
bool canHasChild_ { false };
|
||||
Rotation rotation_ { Rotation::ROTATION_0 };
|
||||
uint32_t modeId_ { 0 };
|
||||
std::vector<sptr<SupportedScreenModes>> modes_ {};
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, id, SCREEN_ID_INVALID);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, VirtualWidth, virtualWidth, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, VirtualHeight, virtualHeight, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(float, VirtualPixelRatio, virtualPixelRatio, 0.0f);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ParentId, parent, 0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(bool, CanHasChild, canHasChild, false);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET(Rotation, Rotation, rotation, Rotation::ROTATION_0);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(uint32_t, ModeId, modeId, 0);
|
||||
DEFINE_VAR_FUNC_GET(std::vector<sptr<SupportedScreenModes>>, Modes, modes);
|
||||
protected:
|
||||
ScreenInfo* InnerUnmarshalling(Parcel& parcel);
|
||||
ScreenInfo() = default;
|
||||
bool InnerUnmarshalling(Parcel& parcel);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DMSERVER_DISPLAY_INFO_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_WM_INCLUDE_WM_HELPER_H
|
||||
|
||||
#include <wm_common.h>
|
||||
#include <wm_common_inner.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -79,15 +80,18 @@ public:
|
||||
return (r.posX_ == 0 && r.posY_ == 0 && r.width_ == 0 && r.height_ == 0);
|
||||
}
|
||||
|
||||
static Rect GetFixedWindowRectByMinRect(const Rect& oriDstRect, const Rect& lastRect, bool isVertical)
|
||||
static Rect GetFixedWindowRectByMinRect(const Rect& oriDstRect, const Rect& lastRect, bool isVertical,
|
||||
float virtualPixelRatio)
|
||||
{
|
||||
uint32_t minVerticalFloatingW = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalFloatingH = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
Rect dstRect = oriDstRect;
|
||||
if (isVertical) {
|
||||
dstRect.width_ = std::max(MIN_VERTICAL_FLOATING_WIDTH, oriDstRect.width_);
|
||||
dstRect.height_ = std::max(MIN_VERTICAL_FLOATING_HEIGHT, oriDstRect.height_);
|
||||
dstRect.width_ = std::max(minVerticalFloatingW, oriDstRect.width_);
|
||||
dstRect.height_ = std::max(minVerticalFloatingH, oriDstRect.height_);
|
||||
} else {
|
||||
dstRect.width_ = std::max(MIN_VERTICAL_FLOATING_HEIGHT, oriDstRect.width_);
|
||||
dstRect.height_ = std::max(MIN_VERTICAL_FLOATING_WIDTH, oriDstRect.height_);
|
||||
dstRect.width_ = std::max(minVerticalFloatingH, oriDstRect.width_);
|
||||
dstRect.height_ = std::max(minVerticalFloatingW, oriDstRect.height_);
|
||||
}
|
||||
|
||||
// limit position by fixed width or height
|
||||
|
||||
@@ -44,6 +44,18 @@ enum class WindowUpdateReason : uint32_t {
|
||||
UPDATE_TYPE,
|
||||
UPDATE_OTHER_PROPS,
|
||||
};
|
||||
namespace {
|
||||
constexpr float DEFAULT_SPLIT_RATIO = 0.5;
|
||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 4;
|
||||
constexpr uint32_t HOTZONE = 40;
|
||||
constexpr uint32_t DIV_HOTZONE = 20;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_WIDTH = 240;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_HEIGHT = 426;
|
||||
constexpr uint32_t MIN_VERTICAL_SPLIT_HEIGHT = 426;
|
||||
constexpr uint32_t MIN_HORIZONTAL_SPLIT_WIDTH = 426;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // OHOS_ROSEN_WM_COMMON_INNER_H
|
||||
@@ -16,19 +16,6 @@
|
||||
#include "display_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
void DisplayInfo::Update(DisplayInfo* info)
|
||||
{
|
||||
id_ = info->id_;
|
||||
type_ = info->type_;
|
||||
width_ = info->width_;
|
||||
height_ = info->height_;
|
||||
freshRate_ = info->freshRate_;
|
||||
screenId_ = info->screenId_;
|
||||
xDpi_ = info->xDpi_;
|
||||
yDpi_ = info->yDpi_;
|
||||
rotation_ = info->rotation_;
|
||||
}
|
||||
|
||||
bool DisplayInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return parcel.WriteUint64(id_) && parcel.WriteUint32(type_) &&
|
||||
@@ -41,9 +28,6 @@ bool DisplayInfo::Marshalling(Parcel &parcel) const
|
||||
DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DisplayInfo *displayInfo = new DisplayInfo();
|
||||
if (displayInfo == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t type = (uint32_t)DisplayType::DEFAULT;
|
||||
uint32_t rotation;
|
||||
bool res = parcel.ReadUint64(displayInfo->id_) && parcel.ReadUint32(type) &&
|
||||
@@ -52,11 +36,11 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel)
|
||||
parcel.ReadFloat(displayInfo->xDpi_) && parcel.ReadFloat(displayInfo->yDpi_) &&
|
||||
parcel.ReadUint32(rotation);
|
||||
if (!res) {
|
||||
displayInfo = nullptr;
|
||||
} else {
|
||||
displayInfo->type_ = (DisplayType)type;
|
||||
displayInfo->rotation_ = static_cast<Rotation>(rotation);
|
||||
delete displayInfo;
|
||||
return nullptr;
|
||||
}
|
||||
displayInfo->type_ = (DisplayType)type;
|
||||
displayInfo->rotation_ = static_cast<Rotation>(rotation);
|
||||
return displayInfo;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -16,16 +16,6 @@
|
||||
#include "screen_group_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
void ScreenGroupInfo::Update(sptr<ScreenGroupInfo> info)
|
||||
{
|
||||
ScreenInfo::Update(info);
|
||||
children_.clear();
|
||||
children_.insert(children_.begin(), info->children_.begin(), info->children_.end());
|
||||
position_.clear();
|
||||
position_.insert(position_.begin(), info->position_.begin(), info->position_.end());
|
||||
combination_ = info->combination_;
|
||||
}
|
||||
|
||||
bool ScreenGroupInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
bool res = ScreenInfo::Marshalling(parcel) && parcel.WriteUint32((uint32_t)combination_) &&
|
||||
@@ -48,29 +38,34 @@ bool ScreenGroupInfo::Marshalling(Parcel &parcel) const
|
||||
ScreenGroupInfo* ScreenGroupInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ScreenGroupInfo* screenGroupInfo = new ScreenGroupInfo();
|
||||
return screenGroupInfo->InnerUnmarshalling(parcel);
|
||||
bool res = screenGroupInfo->InnerUnmarshalling(parcel);
|
||||
if (res) {
|
||||
return screenGroupInfo;
|
||||
}
|
||||
delete screenGroupInfo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScreenGroupInfo* ScreenGroupInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
bool ScreenGroupInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
{
|
||||
uint32_t combination;
|
||||
if (!ScreenInfo::InnerUnmarshalling(parcel) || !parcel.ReadUint32(combination) ||
|
||||
!parcel.ReadUInt64Vector(&children_)) {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
combination_ = (ScreenCombination) combination;
|
||||
uint32_t size;
|
||||
if (!parcel.ReadUint32(size)) {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
Point point;
|
||||
if (parcel.ReadInt32(point.posX_) && parcel.ReadInt32(point.posY_)) {
|
||||
position_.push_back(point);
|
||||
} else {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
+10
-18
@@ -16,19 +16,6 @@
|
||||
#include "screen_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
void ScreenInfo::Update(sptr<ScreenInfo> info)
|
||||
{
|
||||
id_ = info->id_;
|
||||
virtualWidth_ = info->virtualWidth_;
|
||||
virtualHeight_ = info->virtualHeight_;
|
||||
virtualPixelRatio_ = info->virtualPixelRatio_;
|
||||
parent_ = info->parent_;
|
||||
canHasChild_ = info->canHasChild_;
|
||||
rotation_ = info->rotation_;
|
||||
modeId_ = info->modeId_;
|
||||
modes_ = info->modes_;
|
||||
}
|
||||
|
||||
bool ScreenInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
bool res = parcel.WriteUint64(id_) &&
|
||||
@@ -53,10 +40,15 @@ bool ScreenInfo::Marshalling(Parcel &parcel) const
|
||||
ScreenInfo* ScreenInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ScreenInfo* info = new ScreenInfo();
|
||||
return info->InnerUnmarshalling(parcel);
|
||||
bool res = info->InnerUnmarshalling(parcel);
|
||||
if (res) {
|
||||
return info;
|
||||
}
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScreenInfo* ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
bool ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
uint32_t rotation;
|
||||
@@ -66,7 +58,7 @@ ScreenInfo* ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
parcel.ReadBool(canHasChild_) && parcel.ReadUint32(rotation) &&
|
||||
parcel.ReadUint32(modeId_) && parcel.ReadUint32(size);
|
||||
if (!res1) {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
modes_.clear();
|
||||
for (uint32_t modeIndex = 0; modeIndex < size; modeIndex++) {
|
||||
@@ -76,10 +68,10 @@ ScreenInfo* ScreenInfo::InnerUnmarshalling(Parcel& parcel)
|
||||
parcel.ReadUint32(mode->freshRate_)) {
|
||||
modes_.push_back(mode);
|
||||
} else {
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
rotation_ = static_cast<Rotation>(rotation);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -1125,26 +1125,22 @@ void WindowImpl::UpdateWindowState(WindowState state)
|
||||
switch (state) {
|
||||
case WindowState::STATE_FROZEN: {
|
||||
state_ = WindowState::STATE_HIDDEN;
|
||||
if (uiContent_ != nullptr) {
|
||||
uiContent_->Background();
|
||||
}
|
||||
if (abilityContext_ != nullptr) {
|
||||
WLOGFD("DoAbilityBackground KEYGUARD, id: %{public}d", GetWindowId());
|
||||
AAFwk::AbilityManagerClient::GetInstance()->DoAbilityBackground(abilityContext_->GetToken(),
|
||||
static_cast<uint32_t>(WindowStateChangeReason::KEYGUARD));
|
||||
}
|
||||
NotifyAfterBackground();
|
||||
break;
|
||||
}
|
||||
case WindowState::STATE_UNFROZEN: {
|
||||
state_ = WindowState::STATE_SHOWN;
|
||||
if (uiContent_ != nullptr) {
|
||||
uiContent_->Foreground();
|
||||
}
|
||||
if (abilityContext_ != nullptr) {
|
||||
WLOGFD("DoAbilityForeground KEYGUARD, id: %{public}d", GetWindowId());
|
||||
AAFwk::AbilityManagerClient::GetInstance()->DoAbilityForeground(abilityContext_->GetToken(),
|
||||
static_cast<uint32_t>(WindowStateChangeReason::KEYGUARD));
|
||||
}
|
||||
NotifyAfterForeground();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
DisplayId displayId_ = 0;
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
static vector<Rect> fullScreenExpecteds_;
|
||||
static inline float virtualPixelRatio_ = 0.0;
|
||||
};
|
||||
|
||||
vector<Rect> WindowLayoutTest::fullScreenExpecteds_;
|
||||
@@ -47,6 +48,9 @@ void WindowLayoutTest::SetUpTestCase()
|
||||
}
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
|
||||
// calc expected rects
|
||||
Rect expected = { // 0. only statusBar
|
||||
0,
|
||||
@@ -110,7 +114,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3)
|
||||
activeWindows_.push_back(window);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::GetFloatingLimitedRect(utils::customAppRect_)));
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_)));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
@@ -140,12 +144,12 @@ HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3)
|
||||
activeWindows_.push_back(statBar);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, appWin->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_)));
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_)));
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_)));
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_)));
|
||||
ASSERT_TRUE(utils::RectEqualTo(statBar, utils::statusBarRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Hide());
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_)));
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +281,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3)
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size
|
||||
Rect finalExcept = { expect.posX_, expect.posY_, 2u, 2u}; // 2: custom min size
|
||||
finalExcept = utils::GetFloatingLimitedRect(finalExcept);
|
||||
finalExcept = utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, finalExcept));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "pointer_event.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_test_utils.h"
|
||||
#include "wm_common_inner.h"
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
@@ -54,6 +55,8 @@ private:
|
||||
static inline Rect startPointRect_ = {0, 0, 0, 0};
|
||||
static inline Rect expectRect_ = {0, 0, 0, 0};
|
||||
static inline sptr<Window> window_ = nullptr;
|
||||
static inline float virtualPixelRatio_ = 0.0;
|
||||
static inline uint32_t hotZone_ = 0;
|
||||
};
|
||||
|
||||
void WindowMoveDragTest::SetUpTestCase()
|
||||
@@ -83,6 +86,9 @@ void WindowMoveDragTest::SetUp()
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
hotZone_ = static_cast<uint32_t>(HOTZONE * virtualPixelRatio_);
|
||||
|
||||
winInfo_ = {
|
||||
.name = "Floating",
|
||||
.rect = {0, 0, 0, 0},
|
||||
@@ -174,7 +180,7 @@ void WindowMoveDragTest::CalExpectRects()
|
||||
}
|
||||
}
|
||||
bool isVertical = (utils::displayRect_.width_ < utils::displayRect_.height_) ? true : false;
|
||||
expectRect_ = WindowHelper::GetFixedWindowRectByMinRect(oriRect, startPointRect_, isVertical);
|
||||
expectRect_ = WindowHelper::GetFixedWindowRectByMinRect(oriRect, startPointRect_, isVertical, virtualPixelRatio_);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -188,10 +194,10 @@ HWTEST_F(WindowMoveDragTest, DragWindow01, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ * POINT_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -206,11 +212,11 @@ HWTEST_F(WindowMoveDragTest, DragWindow02, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -225,11 +231,11 @@ HWTEST_F(WindowMoveDragTest, DragWindow03, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -244,10 +250,10 @@ HWTEST_F(WindowMoveDragTest, DragWindow04, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
@@ -263,11 +269,11 @@ HWTEST_F(WindowMoveDragTest, DragWindow05, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -282,11 +288,11 @@ HWTEST_F(WindowMoveDragTest, DragWindow06, Function | MediumTest | Level3)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -302,10 +308,10 @@ HWTEST_F(WindowMoveDragTest, DragWindow07, Function | MediumTest | Level3)
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ - hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ - HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ - hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -321,10 +327,10 @@ HWTEST_F(WindowMoveDragTest, DragWindow08, Function | MediumTest | Level3)
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Show());
|
||||
startPointRect_ = window_->GetRect();
|
||||
startPointX_ = startPointRect_.posX_ + startPointRect_.width_ * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * POINT_HOTZONE_RATIO;
|
||||
startPointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -343,7 +349,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow09, Function | MediumTest | Level3)
|
||||
startPointY_ = startPointRect_.posY_ + 1;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + startPointRect_.height_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
DoMoveOrDrag();
|
||||
ASSERT_EQ(WMError::WM_OK, window_->Hide());
|
||||
}
|
||||
@@ -362,7 +368,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow10, Function | MediumTest | Level3)
|
||||
startPointY_ = startPointRect_.posY_ + 1;
|
||||
|
||||
pointX_ = startPointRect_.posX_ + startPointRect_.width_ * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + HOTZONE * DRAG_HOTZONE_RATIO;
|
||||
pointY_ = startPointRect_.posY_ + hotZone_ * DRAG_HOTZONE_RATIO;
|
||||
window_->StartMove();
|
||||
hasStartMove_ = true;
|
||||
DoMoveOrDrag();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "window_test_utils.h"
|
||||
#include <ability_context.h>
|
||||
#include "wm_common_inner.h"
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
@@ -123,13 +124,18 @@ Rect WindowTestUtils::GetDefaultFoatingRect(const sptr<Window>& window)
|
||||
return resRect;
|
||||
}
|
||||
|
||||
Rect WindowTestUtils::GetLimitedDecoRect(const Rect& rect)
|
||||
Rect WindowTestUtils::GetLimitedDecoRect(const Rect& rect, float virtualPixelRatio)
|
||||
{
|
||||
constexpr uint32_t winFrameH = 52u;
|
||||
constexpr uint32_t winFrameW = 8u;
|
||||
constexpr uint32_t windowTitleBarHeight = 48;
|
||||
constexpr uint32_t windowFrameWidth = 4;
|
||||
uint32_t winFrameH = static_cast<uint32_t>((windowTitleBarHeight + windowFrameWidth) * virtualPixelRatio);
|
||||
uint32_t winFrameW = static_cast<uint32_t>((windowFrameWidth + windowFrameWidth) * virtualPixelRatio);
|
||||
uint32_t minVerticalFloatingW = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalFloatingH = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
|
||||
bool vertical = displayRect_.width_ < displayRect_.height_;
|
||||
uint32_t minFloatingW = vertical ? MIN_VERTICAL_FLOATING_WIDTH : MIN_VERTICAL_FLOATING_HEIGHT;
|
||||
uint32_t minFloatingH = vertical ? MIN_VERTICAL_FLOATING_HEIGHT : MIN_VERTICAL_FLOATING_WIDTH;
|
||||
uint32_t minFloatingW = vertical ? minVerticalFloatingW : minVerticalFloatingH;
|
||||
uint32_t minFloatingH = vertical ? minVerticalFloatingH : minVerticalFloatingW;
|
||||
Rect resRect = {
|
||||
rect.posX_,
|
||||
rect.posY_,
|
||||
@@ -139,11 +145,14 @@ Rect WindowTestUtils::GetLimitedDecoRect(const Rect& rect)
|
||||
return resRect;
|
||||
}
|
||||
|
||||
Rect WindowTestUtils::GetFloatingLimitedRect(const Rect& rect)
|
||||
Rect WindowTestUtils::GetFloatingLimitedRect(const Rect& rect, float virtualPixelRatio)
|
||||
{
|
||||
uint32_t minVerticalFloatingW = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalFloatingH = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
bool vertical = displayRect_.width_ < displayRect_.height_;
|
||||
uint32_t minFloatingW = vertical ? MIN_VERTICAL_FLOATING_WIDTH : MIN_VERTICAL_FLOATING_HEIGHT;
|
||||
uint32_t minFloatingH = vertical ? MIN_VERTICAL_FLOATING_HEIGHT : MIN_VERTICAL_FLOATING_WIDTH;
|
||||
|
||||
uint32_t minFloatingW = vertical ? minVerticalFloatingW : minVerticalFloatingH;
|
||||
uint32_t minFloatingH = vertical ? minVerticalFloatingH : minVerticalFloatingW;
|
||||
Rect resRect = {
|
||||
rect.posX_,
|
||||
rect.posY_,
|
||||
@@ -257,18 +266,21 @@ void WindowTestUtils::InitSplitRects()
|
||||
displayRect_ = displayRect;
|
||||
limitDisplayRect_ = displayRect;
|
||||
|
||||
float virtualPixelRatio = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
uint32_t dividerWidth = static_cast<uint32_t>(DIVIDER_WIDTH * virtualPixelRatio);
|
||||
|
||||
if (displayRect_.width_ < displayRect_.height_) {
|
||||
isVerticalDisplay_ = true;
|
||||
}
|
||||
if (isVerticalDisplay_) {
|
||||
splitRects_.dividerRect = { 0,
|
||||
static_cast<uint32_t>((displayRect_.height_ - DIVIDER_WIDTH) * DEFAULT_SPLIT_RATIO),
|
||||
static_cast<uint32_t>((displayRect_.height_ - dividerWidth) * DEFAULT_SPLIT_RATIO),
|
||||
displayRect_.width_,
|
||||
DIVIDER_WIDTH, };
|
||||
dividerWidth, };
|
||||
} else {
|
||||
splitRects_.dividerRect = { static_cast<uint32_t>((displayRect_.width_ - DIVIDER_WIDTH) * DEFAULT_SPLIT_RATIO),
|
||||
splitRects_.dividerRect = { static_cast<uint32_t>((displayRect_.width_ - dividerWidth) * DEFAULT_SPLIT_RATIO),
|
||||
0,
|
||||
DIVIDER_WIDTH,
|
||||
dividerWidth,
|
||||
displayRect_.height_ };
|
||||
}
|
||||
}
|
||||
@@ -374,5 +386,17 @@ void WindowTestUtils::UpdateLimitSplitRect(Rect& limitSplitRect)
|
||||
curLimitRect.posY_ + curLimitRect.height_) -
|
||||
limitSplitRect.posY_;
|
||||
}
|
||||
|
||||
float WindowTestUtils::GetVirtualPixelRatio(DisplayId displayId)
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
if (display == nullptr) {
|
||||
WLOGFE("GetVirtualPixel fail. Get display fail. displayId:%{public}" PRIu64", vpr:%{public}f", displayId, 0.0);
|
||||
return 0.0;
|
||||
}
|
||||
float virtualPixelRatio = display->GetVirtualPixelRatio();
|
||||
WLOGFI("GetVirtualPixel success. displayId:%{public}" PRIu64", vpr:%{public}f", displayId, virtualPixelRatio);
|
||||
return virtualPixelRatio;
|
||||
}
|
||||
} // namespace ROSEN
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -66,9 +66,10 @@ public:
|
||||
static void UpdateSplitRects(const sptr<Window>& window);
|
||||
static bool RectEqualToRect(const Rect& l, const Rect& r);
|
||||
static Rect GetDefaultFoatingRect(const sptr<Window>& window);
|
||||
static Rect GetLimitedDecoRect(const Rect& rect);
|
||||
static Rect GetFloatingLimitedRect(const Rect& rect);
|
||||
static Rect GetLimitedDecoRect(const Rect& rect, float virtualPixelRatio);
|
||||
static Rect GetFloatingLimitedRect(const Rect& rect, float virtualPixelRatio);
|
||||
static void InitTileWindowRects(const sptr<Window>& window);
|
||||
static float GetVirtualPixelRatio(DisplayId displayId);
|
||||
|
||||
private:
|
||||
void UpdateLimitDisplayRect(Rect& avoidRect);
|
||||
|
||||
@@ -76,6 +76,7 @@ ohos_shared_library("libwms") {
|
||||
":window_divider_image",
|
||||
"//foundation/ace/ace_engine/build/external_config/flutter/skia:ace_skia_ohos",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
"//foundation/windowmanager/dmserver:libdms",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
virtual void UpdateWindowNode(sptr<WindowNode>& node);
|
||||
virtual void UpdateLayoutRect(sptr<WindowNode>& node) = 0;
|
||||
void UpdateDefaultFoatingRect();
|
||||
float GetVirtualPixelRatio() const;
|
||||
|
||||
protected:
|
||||
const Rect& displayRect_;
|
||||
@@ -66,6 +67,7 @@ protected:
|
||||
void UpdateLimitRect(const sptr<WindowNode>& node, Rect& limitRect);
|
||||
virtual void LayoutWindowNode(sptr<WindowNode>& node);
|
||||
AvoidPosType GetAvoidPosType(const Rect& rect);
|
||||
void CalcAndSetNodeHotZone(Rect layoutOutRect, sptr<WindowNode>& node);
|
||||
void LimitWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect);
|
||||
void SetRectForFloating(const sptr<WindowNode>& node);
|
||||
Rect ComputeDecoratedWindowRect(const Rect& winRect);
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
|
||||
void SetDisplayId(DisplayId displayId);
|
||||
void SetLayoutRect(const Rect& rect);
|
||||
void SetHotZoneRect(const Rect& rect);
|
||||
void SetWindowRect(const Rect& rect);
|
||||
void SetWindowProperty(const sptr<WindowProperty>& property);
|
||||
void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
|
||||
@@ -95,6 +96,7 @@ private:
|
||||
sptr<WindowProperty> property_;
|
||||
sptr<IWindow> windowToken_;
|
||||
Rect layoutRect_ { 0, 0, 0, 0 };
|
||||
Rect hotZoneRect_ { 0, 0, 0, 0 };
|
||||
int32_t callingPid_;
|
||||
int32_t callingUid_;
|
||||
WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED};
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
sptr<WindowNode> GetAppWindowNode() const;
|
||||
sptr<WindowNode> GetAboveAppWindowNode() const;
|
||||
void DumpWindowTree(std::vector<std::string> &windowTreeInfos, WindowDumpType type);
|
||||
float GetVirtualPixelRatio() const;
|
||||
|
||||
private:
|
||||
void AssignZOrder(sptr<WindowNode>& node);
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
void NotifySystemBarTints();
|
||||
WMError RaiseZOrderForAppWindow(sptr<WindowNode>& node);
|
||||
WMError DumpWindowTree(std::vector<std::string> &windowTreeInfos, WindowDumpType type);
|
||||
float GetVirtualPixelRatio(DisplayId displayId) const;
|
||||
|
||||
private:
|
||||
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
|
||||
|
||||
@@ -163,7 +163,7 @@ void InputWindowMonitor::TraverseWindowNodes(const std::vector<sptr<WindowNode>>
|
||||
|
||||
void InputWindowMonitor::UpdateDisplayDirection(MMI::PhysicalDisplayInfo& physicalDisplayInfo, DisplayId displayId)
|
||||
{
|
||||
Rotation rotation = DisplayManagerServiceInner::GetInstance().GetScreenInfoByDisplayId(displayId)->rotation_;
|
||||
Rotation rotation = DisplayManagerServiceInner::GetInstance().GetScreenInfoByDisplayId(displayId)->GetRotation();
|
||||
switch (rotation) {
|
||||
case Rotation::ROTATION_0:
|
||||
physicalDisplayInfo.direction = MMI::Direction0;
|
||||
|
||||
@@ -141,8 +141,9 @@ WMError WindowController::ResizeRect(uint32_t windowId, const Rect& rect, Window
|
||||
} else if (reason == WindowSizeChangeReason::DRAG) {
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
// fix rect in case of moving window when dragging
|
||||
newRect = WindowHelper::GetFixedWindowRectByMinRect(rect,
|
||||
property->GetWindowRect(), windowRoot_->isVerticalDisplay(node));
|
||||
float virtualPixelRatio = windowRoot_->GetVirtualPixelRatio(node->GetDisplayId());
|
||||
newRect = WindowHelper::GetFixedWindowRectByMinRect(rect, property->GetWindowRect(),
|
||||
windowRoot_->isVerticalDisplay(node), virtualPixelRatio);
|
||||
} else {
|
||||
newRect = rect;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
*/
|
||||
|
||||
#include "window_layout_policy.h"
|
||||
#include "display_manager.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowLayoutPolicy"};
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 4;
|
||||
}
|
||||
WindowLayoutPolicy::WindowLayoutPolicy(const Rect& displayRect, const uint64_t& screenId,
|
||||
sptr<WindowNode>& belowAppNode, sptr<WindowNode>& appNode, sptr<WindowNode>& aboveAppNode)
|
||||
@@ -115,11 +115,14 @@ void WindowLayoutPolicy::UpdateDefaultFoatingRect()
|
||||
|
||||
void WindowLayoutPolicy::SetRectForFloating(const sptr<WindowNode>& node)
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t winFrameW = static_cast<uint32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio);
|
||||
uint32_t winTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
|
||||
// deduct decor size
|
||||
Rect rect = defaultFloatingRect_;
|
||||
if (node->GetWindowProperty()->GetDecorEnable()) {
|
||||
rect.width_ -= (WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH);
|
||||
rect.height_ -= (WINDOW_TITLE_BAR_HEIGHT + WINDOW_FRAME_WIDTH);
|
||||
rect.width_ -= (winFrameW + winFrameW);
|
||||
rect.height_ -= (winTitleBarH + winFrameW);
|
||||
}
|
||||
|
||||
node->SetWindowRect(rect);
|
||||
@@ -174,11 +177,15 @@ void WindowLayoutPolicy::UpdateFloatingLayoutRect(Rect& limitRect, Rect& winRect
|
||||
|
||||
Rect WindowLayoutPolicy::ComputeDecoratedWindowRect(const Rect& winRect)
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t winFrameW = static_cast<uint32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio);
|
||||
uint32_t winTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
|
||||
|
||||
Rect rect;
|
||||
rect.posX_ = winRect.posX_;
|
||||
rect.posY_ = winRect.posY_;
|
||||
rect.width_ = winRect.width_ + WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH;
|
||||
rect.height_ = winRect.height_ + WINDOW_TITLE_BAR_HEIGHT + WINDOW_FRAME_WIDTH;
|
||||
rect.width_ = winRect.width_ + winFrameW + winFrameW;
|
||||
rect.height_ = winRect.height_ + winTitleBarH + winFrameW;
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -221,14 +228,44 @@ void WindowLayoutPolicy::UpdateLayoutRect(sptr<WindowNode>& node)
|
||||
LimitWindowSize(node, displayRect, winRect);
|
||||
|
||||
node->SetLayoutRect(winRect);
|
||||
CalcAndSetNodeHotZone(winRect, node);
|
||||
if (!(lastRect == winRect)) {
|
||||
node->GetWindowToken()->UpdateWindowRect(winRect, node->GetWindowSizeChangeReason());
|
||||
node->surfaceNode_->SetBounds(winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::CalcAndSetNodeHotZone(Rect layoutOutRect, sptr<WindowNode>& node)
|
||||
{
|
||||
Rect rect = layoutOutRect;
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t hotZone = static_cast<uint32_t>(HOTZONE * virtualPixelRatio);
|
||||
uint32_t divHotZone = static_cast<uint32_t>(DIV_HOTZONE * virtualPixelRatio);
|
||||
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
if (rect.width_ < rect.height_) {
|
||||
rect.posX_ -= divHotZone;
|
||||
rect.width_ += (divHotZone + divHotZone);
|
||||
} else {
|
||||
rect.posY_ -= divHotZone;
|
||||
rect.height_ += (divHotZone + divHotZone);
|
||||
}
|
||||
} else if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
rect.posX_ -= hotZone;
|
||||
rect.posY_ -= hotZone;
|
||||
rect.width_ += (hotZone + hotZone);
|
||||
rect.height_ += (hotZone + hotZone);
|
||||
}
|
||||
node->SetHotZoneRect(rect);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LimitWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect)
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t minVerticalFloatingW = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalFloatingH = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
|
||||
|
||||
WindowType windowType = node->GetWindowType();
|
||||
WindowMode windowMode = node->GetWindowMode();
|
||||
bool isVertical = (displayRect.height_ > displayRect.width_) ? true : false;
|
||||
@@ -238,16 +275,16 @@ void WindowLayoutPolicy::LimitWindowSize(const sptr<WindowNode>& node, const Rec
|
||||
}
|
||||
if ((windowMode == WindowMode::WINDOW_MODE_FLOATING) && !WindowHelper::IsSystemWindow(windowType)) {
|
||||
if (isVertical) {
|
||||
winRect.width_ = std::max(MIN_VERTICAL_FLOATING_WIDTH, winRect.width_);
|
||||
winRect.height_ = std::max(MIN_VERTICAL_FLOATING_HEIGHT, winRect.height_);
|
||||
winRect.width_ = std::max(minVerticalFloatingW, winRect.width_);
|
||||
winRect.height_ = std::max(minVerticalFloatingH, winRect.height_);
|
||||
} else {
|
||||
winRect.width_ = std::max(MIN_VERTICAL_FLOATING_HEIGHT, winRect.width_);
|
||||
winRect.height_ = std::max(MIN_VERTICAL_FLOATING_WIDTH, winRect.height_);
|
||||
winRect.width_ = std::max(minVerticalFloatingH, winRect.width_);
|
||||
winRect.height_ = std::max(minVerticalFloatingW, winRect.height_);
|
||||
}
|
||||
}
|
||||
if (WindowHelper::IsMainFloatingWindow(windowType, windowMode)) {
|
||||
winRect.posY_ = std::max(limitRect_.posY_, winRect.posY_);
|
||||
winRect.posY_ = std::min(limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - WINDOW_TITLE_BAR_HEIGHT),
|
||||
winRect.posY_ = std::min(limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - windowTitleBarH),
|
||||
winRect.posY_);
|
||||
}
|
||||
}
|
||||
@@ -314,5 +351,17 @@ void WindowLayoutPolicy::UpdateLimitRect(const sptr<WindowNode>& node, Rect& lim
|
||||
void WindowLayoutPolicy::Reset()
|
||||
{
|
||||
}
|
||||
|
||||
float WindowLayoutPolicy::GetVirtualPixelRatio() const
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(screenId_);
|
||||
if (display == nullptr) {
|
||||
WLOGFE("GetVirtualPixel fail. Get display fail. displayId:%{public}" PRIu64", use Default vpr:1.0", screenId_);
|
||||
return 1.0; // Use DefaultVPR 1.0
|
||||
}
|
||||
float virtualPixelRatio = display->GetVirtualPixelRatio();
|
||||
WLOGFI("GetVirtualPixel success. displayId:%{public}" PRIu64", vpr:%{public}f", screenId_, virtualPixelRatio);
|
||||
return virtualPixelRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -130,19 +131,23 @@ static bool IsLayoutChanged(const Rect& l, const Rect& r)
|
||||
|
||||
void WindowLayoutPolicyCascade::LimitMoveBounds(Rect& rect)
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t minHorizontalSplitW = static_cast<uint32_t>(MIN_HORIZONTAL_SPLIT_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalSplitH = static_cast<uint32_t>(MIN_VERTICAL_SPLIT_HEIGHT * virtualPixelRatio);
|
||||
|
||||
if (rect.width_ < rect.height_) {
|
||||
if (rect.posX_ < (limitRect_.posX_ + static_cast<int32_t>(MIN_HORIZONTAL_SPLIT_WIDTH))) {
|
||||
rect.posX_ = limitRect_.posX_ + static_cast<int32_t>(MIN_HORIZONTAL_SPLIT_WIDTH);
|
||||
if (rect.posX_ < (limitRect_.posX_ + static_cast<int32_t>(minHorizontalSplitW))) {
|
||||
rect.posX_ = limitRect_.posX_ + static_cast<int32_t>(minHorizontalSplitW);
|
||||
} else if (rect.posX_ >
|
||||
(limitRect_.posX_ + limitRect_.width_ - static_cast<int32_t>(MIN_HORIZONTAL_SPLIT_WIDTH))) {
|
||||
rect.posX_ = limitRect_.posX_ + static_cast<int32_t>(limitRect_.width_ - MIN_HORIZONTAL_SPLIT_WIDTH);
|
||||
(limitRect_.posX_ + limitRect_.width_ - static_cast<int32_t>(minHorizontalSplitW))) {
|
||||
rect.posX_ = limitRect_.posX_ + static_cast<int32_t>(limitRect_.width_ - minHorizontalSplitW);
|
||||
}
|
||||
} else {
|
||||
if (rect.posY_ < (limitRect_.posY_ + static_cast<int32_t>(MIN_VERTICAL_SPLIT_HEIGHT))) {
|
||||
rect.posY_ = limitRect_.posY_ + static_cast<int32_t>(MIN_VERTICAL_SPLIT_HEIGHT);
|
||||
if (rect.posY_ < (limitRect_.posY_ + static_cast<int32_t>(minVerticalSplitH))) {
|
||||
rect.posY_ = limitRect_.posY_ + static_cast<int32_t>(minVerticalSplitH);
|
||||
} else if (rect.posY_ >
|
||||
(limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - MIN_VERTICAL_SPLIT_HEIGHT))) {
|
||||
rect.posY_ = limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - MIN_VERTICAL_SPLIT_HEIGHT);
|
||||
(limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - minVerticalSplitH))) {
|
||||
rect.posY_ = limitRect_.posY_ + static_cast<int32_t>(limitRect_.height_ - minVerticalSplitH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,6 +220,7 @@ void WindowLayoutPolicyCascade::UpdateLayoutRect(sptr<WindowNode>& node)
|
||||
}
|
||||
|
||||
node->SetLayoutRect(winRect);
|
||||
CalcAndSetNodeHotZone(winRect, node);
|
||||
if (IsLayoutChanged(lastRect, winRect)) {
|
||||
node->GetWindowToken()->UpdateWindowRect(winRect, node->GetWindowSizeChangeReason());
|
||||
node->surfaceNode_->SetBounds(winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
@@ -265,12 +271,15 @@ void WindowLayoutPolicyCascade::UpdateSplitLimitRect(const Rect& limitRect, Rect
|
||||
|
||||
void WindowLayoutPolicyCascade::InitSplitRects()
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t dividerWidth = static_cast<uint32_t>(DIVIDER_WIDTH * virtualPixelRatio);
|
||||
|
||||
if (!IsVertical()) {
|
||||
dividerRect_ = { static_cast<uint32_t>((displayRect_.width_ - DIVIDER_WIDTH) * DEFAULT_SPLIT_RATIO), 0,
|
||||
DIVIDER_WIDTH, displayRect_.height_ };
|
||||
dividerRect_ = { static_cast<uint32_t>((displayRect_.width_ - dividerWidth) * DEFAULT_SPLIT_RATIO), 0,
|
||||
dividerWidth, displayRect_.height_ };
|
||||
} else {
|
||||
dividerRect_ = { 0, static_cast<uint32_t>((displayRect_.height_ - DIVIDER_WIDTH) * DEFAULT_SPLIT_RATIO),
|
||||
displayRect_.width_, DIVIDER_WIDTH };
|
||||
dividerRect_ = { 0, static_cast<uint32_t>((displayRect_.height_ - dividerWidth) * DEFAULT_SPLIT_RATIO),
|
||||
displayRect_.width_, dividerWidth };
|
||||
}
|
||||
WLOGFI("init dividerRect :[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
dividerRect_.posX_, dividerRect_.posY_, dividerRect_.width_, dividerRect_.height_);
|
||||
|
||||
@@ -99,6 +99,7 @@ void WindowLayoutPolicyTile::LayoutForegroundNodeQueue()
|
||||
Rect lastRect = node->GetLayoutRect();
|
||||
Rect winRect = node->GetWindowProperty()->GetWindowRect();
|
||||
node->SetLayoutRect(winRect);
|
||||
CalcAndSetNodeHotZone(winRect, node);
|
||||
if (!(lastRect == winRect)) {
|
||||
node->GetWindowToken()->UpdateWindowRect(winRect, node->GetWindowSizeChangeReason());
|
||||
node->surfaceNode_->SetBounds(winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
@@ -204,6 +205,7 @@ void WindowLayoutPolicyTile::UpdateLayoutRect(sptr<WindowNode>& node)
|
||||
}
|
||||
LimitWindowSize(node, displayRect, winRect);
|
||||
node->SetLayoutRect(winRect);
|
||||
CalcAndSetNodeHotZone(winRect, node);
|
||||
if (!(lastRect == winRect)) {
|
||||
node->GetWindowToken()->UpdateWindowRect(winRect, node->GetWindowSizeChangeReason());
|
||||
node->surfaceNode_->SetBounds(winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
|
||||
@@ -42,7 +42,7 @@ void WindowManagerRecorder::AddNodeRecord(WindowManagerRecordInfo record)
|
||||
{
|
||||
std::string historyRecord;
|
||||
int32_t number = records_.size();
|
||||
historyRecord += "\nNo." + std::to_string(number) + "\t[WINDOW-ACTIVITY]\n";
|
||||
historyRecord += "\nNo." + std::to_string(number) + "\t[WINDOW-RECORD]\n";
|
||||
char systime[TIME_LENGTH];
|
||||
if (strftime(systime, sizeof(char) * TIME_LENGTH, "%Y/%m/%d %H:%M:%S %p", &record.recordTime) != 0) {
|
||||
std::string recordTime = "Time: " + std::string(systime) + "\n";
|
||||
|
||||
@@ -38,6 +38,11 @@ void WindowNode::SetLayoutRect(const Rect& rect)
|
||||
layoutRect_ = rect;
|
||||
}
|
||||
|
||||
void WindowNode::SetHotZoneRect(const Rect& rect)
|
||||
{
|
||||
hotZoneRect_ = rect;
|
||||
}
|
||||
|
||||
void WindowNode::SetWindowRect(const Rect& rect)
|
||||
{
|
||||
property_->SetWindowRect(rect);
|
||||
@@ -134,23 +139,7 @@ const Rect& WindowNode::GetLayoutRect() const
|
||||
|
||||
Rect WindowNode::GetHotZoneRect() const
|
||||
{
|
||||
Rect rect = layoutRect_;
|
||||
if (GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
const int32_t divHotZone = 20;
|
||||
if (rect.width_ < rect.height_) {
|
||||
rect.posX_ -= divHotZone;
|
||||
rect.width_ += (divHotZone + divHotZone);
|
||||
} else {
|
||||
rect.posY_ -= divHotZone;
|
||||
rect.height_ += (divHotZone + divHotZone);
|
||||
}
|
||||
} else if (WindowHelper::IsMainFloatingWindow(GetWindowType(), GetWindowMode())) {
|
||||
rect.posX_ -= HOTZONE;
|
||||
rect.posY_ -= HOTZONE;
|
||||
rect.width_ += (HOTZONE + HOTZONE);
|
||||
rect.height_ += (HOTZONE + HOTZONE);
|
||||
}
|
||||
return rect;
|
||||
return hotZoneRect_;
|
||||
}
|
||||
|
||||
WindowType WindowNode::GetWindowType() const
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "window_manager_agent_controller.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -1070,6 +1071,11 @@ sptr<WindowNode> WindowNodeContainer::GetAboveAppWindowNode() const
|
||||
return aboveAppWindowNode_;
|
||||
}
|
||||
|
||||
float WindowNodeContainer::GetVirtualPixelRatio() const
|
||||
{
|
||||
return layoutPolicy_->GetVirtualPixelRatio();
|
||||
}
|
||||
|
||||
bool WindowNodeContainer::ReadIsWindowAnimationEnabledProperty()
|
||||
{
|
||||
if (access(DISABLE_WINDOW_ANIMATION_PATH, F_OK) == 0) {
|
||||
|
||||
@@ -488,5 +488,11 @@ WMError WindowRoot::DumpWindowTree(std::vector<std::string> &windowTreeInfos, Wi
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
float WindowRoot::GetVirtualPixelRatio(DisplayId displayId) const
|
||||
{
|
||||
auto container = const_cast<WindowRoot*>(this)->GetOrCreateWindowNodeContainer(displayId);
|
||||
return container->GetVirtualPixelRatio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user