diff --git a/dm/src/display.cpp b/dm/src/display.cpp index 64b35efc5f332dfd620d1b1c07c17db8fe897e2b..ebb7f54fb594647083a03be57273d67afac7d3a8 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 534baa157212cd033943022bf649e51e70a54890..a393564348e773622c5d9d8fbddc4a2919c1f966 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 51d38134f6d2fbdb39359585fc244e3c5791015b..2db07a6db890491ed4f4fa654d2c026716a7e9af 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 45c298cd4b47039f731bdd937313bef01b2b45ca..6e9708d9a34ab4330d92c1e3b84454812c366e8f 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) {