Add interface for 'Screen'

Signed-off-by: lu <zhaolu2@huawei.com>
Change-Id: Ifae6fde45bfc57ffd18b0db42624ed113a20c409
This commit is contained in:
lu
2022-01-11 16:27:33 +08:00
parent 67abd1856b
commit ac578100ae
19 changed files with 633 additions and 77 deletions
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#include "screen.h"
namespace OHOS::Rosen {
class Screen::Impl : public RefBase {
friend class Screen;
public:
Impl() = default;
~Impl() = default;
ScreenId id_ { SCREEN_ID_INVALD };
uint32_t width_ { 0 };
uint32_t height_ { 0 };
uint32_t virtualWidth_ { 0 };
uint32_t virtualHeight_ { 0 };
float virtualPixelRatio_ { 0.0 };
sptr<Screen> parent_ { nullptr };
bool hasChild_ { false };
};
Screen::Screen()
{
pImpl_ = new Impl();
}
Screen::~Screen()
{
}
bool Screen::IsGroup() const
{
return pImpl_->hasChild_;
}
ScreenId Screen::GetId() const
{
return pImpl_->id_;
}
uint32_t Screen::GetWidth() const
{
return pImpl_->width_;
}
uint32_t Screen::GetHeight() const
{
return pImpl_->height_;
}
uint32_t Screen::GetVirtualWidth() const
{
return pImpl_->virtualWidth_;
}
uint32_t Screen::GetVirtualHeight() const
{
return pImpl_->virtualHeight_;
}
float Screen::GetVirtualPixelRatio() const
{
return pImpl_->virtualPixelRatio_;
}
sptr<Screen> Screen::GetParent() const
{
return pImpl_->parent_;
}
} // namespace OHOS::Rosen
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#include "screen_group.h"
#include "wm_common.h"
namespace OHOS::Rosen {
class ScreenGroup::Impl : public RefBase {
friend class ScreenGroup;
private:
Impl() = default;
~Impl() = default;
std::vector<sptr<Screen>> children_;
std::vector<Point> position_;
ScreenType type_ { ScreenType::SCREEN_ALONE };
};
ScreenGroup::ScreenGroup()
{
pImpl_ = new Impl();
}
ScreenGroup::~ScreenGroup()
{
}
ScreenType ScreenGroup::GetType() const
{
return pImpl_->type_;
}
std::vector<sptr<Screen>> ScreenGroup::GetChildren() const
{
return pImpl_->children_;
}
std::vector<Point> ScreenGroup::GetChildrenPosition() const
{
return pImpl_->position_;
}
} // namespace OHOS::Rosen
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#include "screen_manager.h"
#include <map>
#include <vector>
namespace OHOS::Rosen {
class ScreenManager::Impl : public RefBase {
friend class ScreenManager;
private:
Impl() = default;
~Impl() = default;
std::map<ScreenId, sptr<Screen>> monitorMap_;
};
ScreenManager::ScreenManager()
{
pImpl_ = new Impl();
}
ScreenManager::~ScreenManager()
{
}
sptr<Screen> ScreenManager::GetScreenById(ScreenId id)
{
return nullptr;
}
std::vector<const sptr<Screen>> ScreenManager::GetAllScreens()
{
std::vector<const sptr<Screen>> res;
return res;
}
sptr<ScreenGroup> ScreenManager::makeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint)
{
return nullptr;
}
sptr<ScreenGroup> ScreenManager::makeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId)
{
return nullptr;
}
sptr<Screen> ScreenManager::createVirtualScreen(VirtualScreenOption option)
{
return nullptr;
}
} // namespace OHOS::Rosen
@@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_MANAGER_H
#define FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_MANAGER_H
#ifndef FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H
#define FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H
#include <map>
#include <pixel_map.h>
@@ -26,8 +26,8 @@
#include "virtual_display_info.h"
namespace OHOS::Rosen {
class AbstractDisplayManager {
DECLARE_SINGLE_INSTANCE_BASE(AbstractDisplayManager);
class AbstractDisplayController {
DECLARE_SINGLE_INSTANCE_BASE(AbstractDisplayController);
public:
std::map<int32_t, sptr<AbstractDisplay>> abstractDisplayMap_;
@@ -38,11 +38,11 @@ public:
sptr<Media::PixelMap> GetScreenSnapshot(ScreenId screenId);
private:
AbstractDisplayManager();
~AbstractDisplayManager();
AbstractDisplayController();
~AbstractDisplayController();
void parepareRSScreenManger();
OHOS::Rosen::RSInterfaces *rsInterface_;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_MANAGER_H
#endif // FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H
#define FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H
#include <refbase.h>
#include <screen_manager/screen_types.h>
namespace OHOS::Rosen {
struct Point {
int32_t posX_;
int32_t posY_;
};
enum class AbstractScreenType : uint32_t {
SCREEN_ALONE,
SCREEN_EXPAND,
SCREEN_MIRROR,
};
class AbstractScreen : public RefBase {
public:
AbstractScreen(ScreenId dmsId, ScreenId rsId);
AbstractScreen() = delete;
~AbstractScreen();
ScreenId dmsId_;
ScreenId rsId_;
};
class AbstractScreenGroup : public AbstractScreen {
public:
AbstractScreenGroup(ScreenId dmsId, ScreenId rsId);
AbstractScreenGroup() = delete;
~AbstractScreenGroup();
AbstractScreenType GetType() const;
std::vector<sptr<AbstractScreen>> GetChildren() const;
std::vector<Point> GetChildrenPosition() const;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H
#define FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H
#include <map>
#include <vector>
#include <refbase.h>
#include <surface.h>
#include <transaction/rs_interfaces.h>
#include "abstract_screen.h"
namespace OHOS::Rosen {
class AbstractScreenController : public RefBase {
using OnAbstractScreenCallback = std::function<void(ScreenId)>;
struct AbstractScreenCallback : public RefBase {
OnAbstractScreenCallback onConnected_;
OnAbstractScreenCallback onDisconnected_;
OnAbstractScreenCallback onChanged_;
};
public:
AbstractScreenController(std::recursive_mutex& mutex);
~AbstractScreenController();
std::vector<ScreenId> GetAllScreenIds();
std::shared_ptr<std::vector<ScreenId>> ConvertToRsScreenId(ScreenId dmsScreenId);
std::shared_ptr<std::vector<ScreenId>> ConvertToDmsScreenId(ScreenId rsScreenId);
void RegisterAbstractScreenCallback(sptr<AbstractScreenCallback> cb);
std::map<ScreenId, sptr<AbstractScreen>> abstractDisplayMap_;
private:
void PrepareRSScreenManger();
void OnRsScreenChange(ScreenId rsScreenId, ScreenEvent screenEvent);
void AddToGroup(sptr<AbstractScreen> newScreen);
void AddAsFirstScreenLocked(sptr<AbstractScreen> newScreen);
void AddAsSuccedentScreenLocked(sptr<AbstractScreen> newScreen);
std::recursive_mutex& mutex_;
RSInterfaces& rsInterface_;
volatile ScreenId dmsScreenCount_;
std::map<ScreenId, std::shared_ptr<std::vector<ScreenId>>> rs2DmsScreenIdMap_;
std::map<ScreenId, std::shared_ptr<std::vector<ScreenId>>> dms2RsScreenIdMap_;
std::map<ScreenId, sptr<AbstractScreen>> dmsScreenMap_;
ScreenId defaultScreenId_ {INVALID_SCREEN_ID};
sptr<AbstractScreenCallback> abstractScreenCallback_;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H
+4 -1
View File
@@ -23,7 +23,8 @@
#include <surface.h>
#include "abstract_display.h"
#include "abstract_display_manager.h"
#include "abstract_display_controller.h"
#include "abstract_screen_controller.h"
#include "display_manager_stub.h"
#include "display_power_controller.h"
#include "single_instance.h"
@@ -58,8 +59,10 @@ private:
DisplayId GetDisplayIdFromScreenId(ScreenId screenId);
ScreenId GetScreenIdFromDisplayId(DisplayId displayId);
std::recursive_mutex mutex_;
static inline SingletonDelegator<DisplayManagerService> delegator_;
std::map<int32_t, sptr<AbstractDisplay>> abstractDisplayMap_;
AbstractScreenController screenController_ = AbstractScreenController(mutex_);
DisplayPowerController displayPowerController_;
};
} // namespace OHOS::Rosen
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "abstract_display_manager.h"
#include "abstract_display_controller.h"
#include "window_manager_hilog.h"
@@ -21,24 +21,24 @@
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "AbstractDisplayManager"};
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "AbstractDisplayController"};
}
AbstractDisplayManager::AbstractDisplayManager() : rsInterface_(&(RSInterfaces::GetInstance()))
AbstractDisplayController::AbstractDisplayController() : rsInterface_(&(RSInterfaces::GetInstance()))
{
parepareRSScreenManger();
}
AbstractDisplayManager::~AbstractDisplayManager()
AbstractDisplayController::~AbstractDisplayController()
{
rsInterface_ = nullptr;
}
void AbstractDisplayManager::parepareRSScreenManger()
void AbstractDisplayController::parepareRSScreenManger()
{
}
ScreenId AbstractDisplayManager::GetDefaultScreenId()
ScreenId AbstractDisplayController::GetDefaultScreenId()
{
if (rsInterface_ == nullptr) {
return INVALID_SCREEN_ID;
@@ -46,7 +46,7 @@ ScreenId AbstractDisplayManager::GetDefaultScreenId()
return rsInterface_->GetDefaultScreenId();
}
RSScreenModeInfo AbstractDisplayManager::GetScreenActiveMode(ScreenId id)
RSScreenModeInfo AbstractDisplayController::GetScreenActiveMode(ScreenId id)
{
RSScreenModeInfo screenModeInfo;
if (rsInterface_ == nullptr) {
@@ -55,7 +55,7 @@ RSScreenModeInfo AbstractDisplayManager::GetScreenActiveMode(ScreenId id)
return rsInterface_->GetScreenActiveMode(id);
}
ScreenId AbstractDisplayManager::CreateVirtualScreen(const VirtualDisplayInfo &virtualDisplayInfo,
ScreenId AbstractDisplayController::CreateVirtualScreen(const VirtualDisplayInfo &virtualDisplayInfo,
sptr<Surface> surface)
{
if (rsInterface_ == nullptr) {
@@ -63,21 +63,21 @@ ScreenId AbstractDisplayManager::CreateVirtualScreen(const VirtualDisplayInfo &v
}
ScreenId result = rsInterface_->CreateVirtualScreen(virtualDisplayInfo.name_, virtualDisplayInfo.width_,
virtualDisplayInfo.height_, surface, virtualDisplayInfo.displayIdToMirror_, virtualDisplayInfo.flags_);
WLOGFI("AbstractDisplayManager::CreateVirtualDisplay id: %{public}llu", result >> 32);
WLOGFI("AbstractDisplayController::CreateVirtualDisplay id: %{public}llu", result);
return result;
}
bool AbstractDisplayManager::DestroyVirtualScreen(ScreenId screenId)
bool AbstractDisplayController::DestroyVirtualScreen(ScreenId screenId)
{
if (rsInterface_ == nullptr) {
return false;
}
WLOGFI("AbstractDisplayManager::DestroyVirtualScreen");
WLOGFI("AbstractDisplayController::DestroyVirtualScreen");
rsInterface_->RemoveVirtualScreen(screenId);
return true;
}
sptr<Media::PixelMap> AbstractDisplayManager::GetScreenSnapshot(ScreenId screenId)
sptr<Media::PixelMap> AbstractDisplayController::GetScreenSnapshot(ScreenId screenId)
{
if (rsInterface_ == nullptr) {
return nullptr;
@@ -13,7 +13,23 @@
* limitations under the License.
*/
#include "monitor.h"
#include "abstract_screen.h"
namespace OHOS::Rosen {
AbstractScreen::AbstractScreen(ScreenId dmsId, ScreenId rsId)
: dmsId_(dmsId), rsId_(rsId)
{
}
AbstractScreen::~AbstractScreen()
{
}
AbstractScreenGroup::AbstractScreenGroup(ScreenId dmsId, ScreenId rsId) : AbstractScreen(dmsId, rsId)
{
}
AbstractScreenGroup::~AbstractScreenGroup()
{
}
} // namespace OHOS::Rosen
+125
View File
@@ -0,0 +1,125 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#include "abstract_screen_controller.h"
#include <screen_manager/screen_types.h>
#include <surface.h>
#include "display_manager_service.h"
#include "window_manager_hilog.h"
namespace OHOS::Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "AbstractScreenController"};
}
AbstractScreenController::AbstractScreenController(std::recursive_mutex& mutex)
: mutex_(mutex), rsInterface_(RSInterfaces::GetInstance())
{
dmsScreenCount_ = 0;
// TODO : PrepareRSScreenManger
}
AbstractScreenController::~AbstractScreenController()
{
}
std::vector<ScreenId> AbstractScreenController::GetAllScreenIds()
{
std::vector<ScreenId> tmp;
return tmp;
}
std::shared_ptr<std::vector<ScreenId>> AbstractScreenController::ConvertToRsScreenId(ScreenId dmsScreenId)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
std::shared_ptr<std::vector<ScreenId>> empty = std::make_shared<std::vector<ScreenId>>();
return empty;
}
std::shared_ptr<std::vector<ScreenId>> AbstractScreenController::ConvertToDmsScreenId(ScreenId rsScreenId)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
std::shared_ptr<std::vector<ScreenId>> empty = std::make_shared<std::vector<ScreenId>>();
return empty;
}
void AbstractScreenController::RegisterAbstractScreenCallback(sptr<AbstractScreenCallback> cb)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
abstractScreenCallback_ = cb;
}
void AbstractScreenController::PrepareRSScreenManger()
{
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
defaultScreenId_ = rsInterface_.GetDefaultScreenId();
}
rsInterface_.SetScreenChangeCallback(
std::bind(&AbstractScreenController::OnRsScreenChange, this, std::placeholders::_1, std::placeholders::_2));
}
void AbstractScreenController::OnRsScreenChange(ScreenId rsScreenId, ScreenEvent screenEvent)
{
ScreenId dmsScreenId = INVALID_SCREEN_ID;
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (screenEvent == ScreenEvent::CONNECTED) {
auto iter = rs2DmsScreenIdMap_.find(rsScreenId);
if (iter == rs2DmsScreenIdMap_.end()) {
dmsScreenId = dmsScreenCount_++;
std::shared_ptr<std::vector<ScreenId>> dmsVector = std::make_shared<std::vector<ScreenId>>();
dmsVector->push_back(dmsScreenId);
rs2DmsScreenIdMap_.insert(std::make_pair(rsScreenId, dmsVector));
std::shared_ptr<std::vector<ScreenId>> rsVector = std::make_shared<std::vector<ScreenId>>();
dmsVector->push_back(rsScreenId);
dms2RsScreenIdMap_.insert(std::make_pair(dmsScreenId, rsVector));
sptr<AbstractScreen> absScreen = new AbstractScreen(dmsScreenId, rsScreenId);
dmsScreenMap_.insert(std::make_pair(dmsScreenId, absScreen));
// TODO: rsInterface_.GetScreenActiveMode()
// TODO: rsInterface_.GetScreenSupportedModes()
AddToGroup(absScreen);
}
} else if (screenEvent == ScreenEvent::DISCONNECTED) {
WLOGI("connect screen");
} else {
WLOGE("unknow message:%{public}ud", static_cast<uint8_t>(screenEvent));
}
}
void AbstractScreenController::AddToGroup(sptr<AbstractScreen> newScreen)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = dmsScreenMap_.find(defaultScreenId_);
if (iter == dmsScreenMap_.end()) {
WLOGE("did not find default screen screenId:%{public}llu", defaultScreenId_);
AddAsFirstScreenLocked(newScreen);
} else {
sptr<AbstractScreen> defaultScreen = iter->second;
AddAsSuccedentScreenLocked(newScreen);
}
}
void AbstractScreenController::AddAsFirstScreenLocked(sptr<AbstractScreen> newScreen)
{
// TODO: Create default display
}
void AbstractScreenController::AddAsSuccedentScreenLocked(sptr<AbstractScreen> newScreen)
{
// TODO: Mirror to default screen
}
} // namespace OHOS::Rosen
+5 -5
View File
@@ -67,7 +67,7 @@ ScreenId DisplayManagerService::GetScreenIdFromDisplayId(DisplayId displayId)
DisplayId DisplayManagerService::GetDefaultDisplayId()
{
ScreenId screenId = AbstractDisplayManager::GetInstance().GetDefaultScreenId();
ScreenId screenId = AbstractDisplayController::GetInstance().GetDefaultScreenId();
WLOGFI("GetDefaultDisplayId %{public}llu", screenId);
return GetDisplayIdFromScreenId(screenId);
}
@@ -76,7 +76,7 @@ DisplayInfo DisplayManagerService::GetDisplayInfoById(DisplayId displayId)
{
DisplayInfo displayInfo;
ScreenId screenId = GetScreenIdFromDisplayId(displayId);
auto screenModeInfo = AbstractDisplayManager::GetInstance().GetScreenActiveMode(screenId);
auto screenModeInfo = AbstractDisplayController::GetInstance().GetScreenActiveMode(screenId);
displayInfo.id_ = displayId;
displayInfo.width_ = screenModeInfo.GetScreenWidth();
displayInfo.height_ = screenModeInfo.GetScreenHeight();
@@ -90,7 +90,7 @@ DisplayId DisplayManagerService::CreateVirtualDisplay(const VirtualDisplayInfo &
WLOGFI("name %{public}s, width %{public}u, height %{public}u, mirrotId %{public}llu, flags %{public}d",
virtualDisplayInfo.name_.c_str(), virtualDisplayInfo.width_, virtualDisplayInfo.height_,
virtualDisplayInfo.displayIdToMirror_, virtualDisplayInfo.flags_);
ScreenId screenId = AbstractDisplayManager::GetInstance().CreateVirtualScreen(virtualDisplayInfo, surface);
ScreenId screenId = AbstractDisplayController::GetInstance().CreateVirtualScreen(virtualDisplayInfo, surface);
return GetDisplayIdFromScreenId(screenId);
}
@@ -98,13 +98,13 @@ bool DisplayManagerService::DestroyVirtualDisplay(DisplayId displayId)
{
WLOGFI("DisplayManagerService::DestroyVirtualDisplay");
ScreenId screenId = GetScreenIdFromDisplayId(displayId);
return AbstractDisplayManager::GetInstance().DestroyVirtualScreen(screenId);
return AbstractDisplayController::GetInstance().DestroyVirtualScreen(screenId);
}
sptr<Media::PixelMap> DisplayManagerService::GetDispalySnapshot(DisplayId displayId)
{
ScreenId screenId = GetScreenIdFromDisplayId(displayId);
sptr<Media::PixelMap> screenSnapshot = AbstractDisplayManager::GetInstance().GetScreenSnapshot(screenId);
sptr<Media::PixelMap> screenSnapshot = AbstractDisplayController::GetInstance().GetScreenSnapshot(screenId);
return screenSnapshot;
}
@@ -22,7 +22,7 @@
#include <iservice_registry.h>
#include <system_ability_definition.h>
#include "abstract_display_manager.h"
#include "abstract_display_controller.h"
#include "display_manager_service.h"
#include "window_manager_hilog.h"
-19
View File
@@ -1,19 +0,0 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#include "screen.h"
namespace OHOS::Rosen {
} // namespace OHOS::Rosen
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DM_MONITOR_H
#define FOUNDATION_DM_MONITOR_H
namespace OHOS::Rosen {
class Monitor {
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DM_MONITOR_H
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DM_SCREEN_H
#define FOUNDATION_DM_SCREEN_H
#include <string>
#include <refbase.h>
#include <surface.h>
namespace OHOS::Rosen {
using ScreenId = uint64_t;
static constexpr ScreenId SCREEN_ID_INVALD = -1ULL;
struct Point {
int32_t posX_;
int32_t posY_;
};
struct VirtualScreenOption {
const std::string& name_;
uint32_t width_;
uint32_t height_;
float density_;
sptr<Surface> surface_;
int32_t flags_;
};
class Screen : public RefBase {
public:
Screen();
~Screen();
bool IsGroup() const;
ScreenId GetId() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
uint32_t GetVirtualWidth() const;
uint32_t GetVirtualHeight() const;
float GetVirtualPixelRatio() const;
sptr<Screen> GetParent() const;
private:
class Impl;
sptr<Impl> pImpl_;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DM_SCREEN_H
@@ -13,13 +13,33 @@
* limitations under the License.
*/
#ifndef FOUNDATION_DMSERVER_SCREEN_H
#define FOUNDATION_DMSERVER_SCREEN_H
#ifndef FOUNDATION_DM_SCREEN_GROUP_H
#define FOUNDATION_DM_SCREEN_GROUP_H
#include <refbase.h>
#include <vector>
#include "screen.h"
namespace OHOS::Rosen {
class Screen : public RefBase {
enum class ScreenType : uint32_t {
SCREEN_ALONE,
SCREEN_EXPAND,
SCREEN_MIRROR,
};
class ScreenGroup : public Screen {
public:
ScreenType GetType() const;
std::vector<sptr<Screen>> GetChildren() const;
std::vector<Point> GetChildrenPosition() const;
private:
ScreenGroup();
~ScreenGroup();
class Impl;
sptr<Impl> pImpl_;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DMSERVER_SCREEN_H
#endif // FOUNDATION_DM_SCREEN_GROUP_H
+50
View File
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2021 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 permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_DM_SCREEN_MANAGER_H
#define FOUNDATION_DM_SCREEN_MANAGER_H
#include <refbase.h>
#include "screen.h"
#include "screen_group.h"
#include "single_instance.h"
namespace OHOS::Rosen {
class IScreenChangeListener : public RefBase {
public:
virtual void OnCreate(ScreenId) = 0;
virtual void OnDestroy(ScreenId) = 0;
virtual void OnChange(std::vector<ScreenId>) = 0;
};
class ScreenManager : public RefBase {
DECLARE_SINGLE_INSTANCE_BASE(ScreenManager);
public:
sptr<Screen> GetScreenById(ScreenId id);
std::vector<const sptr<Screen>> GetAllScreens();
sptr<ScreenGroup> makeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoint);
sptr<ScreenGroup> makeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
sptr<Screen> createVirtualScreen(VirtualScreenOption option);
private:
ScreenManager();
~ScreenManager();
class Impl;
sptr<Impl> pImpl_;
};
} // namespace OHOS::Rosen
#endif // FOUNDATION_DM_SCREEN_MANAGER_H
+1 -1
View File
@@ -105,7 +105,7 @@ ohos_shared_library("libwm") {
"../dm/src/display.cpp",
"../dm/src/display_manager.cpp",
"../dm/src/display_manager_adapter.cpp",
"../dm/src/monitor.cpp",
"../dm/src/screen.cpp",
"../utils/src/static_call.cpp",
"src/input_transfer_station.cpp",
"src/vsync_station.cpp",
+3 -2
View File
@@ -32,13 +32,14 @@ config("libwms_config") {
ohos_shared_library("libwms") {
sources = [
"../dmserver/src/abstract_display.cpp",
"../dmserver/src/abstract_display_manager.cpp",
"../dmserver/src/abstract_display_controller.cpp",
"../dmserver/src/abstract_screen.cpp",
"../dmserver/src/abstract_screen_controller.cpp",
"../dmserver/src/display_manager_service.cpp",
"../dmserver/src/display_manager_service_inner.cpp",
"../dmserver/src/display_manager_stub.cpp",
"../dmserver/src/display_node_control.cpp",
"../dmserver/src/display_power_controller.cpp",
"../dmserver/src/screen.cpp",
"../wm/src/zidl/window_manager_agent_proxy.cpp",
"src/input_window_monitor.cpp",
"src/window_controller.cpp",