mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-28 01:21:13 +00:00
commit
c3592e2190
@ -41,6 +41,7 @@ public:
|
||||
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
virtual bool RequestRotation(ScreenId screenId, Rotation rotation);
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId);
|
||||
|
||||
|
@ -206,6 +206,15 @@ DMError DisplayManagerAdapter::DestroyVirtualScreen(ScreenId screenId)
|
||||
return displayManagerServiceProxy_->DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError DisplayManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED;
|
||||
}
|
||||
WLOGFI("DisplayManagerAdapter::SetVirtualScreenSurface");
|
||||
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
|
||||
DisplayManagerAgentType type)
|
||||
{
|
||||
|
@ -195,4 +195,9 @@ DMError ScreenManager::DestroyVirtualScreen(ScreenId screenId)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError ScreenManager::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -53,6 +53,7 @@ public:
|
||||
void RegisterAbstractScreenCallback(sptr<AbstractScreenCallback> cb);
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
bool RequestRotation(ScreenId screenId, Rotation rotation);
|
||||
|
||||
void OnScreenRotate(ScreenId dmsScreenId, Rotation before, Rotation after);
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
TRANS_ID_SCREEN_BASE = 1000,
|
||||
TRANS_ID_CREATE_VIRTUAL_SCREEN = TRANS_ID_SCREEN_BASE,
|
||||
TRANS_ID_DESTROY_VIRTUAL_SCREEN,
|
||||
TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE,
|
||||
TRANS_ID_GET_SCREEN_INFO_BY_ID,
|
||||
TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID,
|
||||
TRANS_ID_SET_SCREEN_ACTIVE_MODE,
|
||||
@ -71,6 +72,7 @@ public:
|
||||
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option) = 0;
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) = 0;
|
||||
virtual bool RequestRotation(ScreenId screenId, Rotation rotation) = 0;
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) = 0;
|
||||
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
bool RequestRotation(ScreenId screenId, Rotation rotation) override;
|
||||
std::shared_ptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
|
||||
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void OnStop() override;
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
|
||||
DisplayId GetDefaultDisplayId() override;
|
||||
DisplayInfo GetDisplayInfoById(DisplayId displayId) override;
|
||||
|
@ -474,6 +474,17 @@ DMError AbstractScreenController::DestroyVirtualScreen(ScreenId screenId)
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
DMError AbstractScreenController::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
WLOGFI("AbstractScreenController::SetVirtualScreenSurface");
|
||||
int32_t res = rsInterface_.SetVirtualScreenSurface(screenId, surface);
|
||||
if (res != 0) {
|
||||
WLOGE("SetVirtualScreenSurface failed in RenderService");
|
||||
return DMError::DM_ERROR_RENDER_SERVICE_FAILED;
|
||||
}
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
bool AbstractScreenController::RequestRotation(ScreenId screenId, Rotation rotation)
|
||||
{
|
||||
WLOGD("request rotation: screen %{public}" PRIu64"", screenId);
|
||||
|
@ -143,6 +143,33 @@ DMError DisplayManagerProxy::DestroyVirtualScreen(ScreenId screenId)
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("SetVirtualScreenSurface: remote is nullptr");
|
||||
return DMError::DM_ERROR_REMOTE_CREATE_FAILED;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("SetVirtualScreenSurface: WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteUint64(static_cast<uint64_t>(screenId)) ||
|
||||
!data.WriteRemoteObject(surface->GetProducer()->AsObject())) {
|
||||
WLOGFW("SetVirtualScreenSurface: Write screenId/surface failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SetVirtualScreenSurface: SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::RequestRotation(ScreenId screenId, Rotation rotation)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
|
@ -148,6 +148,17 @@ DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId)
|
||||
return abstractScreenController_->DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
{
|
||||
WLOGFI("SetVirtualScreenSurface::ScreenId: %{public}" PRIu64 "", screenId);
|
||||
if (screenId == SCREEN_ID_INVALID) {
|
||||
WLOGFE("SetVirtualScreenSurface: virtualScreenId is invalid");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
WM_SCOPED_TRACE("dms:SetVirtualScreenSurface(%" PRIu64")", screenId);
|
||||
return abstractScreenController_->SetVirtualScreenSurface(screenId, surface);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::RequestRotation(ScreenId screenId, Rotation rotation)
|
||||
{
|
||||
WM_SCOPED_TRACE("dms:RequestRotation(%" PRIu64")", screenId);
|
||||
|
@ -77,6 +77,15 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
sptr<IRemoteObject> surfaceObject = data.ReadRemoteObject();
|
||||
sptr<IBufferProducer> bp = iface_cast<IBufferProducer>(surfaceObject);
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsProducer(bp);
|
||||
DMError result = SetVirtualScreenSurface(screenId, surface);
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_REQUEST_ROTATION: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
Rotation rotation = static_cast<Rotation>(data.ReadUint32());
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
ScreenId MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId);
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option);
|
||||
DMError DestroyVirtualScreen(ScreenId screenId);
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface);
|
||||
|
||||
private:
|
||||
ScreenManager();
|
||||
|
Loading…
Reference in New Issue
Block a user