mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
!2246 window_manager——Surface Refactoring step 1:separate IConsumerSurface from Surface
Merge pull request !2246 from MingZhu/lmz_remote
This commit is contained in:
commit
0d10d2ab5c
@ -124,7 +124,7 @@ DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr<Su
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
||||
WLOGFI("DisplayManagerAdapter::SetVirtualScreenSurface");
|
||||
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface);
|
||||
return displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer());
|
||||
}
|
||||
|
||||
DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
virtual ScreenId CreateVirtualScreen(VirtualScreenOption option,
|
||||
const sptr<IRemoteObject>& displayManagerAgent) = 0;
|
||||
virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) = 0;
|
||||
virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) = 0;
|
||||
virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0;
|
||||
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) = 0;
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option,
|
||||
const sptr<IRemoteObject>& displayManagerAgent) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) override;
|
||||
DMError SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
ScreenId CreateVirtualScreen(VirtualScreenOption option,
|
||||
const sptr<IRemoteObject>& displayManagerAgent) override;
|
||||
DMError DestroyVirtualScreen(ScreenId screenId) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface) override;
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
|
||||
|
@ -193,7 +193,7 @@ DMError DisplayManagerProxy::DestroyVirtualScreen(ScreenId screenId)
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
@ -209,10 +209,10 @@ DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr<Sur
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
bool res = data.WriteUint64(static_cast<uint64_t>(screenId));
|
||||
if (surface != nullptr && surface->GetProducer() != nullptr) {
|
||||
if (surface != nullptr) {
|
||||
res = res &&
|
||||
data.WriteBool(true) &&
|
||||
data.WriteRemoteObject(surface->GetProducer()->AsObject());
|
||||
data.WriteRemoteObject(surface->AsObject());
|
||||
} else {
|
||||
WLOGFW("SetVirtualScreenSurface: surface is nullptr");
|
||||
res = res && data.WriteBool(false);
|
||||
|
@ -252,13 +252,14 @@ DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId)
|
||||
return abstractScreenController_->DestroyVirtualScreen(screenId);
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr<Surface> surface)
|
||||
DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface)
|
||||
{
|
||||
WLOGFI("SetVirtualScreenSurface::ScreenId: %{public}" PRIu64 "", screenId);
|
||||
CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM);
|
||||
if (Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION) ||
|
||||
Permission::IsStartByHdcd()) {
|
||||
return abstractScreenController_->SetVirtualScreenSurface(screenId, surface);
|
||||
sptr<Surface> pPurface = Surface::CreateSurfaceAsProducer(surface);
|
||||
return abstractScreenController_->SetVirtualScreenSurface(screenId, pPurface);
|
||||
}
|
||||
WLOGFE("permission denied");
|
||||
return DMError::DM_ERROR_INVALID_CALLING;
|
||||
|
@ -93,13 +93,12 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE: {
|
||||
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
|
||||
bool isSurfaceValid = data.ReadBool();
|
||||
sptr<Surface> surface = nullptr;
|
||||
sptr<IBufferProducer> bp = nullptr;
|
||||
if (isSurfaceValid) {
|
||||
sptr<IRemoteObject> surfaceObject = data.ReadRemoteObject();
|
||||
sptr<IBufferProducer> bp = iface_cast<IBufferProducer>(surfaceObject);
|
||||
surface = Surface::CreateSurfaceAsProducer(bp);
|
||||
bp = iface_cast<IBufferProducer>(surfaceObject);
|
||||
}
|
||||
DMError result = SetVirtualScreenSurface(screenId, surface);
|
||||
DMError result = SetVirtualScreenSurface(screenId, bp);
|
||||
reply.WriteInt32(static_cast<int32_t>(result));
|
||||
break;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "display_manager_proxy.h"
|
||||
#include "iremote_object_mocker.h"
|
||||
|
||||
#include "iconsumer_surface.h"
|
||||
#include <surface.h>
|
||||
|
||||
using namespace testing;
|
||||
@ -191,12 +192,12 @@ HWTEST_F(DisplayManagerProxyTest, SetVirtualScreenSurface01, Function | SmallTes
|
||||
|
||||
auto result2 = proxy2.SetVirtualScreenSurface(0, nullptr);
|
||||
ASSERT_EQ(DMError::DM_OK, result2);
|
||||
sptr<Surface> surface = OHOS::Surface::CreateSurfaceAsConsumer();
|
||||
auto result3 = proxy2.SetVirtualScreenSurface(0, surface);
|
||||
sptr<IConsumerSurface> surface = OHOS::IConsumerSurface::Create();
|
||||
auto result3 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer());
|
||||
ASSERT_EQ(DMError::DM_OK, result3);
|
||||
|
||||
remoteMocker->sendRequestResult_ = 1;
|
||||
auto result4 = proxy2.SetVirtualScreenSurface(0, surface);
|
||||
auto result4 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer());
|
||||
ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result4);
|
||||
}
|
||||
/**
|
||||
|
@ -21,12 +21,14 @@
|
||||
#include <string>
|
||||
#include <surface.h>
|
||||
|
||||
#include "iconsumer_surface.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenManagerUtils {
|
||||
public:
|
||||
bool CreateSurface();
|
||||
|
||||
sptr<Surface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<IConsumerSurface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<Surface> psurface_ = nullptr; // producer surface
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -23,7 +23,7 @@ namespace {
|
||||
|
||||
bool ScreenManagerUtils::CreateSurface()
|
||||
{
|
||||
csurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
csurface_ = IConsumerSurface::Create();
|
||||
if (csurface_ == nullptr) {
|
||||
WLOGFE("csurface create failed");
|
||||
return false;
|
||||
|
@ -65,7 +65,7 @@ bool DisplayTestUtils::SizeEqual(const Media::Size dst, const Media::Size cur)
|
||||
|
||||
bool DisplayTestUtils::CreateSurface()
|
||||
{
|
||||
csurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
csurface_ = IConsumerSurface::Create();
|
||||
if (csurface_ == nullptr) {
|
||||
WLOGFE("csurface create failed");
|
||||
return false;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "display_info.h"
|
||||
#include "wm_common.h"
|
||||
#include "dm_common.h"
|
||||
#include "iconsumer_surface.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "unique_fd.h"
|
||||
#include "ui/rs_surface_node.h"
|
||||
@ -63,7 +64,7 @@ public:
|
||||
uint32_t defaultWidth_ = 0;
|
||||
uint32_t defaultHeight_ = 0;
|
||||
sptr<IBufferConsumerListener> listener_ = nullptr;
|
||||
sptr<Surface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<IConsumerSurface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<Surface> psurface_ = nullptr; // producer surface
|
||||
sptr<SurfaceBuffer> prevBuffer_ = nullptr;
|
||||
BufferHandle *bufferHandle_ = nullptr;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "refbase.h"
|
||||
|
||||
#include <surface.h>
|
||||
|
||||
#include "iconsumer_surface.h"
|
||||
#include "surface_reader_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -55,7 +55,7 @@ private:
|
||||
bool ProcessBuffer(const sptr<SurfaceBuffer> &buf);
|
||||
|
||||
sptr<IBufferConsumerListener> listener_ = nullptr;
|
||||
sptr<Surface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<IConsumerSurface> csurface_ = nullptr; // cosumer surface
|
||||
sptr<Surface> psurface_ = nullptr; // producer surface
|
||||
sptr<SurfaceBuffer> prevBuffer_ = nullptr;
|
||||
sptr<SurfaceReaderHandler> handler_ = nullptr;
|
||||
|
@ -44,7 +44,7 @@ SurfaceReader::~SurfaceReader()
|
||||
|
||||
bool SurfaceReader::Init()
|
||||
{
|
||||
csurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
csurface_ = IConsumerSurface::Create();
|
||||
if (csurface_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user