From bb2506cb373bb895a5dd1367a8cf21340c04ecea Mon Sep 17 00:00:00 2001 From: whqwe Date: Sun, 26 Nov 2023 21:28:11 +0800 Subject: [PATCH] fix colorspace and hdr codes Signed-off-by: whqwe --- dm/src/display.cpp | 2 +- dm/src/display_manager_adapter.cpp | 18 +- dmserver/include/display_manager_proxy.h | 9 + dmserver/src/display_manager_proxy.cpp | 256 +++++++++++++++++++++++ 4 files changed, 276 insertions(+), 9 deletions(-) diff --git a/dm/src/display.cpp b/dm/src/display.cpp index 64b35efc5f..ebb7f54fb5 100644 --- a/dm/src/display.cpp +++ b/dm/src/display.cpp @@ -208,7 +208,7 @@ DMError Display::GetSupportedHDRFormats(std::vector& hdrFormats) const DMError Display::GetSupportedColorSpaces(std::vector& colorSpaces) const { - return SingletonContainer::Get().GetSupportedHDRFormats(GetScreenId(), colorSpaces); + return SingletonContainer::Get().GetSupportedColorSpaces(GetScreenId(), colorSpaces); } } // namespace OHOS::Rosen diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 534baa1572..a393564348 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -112,14 +112,14 @@ DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId) DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::GetPixelFormat"); return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat); } DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::SetPixelFormat"); return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat); } @@ -127,21 +127,21 @@ DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats"); return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats); } DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::GetScreenHDRFormat"); return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat); } DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::SetScreenHDRFormat"); return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx); } @@ -149,7 +149,7 @@ DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces"); return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces); } @@ -157,7 +157,7 @@ DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::GetScreenColorSpace"); return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace); } @@ -165,7 +165,7 @@ DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - + WLOGFI("ScreenManagerAdapter::SetScreenColorSpace"); return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace); } @@ -177,6 +177,7 @@ DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vec for (auto value : hdrFormatsVec) { hdrFormats.push_back(static_cast(value)); } + WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast(ret)); return ret; } @@ -188,6 +189,7 @@ DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::ve for (auto value : colorSpacesVec) { colorSpaces.push_back(static_cast(value)); } + WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast(ret)); return ret; } diff --git a/dmserver/include/display_manager_proxy.h b/dmserver/include/display_manager_proxy.h index 51d38134f6..2db07a6db8 100644 --- a/dmserver/include/display_manager_proxy.h +++ b/dmserver/include/display_manager_proxy.h @@ -54,6 +54,15 @@ public: DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override; DMError SetScreenColorTransform(ScreenId screenId) override; + DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) override; + DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) override; + DMError GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) override; + DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) override; + DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) override; + DMError GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces) override; + DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) override; + DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) override; + DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/dmserver/src/display_manager_proxy.cpp b/dmserver/src/display_manager_proxy.cpp index 45c298cd4b..6e9708d9a3 100644 --- a/dmserver/src/display_manager_proxy.cpp +++ b/dmserver/src/display_manager_proxy.cpp @@ -485,6 +485,262 @@ DMError DisplayManagerProxy::SetScreenColorTransform(ScreenId screenId) return static_cast(reply.ReadInt32()); } +DMError DisplayManagerProxy::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("GetPixelFormat: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("GetPixelFormat: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("GetPixelFormat: WriteUint64 uint64_t failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT), + data, reply, option) != ERR_NONE) { + WLOGFW("GetPixelFormat: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + pixelFormat = static_cast(reply.ReadUint32()); + return ret; +} + +DMError DisplayManagerProxy::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("SetPixelFormat: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("SetPixelFormat: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(pixelFormat)) { + WLOGFW("SetPixelFormat: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT), + data, reply, option) != ERR_NONE) { + WLOGFW("SetPixelFormat: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + +DMError DisplayManagerProxy::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("GetSupportedHDRFormats: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("GetSupportedHDRFormats: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("GetSupportedHDRFormats: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT), + data, reply, option) != ERR_NONE) { + WLOGFW("GetSupportedHDRFormats: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + MarshallingHelper::UnmarshallingVectorObj(reply, hdrFormats, + [](Parcel& parcel, ScreenHDRFormat& hdrFormat) { + uint32_t value; + bool res = parcel.ReadUint32(value); + hdrFormat = static_cast(value); + return res; + } + ); + return ret; +} + +DMError DisplayManagerProxy::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("GetScreenHDRFormat: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("GetScreenHDRFormat: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("GetScreenHDRFormat: WriteUint64 uint64_t failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_HDR_FORMAT), + data, reply, option) != ERR_NONE) { + WLOGFW("GetScreenHDRFormat: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + hdrFormat = static_cast(reply.ReadUint32()); + return ret; +} + +DMError DisplayManagerProxy::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("SetScreenHDRFormat: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("SetScreenHDRFormat: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(modeIdx)) { + WLOGFW("SetScreenHDRFormat: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT), + data, reply, option) != ERR_NONE) { + WLOGFW("SetScreenHDRFormat: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + +DMError DisplayManagerProxy::GetSupportedColorSpaces(ScreenId screenId, + std::vector& colorSpaces) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("GetSupportedColorSpaces: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("GetSupportedColorSpaces: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("GetSupportedColorSpaces: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE), + data, reply, option) != ERR_NONE) { + WLOGFW("GetSupportedColorSpaces: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + MarshallingHelper::UnmarshallingVectorObj(reply, colorSpaces, + [](Parcel& parcel, GraphicCM_ColorSpaceType& color) { + uint32_t value; + bool res = parcel.ReadUint32(value); + color = static_cast(value); + return res; + } + ); + return ret; +} + +DMError DisplayManagerProxy::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("GetScreenColorSpace: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("GetScreenColorSpace: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("GetScreenColorSpace: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_SPACE), + data, reply, option) != ERR_NONE) { + WLOGFW("GetScreenColorSpace: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + colorSpace = static_cast(reply.ReadUint32()); + return ret; +} + +DMError DisplayManagerProxy::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("SetScreenColorSpace: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("SetScreenColorSpace: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(colorSpace)) { + WLOGFW("SetScreenColorSpace: Write failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE), + data, reply, option) != ERR_NONE) { + WLOGFW("SetScreenColorSpace: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + DMError DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) { -- Gitee