mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-18 16:24:27 -04:00
!356 恢复“modify screenInfo, screengroupinfo, displayInfo,screen, screengroup, display"修改,修复accessibility编译问题
Merge pull request !356 from xiaojianfeng_huawei/master
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
|
||||
|
||||
+31
-56
@@ -16,89 +16,69 @@
|
||||
#include "display.h"
|
||||
#include "display_info.h"
|
||||
#include "display_manager_adapter.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "Display"};
|
||||
}
|
||||
class Display::Impl : public RefBase {
|
||||
friend class Display;
|
||||
private:
|
||||
void UpdateDisplay(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;
|
||||
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(DisplayInfo& info)
|
||||
Display::Display(const std::string& name, sptr<DisplayInfo> info)
|
||||
: pImpl_(new Impl(name, info))
|
||||
{
|
||||
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())
|
||||
Display::~Display()
|
||||
{
|
||||
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
|
||||
@@ -110,9 +90,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
|
||||
+47
-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,18 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "Screen"};
|
||||
}
|
||||
class Screen::Impl : public RefBase {
|
||||
friend class Screen;
|
||||
public:
|
||||
Impl() = default;
|
||||
Impl(sptr<ScreenInfo> info)
|
||||
{
|
||||
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 +44,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 +66,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 +77,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 >= 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
|
||||
+19
-17
@@ -23,26 +23,28 @@ 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)
|
||||
{
|
||||
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.");
|
||||
WLOGFE("ScreenGroupInfo is nullptr.");
|
||||
return;
|
||||
}
|
||||
pImpl_->children_ = info->children_;
|
||||
pImpl_->position_ = info->position_;
|
||||
pImpl_->combination_ = info->combination_;
|
||||
pImpl_->SetScreenGroupInfo(info);
|
||||
}
|
||||
|
||||
ScreenGroup::~ScreenGroup()
|
||||
@@ -51,16 +53,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,7 +682,7 @@ sptr<ScreenInfo> DisplayManagerProxy::GetScreenInfoById(ScreenId screenId)
|
||||
WLOGFW("GetScreenInfoById SendRequest nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
for (auto& mode : info->modes_) {
|
||||
for (auto& mode : info->GetModes()) {
|
||||
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
|
||||
mode->width_, mode->height_, mode->freshRate_);
|
||||
}
|
||||
|
||||
@@ -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,7 +166,7 @@ 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 (auto& mode : screenInfo->modes_) {
|
||||
for (auto& mode : screenInfo->GetModes()) {
|
||||
WLOGFI("info modes is width: %{public}u, height: %{public}u, freshRate: %{public}u",
|
||||
mode->width_, mode->height_, mode->freshRate_);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,13 @@ typedef enum DisplayType {
|
||||
} DisplayType;
|
||||
|
||||
class Display : public RefBase {
|
||||
friend class DisplayManagerAdapter;
|
||||
public:
|
||||
Display(const std::string& name, DisplayInfo* info);
|
||||
~Display() = default;
|
||||
|
||||
~Display();
|
||||
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;
|
||||
@@ -38,12 +41,10 @@ public:
|
||||
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);
|
||||
|
||||
protected:
|
||||
Display(const std::string& name, sptr<DisplayInfo> info);
|
||||
private:
|
||||
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_;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
@@ -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_DEFINITION_H
|
||||
#define OHOS_ROSEN_CLASS_VAR_DEFINITION_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_DEFINITION_H
|
||||
@@ -18,29 +18,34 @@
|
||||
|
||||
#include <parcel.h>
|
||||
|
||||
#include "class_var_definition.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);
|
||||
protected:
|
||||
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_definition.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
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user