!390 Optimize DM and MDS code

Merge pull request !390 from xiaojianfeng/master
This commit is contained in:
openharmony_ci 2022-03-03 12:23:34 +00:00 committed by Gitee
commit 1c502a8dec
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
25 changed files with 329 additions and 261 deletions

View File

@ -108,7 +108,7 @@ void Display::UpdateDisplayInfo() const
float Display::GetVirtualPixelRatio() const
{
// TODO: Should get from DMS
// Should get from DMS
if ((pImpl_->GetDisplayInfo()->GetWidth() == LARGE_SCREEN_WIDTH)
|| (pImpl_->GetDisplayInfo()->GetHeight() == LARGE_SCREEN_WIDTH)) {
return 2.0f;

View File

@ -33,6 +33,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManager)
class DisplayManager::Impl : public RefBase {
public:
~Impl();
static inline SingletonDelegator<DisplayManager> delegator;
bool CheckRectValid(const Media::Rect& rect, int32_t oriHeight, int32_t oriWidth) const;
bool CheckSizeValid(const Media::Size& size, int32_t oriHeight, int32_t oriWidth) const;
@ -58,11 +59,11 @@ private:
std::map<DisplayId, sptr<Display>> displayMap_;
DisplayStateCallback displayStateCallback_;
std::recursive_mutex mutex_;
std::vector<sptr<IDisplayPowerEventListener>> powerEventListeners_;
std::set<sptr<IDisplayPowerEventListener>> powerEventListeners_;
class DisplayManagerAgent;
sptr<DisplayManagerAgent> powerEventListenerAgent_;
sptr<DisplayManagerAgent> displayStateAgent_;
std::vector<sptr<IDisplayListener>> displayListeners_;
std::set<sptr<IDisplayListener>> displayListeners_;
};
class DisplayManager::Impl::DisplayManagerListener : public DisplayManagerAgentDefault {
@ -187,6 +188,30 @@ void DisplayManager::Impl::ClearDisplayStateCallback()
}
}
DisplayManager::Impl::~Impl()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
bool res = true;
if (displayManagerListener_ != nullptr) {
res = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
displayManagerListener_, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER);
}
displayManagerListener_ = nullptr;
if (!res) {
WLOGFW("UnregisterDisplayManagerAgent DISPLAY_EVENT_LISTENER failed !");
}
res = true;
if (powerEventListenerAgent_ != nullptr) {
res = SingletonContainer::Get<DisplayManagerAdapter>().UnregisterDisplayManagerAgent(
powerEventListenerAgent_, DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER);
}
powerEventListenerAgent_ = nullptr;
if (!res) {
WLOGFW("UnregisterDisplayManagerAgent DISPLAY_POWER_EVENT_LISTENER failed !");
}
ClearDisplayStateCallback();
}
DisplayManager::DisplayManager() : pImpl_(new Impl())
{
}
@ -338,17 +363,18 @@ std::vector<sptr<Display>> DisplayManager::GetAllDisplays()
bool DisplayManager::Impl::RegisterDisplayListener(sptr<IDisplayListener> listener)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
displayListeners_.push_back(listener);
bool ret = true;
if (displayManagerListener_ == nullptr) {
displayManagerListener_ = new DisplayManagerListener(this);
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
displayManagerListener_,
DisplayManagerAgentType::DISPLAY_EVENT_LISTENER);
if (!ret) {
WLOGFW("RegisterDisplayManagerAgent failed ! remove listener!");
displayListeners_.pop_back();
}
}
if (!ret) {
WLOGFW("RegisterDisplayManagerAgent failed !");
displayManagerListener_ = nullptr;
} else {
displayListeners_.insert(listener);
}
return ret;
}
@ -393,17 +419,18 @@ bool DisplayManager::UnregisterDisplayListener(sptr<IDisplayListener> listener)
bool DisplayManager::Impl::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
powerEventListeners_.push_back(listener);
bool ret = true;
if (powerEventListenerAgent_ == nullptr) {
powerEventListenerAgent_ = new DisplayManagerAgent(this);
ret = SingletonContainer::Get<DisplayManagerAdapter>().RegisterDisplayManagerAgent(
powerEventListenerAgent_,
DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER);
if (!ret) {
WLOGFW("RegisterDisplayManagerAgent failed ! remove listener!");
powerEventListeners_.pop_back();
}
}
if (!ret) {
WLOGFW("RegisterDisplayManagerAgent failed !");
powerEventListenerAgent_ = nullptr;
} else {
powerEventListeners_.insert(listener);
}
WLOGFI("RegisterDisplayPowerEventListener end");
return ret;
@ -451,7 +478,7 @@ void DisplayManager::Impl::NotifyDisplayPowerEvent(DisplayPowerEvent event, Even
{
WLOGFI("NotifyDisplayPowerEvent event:%{public}u, status:%{public}u, size:%{public}zu", event, status,
powerEventListeners_.size());
std::vector<sptr<IDisplayPowerEventListener>> powerEventListeners;
std::set<sptr<IDisplayPowerEventListener>> powerEventListeners;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
powerEventListeners = powerEventListeners_;

View File

@ -30,7 +30,7 @@ public:
screenInfo_ = info;
}
~Impl() = default;
DEFINE_VAR_FUNC_GET_SET(sptr<ScreenInfo>, ScreenInfo, screenInfo);
DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<ScreenInfo>, ScreenInfo, screenInfo);
};
Screen::Screen(sptr<ScreenInfo> info)

View File

@ -30,7 +30,7 @@ public:
}
~Impl() = default;
DEFINE_VAR_FUNC_GET_SET(sptr<ScreenGroupInfo>, ScreenGroupInfo, screenGroupInfo);
DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<ScreenGroupInfo>, ScreenGroupInfo, screenGroupInfo);
};
ScreenGroup::ScreenGroup(sptr<ScreenGroupInfo> info)

View File

@ -32,7 +32,7 @@ namespace {
class ScreenManager::Impl : public RefBase {
public:
Impl() = default;
~Impl() = default;
~Impl();
static inline SingletonDelegator<ScreenManager> delegator;
bool RegisterScreenListener(sptr<IScreenListener> listener);
bool UnregisterScreenListener(sptr<IScreenListener> listener);
@ -54,8 +54,8 @@ private:
std::map<ScreenId, sptr<Screen>> screenMap_;
std::map<ScreenId, sptr<ScreenGroup>> screenGroupMap_;
std::recursive_mutex mutex_;
std::vector<sptr<IScreenListener>> screenListeners_;
std::vector<sptr<IScreenGroupListener>> screenGroupListeners_;
std::set<sptr<IScreenListener>> screenListeners_;
std::set<sptr<IScreenGroupListener>> screenGroupListeners_;
};
class ScreenManager::Impl::ScreenManagerListener : public DisplayManagerAgentDefault {
@ -149,6 +149,21 @@ ScreenManager::~ScreenManager()
{
}
ScreenManager::Impl::~Impl()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
bool res = true;
if (screenManagerListener_ != nullptr) {
res = SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
screenManagerListener_,
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
}
screenManagerListener_ = nullptr;
if (!res) {
WLOGFW("UnregisterDisplayManagerAgent SCREEN_EVENT_LISTENER failed !");
}
}
sptr<Screen> ScreenManager::Impl::GetScreen(ScreenId screenId)
{
auto screenInfo = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenInfo(screenId);
@ -215,14 +230,20 @@ std::vector<sptr<Screen>> ScreenManager::GetAllScreens()
bool ScreenManager::Impl::RegisterScreenListener(sptr<IScreenListener> listener)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
screenListeners_.push_back(listener);
bool ret = true;
if (screenManagerListener_ == nullptr) {
screenManagerListener_ = new ScreenManagerListener(this);
SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
ret = SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
screenManagerListener_,
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
}
return true;
if (!ret) {
WLOGFW("RegisterScreenListener failed !");
screenManagerListener_ = nullptr;
} else {
screenListeners_.insert(listener);
}
return ret;
}
bool ScreenManager::RegisterScreenListener(sptr<IScreenListener> listener)
@ -242,14 +263,15 @@ bool ScreenManager::Impl::UnregisterScreenListener(sptr<IScreenListener> listene
WLOGFE("could not find this listener");
return false;
}
bool ret = true;
screenListeners_.erase(iter);
if (screenListeners_.empty() && screenManagerListener_ != nullptr) {
SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
if (screenListeners_.empty() && screenGroupListeners_.empty() && screenManagerListener_ != nullptr) {
ret = SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
screenManagerListener_,
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
screenManagerListener_ = nullptr;
}
return true;
return ret;
}
bool ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
@ -264,14 +286,20 @@ bool ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
bool ScreenManager::Impl::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
screenGroupListeners_.push_back(listener);
bool ret = true;
if (screenManagerListener_ == nullptr) {
screenManagerListener_ = new ScreenManagerListener(this);
SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
ret = SingletonContainer::Get<ScreenManagerAdapter>().RegisterDisplayManagerAgent(
screenManagerListener_,
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
}
return true;
if (!ret) {
WLOGFW("RegisterScreenGroupListener failed !");
screenManagerListener_ = nullptr;
} else {
screenGroupListeners_.insert(listener);
}
return ret;
}
bool ScreenManager::RegisterScreenGroupListener(sptr<IScreenGroupListener> listener)
@ -291,14 +319,15 @@ bool ScreenManager::Impl::UnregisterScreenGroupListener(sptr<IScreenGroupListene
WLOGFE("could not find this listener");
return false;
}
bool ret = true;
screenGroupListeners_.erase(iter);
if (screenGroupListeners_.empty() && screenManagerListener_ != nullptr) {
SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
if (screenGroupListeners_.empty() && screenGroupListeners_.empty() && screenManagerListener_ != nullptr) {
ret = SingletonContainer::Get<ScreenManagerAdapter>().UnregisterDisplayManagerAgent(
screenManagerListener_,
DisplayManagerAgentType::SCREEN_EVENT_LISTENER);
screenManagerListener_ = nullptr;
}
return true;
return ret;
}
bool ScreenManager::UnregisterScreenGroupListener(sptr<IScreenGroupListener> listener)
@ -344,11 +373,6 @@ void ScreenManager::RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens)
SingletonContainer::Get<ScreenManagerAdapter>().RemoveVirtualScreenFromGroup(screens);
}
void ScreenManager::CancelMakeMirrorOrExpand(std::vector<ScreenId> screens)
{
RemoveVirtualScreenFromGroup(screens);
}
ScreenId ScreenManager::CreateVirtualScreen(VirtualScreenOption option)
{
return SingletonContainer::Get<ScreenManagerAdapter>().CreateVirtualScreen(option);

View File

@ -30,6 +30,7 @@ public:
constexpr static uint32_t DEFAULT_FRESH_RATE = 60;
AbstractDisplay(const DisplayInfo* info);
AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t refreshRate);
WM_DISALLOW_COPY_AND_MOVE(AbstractDisplay);
~AbstractDisplay() = default;
static inline bool IsVertical(Rotation rotation)
{

View File

@ -33,6 +33,7 @@ class AbstractDisplayController : public RefBase {
public:
AbstractDisplayController(std::recursive_mutex& mutex);
~AbstractDisplayController();
WM_DISALLOW_COPY_AND_MOVE(AbstractDisplayController);
void Init(sptr<AbstractScreenController> abstractScreenController);
ScreenId GetDefaultScreenId();

View File

@ -24,6 +24,7 @@
#include <ui/rs_display_node.h>
#include <ui/rs_surface_node.h>
#include "noncopyable.h"
#include "screen.h"
#include "screen_group.h"
#include "screen_group_info.h"
@ -34,8 +35,9 @@ class AbstractScreenGroup;
class AbstractScreenController;
class AbstractScreen : public RefBase {
public:
AbstractScreen(const std::string& name, ScreenId dmsId, ScreenId rsId);
AbstractScreen(sptr<AbstractScreenController>, const std::string& name, ScreenId dmsId, ScreenId rsId);
AbstractScreen() = delete;
WM_DISALLOW_COPY_AND_MOVE(AbstractScreen);
~AbstractScreen();
sptr<SupportedScreenModes> GetActiveScreenMode() const;
std::vector<sptr<SupportedScreenModes>> GetAbstractScreenModes() const;
@ -56,8 +58,8 @@ public:
DMError SetScreenColorTransform();
const std::string name_;
ScreenId dmsId_;
ScreenId rsId_;
const ScreenId dmsId_;
const ScreenId rsId_;
bool canHasChild_ { false };
std::shared_ptr<RSDisplayNode> rsDisplayNode_;
RSDisplayNodeConfig rSDisplayNodeConfig_;
@ -65,18 +67,19 @@ public:
ScreenType type_ { ScreenType::REAL };
int32_t activeIdx_ { 0 };
std::vector<sptr<SupportedScreenModes>> modes_ = {};
float virtualPixelRatio = { 1.0 };
float virtualPixelRatio_ = { 1.0 };
Orientation orientation_ { Orientation::UNSPECIFIED };
Rotation rotation_ { Rotation::ROTATION_0 };
protected:
void FillScreenInfo(sptr<ScreenInfo>) const;
sptr<AbstractScreenController>& screenController_;
const sptr<AbstractScreenController> screenController_;
};
class AbstractScreenGroup : public AbstractScreen {
public:
AbstractScreenGroup(ScreenId dmsId, ScreenId rsId, ScreenCombination combination);
AbstractScreenGroup(sptr<AbstractScreenController>, ScreenId dmsId, ScreenId rsId, ScreenCombination combination);
AbstractScreenGroup() = delete;
WM_DISALLOW_COPY_AND_MOVE(AbstractScreenGroup);
~AbstractScreenGroup();
bool AddChild(sptr<AbstractScreen>& dmsScreen, Point& startPoint);
@ -87,12 +90,13 @@ public:
std::vector<Point> GetChildrenPosition() const;
size_t GetChildCount() const;
sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
bool SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config);
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
ScreenId mirrorScreenId_ { SCREEN_ID_INVALID };
private:
bool SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config);
std::map<ScreenId, std::pair<sptr<AbstractScreen>, Point>> abstractScreenMap_;
};
} // namespace OHOS::Rosen

View File

@ -40,6 +40,7 @@ public:
AbstractScreenController(std::recursive_mutex& mutex);
~AbstractScreenController();
WM_DISALLOW_COPY_AND_MOVE(AbstractScreenController);
void Init();
void ScreenConnectionInDisplayInit(sptr<AbstractScreenCallback> abstractScreenCallback);
@ -49,7 +50,6 @@ public:
std::vector<ScreenId> GetAllExpandOrMirrorScreenIds(std::vector<ScreenId>) const;
sptr<AbstractScreenGroup> GetAbstractScreenGroup(ScreenId dmsScreenId);
ScreenId GetDefaultAbstractScreenId();
ScreenId GetDefaultScreenId() const; // save default screenID got by GetDefaultAbstractScreenId as cache
ScreenId ConvertToRsScreenId(ScreenId dmsScreenId);
ScreenId ConvertToDmsScreenId(ScreenId rsScreenId);
void RegisterAbstractScreenCallback(sptr<AbstractScreenCallback> cb);
@ -78,6 +78,8 @@ public:
private:
void OnRsScreenConnectionChange(ScreenId rsScreenId, ScreenEvent screenEvent);
void ProcessScreenConnected(ScreenId rsScreenId);
sptr<AbstractScreen> InitAndGetScreen(ScreenId rsScreenId);
void ProcessScreenDisconnected(ScreenId rsScreenId);
bool FillAbstractScreen(sptr<AbstractScreen>& absScreen, ScreenId rsScreenId);
sptr<AbstractScreenGroup> AddToGroupLocked(sptr<AbstractScreen> newScreen);
@ -92,16 +94,32 @@ private:
void AddScreenToGroup(sptr<AbstractScreenGroup>, const std::vector<ScreenId>&,
const std::vector<Point>&, std::map<ScreenId, bool>&);
class ScreenIdManager {
public:
ScreenIdManager() = default;
~ScreenIdManager() = default;
WM_DISALLOW_COPY_AND_MOVE(ScreenIdManager);
ScreenId CreateAndGetNewScreenId(ScreenId rsScreenId);
bool DeleteScreenId(ScreenId dmsScreenId);
bool HasDmsScreenId(ScreenId dmsScreenId) const;
bool HasRsScreenId(ScreenId dmsScreenId) const;
bool ConvertToRsScreenId(ScreenId, ScreenId&) const;
ScreenId ConvertToRsScreenId(ScreenId) const;
bool ConvertToDmsScreenId(ScreenId, ScreenId&) const;
ScreenId ConvertToDmsScreenId(ScreenId) const;
void DumpScreenIdInfo() const;
private:
std::atomic<ScreenId> dmsScreenCount_ {0};
std::map<ScreenId, ScreenId> rs2DmsScreenIdMap_;
std::map<ScreenId, ScreenId> dms2RsScreenIdMap_;
};
std::recursive_mutex& mutex_;
OHOS::Rosen::RSInterfaces& rsInterface_;
std::atomic<ScreenId> dmsScreenCount_;
// No AbstractScreenGroup
std::map<ScreenId, ScreenId> rs2DmsScreenIdMap_;
std::map<ScreenId, ScreenId> dms2RsScreenIdMap_;
ScreenIdManager screenIdManager_;
std::map<ScreenId, sptr<AbstractScreen>> dmsScreenMap_;
std::map<ScreenId, sptr<AbstractScreenGroup>> dmsScreenGroupMap_;
sptr<AbstractScreenCallback> abstractScreenCallback_;
ScreenId defaultScreenId = INVALID_SCREEN_ID;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H

View File

@ -60,7 +60,7 @@ public:
TRANS_ID_SCREENGROUP_BASE = 1100,
TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE,
TRANS_ID_SCREEN_MAKE_EXPAND,
TRANS_ID_SCREEN_MAKE_MIRROR_OR_EXPAND_CANCELED,
TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP,
TRANS_ID_SCREEN_GAMUT_BASE = 1200,
TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS = TRANS_ID_SCREEN_GAMUT_BASE,
TRANS_ID_SCREEN_GET_COLOR_GAMUT,

View File

@ -15,6 +15,7 @@
#include "abstract_screen.h"
#include <cmath>
#include "abstract_screen_controller.h"
#include "display_manager_service.h"
#include "dm_common.h"
@ -25,9 +26,8 @@ namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "AbstractScreenGroup"};
}
AbstractScreen::AbstractScreen(const std::string& name, ScreenId dmsId, ScreenId rsId)
: name_(name), dmsId_(dmsId), rsId_(rsId),
screenController_(DisplayManagerService::GetInstance().abstractScreenController_)
AbstractScreen::AbstractScreen(sptr<AbstractScreenController> screenController, const std::string& name, ScreenId dmsId,
ScreenId rsId) : name_(name), dmsId_(dmsId), rsId_(rsId), screenController_(screenController)
{
}
@ -51,7 +51,7 @@ std::vector<sptr<SupportedScreenModes>> AbstractScreen::GetAbstractScreenModes()
sptr<AbstractScreenGroup> AbstractScreen::GetGroup() const
{
return DisplayManagerService::GetInstance().GetAbstractScreenController()->GetAbstractScreenGroup(groupDmsId_);
return screenController_->GetAbstractScreenGroup(groupDmsId_);
}
sptr<ScreenInfo> AbstractScreen::ConvertToScreenInfo() const
@ -188,9 +188,14 @@ void AbstractScreen::FillScreenInfo(sptr<ScreenInfo> info) const
height = abstractScreenModes->height_;
width = abstractScreenModes->width_;
}
float virtualPixelRatio = virtualPixelRatio_;
// "< 1e-6" means virtualPixelRatio is 0.
if (fabsf(virtualPixelRatio) < 1e-6) {
virtualPixelRatio = 1.0f;
}
info->virtualPixelRatio_ = virtualPixelRatio;
info->virtualHeight_ = virtualPixelRatio * height;
info->virtualWidth_ = virtualPixelRatio * width;
info->virtualHeight_ = height / virtualPixelRatio;
info->virtualWidth_ = width / virtualPixelRatio;
info->parent_ = groupDmsId_;
info->canHasChild_ = canHasChild_;
info->rotation_ = rotation_;
@ -238,8 +243,8 @@ Rotation AbstractScreen::CalcRotation(Orientation orientation) const
}
}
AbstractScreenGroup::AbstractScreenGroup(ScreenId dmsId, ScreenId rsId, ScreenCombination combination)
: AbstractScreen("", dmsId, rsId), combination_(combination)
AbstractScreenGroup::AbstractScreenGroup(sptr<AbstractScreenController> screenController, ScreenId dmsId, ScreenId rsId,
ScreenCombination combination) : AbstractScreen(screenController, "", dmsId, rsId), combination_(combination)
{
type_ = ScreenType::UNDEFINE;
canHasChild_ = true;
@ -279,11 +284,9 @@ bool AbstractScreenGroup::SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen
}
if (mirrorScreenId_ == INVALID_SCREEN_ID || !HasChild(mirrorScreenId_)) {
WLOGI("AddChild, mirrorScreenId_ is invalid, use default screen");
mirrorScreenId_ =
DisplayManagerService::GetInstance().GetAbstractScreenController()->GetDefaultAbstractScreenId();
mirrorScreenId_ = screenController_->GetDefaultAbstractScreenId();
}
std::shared_ptr<RSDisplayNode> displayNode = SingletonContainer::Get<DisplayManagerService>().
GetAbstractScreenController()->GetRSDisplayNodeByScreenId(mirrorScreenId_);
std::shared_ptr<RSDisplayNode> displayNode = screenController_->GetRSDisplayNodeByScreenId(mirrorScreenId_);
if (displayNode == nullptr) {
WLOGFE("AddChild fail, displayNode is nullptr, cannot get DisplayNode");
return false;

View File

@ -43,7 +43,6 @@ AbstractScreenController::~AbstractScreenController()
void AbstractScreenController::Init()
{
WLOGFD("screen controller init");
dmsScreenCount_ = 0;
rsInterface_.SetScreenChangeCallback(
std::bind(&AbstractScreenController::OnRsScreenConnectionChange,
this, std::placeholders::_1, std::placeholders::_2));
@ -62,11 +61,11 @@ std::vector<ScreenId> AbstractScreenController::GetAllScreenIds()
std::vector<ScreenId> AbstractScreenController::GetShotScreenIds(std::vector<ScreenId> mirrorScreenIds) const
{
WLOGI("GetShotScreenIds");
std::lock_guard<std::recursive_mutex> lock(mutex_);
std::vector<ScreenId> screenIds;
for (ScreenId screenId : mirrorScreenIds) {
auto dmsScreenIdIter = dms2RsScreenIdMap_.find(screenId);
auto dmsScreenIter = dmsScreenMap_.find(screenId);
if (dmsScreenIdIter != dms2RsScreenIdMap_.end() && dmsScreenIter == dmsScreenMap_.end()) {
if (screenIdManager_.HasDmsScreenId(screenId) && dmsScreenIter == dmsScreenMap_.end()) {
screenIds.emplace_back(screenId);
WLOGI("GetShotScreenIds: screenId: %{public}" PRIu64"", screenId);
}
@ -77,6 +76,7 @@ std::vector<ScreenId> AbstractScreenController::GetShotScreenIds(std::vector<Scr
std::vector<ScreenId> AbstractScreenController::GetAllExpandOrMirrorScreenIds(
std::vector<ScreenId> mirrorScreenIds) const
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
std::vector<ScreenId> screenIds;
for (ScreenId screenId : mirrorScreenIds) {
auto iter = dmsScreenMap_.find(screenId);
@ -125,15 +125,14 @@ void AbstractScreenController::UpdateRSTree(ScreenId dmsScreenId, std::shared_pt
sptr<AbstractScreen> AbstractScreenController::GetAbstractScreen(ScreenId dmsScreenId) const
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
WLOGI("GetAbstractScreen: screenId: %{public}" PRIu64"", dmsScreenId);
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = dmsScreenMap_.find(dmsScreenId);
if (iter == dmsScreenMap_.end()) {
WLOGE("did not find screen:%{public}" PRIu64"", dmsScreenId);
return nullptr;
}
sptr<AbstractScreen> screen = iter->second;
return screen;
return iter->second;
}
sptr<AbstractScreenGroup> AbstractScreenController::GetAbstractScreenGroup(ScreenId dmsScreenId)
@ -144,62 +143,40 @@ sptr<AbstractScreenGroup> AbstractScreenController::GetAbstractScreenGroup(Scree
WLOGE("didnot find screen:%{public}" PRIu64"", dmsScreenId);
return nullptr;
}
sptr<AbstractScreenGroup> screen = iter->second;
return screen;
return iter->second;
}
ScreenId AbstractScreenController::GetDefaultAbstractScreenId()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
ScreenId rsDefaultId = rsInterface_.GetDefaultScreenId();
if (rsDefaultId == INVALID_SCREEN_ID) {
if (rsDefaultId == SCREEN_ID_INVALID) {
WLOGFW("GetDefaultAbstractScreenId, rsDefaultId is invalid.");
return INVALID_SCREEN_ID;
return SCREEN_ID_INVALID;
}
auto iter = rs2DmsScreenIdMap_.find(rsDefaultId);
if (iter != rs2DmsScreenIdMap_.end()) {
WLOGI("GetDefaultAbstractScreenId, screen:%{public}" PRIu64"", iter->second);
defaultScreenId = iter->second;
return iter->second;
ScreenId defaultDmsScreenId;
if (screenIdManager_.ConvertToDmsScreenId(rsDefaultId, defaultDmsScreenId)) {
WLOGI("GetDefaultAbstractScreenId, screen:%{public}" PRIu64"", defaultDmsScreenId);
return defaultDmsScreenId;
}
WLOGFI("GetDefaultAbstractScreenId, default screen is null, try to get.");
ScreenId dmsScreenId = dmsScreenCount_;
sptr<AbstractScreen> absScreen = new AbstractScreen(DEFAULT_SCREEN_NAME, dmsScreenId, rsDefaultId);
if (!FillAbstractScreen(absScreen, rsDefaultId)) {
WLOGFW("GetDefaultAbstractScreenId, FillAbstractScreen failed.");
return INVALID_SCREEN_ID;
auto defaultScreen = InitAndGetScreen(rsDefaultId);
if (defaultScreen == nullptr) {
return SCREEN_ID_INVALID;
}
rs2DmsScreenIdMap_.insert(std::make_pair(rsDefaultId, dmsScreenId));
dms2RsScreenIdMap_.insert(std::make_pair(dmsScreenId, rsDefaultId));
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
dmsScreenCount_++;
defaultScreenId = dmsScreenId;
return dmsScreenId;
}
ScreenId AbstractScreenController::GetDefaultScreenId() const
{
return defaultScreenId;
return defaultScreen->dmsId_;
}
ScreenId AbstractScreenController::ConvertToRsScreenId(ScreenId dmsScreenId)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = dms2RsScreenIdMap_.find(dmsScreenId);
if (iter == dms2RsScreenIdMap_.end()) {
return SCREEN_ID_INVALID;
}
return iter->second;
return screenIdManager_.ConvertToRsScreenId(dmsScreenId);
}
ScreenId AbstractScreenController::ConvertToDmsScreenId(ScreenId rsScreenId)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = rs2DmsScreenIdMap_.find(rsScreenId);
if (iter == rs2DmsScreenIdMap_.end()) {
return SCREEN_ID_INVALID;
}
return iter->second;
return screenIdManager_.ConvertToDmsScreenId(rsScreenId);
}
void AbstractScreenController::RegisterAbstractScreenCallback(sptr<AbstractScreenCallback> cb)
@ -211,29 +188,9 @@ void AbstractScreenController::RegisterAbstractScreenCallback(sptr<AbstractScree
void AbstractScreenController::OnRsScreenConnectionChange(ScreenId rsScreenId, ScreenEvent screenEvent)
{
WLOGFI("rs screen event. id:%{public}" PRIu64", event:%{public}u", rsScreenId, static_cast<uint32_t>(screenEvent));
ScreenId dmsScreenId = SCREEN_ID_INVALID;
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (screenEvent == ScreenEvent::CONNECTED) {
auto iter = rs2DmsScreenIdMap_.find(rsScreenId);
if (iter == rs2DmsScreenIdMap_.end()) {
WLOGFD("connect new screen");
dmsScreenId = dmsScreenCount_;
sptr<AbstractScreen> absScreen = new AbstractScreen(DEFAULT_SCREEN_NAME, dmsScreenId, rsScreenId);
if (!FillAbstractScreen(absScreen, rsScreenId)) {
return;
}
rs2DmsScreenIdMap_.insert(std::make_pair(rsScreenId, dmsScreenId));
dms2RsScreenIdMap_.insert(std::make_pair(dmsScreenId, rsScreenId));
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
DisplayManagerAgentController::GetInstance().OnScreenConnect(absScreen->ConvertToScreenInfo());
dmsScreenCount_++;
sptr<AbstractScreenGroup> screenGroup = AddToGroupLocked(absScreen);
if (screenGroup != nullptr && abstractScreenCallback_ != nullptr) {
abstractScreenCallback_->onConnect_(absScreen);
}
} else {
WLOGE("reconnect screen, screenId=%{public}" PRIu64"", rsScreenId);
}
ProcessScreenConnected(rsScreenId);
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
ProcessScreenDisconnected(rsScreenId);
} else {
@ -260,15 +217,51 @@ void AbstractScreenController::ScreenConnectionInDisplayInit(sptr<AbstractScreen
}
}
void AbstractScreenController::ProcessScreenConnected(ScreenId rsScreenId)
{
if (!screenIdManager_.HasRsScreenId(rsScreenId)) {
WLOGFD("connect new screen");
auto absScreen = InitAndGetScreen(rsScreenId);
if (absScreen == nullptr) {
return;
}
sptr<AbstractScreenGroup> screenGroup = AddToGroupLocked(absScreen);
if (screenGroup != nullptr && abstractScreenCallback_ != nullptr) {
abstractScreenCallback_->onConnect_(absScreen);
}
} else {
WLOGE("reconnect screen, screenId=%{public}" PRIu64"", rsScreenId);
}
}
sptr<AbstractScreen> AbstractScreenController::InitAndGetScreen(ScreenId rsScreenId)
{
ScreenId dmsScreenId = screenIdManager_.CreateAndGetNewScreenId(rsScreenId);
sptr<AbstractScreen> absScreen =
new(std::nothrow) AbstractScreen(this, DEFAULT_SCREEN_NAME, dmsScreenId, rsScreenId);
if (absScreen == nullptr) {
WLOGFE("new AbstractScreen failed.");
return nullptr;
}
if (!FillAbstractScreen(absScreen, rsScreenId)) {
screenIdManager_.DeleteScreenId(dmsScreenId);
WLOGFE("InitAndGetScreen failed.");
return nullptr;
}
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
// Switch threads to notify
DisplayManagerAgentController::GetInstance().OnScreenConnect(absScreen->ConvertToScreenInfo());
return absScreen;
}
void AbstractScreenController::ProcessScreenDisconnected(ScreenId rsScreenId)
{
WLOGI("disconnect screen, screenId=%{public}" PRIu64"", rsScreenId);
auto iter = rs2DmsScreenIdMap_.find(rsScreenId);
if (iter == rs2DmsScreenIdMap_.end()) {
WLOGE("disconnect screen, screenId=%{public}" PRIu64" is not in rs2DmsScreenIdMap_", rsScreenId);
WLOGFI("disconnect screen, screenId=%{public}" PRIu64"", rsScreenId);
ScreenId dmsScreenId;
if (!screenIdManager_.ConvertToDmsScreenId(rsScreenId, dmsScreenId)) {
WLOGFE("disconnect screen, screenId=%{public}" PRIu64" is not in rs2DmsScreenIdMap_", rsScreenId);
return;
}
ScreenId dmsScreenId = iter->second;
auto dmsScreenMapIter = dmsScreenMap_.find(dmsScreenId);
if (dmsScreenMapIter != dmsScreenMap_.end()) {
if (abstractScreenCallback_ != nullptr && CheckScreenInScreenGroup(dmsScreenMapIter->second)) {
@ -284,8 +277,7 @@ void AbstractScreenController::ProcessScreenDisconnected(ScreenId rsScreenId)
}
dmsScreenMap_.erase(dmsScreenMapIter);
}
rs2DmsScreenIdMap_.erase(iter);
dms2RsScreenIdMap_.erase(dmsScreenId);
screenIdManager_.DeleteScreenId(dmsScreenId);
DisplayManagerAgentController::GetInstance().OnScreenDisconnect(dmsScreenId);
}
@ -384,15 +376,19 @@ bool AbstractScreenController::CheckScreenInScreenGroup(sptr<AbstractScreen> scr
sptr<AbstractScreenGroup> AbstractScreenController::AddAsFirstScreenLocked(sptr<AbstractScreen> newScreen)
{
ScreenId dmsGroupScreenId = dmsScreenCount_.load();
sptr<AbstractScreenGroup> screenGroup =
new AbstractScreenGroup(dmsGroupScreenId, SCREEN_ID_INVALID, ScreenCombination::SCREEN_MIRROR);
ScreenId dmsGroupScreenId = screenIdManager_.CreateAndGetNewScreenId(SCREEN_ID_INVALID);
sptr<AbstractScreenGroup> screenGroup = new(std::nothrow) AbstractScreenGroup(this, dmsGroupScreenId,
SCREEN_ID_INVALID, ScreenCombination::SCREEN_MIRROR);
if (screenGroup == nullptr) {
WLOGE("new AbstractScreenGroup failed");
return nullptr;
}
Point point;
if (!screenGroup->AddChild(newScreen, point)) {
WLOGE("fail to add screen to group. screen=%{public}" PRIu64"", newScreen->dmsId_);
screenIdManager_.DeleteScreenId(dmsGroupScreenId);
return nullptr;
}
dmsScreenCount_++;
auto iter = dmsScreenGroupMap_.find(dmsGroupScreenId);
if (iter != dmsScreenGroupMap_.end()) {
WLOGE("group screen existed. id=%{public}" PRIu64"", dmsGroupScreenId);
@ -431,20 +427,23 @@ sptr<AbstractScreenGroup> AbstractScreenController::AddAsSuccedentScreenLocked(s
ScreenId AbstractScreenController::CreateVirtualScreen(VirtualScreenOption option)
{
ScreenId rsId = rsInterface_.CreateVirtualScreen(option.name_, option.width_,
option.height_, option.surface_, INVALID_SCREEN_ID, option.flags_);
WLOGFI("CreateVirtualScreen id: %{public}" PRIu64"", rsId);
option.height_, option.surface_, SCREEN_ID_INVALID, option.flags_);
WLOGFI("id: %{public}" PRIu64"", rsId);
if (rsId == SCREEN_ID_INVALID) {
return SCREEN_ID_INVALID;
}
std::lock_guard<std::recursive_mutex> lock(mutex_);
ScreenId dmsScreenId = SCREEN_ID_INVALID;
auto iter = rs2DmsScreenIdMap_.find(rsId);
if (iter == rs2DmsScreenIdMap_.end()) {
if (!screenIdManager_.ConvertToDmsScreenId(rsId, dmsScreenId)) {
dmsScreenId = screenIdManager_.CreateAndGetNewScreenId(rsId);
if (!option.isForShot_) {
WLOGI("CreateVirtualScreen is not shot");
dmsScreenId = dmsScreenCount_;
sptr<AbstractScreen> absScreen = new AbstractScreen(option.name_, dmsScreenId, rsId);
sptr<SupportedScreenModes> info = new SupportedScreenModes();
sptr<AbstractScreen> absScreen = new(std::nothrow) AbstractScreen(this, option.name_, dmsScreenId, rsId);
sptr<SupportedScreenModes> info = new(std::nothrow) SupportedScreenModes();
if (absScreen == nullptr || info == nullptr) {
WLOGFI("new AbstractScreen or SupportedScreenModes failed");
return SCREEN_ID_INVALID;
}
info->width_ = option.width_;
info->height_ = option.height_;
auto defaultScreen = GetAbstractScreen(GetDefaultAbstractScreenId());
@ -454,19 +453,13 @@ ScreenId AbstractScreenController::CreateVirtualScreen(VirtualScreenOption optio
absScreen->modes_.push_back(info);
absScreen->activeIdx_ = 0;
absScreen->type_ = ScreenType::VIRTUAL;
dmsScreenCount_++;
rs2DmsScreenIdMap_.insert(std::make_pair(rsId, dmsScreenId));
dms2RsScreenIdMap_.insert(std::make_pair(dmsScreenId, rsId));
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
DisplayManagerAgentController::GetInstance().OnScreenConnect(absScreen->ConvertToScreenInfo());
} else {
WLOGI("CreateVirtualScreen is shot");
dmsScreenId = dmsScreenCount_++;
rs2DmsScreenIdMap_.insert(std::make_pair(rsId, dmsScreenId));
dms2RsScreenIdMap_.insert(std::make_pair(dmsScreenId, rsId));
}
} else {
return iter->second;
WLOGFI("id: %{public}" PRIu64" appears in screenIdManager_. ", rsId);
}
return dmsScreenId;
}
@ -476,15 +469,11 @@ DMError AbstractScreenController::DestroyVirtualScreen(ScreenId screenId)
WLOGFI("AbstractScreenController::DestroyVirtualScreen");
std::lock_guard<std::recursive_mutex> lock(mutex_);
ScreenId rsScreenId = SCREEN_ID_INVALID;
auto iter = dms2RsScreenIdMap_.find(screenId);
if (iter != dms2RsScreenIdMap_.end()) {
rsScreenId = iter->second;
}
screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId);
if (rsScreenId != SCREEN_ID_INVALID && GetAbstractScreen(screenId) != nullptr) {
OnRsScreenConnectionChange(rsScreenId, ScreenEvent::DISCONNECTED);
}
dms2RsScreenIdMap_.erase(screenId);
rs2DmsScreenIdMap_.erase(rsScreenId);
screenIdManager_.DeleteScreenId(screenId);
if (rsScreenId != SCREEN_ID_INVALID) {
rsInterface_.RemoveVirtualScreen(rsScreenId);
}
@ -497,9 +486,9 @@ DMError AbstractScreenController::SetVirtualScreenSurface(ScreenId screenId, spt
{
WLOGFI("AbstractScreenController::SetVirtualScreenSurface");
int32_t res = -1;
auto iter = dms2RsScreenIdMap_.find(screenId);
if (iter != dms2RsScreenIdMap_.end()) {
res = rsInterface_.SetVirtualScreenSurface(iter->second, surface);
ScreenId rsScreenId;
if (screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) {
res = rsInterface_.SetVirtualScreenSurface(rsScreenId, surface);
}
if (res != 0) {
WLOGE("SetVirtualScreenSurface failed in RenderService");
@ -622,12 +611,12 @@ bool AbstractScreenController::SetScreenActiveMode(ScreenId screenId, uint32_t m
uint32_t usedModeId = 0;
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = dms2RsScreenIdMap_.find(screenId);
if (iter == dms2RsScreenIdMap_.end()) {
ScreenId rsScreenId = SCREEN_ID_INVALID;
if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) {
WLOGFE("SetScreenActiveMode: No corresponding rsId");
return false;
}
rsInterface_.SetScreenActiveMode(iter->second, modeId);
rsInterface_.SetScreenActiveMode(rsScreenId, modeId);
auto screen = GetAbstractScreen(screenId);
if (screen == nullptr) {
WLOGFE("SetScreenActiveMode: Get AbstractScreen failed");
@ -831,9 +820,7 @@ void AbstractScreenController::DumpScreenInfo() const
WLOGI("-------- dump screen info begin---------");
WLOGI("-------- the Screen Id Map Info---------");
WLOGI(" DmsScreenId RsScreenId");
for (auto iter = dms2RsScreenIdMap_.begin(); iter != dms2RsScreenIdMap_.end(); iter++) {
WLOGI("%{public}20" PRIu64" %{public}20" PRIu64"", iter->first, iter->second);
}
screenIdManager_.DumpScreenIdInfo();
WLOGI("-------- the Screen Info ---------");
WLOGI(" dmsId rsId groupDmsId "
"isGroup type NodeId isMirrored mirrorNodeId");
@ -849,7 +836,7 @@ void AbstractScreenController::DumpScreenInfo() const
}
std::string isMirrored = screen->rSDisplayNodeConfig_.isMirrored ? "true" : "false";
std::string isGroup = (dmsScreenGroupMap_.find(screen->dmsId_) != dmsScreenGroupMap_.end()) ? "true" : "false";
NodeId nodeId = (screen->rsDisplayNode_ == nullptr) ? INVALID_SCREEN_ID : screen->rsDisplayNode_->GetId();
NodeId nodeId = (screen->rsDisplayNode_ == nullptr) ? SCREEN_ID_INVALID : screen->rsDisplayNode_->GetId();
WLOGI("%{public}20" PRIu64" %{public}20" PRIu64" %{public}20" PRIu64" %{public}10s %{public}10s %{public}20"
PRIu64" %{public}10s %{public}20" PRIu64" ", screen->dmsId_, screen->rsId_, screen->groupDmsId_,
isGroup.c_str(), screenType.c_str(), nodeId, isMirrored.c_str(), screen->rSDisplayNodeConfig_.mirrorNodeId);
@ -892,4 +879,84 @@ void AbstractScreenController::DumpScreenGroupInfo() const
}
}
}
void AbstractScreenController::ScreenIdManager::DumpScreenIdInfo() const
{
for (auto& pair : dms2RsScreenIdMap_) {
WLOGI("%{public}20" PRIu64" %{public}20" PRIu64"", pair.first, pair.second);
}
};
ScreenId AbstractScreenController::ScreenIdManager::CreateAndGetNewScreenId(ScreenId rsScreenId)
{
ScreenId dmsScreenId = dmsScreenCount_++;
if (dms2RsScreenIdMap_.find(dmsScreenId) != dms2RsScreenIdMap_.end()) {
WLOGFW("dmsScreenId: %{public}" PRIu64" exit in dms2RsScreenIdMap_, warning.", dmsScreenId);
}
dms2RsScreenIdMap_[dmsScreenId] = rsScreenId;
if (rsScreenId == SCREEN_ID_INVALID) {
return dmsScreenId;
}
if (rs2DmsScreenIdMap_.find(rsScreenId) != rs2DmsScreenIdMap_.end()) {
WLOGFW("rsScreenId: %{public}" PRIu64" exit in rs2DmsScreenIdMap_, warning.", rsScreenId);
}
rs2DmsScreenIdMap_[rsScreenId] = dmsScreenId;
return dmsScreenId;
}
bool AbstractScreenController::ScreenIdManager::DeleteScreenId(ScreenId dmsScreenId)
{
auto iter = dms2RsScreenIdMap_.find(dmsScreenId);
if (iter == dms2RsScreenIdMap_.end()) {
return false;
}
ScreenId rsScreenId = iter->second;
dms2RsScreenIdMap_.erase(dmsScreenId);
rs2DmsScreenIdMap_.erase(rsScreenId);
return true;
}
bool AbstractScreenController::ScreenIdManager::HasDmsScreenId(ScreenId dmsScreenId) const
{
return dms2RsScreenIdMap_.find(dmsScreenId) != dms2RsScreenIdMap_.end();
}
bool AbstractScreenController::ScreenIdManager::HasRsScreenId(ScreenId dmsScreenId) const
{
return rs2DmsScreenIdMap_.find(dmsScreenId) != rs2DmsScreenIdMap_.end();
}
bool AbstractScreenController::ScreenIdManager::ConvertToRsScreenId(ScreenId dmsScreenId, ScreenId& rsScreenId) const
{
auto iter = dms2RsScreenIdMap_.find(dmsScreenId);
if (iter == dms2RsScreenIdMap_.end()) {
return false;
}
rsScreenId = iter->second;
return true;
}
ScreenId AbstractScreenController::ScreenIdManager::ConvertToRsScreenId(ScreenId dmsScreenId) const
{
ScreenId rsScreenId = SCREEN_ID_INVALID;
ConvertToRsScreenId(dmsScreenId, rsScreenId);
return rsScreenId;
}
bool AbstractScreenController::ScreenIdManager::ConvertToDmsScreenId(ScreenId rsScreenId, ScreenId& dmsScreenId) const
{
auto iter = rs2DmsScreenIdMap_.find(rsScreenId);
if (iter == rs2DmsScreenIdMap_.end()) {
return false;
}
dmsScreenId = iter->second;
return true;
}
ScreenId AbstractScreenController::ScreenIdManager::ConvertToDmsScreenId(ScreenId rsScreenId) const
{
ScreenId dmsScreenId = SCREEN_ID_INVALID;
ConvertToDmsScreenId(dmsScreenId, dmsScreenId);
return dmsScreenId;
}
} // namespace OHOS::Rosen

View File

@ -872,7 +872,7 @@ void DisplayManagerProxy::RemoveVirtualScreenFromGroup(std::vector<ScreenId> scr
WLOGFE("cancel make mirror or expand fail: write screens failed.");
return;
}
if (remote->SendRequest(TRANS_ID_SCREEN_MAKE_MIRROR_OR_EXPAND_CANCELED, data, reply, option) != ERR_NONE) {
if (remote->SendRequest(TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP, data, reply, option) != ERR_NONE) {
WLOGFW("cancel make mirror or expand fail: SendRequest failed");
}
}

View File

@ -84,7 +84,7 @@ void DisplayManagerService::NotifyDisplayStateChange(DisplayId id, DisplayStateC
DisplayId DisplayManagerService::GetDefaultDisplayId()
{
ScreenId dmsScreenId = abstractScreenController_->GetDefaultScreenId();
ScreenId dmsScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
WLOGFI("GetDefaultDisplayId %{public}" PRIu64"", dmsScreenId);
sptr<AbstractDisplay> display = GetDisplayByScreen(dmsScreenId);
if (display == nullptr) {

View File

@ -223,7 +223,7 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
reply.WriteUint64(static_cast<uint64_t>(result));
break;
}
case TRANS_ID_SCREEN_MAKE_MIRROR_OR_EXPAND_CANCELED: {
case TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP: {
std::vector<ScreenId> screenId;
if (!data.ReadUInt64Vector(&screenId)) {
WLOGE("fail to receive screens in stub.");

View File

@ -18,6 +18,7 @@
#include <string>
#include "dm_common.h"
#include "noncopyable.h"
namespace OHOS::Rosen {
class DisplayInfo;
@ -30,10 +31,7 @@ class Display : public RefBase {
friend class DisplayManager;
public:
~Display();
Display(const Display&) = delete;
Display(Display&&) = delete;
Display& operator=(const Display&) = delete;
Display& operator=(Display&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(Display);
DisplayId GetId() const;
int32_t GetWidth() const;
int32_t GetHeight() const;

View File

@ -23,6 +23,7 @@
#include <screen_manager/screen_types.h>
#include "dm_common.h"
#include "noncopyable.h"
namespace OHOS::Rosen {
class ScreenInfo;
@ -60,10 +61,7 @@ class Screen : public RefBase {
friend class ScreenManager;
public:
~Screen();
Screen(const Screen&) = delete;
Screen(Screen&&) = delete;
Screen& operator=(const Screen&) = delete;
Screen& operator=(Screen&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(Screen);
bool IsGroup() const;
const std::string GetName() const;
ScreenId GetId() const;

View File

@ -32,10 +32,7 @@ class ScreenGroup : public Screen {
friend class ScreenManager;
public:
~ScreenGroup();
ScreenGroup(const ScreenGroup&) = delete;
ScreenGroup(ScreenGroup&&) = delete;
ScreenGroup& operator=(const ScreenGroup&) = delete;
ScreenGroup& operator=(ScreenGroup&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(ScreenGroup);
ScreenCombination GetCombination() const;
std::vector<ScreenId> GetChildIds() const;
std::vector<Point> GetChildPositions() const;

View File

@ -50,7 +50,6 @@ public:
ScreenId MakeExpand(const std::vector<ExpandOption>& options);
ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens);
void CancelMakeMirrorOrExpand(std::vector<ScreenId> screens);
ScreenId CreateVirtualScreen(VirtualScreenOption option);
DMError DestroyVirtualScreen(ScreenId screenId);
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);

View File

@ -1 +0,0 @@
../../script/run_git_set_upstream.sh

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2021-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

View File

@ -18,7 +18,7 @@
#include <map>
#include <mutex>
#include <vector>
#include <set>
#include "agent_death_recipient.h"
#include "window_manager_hilog.h"
@ -32,11 +32,11 @@ public:
bool RegisterAgent(const sptr<T1>& agent, T2 type);
bool UnregisterAgent(const sptr<T1>& agent, T2 type);
std::vector<sptr<T1>> GetAgentsByType(T2 type);
std::set<sptr<T1>> GetAgentsByType(T2 type);
private:
void RemoveAgent(const sptr<IRemoteObject>& remoteObject);
bool UnregisterAgentLocked(std::vector<sptr<T1>>& agents, const sptr<IRemoteObject>& agent);
bool UnregisterAgentLocked(std::set<sptr<T1>>& agents, const sptr<IRemoteObject>& agent);
static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "ClientAgentContainer"};
@ -52,7 +52,7 @@ private:
};
std::recursive_mutex mutex_;
std::map<T2, std::vector<sptr<T1>>> agentMap_;
std::map<T2, std::set<sptr<T1>>> agentMap_;
sptr<AgentDeathRecipient> deathRecipient_;
};
@ -64,7 +64,7 @@ template<typename T1, typename T2>
bool ClientAgentContainer<T1, T2>::RegisterAgent(const sptr<T1>& agent, T2 type)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
agentMap_[type].push_back(agent);
agentMap_[type].insert(agent);
WLOGFI("agent registered type:%{public}u", type);
if (deathRecipient_ == nullptr || !agent->AsObject()->AddDeathRecipient(deathRecipient_)) {
WLOGFI("failed to add death recipient");
@ -87,18 +87,18 @@ bool ClientAgentContainer<T1, T2>::UnregisterAgent(const sptr<T1>& agent, T2 typ
}
template<typename T1, typename T2>
std::vector<sptr<T1>> ClientAgentContainer<T1, T2>::GetAgentsByType(T2 type)
std::set<sptr<T1>> ClientAgentContainer<T1, T2>::GetAgentsByType(T2 type)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (agentMap_.count(type) == 0) {
WLOGFI("no such type of agent registered! type:%{public}u", type);
return std::vector<sptr<T1>>();
return std::set<sptr<T1>>();
}
return agentMap_.at(type);
}
template<typename T1, typename T2>
bool ClientAgentContainer<T1, T2>::UnregisterAgentLocked(std::vector<sptr<T1>>& agents,
bool ClientAgentContainer<T1, T2>::UnregisterAgentLocked(std::set<sptr<T1>>& agents,
const sptr<IRemoteObject>& agent)
{
auto iter = std::find_if(agents.begin(), agents.end(), finder_t(agent));

View File

@ -27,10 +27,7 @@ class DisplayInfo : public Parcelable {
friend class AbstractDisplay;
public:
~DisplayInfo() = default;
DisplayInfo(const DisplayInfo&) = delete;
DisplayInfo(DisplayInfo&&) = delete;
DisplayInfo& operator=(const DisplayInfo&) = delete;
DisplayInfo& operator=(DisplayInfo&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(DisplayInfo);
virtual bool Marshalling(Parcel& parcel) const override;
static DisplayInfo *Unmarshalling(Parcel& parcel);

View File

@ -26,10 +26,7 @@ class ScreenGroupInfo : public ScreenInfo {
friend class AbstractScreenGroup;
public:
~ScreenGroupInfo() = default;
ScreenGroupInfo(const ScreenGroupInfo&) = delete;
ScreenGroupInfo(ScreenGroupInfo&&) = delete;
ScreenGroupInfo& operator=(const ScreenGroupInfo&) = delete;
ScreenGroupInfo& operator=(ScreenGroupInfo&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(ScreenGroupInfo);
virtual bool Marshalling(Parcel& parcel) const override;
static ScreenGroupInfo* Unmarshalling(Parcel& parcel);

View File

@ -31,10 +31,7 @@ class ScreenInfo : public Parcelable {
friend class AbstractScreen;
public:
~ScreenInfo() = default;
ScreenInfo(const ScreenInfo&) = delete;
ScreenInfo(ScreenInfo&&) = delete;
ScreenInfo& operator=(const ScreenInfo&) = delete;
ScreenInfo& operator= (ScreenInfo&&) = delete;
WM_DISALLOW_COPY_AND_MOVE(ScreenInfo);
virtual bool Marshalling(Parcel& parcel) const override;
static ScreenInfo* Unmarshalling(Parcel& parcel);