Add screen expand code

Signed-off-by: youqijing <youqijing@huawei.com>
Change-Id: I79f0cf9cd50dfc09c0e12326784b62477f9b3a29
This commit is contained in:
youqijing
2022-02-14 17:46:11 +08:00
parent 444e200c28
commit 112819dc5b
19 changed files with 281 additions and 65 deletions
+2
View File
@@ -371,6 +371,7 @@ void DisplayManagerAdapter::Clear()
DMError DisplayManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!InitDMSProxyLocked()) {
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
}
@@ -452,6 +453,7 @@ std::vector<sptr<Screen>> DisplayManagerAdapter::GetAllScreens()
DMError DisplayManagerAdapter::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (!InitDMSProxyLocked()) {
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
}
+8 -3
View File
@@ -162,6 +162,10 @@ bool ScreenManager::UnregisterScreenListener(sptr<IScreenListener> listener)
ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
{
WLOGFI("make expand");
if (options.empty()) {
return SCREEN_ID_INVALID;
}
std::vector<ScreenId> screenIds;
std::vector<Point> startPoints;
for (auto& option: options) {
@@ -169,10 +173,11 @@ ScreenId ScreenManager::MakeExpand(const std::vector<ExpandOption>& options)
startPoints.emplace_back(Point(option.startX_, option.startY_));
}
DMError result = SingletonContainer::Get<DisplayManagerAdapter>().MakeExpand(screenIds, startPoints);
if (result == DMError::DM_OK) {
WLOGFI("make expand success");
if (result != DMError::DM_OK) {
return SCREEN_ID_INVALID;
}
return SCREEN_ID_INVALID;
WLOGFI("make expand success");
return screenIds.front(); // default main screenId is the first element of screenIds
}
ScreenId ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
@@ -40,6 +40,7 @@ public:
std::shared_ptr<Media::PixelMap> GetScreenSnapshot(DisplayId displayId);
sptr<AbstractDisplay> GetAbstractDisplay(DisplayId displayId) const;
void AddDisplayForExpandScreen(sptr<AbstractScreen> absScreen);
private:
void OnAbstractScreenConnect(sptr<AbstractScreen> absScreen);
@@ -48,8 +49,10 @@ private:
void ProcessDisplayUpdateRotation(sptr<AbstractScreen> absScreen);
void ProcessDisplaySizeChange(sptr<AbstractScreen> absScreen);
void BindAloneScreenLocked(sptr<AbstractScreen> absScreen);
void AddScreenToMirrorLocked(sptr<AbstractScreenGroup> group, sptr<AbstractScreen> realAbsScreen);
void ProcessScreenDisconnected(sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup);
void AddScreenToMirrorLocked(sptr<AbstractScreen> absScreen);
void AddScreenToExpandLocked(sptr<AbstractScreen> absScreen);
void ProcessNormalScreenDisconnected(sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup);
void ProcessExpandScreenDisconnected(sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup);
bool UpdateDisplaySize(sptr<AbstractDisplay> absDisplay, sptr<SupportedScreenModes> info);
std::recursive_mutex& mutex_;
+2
View File
@@ -91,9 +91,11 @@ public:
std::vector<Point> GetChildrenPosition() const;
size_t GetChildCount() const;
const sptr<ScreenGroupInfo> ConvertToScreenGroupInfo() const;
bool SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config);
ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE };
ScreenId mirrorScreenId_ {INVALID_SCREEN_ID};
private:
std::map<ScreenId, std::pair<sptr<AbstractScreen>, Point>> abstractScreenMap_;
};
@@ -45,7 +45,7 @@ public:
std::vector<ScreenId> GetAllScreenIds();
sptr<AbstractScreen> GetAbstractScreen(ScreenId dmsScreenId) const;
std::vector<ScreenId> GetShotScreenIds(std::vector<ScreenId>) const;
std::vector<ScreenId> GetAllMirrorScreenIds(std::vector<ScreenId>) const;
std::vector<ScreenId> GetAllExpandOrMirrorScreenIds(std::vector<ScreenId>) const;
sptr<AbstractScreenGroup> GetAbstractScreenGroup(ScreenId dmsScreenId);
ScreenId GetDefaultAbstractScreenId();
ScreenId ConvertToRsScreenId(ScreenId dmsScreenId);
@@ -62,6 +62,7 @@ public:
std::shared_ptr<RSDisplayNode> GetRSDisplayNodeByScreenId(ScreenId dmsScreenId) const;
void UpdateRSTree(ScreenId dmsScreenId, std::shared_ptr<RSSurfaceNode>& surfaceNode, bool isAdd);
bool MakeMirror(ScreenId, std::vector<ScreenId> screens);
bool MakeExpand(std::vector<ScreenId> screenIds, std::vector<Point> startPoints);
void DumpScreenInfo() const;
void DumpScreenGroupInfo() const;
@@ -97,6 +97,7 @@ private:
ScreenId GetScreenIdFromDisplayId(DisplayId displayId);
void RegisterDisplayChangeListener(sptr<IDisplayChangeListener> listener);
void NotifyDisplayStateChange(DisplayId id, DisplayStateChangeType type);
void SetShotScreen(ScreenId mainScreenId, std::vector<ScreenId> shotScreenIds);
ScreenId GetScreenIdByDisplayId(DisplayId displayId) const;
std::shared_ptr<RSDisplayNode> GetRSDisplayNodeByDisplayId(DisplayId displayId) const;
+79 -13
View File
@@ -112,16 +112,14 @@ void AbstractDisplayController::OnAbstractScreenConnect(sptr<AbstractScreen> abs
WLOGE("the group information of the screen is wrong");
return;
}
if (group->combination_ == ScreenCombination::SCREEN_ALONE) {
if (group->combination_ == ScreenCombination::SCREEN_ALONE || group->GetChildCount() == 1) {
BindAloneScreenLocked(absScreen);
} else if (group->combination_ == ScreenCombination::SCREEN_MIRROR) {
if (group->GetChildCount() == 1) {
WLOGI("OnAbstractScreenConnected, ScreenCombination::SCREEN_MIRROR, BindAloneScreenLocked");
BindAloneScreenLocked(absScreen);
} else {
WLOGI("OnAbstractScreenConnected, ScreenCombination::SCREEN_MIRROR, AddScreenToMirrorLocked");
AddScreenToMirrorLocked(group, absScreen);
}
WLOGI("OnAbstractScreenConnect, ScreenCombination::SCREEN_MIRROR, AddScreenToMirrorLocked");
AddScreenToMirrorLocked(absScreen);
} else if (group->combination_ == ScreenCombination::SCREEN_EXPAND) {
WLOGI("OnAbstractScreenConnect, ScreenCombination::SCREEN_EXPAND, AddScreenToExpandLocked");
AddScreenToExpandLocked(absScreen);
} else {
WLOGE("support in future. combination:%{public}u", group->combination_);
}
@@ -142,15 +140,18 @@ void AbstractDisplayController::OnAbstractScreenDisconnect(sptr<AbstractScreen>
}
if (screenGroup->combination_ == ScreenCombination::SCREEN_ALONE
|| screenGroup->combination_ == ScreenCombination::SCREEN_MIRROR) {
ProcessScreenDisconnected(absScreen, screenGroup);
ProcessNormalScreenDisconnected(absScreen, screenGroup);
} else if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) {
ProcessExpandScreenDisconnected(absScreen, screenGroup);
} else {
WLOGE("support in future. combination:%{public}u", screenGroup->combination_);
}
}
void AbstractDisplayController::ProcessScreenDisconnected(
void AbstractDisplayController::ProcessNormalScreenDisconnected(
sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup)
{
WLOGI("normal screen disconnect");
ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
sptr<AbstractScreen> defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId);
for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) {
@@ -166,6 +167,28 @@ void AbstractDisplayController::ProcessScreenDisconnected(
}
}
void AbstractDisplayController::ProcessExpandScreenDisconnected(
sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup)
{
WLOGI("expand screen disconnect");
ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
sptr<AbstractScreen> defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId);
for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) {
DisplayId displayId = iter->first;
sptr<AbstractDisplay> abstractDisplay = iter->second;
if (abstractDisplay->GetAbstractScreenId() != absScreen->dmsId_) {
continue;
}
WLOGI("notify wms and dm which expand screen disconnect, displayId: %{public}" PRIu64""
", screenId: %{public}" PRIu64"", displayId, abstractDisplay->GetAbstractScreenId());
// Notify disconnect event to WMS
DisplayManagerService::GetInstance().NotifyDisplayStateChange(displayId, DisplayStateChangeType::DESTROY);
abstractDisplayMap_.erase(iter);
// Notify disconnect event to DisplayManager
DisplayManagerAgentController::GetInstance().OnDisplayDestroy(abstractDisplay->GetId());
}
}
void AbstractDisplayController::OnAbstractScreenChange(sptr<AbstractScreen> absScreen, DisplayChangeEvent event)
{
if (absScreen == nullptr) {
@@ -294,9 +317,52 @@ void AbstractDisplayController::BindAloneScreenLocked(sptr<AbstractScreen> realA
}
}
void AbstractDisplayController::AddScreenToMirrorLocked(sptr<AbstractScreenGroup> group,
sptr<AbstractScreen> realAbsScreen)
void AbstractDisplayController::AddScreenToMirrorLocked(sptr<AbstractScreen> absScreen)
{
WLOGI("bind screen to mirror. screen:%{public}" PRIu64"", realAbsScreen->dmsId_);
WLOGI("bind display to mirror. screen:%{public}" PRIu64"", absScreen->dmsId_);
}
void AbstractDisplayController::AddScreenToExpandLocked(sptr<AbstractScreen> absScreen)
{
WLOGI("bind display to expand. screen:%{public}" PRIu64"", absScreen->dmsId_);
sptr<SupportedScreenModes> info;
if (absScreen->type_ == ScreenType::VIRTUAL) {
WLOGI("screen type is virtual, use default screen info");
ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
sptr<AbstractScreen> defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId);
if (defaultScreen == nullptr) {
WLOGE("bind display error, cannot get defaultScreen.");
return;
}
info = defaultScreen->GetActiveScreenMode();
} else {
WLOGI("screen type is not virtual, get this screen info");
info = absScreen->GetActiveScreenMode();
}
if (info == nullptr) {
WLOGE("bind display error, cannot get info.");
return;
}
sptr<AbstractDisplay> display = new AbstractDisplay(displayCount_.fetch_add(1),
absScreen->dmsId_, info->width_, info->height_, info->freshRate_);
abstractDisplayMap_.insert((std::make_pair(display->GetId(), display)));
WLOGI("create display for new screen. screen:%{public}" PRIu64", display:%{public}" PRIu64"",
absScreen->dmsId_, display->GetId());
DisplayManagerAgentController::GetInstance().OnDisplayCreate(display->ConvertToDisplayInfo());
}
void AbstractDisplayController::AddDisplayForExpandScreen(sptr<AbstractScreen> absScreen)
{
for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) {
sptr<AbstractDisplay> abstractDisplay = iter->second;
if (abstractDisplay->GetAbstractScreenId() == absScreen->dmsId_) {
WLOGE("error, screenId: %{public}" PRIu64" already has corresponding display",
absScreen->dmsId_);
return;
}
}
WLOGI("screenId: %{public}" PRIu64" has no corresponding display, create new dispaly.",
absScreen->dmsId_);
AddScreenToExpandLocked(absScreen);
}
} // namespace OHOS::Rosen
+20 -13
View File
@@ -223,20 +223,8 @@ const sptr<ScreenGroupInfo> AbstractScreenGroup::ConvertToScreenGroupInfo() cons
return screenGroupInfo;
}
bool AbstractScreenGroup::AddChild(sptr<AbstractScreen>& dmsScreen, Point& startPoint)
bool AbstractScreenGroup::SetRSDisplayNodeConfig(sptr<AbstractScreen>& dmsScreen, struct RSDisplayNodeConfig& config)
{
if (dmsScreen == nullptr) {
WLOGE("AddChild, dmsScreen is nullptr.");
return false;
}
ScreenId screenId = dmsScreen->dmsId_;
auto iter = abstractScreenMap_.find(screenId);
if (iter != abstractScreenMap_.end()) {
WLOGE("AddChild, abstractScreenMap_ has dmsScreen:%{public}" PRIu64"", screenId);
return false;
}
struct RSDisplayNodeConfig config;
switch (combination_) {
case ScreenCombination::SCREEN_ALONE:
case ScreenCombination::SCREEN_EXPAND:
@@ -269,6 +257,25 @@ bool AbstractScreenGroup::AddChild(sptr<AbstractScreen>& dmsScreen, Point& start
WLOGE("fail to add child. invalid group combination:%{public}u", combination_);
return false;
}
return true;
}
bool AbstractScreenGroup::AddChild(sptr<AbstractScreen>& dmsScreen, Point& startPoint)
{
if (dmsScreen == nullptr) {
WLOGE("AddChild, dmsScreen is nullptr.");
return false;
}
ScreenId screenId = dmsScreen->dmsId_;
auto iter = abstractScreenMap_.find(screenId);
if (iter != abstractScreenMap_.end()) {
WLOGE("AddChild, abstractScreenMap_ has dmsScreen:%{public}" PRIu64"", screenId);
return false;
}
struct RSDisplayNodeConfig config;
if (!SetRSDisplayNodeConfig(dmsScreen, config)) {
return false;
}
dmsScreen->InitRSDisplayNode(config);
dmsScreen->groupDmsId_ = dmsId_;
abstractScreenMap_.insert(std::make_pair(screenId, std::make_pair(dmsScreen, startPoint)));
+40 -7
View File
@@ -73,7 +73,8 @@ std::vector<ScreenId> AbstractScreenController::GetShotScreenIds(std::vector<Scr
return screenIds;
}
std::vector<ScreenId> AbstractScreenController::GetAllMirrorScreenIds(std::vector<ScreenId> mirrorScreenIds) const
std::vector<ScreenId> AbstractScreenController::GetAllExpandOrMirrorScreenIds(
std::vector<ScreenId> mirrorScreenIds) const
{
std::vector<ScreenId> screenIds;
for (ScreenId screenId : mirrorScreenIds) {
@@ -83,7 +84,7 @@ std::vector<ScreenId> AbstractScreenController::GetAllMirrorScreenIds(std::vecto
}
}
if (screenIds.empty()) {
WLOGI("GetAllMirrorScreenIds, screenIds is empty");
WLOGI("GetAllExpandOrMirrorScreenIds, screenIds is empty");
return screenIds;
}
for (auto iter = dmsScreenMap_.begin(); iter != dmsScreenMap_.end(); iter++) {
@@ -93,7 +94,7 @@ std::vector<ScreenId> AbstractScreenController::GetAllMirrorScreenIds(std::vecto
auto screenIdIter = std::find(screenIds.begin(), screenIds.end(), iter->first);
if (screenIdIter == screenIds.end()) {
screenIds.emplace_back(iter->first);
WLOGI("GetAllMirrorScreenIds: screenId: %{public}" PRIu64"", iter->first);
WLOGI("GetAllExpandOrMirrorScreenIds: screenId: %{public}" PRIu64"", iter->first);
}
}
return screenIds;
@@ -428,7 +429,7 @@ ScreenId AbstractScreenController::CreateVirtualScreen(VirtualScreenOption optio
ScreenId dmsScreenId = SCREEN_ID_INVALID;
auto iter = rs2DmsScreenIdMap_.find(result);
if (iter == rs2DmsScreenIdMap_.end()) {
if (!option.isForShot) {
if (!option.isForShot_) {
WLOGI("CreateVirtualScreen is not shot");
dmsScreenId = dmsScreenCount_;
sptr<AbstractScreen> absScreen = new AbstractScreen(dmsScreenId, result);
@@ -620,7 +621,6 @@ bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenI
return false;
}
WLOGFI("GetAbstractScreenGroup start");
GetRSDisplayNodeByScreenId(screenId);
auto group = GetAbstractScreenGroup(screen->groupDmsId_);
if (group == nullptr) {
WLOGFE("group is nullptr, try to get");
@@ -637,7 +637,6 @@ bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenI
}
}
WLOGFI("GetAbstractScreenGroup end");
GetRSDisplayNodeByScreenId(screenId);
group->combination_ = ScreenCombination::SCREEN_MIRROR;
group->mirrorScreenId_ = screen->dmsId_;
Point point;
@@ -659,6 +658,40 @@ bool AbstractScreenController::MakeMirror(ScreenId screenId, std::vector<ScreenI
return true;
}
bool AbstractScreenController::MakeExpand(std::vector<ScreenId> screenIds, std::vector<Point> startPoints)
{
ScreenId defaultScreenId = GetDefaultAbstractScreenId();
WLOGI("MakeExpand, defaultScreenId:%{public}" PRIu64"", defaultScreenId);
auto defaultScreen = GetAbstractScreen(defaultScreenId);
if (defaultScreen == nullptr) {
return false;
}
auto group = GetAbstractScreenGroup(defaultScreen->groupDmsId_);
if (group == nullptr) {
return false;
}
group->combination_ = ScreenCombination::SCREEN_EXPAND;
for (uint64_t i = 0; i != screenIds.size(); i++) {
ScreenId expandScreenId = screenIds[i];
Point expandPoint = startPoints[i];
WLOGFI("expandScreenId: %{public}" PRIu64", Point: %{public}d, %{public}d",
expandScreenId, expandPoint.posX_, expandPoint.posY_);
auto expandScreen = GetAbstractScreen(expandScreenId);
if (expandScreen == nullptr) {
WLOGFE("expandScreen:%{public}" PRIu64" is nullptr", expandScreenId);
continue;
}
WLOGI("expandScreen->groupDmsId_: %{public}" PRIu64"", expandScreen->groupDmsId_);
auto originGroup = GetAbstractScreenGroup(expandScreen->groupDmsId_);
if (originGroup != nullptr) {
originGroup->RemoveChild(expandScreen);
}
group->AddChild(expandScreen, expandPoint);
}
WLOGI("MakeExpand success");
return true;
}
void AbstractScreenController::DumpScreenInfo() const
{
WLOGI("-------- dump screen info begin---------");
@@ -684,7 +717,7 @@ void AbstractScreenController::DumpScreenInfo() const
std::string isGroup = (dmsScreenGroupMap_.find(screen->dmsId_) != dmsScreenGroupMap_.end()) ? "true" : "false";
NodeId nodeId = (screen->rsDisplayNode_ == nullptr) ? INVALID_SCREEN_ID : 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_,
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);
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ ScreenId DisplayManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOpt
bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) &&
data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) &&
data.WriteRemoteObject(virtualOption.surface_->GetProducer()->AsObject()) &&
data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot);
data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_);
if (!res) {
WLOGFE("DisplayManagerProxy::Write data failed");
return SCREEN_ID_INVALID;
+56 -23
View File
@@ -365,6 +365,28 @@ std::shared_ptr<RSDisplayNode> DisplayManagerService::GetRSDisplayNodeByDisplayI
return abstractScreenController_->GetRSDisplayNodeByScreenId(dmsScreenId);
}
void DisplayManagerService::SetShotScreen(ScreenId mainScreenId, std::vector<ScreenId> shotScreenIds)
{
WLOGFI("SetShotScreen. mainScreenId: %{public}" PRIu64"", mainScreenId);
std::shared_ptr<RSDisplayNode> displayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(mainScreenId);
if (displayNode == nullptr) {
WLOGFE("SetShotScreen error, cannot get DisplayNode");
return;
}
NodeId nodeId = displayNode->GetId();
WLOGI("SetShotScreen, mainScreen nodeId:%{public}" PRIu64"", nodeId);
for (ScreenId shotScreenId : shotScreenIds) {
shotScreenId = abstractScreenController_->ConvertToRsScreenId(shotScreenId);
if (shotScreenId == INVALID_SCREEN_ID) {
continue;
}
struct RSDisplayNodeConfig config = {shotScreenId, true, nodeId};
displayNodeMap_[shotScreenId] = RSDisplayNode::Create(config);
}
auto transactionProxy = RSTransactionProxy::GetInstance();
transactionProxy->FlushImplicitTransaction();
}
DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds)
{
WLOGFI("MakeMirror. mainScreenId :%{public}" PRIu64"", mainScreenId);
@@ -374,7 +396,7 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<Scr
if (iter != shotScreenIds.end()) {
shotScreenIds.erase(iter);
}
auto allMirrorScreenIds = abstractScreenController_->GetAllMirrorScreenIds(mirrorScreenIds);
auto allMirrorScreenIds = abstractScreenController_->GetAllExpandOrMirrorScreenIds(mirrorScreenIds);
iter = std::find(allMirrorScreenIds.begin(), allMirrorScreenIds.end(), mainScreenId);
if (iter != allMirrorScreenIds.end()) {
allMirrorScreenIds.erase(iter);
@@ -383,31 +405,12 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector<Scr
WLOGFI("create mirror fail, screen is invalid. Screen :%{public}" PRIu64"", mainScreenId);
return DMError::DM_ERROR_INVALID_PARAM;
}
SetShotScreen(mainScreenId, shotScreenIds);
WM_SCOPED_TRACE("dms:MakeMirror");
WLOGFI("create mirror. Screen: %{public}" PRIu64"", mainScreenId);
std::shared_ptr<RSDisplayNode> displayNode = abstractScreenController_->GetRSDisplayNodeByScreenId(mainScreenId);
if (displayNode == nullptr) {
WLOGFE("create mirror fail, cannot get DisplayNode");
return DMError::DM_ERROR_NULLPTR;
}
NodeId nodeId = displayNode->GetId();
WLOGI("MakeMirror, nodeId:%{public}" PRIu64"", nodeId);
for (ScreenId mirrorScreenId : shotScreenIds) {
mirrorScreenId = abstractScreenController_->ConvertToRsScreenId(mirrorScreenId);
if (mirrorScreenId == INVALID_SCREEN_ID) {
continue;
}
struct RSDisplayNodeConfig config = {mirrorScreenId, true, nodeId};
displayNodeMap_[mirrorScreenId] = RSDisplayNode::Create(config);
}
auto transactionProxy = RSTransactionProxy::GetInstance();
transactionProxy->FlushImplicitTransaction();
if (!allMirrorScreenIds.empty() && !abstractScreenController_->MakeMirror(mainScreenId, allMirrorScreenIds)) {
WLOGFE("make mirror failed.");
return DMError::DM_ERROR_NULLPTR;
}
WLOGFI("create mirror. NodeId: %{public}" PRIu64"", nodeId);
abstractScreenController_->DumpScreenInfo();
return DMError::DM_OK;
}
@@ -458,9 +461,39 @@ std::vector<sptr<ScreenInfo>> DisplayManagerService::GetAllScreenInfos()
return screenInfos;
}
DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
DMError DisplayManagerService::MakeExpand(std::vector<ScreenId> expandScreenIds, std::vector<Point> startPoints)
{
// todo: make expand
WLOGI("MakeExpand");
if (expandScreenIds.empty() || startPoints.empty() || expandScreenIds.size() != startPoints.size()) {
WLOGFI("create expand fail, input params is invalid. "
"screenId vector size :%{public}ud, startPoint vector size :%{public}ud",
static_cast<uint32_t>(expandScreenIds.size()), static_cast<uint32_t>(startPoints.size()));
return DMError::DM_ERROR_INVALID_PARAM;
}
abstractScreenController_->DumpScreenInfo();
ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId();
WLOGI("MakeExpand, defaultScreenId:%{public}" PRIu64"", defaultScreenId);
auto shotScreenIds = abstractScreenController_->GetShotScreenIds(expandScreenIds);
auto iter = std::find(shotScreenIds.begin(), shotScreenIds.end(), defaultScreenId);
if (iter != shotScreenIds.end()) {
shotScreenIds.erase(iter);
}
auto allExpandScreenIds = abstractScreenController_->GetAllExpandOrMirrorScreenIds(expandScreenIds);
iter = std::find(allExpandScreenIds.begin(), allExpandScreenIds.end(), defaultScreenId);
if (iter != allExpandScreenIds.end()) {
allExpandScreenIds.erase(iter);
}
for (ScreenId expandScreenId : allExpandScreenIds) {
auto expandScreen = abstractScreenController_->GetAbstractScreen(expandScreenId);
abstractDisplayController_->AddDisplayForExpandScreen(expandScreen);
}
SetShotScreen(defaultScreenId, shotScreenIds);
WM_SCOPED_TRACE("dms:MakeExpand");
if (!allExpandScreenIds.empty() && !abstractScreenController_->MakeExpand(allExpandScreenIds, startPoints)) {
WLOGFE("make expand failed.");
return DMError::DM_ERROR_NULLPTR;
}
abstractScreenController_->DumpScreenInfo();
return DMError::DM_OK;
}
+1 -1
View File
@@ -65,7 +65,7 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
.density_ = density,
.surface_ = surface,
.flags_ = flags,
.isForShot = isForShot
.isForShot_ = isForShot
};
ScreenId screenId = CreateVirtualScreen(option);
reply.WriteUint64(static_cast<uint64_t>(screenId));
+1 -1
View File
@@ -47,7 +47,7 @@ struct VirtualScreenOption {
float density_;
sptr<Surface> surface_;
int32_t flags_;
bool isForShot {true};
bool isForShot_ {true};
};
struct ExpandOption {
+1
View File
@@ -25,6 +25,7 @@ enum class DisplayStateChangeType : uint32_t {
BEFORE_UNLOCK,
UPDATE_ROTATION,
SIZE_CHANGE,
DESTROY
};
class IDisplayChangeListener : public RefBase {
public:
+4
View File
@@ -61,6 +61,10 @@ public:
WMError EnterSplitWindowMode(sptr<WindowNode>& node);
WMError ExitSplitWindowMode(sptr<WindowNode>& node);
WMError SwitchLayoutPolicy(WindowLayoutMode mode, bool reorder = false);
void MoveWindowNode(sptr<WindowNodeContainer>& container);
sptr<WindowNode> GetBelowAppWindowNode() const;
sptr<WindowNode> GetAppWindowNode() const;
sptr<WindowNode> GetAboveAppWindowNode() const;
private:
void AssignZOrder(sptr<WindowNode>& node);
+1
View File
@@ -59,6 +59,7 @@ public:
void NotifyWindowStateChange(WindowState state, WindowStateChangeReason reason);
void NotifyDisplayChange(sptr<AbstractDisplay> abstractDisplay);
void NotifyDisplayDestory(DisplayId displayId);
WMError RaiseZOrderForAppWindow(sptr<WindowNode>& node);
private:
+4
View File
@@ -272,6 +272,10 @@ void WindowController::NotifyDisplayStateChange(DisplayId displayId, DisplayStat
FlushWindowInfoWithDisplayId(displayId);
break;
}
case DisplayStateChangeType::DESTROY: {
windowRoot_->NotifyDisplayDestory(displayId);
break;
}
default: {
WLOGFE("unknown DisplayStateChangeType:%{public}u", type);
return;
+42
View File
@@ -20,6 +20,7 @@
#include <cinttypes>
#include "display_manager_service_inner.h"
#include "dm_common.h"
#include "window_helper.h"
#include "window_layout_policy_cascade.h"
#include "window_layout_policy_tile.h"
@@ -966,5 +967,46 @@ void WindowNodeContainer::RaiseInputMethodWindowPriorityIfNeeded(const sptr<Wind
node->priority_ = WINDOW_TYPE_RAISED_INPUT_METHOD;
}
}
void WindowNodeContainer::MoveWindowNode(sptr<WindowNodeContainer>& container)
{
WLOGFI("MoveWindowNode: disconnect expand display, move window node");
sptr<WindowNode> belowAppNode = container->GetBelowAppWindowNode();
sptr<WindowNode> appNode = container->GetAppWindowNode();
sptr<WindowNode> aboveAppNode = container->GetAboveAppWindowNode();
for (auto& node : belowAppNode->children_) {
WLOGFI("belowAppWindowNode_: move windowNode: {public}%d from displayId: %{public}" PRId64 ""
" to displayID %{public}" PRId64 "", node->GetWindowId(), node->GetDisplayId(), displayId_);
node->SetDisplayId(displayId_);
belowAppWindowNode_->children_.push_back(node);
}
for (auto& node : appNode->children_) {
WLOGFI("appWindowNode_: move windowNode: {public}%d from displayId: %{public}" PRId64 ""
" to displayID %{public}" PRId64 "", node->GetWindowId(), node->GetDisplayId(), displayId_);
node->SetDisplayId(displayId_);
appWindowNode_->children_.push_back(node);
}
for (auto& node : aboveAppNode->children_) {
WLOGFI("aboveAppWindowNode_: move windowNode: {public}%d from displayId: %{public}" PRId64 ""
" to displayID %{public}" PRId64 "", node->GetWindowId(), node->GetDisplayId(), displayId_);
node->SetDisplayId(displayId_);
aboveAppWindowNode_->children_.push_back(node);
}
}
sptr<WindowNode> WindowNodeContainer::GetBelowAppWindowNode() const
{
return belowAppWindowNode_;
}
sptr<WindowNode> WindowNodeContainer::GetAppWindowNode() const
{
return appWindowNode_;
}
sptr<WindowNode> WindowNodeContainer::GetAboveAppWindowNode() const
{
return aboveAppWindowNode_;
}
}
}
+11
View File
@@ -456,5 +456,16 @@ WMError WindowRoot::SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mo
}
return ret;
}
void WindowRoot::NotifyDisplayDestory(DisplayId expandDisplayId)
{
WLOGFW("disconnect expand display, get default and expand display container");
DisplayId defaultDisplayId = DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId();
auto expandDisplaycontainer = GetOrCreateWindowNodeContainer(expandDisplayId);
auto defaultDisplaycontainer = GetOrCreateWindowNodeContainer(defaultDisplayId);
defaultDisplaycontainer->MoveWindowNode(expandDisplaycontainer);
NotifyDisplayRemoved(expandDisplayId);
}
}
}