From f7e4efcaacd5ee4bab7ca2c73d3c8ad8cdbc8524 Mon Sep 17 00:00:00 2001 From: whqwe Date: Sun, 26 Nov 2023 16:44:57 +0800 Subject: [PATCH] add support for colorspace and hdr Signed-off-by: whqwe --- dm/include/display_manager_adapter.h | 11 + dm/src/display.cpp | 10 + dm/src/display_manager_adapter.cpp | 82 ++++++ dm/src/screen.cpp | 40 +++ dmserver/include/display_manager_interface.h | 43 +++ interfaces/innerkits/dm/display.h | 16 ++ interfaces/innerkits/dm/screen.h | 61 +++++ .../kits/napi/display_runtime/js_display.cpp | 226 ++++++++++++++++ .../kits/napi/display_runtime/js_display.h | 32 +++ .../display_runtime/js_display_manager.cpp | 84 ++++++ .../session/screen/include/screen_session.h | 9 + .../session/screen/src/screen_session.cpp | 124 +++++++++ .../include/screen_session_manager.h | 9 + .../zidl/screen_session_manager_proxy.h | 9 + .../src/screen_session_manager.cpp | 108 ++++++++ .../src/zidl/screen_session_manager_proxy.cpp | 256 ++++++++++++++++++ .../src/zidl/screen_session_manager_stub.cpp | 84 ++++++ 17 files changed, 1204 insertions(+) diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index c8f2989e64..19f0c8bd61 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -126,6 +126,17 @@ public: virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap); virtual DMError SetScreenColorTransform(ScreenId screenId); + virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat); + virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat); + virtual DMError GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats); + virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat); + virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx); + virtual DMError GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces); + virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace); + virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace); + virtual DMError GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats); + virtual DMError GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces); + // unique screen virtual DMError MakeUniqueScreen(const std::vector& screenIds); private: diff --git a/dm/src/display.cpp b/dm/src/display.cpp index ebb92607a6..64b35efc5f 100644 --- a/dm/src/display.cpp +++ b/dm/src/display.cpp @@ -201,4 +201,14 @@ DMError Display::HasImmersiveWindow(bool& immersive) return SingletonContainer::Get().HasImmersiveWindow(immersive); } +DMError Display::GetSupportedHDRFormats(std::vector& hdrFormats) const +{ + return SingletonContainer::Get().GetSupportedHDRFormats(GetScreenId(), hdrFormats); +} + +DMError Display::GetSupportedColorSpaces(std::vector& colorSpaces) const +{ + return SingletonContainer::Get().GetSupportedHDRFormats(GetScreenId(), colorSpaces); +} + } // namespace OHOS::Rosen diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 83bc7fdd9a..534baa1572 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -109,6 +109,88 @@ DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId) return displayManagerServiceProxy_->SetScreenColorTransform(screenId); } +DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat); +} + +DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat); +} + +DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, + std::vector& hdrFormats) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats); +} + +DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat); +} + +DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx); +} + +DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, + std::vector& colorSpaces) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces); +} + +DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId, + GraphicCM_ColorSpaceType& colorSpace) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace); +} + +DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId, + GraphicCM_ColorSpaceType colorSpace) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + + return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace); +} + +DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + std::vector hdrFormatsVec; + DMError ret = GetSupportedHDRFormats(screenId, hdrFormatsVec); + for (auto value : hdrFormatsVec) { + hdrFormats.push_back(static_cast(value)); + } + return ret; +} + +DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + std::vector colorSpacesVec; + DMError ret = GetSupportedColorSpaces(screenId, colorSpacesVec); + for (auto value : colorSpacesVec) { + colorSpaces.push_back(static_cast(value)); + } + return ret; +} + ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option, const sptr& displayManagerAgent) { diff --git a/dm/src/screen.cpp b/dm/src/screen.cpp index a25780c626..b5de663595 100644 --- a/dm/src/screen.cpp +++ b/dm/src/screen.cpp @@ -156,6 +156,46 @@ DMError Screen::SetScreenColorTransform() return SingletonContainer::Get().SetScreenColorTransform(GetId()); } +DMError Screen::GetPixelFormat(GraphicPixelFormat& pixelFormat) const +{ + return SingletonContainer::Get().GetPixelFormat(GetId(), pixelFormat); +} + +DMError Screen::SetPixelFormat(GraphicPixelFormat pixelFormat) +{ + return SingletonContainer::Get().SetPixelFormat(GetId(), pixelFormat); +} + +DMError Screen::GetSupportedHDRFormats(std::vector& hdrFormats) const +{ + return SingletonContainer::Get().GetSupportedHDRFormats(GetId(), hdrFormats); +} + +DMError Screen::GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const +{ + return SingletonContainer::Get().GetScreenHDRFormat(GetId(), hdrFormat); +} + +DMError Screen::SetScreenHDRFormat(int32_t modeIdx) +{ + return SingletonContainer::Get().SetScreenHDRFormat(GetId(), modeIdx); +} + +DMError Screen::GetSupportedColorSpaces(std::vector& colorSpaces) const +{ + return SingletonContainer::Get().GetSupportedColorSpaces(GetId(), colorSpaces); +} + +DMError Screen::GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const +{ + return SingletonContainer::Get().GetScreenColorSpace(GetId(), colorSpace); +} + +DMError Screen::SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace) +{ + return SingletonContainer::Get().SetScreenColorSpace(GetId(), colorSpace); +} + ScreenId Screen::GetParentId() const { UpdateScreenInfo(); diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index 2818420f4b..47d84a0591 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -77,6 +77,14 @@ public: TRANS_ID_SCREEN_GET_GAMUT_MAP, TRANS_ID_SCREEN_SET_GAMUT_MAP, TRANS_ID_SCREEN_SET_COLOR_TRANSFORM, + TRANS_ID_SCREEN_GET_PIXEL_FORMAT, + TRANS_ID_SCREEN_SET_PIXEL_FORMAT, + TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT, + TRANS_ID_SCREEN_GET_HDR_FORMAT, + TRANS_ID_SCREEN_SET_HDR_FORMAT, + TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE, + TRANS_ID_SCREEN_GET_COLOR_SPACE, + TRANS_ID_SCREEN_SET_COLOR_SPACE, TRANS_ID_IS_SCREEN_ROTATION_LOCKED, TRANS_ID_SET_SCREEN_ROTATION_LOCKED, TRANS_ID_HAS_PRIVATE_WINDOW, @@ -133,6 +141,41 @@ public: virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0; virtual DMError SetScreenColorTransform(ScreenId screenId) = 0; + virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError GetSupportedHDRFormats(ScreenId screenId, + std::vector& hdrFormats) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError GetSupportedColorSpaces(ScreenId screenId, + std::vector& colorSpaces) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) = 0; virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/interfaces/innerkits/dm/display.h b/interfaces/innerkits/dm/display.h index f18942a72f..faccece523 100644 --- a/interfaces/innerkits/dm/display.h +++ b/interfaces/innerkits/dm/display.h @@ -143,6 +143,22 @@ public: */ DMError HasImmersiveWindow(bool& immersive); + /** + * @brief Get the supported HDR format of the screen. + * + * @param colorSpaces Supported HDR format of the screen. + * @return DM_OK means get success, others means get failed. + */ + DMError GetSupportedHDRFormats(std::vector& hdrFormats) const; + + /** + * @brief Get the supported color space of the screen. + * + * @param colorSpaces Supported color space of the screen. + * @return DM_OK means get success, others means get failed. + */ + DMError GetSupportedColorSpaces(std::vector& colorSpaces) const; + protected: // No more methods or variables can be defined here. Display(const std::string& name, sptr info); diff --git a/interfaces/innerkits/dm/screen.h b/interfaces/innerkits/dm/screen.h index 145e774c7e..156bc99457 100644 --- a/interfaces/innerkits/dm/screen.h +++ b/interfaces/innerkits/dm/screen.h @@ -242,6 +242,67 @@ public: * @return DM_OK means set success, others means set failed. */ DMError SetResolution(uint32_t width, uint32_t height, uint32_t dpi) const; + + /** + * @brief Get the pixel format of the screen. + * + * @return DM_OK means set success, others means set failed. + */ + DMError GetPixelFormat(GraphicPixelFormat& pixelFormat) const; + + /** + * @brief Set the color gamut of the screen. + * + * @return DM_OK means set success, others means set failed. + */ + DMError SetPixelFormat(GraphicPixelFormat pixelFormat); + + /** + * @brief Get the supported HDR format of the screen. + * + * @param colorSpaces Supported HDR format of the screen. + * @return DM_OK means get success, others means get failed. + */ + DMError GetSupportedHDRFormats(std::vector& hdrFormats) const; + + /** + * @brief Get the HDR format of the screen. + * + * @return DM_OK means set success, others means set failed. + */ + DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) const; + + /** + * @brief Set the HDR format of the screen. + * + * @return DM_OK means set success, others means set failed. + */ + DMError SetScreenHDRFormat(int32_t modeIdx); + + /** + * @brief Get the supported color space of the screen. + * + * @param colorSpaces Supported color space of the screen. + * @return DM_OK means get success, others means get failed. + */ + DMError GetSupportedColorSpaces(std::vector& colorSpaces) const; + + /** + * @brief Get the color space of the screen. + * + * @param colorSpace Color space of the screen. + * @return DM_OK means get success, others means get failed. + */ + DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) const; + + /** + * @brief Set the color space of the screen. + * + * @param colorSpace Color space of the screen. + * @return DM_OK means set success, others means set failed. + */ + DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace); + protected: // No more methods or variables can be defined here. explicit Screen(sptr info); diff --git a/interfaces/kits/napi/display_runtime/js_display.cpp b/interfaces/kits/napi/display_runtime/js_display.cpp index 6c354e82d4..14ef101349 100644 --- a/interfaces/kits/napi/display_runtime/js_display.cpp +++ b/interfaces/kits/napi/display_runtime/js_display.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "cutout_info.h" #include "display.h" @@ -38,6 +39,103 @@ namespace { { DisplayState::VR, DisplayStateMode::STATE_VR }, { DisplayState::ON_SUSPEND, DisplayStateMode::STATE_ON_SUSPEND }, }; + +using GraphicCM_ColorSpaceType = enum { + GRAPHIC_CM_COLORSPACE_NONE, + + GRAPHIC_CM_BT601_EBU_FULL = 2 | (1 << 8) | (2 << 16) | (1 << 21), // COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT601_SMPLE_C_FULL = 3 | (1 << 8) | (3 << 16) | (1 << 21), // COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT709_FULL = 1 | (1 << 8) | (1 << 16) | (1 << 21), // COLORPRIMARIES_BT709 | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT2020_HLG_FULL = 4 | (5 << 8) | (4 << 16) | (1 << 21), // COLORPRIMARIES_BT2020 | (TRANSFUNC_HLG << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT2020_PQ_FULL = 4 | (4 << 8) | (4 << 16) | (1 << 21), // COLORPRIMARIES_BT2020 | (TRANSFUNC_PQ << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + + GRAPHIC_CM_BT601_EBU_LIMIT = 2 | (1 << 8) | (2 << 16) | (2 << 21), // COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT601_SMPLE_C_LIMIT = 3 | (1 << 8) | (3 << 16) | (2 << 21), // COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT709_LIMIT = 1 | (1 << 8) | (1 << 16) | (2 << 21), // COLORPRIMARIES_BT709 | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT2020_HLG_LIMIT = 4 | (5 << 8) | (4 << 16) | (2 << 21), // COLORPRIMARIES_BT2020 | (TRANSFUNC_HLG << 8) | (MATRIX_BT2020 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT2020_PQ_LIMIT = 4 | (4 << 8) | (4 << 16) | (2 << 21), // COLORPRIMARIES_BT2020 | (TRANSFUNC_PQ << 8) | (MATRIX_BT2020 << 16) | (RANGE_LIMITED << 21) + + GRAPHIC_CM_SRGB_FULL = 1 | (2 << 8) | (3 << 16) | (1 << 21), // COLORPRIMARIES_SRGB | (TRANSFUNC_SRGB << 8) | (MATRIX_BT601_N << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_FULL = 6 | (2 << 8) | (3 << 16) | (1 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_SRGB << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_HLG_FULL = 6 | (5 << 8) | (3 << 16) | (1 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_HLG << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_PQ_FULL = 6 | (4 << 8) | (3 << 16) | (1 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_PQ << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_ADOBERGB_FULL = 23 | (6 << 8) | (0 << 16) | (1 << 21), // COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_FULL << 21) + + GRAPHIC_CM_SRGB_LIMIT = 1 | (2 << 8) | (3 << 16) | (2 << 21), // COLORPRIMARIES_SRGB | (TRANSFUNC_SRGB << 8) | (MATRIX_BT601_N << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_LIMIT = 6 | (2 << 8) | (3 << 16) | (2 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_SRGB << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_HLG_LIMIT = 6 | (5 << 8) | (3 << 16) | (2 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_HLG << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_PQ_LIMIT = 6 | (4 << 8) | (3 << 16) | (2 << 21), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_PQ << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_ADOBERGB_LIMIT = 23 | (6 << 8) | (0 << 16) | (2 << 21), // COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_LIMITED << 21) + + GRAPHIC_CM_LINEAR_SRGB = 1 | (3 << 8), // COLORPRIMARIES_SRGB | (TRANSFUNC_LINEAR << 8) + GRAPHIC_CM_LINEAR_BT709 = 1 | (3 << 8), // equal to GRAPHIC_CM_LINEAR_SRGB + GRAPHIC_CM_LINEAR_P3 = 6 | (3 << 8), // COLORPRIMARIES_P3_D65 | (TRANSFUNC_LINEAR << 8) + GRAPHIC_CM_LINEAR_BT2020 = 4 | (3 << 8), // COLORPRIMARIES_BT2020 | (TRANSFUNC_LINEAR << 8) + + GRAPHIC_CM_DISPLAY_SRGB = 1 | (2 << 8) | (3 << 16) | (1 << 21), // equal to GRAPHIC_CM_SRGB_FULL + GRAPHIC_CM_DISPLAY_P3_SRGB = 6 | (2 << 8) | (3 << 16) | (1 << 21), // equal to GRAPHIC_CM_P3_FULL + GRAPHIC_CM_DISPLAY_P3_HLG = 6 | (5 << 8) | (3 << 16) | (1 << 21), // equal to GRAPHIC_CM_P3_HLG_FULL + GRAPHIC_CM_DISPLAY_P3_PQ = 6 | (4 << 8) | (3 << 16) | (1 << 21), // equal to GRAPHIC_CM_P3_PQ_FULL + GRAPHIC_CM_DISPLAY_BT2020_SRGB = 4 | (2 << 8) | (4 << 16) | (1 << 21), // COLORPRIMARIES_BT2020 | (TRANSFUNC_SRGB << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_DISPLAY_BT2020_HLG = 4 | (5 << 8) | (4 << 16) | (1 << 21), // equal to GRAPHIC_CM_BT2020_HLG_FULL + GRAPHIC_CM_DISPLAY_BT2020_PQ = 4 | (4 << 8) | (4 << 16) | (1 << 21) // equal to GRAPHIC_CM_BT2020_PQ_FULL +}; + +typedef enum : uint32_t { + NOT_SUPPORT_HDR = 0, + VIDEO_HLG, + VIDEO_HDR10, + VIDEO_HDR_VIVID, + IMAGE_HDR_VIVID_DUAL, + IMAGE_HDR_VIVID_SINGLE, + IMAGE_HDR_ISO_DUAL, + IMAGE_HDR_ISO_SINGLE, +} ScreenHDRFormat; + +const std::map NATIVE_TO_JS_COLOR_SPACE_TYPE_MAP { + { GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE, ColorSpace::UNKNOWN }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_ADOBERGB_FULL, ColorSpace::ADOBE_RGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_ADOBERGB_LIMIT, ColorSpace::ADOBE_RGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_HLG_FULL, ColorSpace::BT2020_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_HLG_LIMIT, ColorSpace::BT2020_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_BT2020_HLG, ColorSpace::BT2020_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_PQ_FULL, ColorSpace::BT2020_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_PQ_LIMIT, ColorSpace::BT2020_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_BT2020_PQ, ColorSpace::BT2020_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_EBU_FULL, ColorSpace::BT601_EBU }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_EBU_LIMIT, ColorSpace::BT601_EBU }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_SMPLE_C_FULL, ColorSpace::BT601_SMPTE_C }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_SMPLE_C_LIMIT, ColorSpace::BT601_SMPTE_C }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT709_FULL, ColorSpace::BT709 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_BT709_LIMIT, ColorSpace::BT709 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_HLG_FULL, ColorSpace::P3_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_HLG_LIMIT, ColorSpace::P3_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_HLG, ColorSpace::P3_HLG }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_PQ_FULL, ColorSpace::P3_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_PQ_LIMIT, ColorSpace::P3_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_PQ, ColorSpace::P3_PQ }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_FULL, ColorSpace::DISPLAY_P3 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_LIMIT, ColorSpace::DISPLAY_P3 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_SRGB, ColorSpace::DISPLAY_P3 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_SRGB_FULL, ColorSpace::SRGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_SRGB_LIMIT, ColorSpace::SRGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_SRGB, ColorSpace::SRGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_SRGB, ColorSpace::LINEAR_SRGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_BT709, ColorSpace::LINEAR_SRGB }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_P3, ColorSpace::LINEAR_P3 }, + { GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_BT2020, ColorSpace::LINEAR_BT2020 }, +}; + +const std::map NATIVE_TO_JS_HDR_FORMAT_TYPE_MAP { + { ScreenHDRFormat::NOT_SUPPORT_HDR, HDRFormat::NONE }, + { ScreenHDRFormat::VIDEO_HLG, HDRFormat::VIDEO_HLG }, + { ScreenHDRFormat::VIDEO_HDR10, HDRFormat::VIDEO_HDR10 }, + { ScreenHDRFormat::VIDEO_HDR_VIVID, HDRFormat::VIDEO_HDR_VIVID }, + { ScreenHDRFormat::IMAGE_HDR_VIVID_DUAL, HDRFormat::IMAGE_HDR_VIVID_DUAL }, + { ScreenHDRFormat::IMAGE_HDR_VIVID_SINGLE, HDRFormat::IMAGE_HDR_VIVID_SINGLE }, + { ScreenHDRFormat::IMAGE_HDR_ISO_DUAL, HDRFormat::IMAGE_HDR_ISO_DUAL }, + { ScreenHDRFormat::IMAGE_HDR_ISO_SINGLE, HDRFormat::IMAGE_HDR_ISO_SINGLE }, +}; } static thread_local std::map> g_JsDisplayMap; @@ -152,6 +250,132 @@ napi_value JsDisplay::OnHasImmersiveWindow(napi_env env, napi_callback_info info return result; } +napi_value JsDisplay::GetSupportedColorSpaces(napi_env env, napi_callback_info info) +{ + WLOGI("GetSupportedColorSpaces is called"); + JsDisplay* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetSupportedColorSpaces(env, info) : nullptr; +} + +static napi_value CreateJsColorSpaceArray(napi_env env, const std::vector& colorSpaces) +{ + WLOGI("JsDisplay::CreateJsColorSpaceArray is called"); + std::set nativeColorSpaces; + for (const auto colorSpace : colorSpaces) { + GraphicCM_ColorSpaceType colorSpaceValue = static_cast(colorSpace); + if (NATIVE_TO_JS_COLOR_SPACE_TYPE_MAP.count(colorSpaceValue) == 0) { + WLOGFE("Get color space name %{public}u, but not in api type", colorSpace); + napi_throw(env, CreateJsError(env, static_cast(DMError::DM_ERROR_DEVICE_NOT_SUPPORT))); + return NapiGetUndefined(env); + } + nativeColorSpaces.insert(static_cast(NATIVE_TO_JS_COLOR_SPACE_TYPE_MAP.at(colorSpaceValue))); + } + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, nativeColorSpaces.size(), &arrayValue); + if (arrayValue == nullptr) { + WLOGFE("Failed to create color space array"); + return NapiGetUndefined(env); + } + uint32_t index = 0; + for (const auto nativeColorSpace : nativeColorSpaces) { + napi_set_element(env, arrayValue, index++, CreateJsValue(env, nativeColorSpace)); + } + return arrayValue; +} + +napi_value JsDisplay::OnGetSupportedColorSpaces(napi_env env, napi_callback_info info) +{ + WLOGI("OnGetSupportedColorSpaces is called"); + NapiAsyncTask::CompleteCallback complete = + [=](napi_env env, NapiAsyncTask& task, int32_t status) { + std::vector colorSpaces; + DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(display_->GetSupportedColorSpaces(colorSpaces)); + if (ret == DmErrorCode::DM_OK) { + task.Resolve(env, CreateJsColorSpaceArray(env, colorSpaces)); + WLOGI("OnGetSupportedColorSpaces success"); + } else { + task.Reject(env, CreateJsError(env, static_cast(ret), + "JsDisplay::OnGetSupportedColorSpaces failed.")); + WLOGFE("OnGetSupportedColorSpaces failed"); + } + }; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value lastParam = nullptr; + if (argc >= ARGC_ONE && argv[ARGC_ONE - 1] != nullptr && + GetType(env, argv[ARGC_ONE - 1]) == napi_function) { + lastParam = argv[ARGC_ONE - 1]; + } + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsDisplay::OnGetSupportedColorSpaces", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsDisplay::GetSupportedHDRFormats(napi_env env, napi_callback_info info) +{ + WLOGI("GetSupportedHDRFormats is called"); + JsDisplay* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetSupportedHDRFormats(env, info) : nullptr; +} + +static napi_value CreateJsHDRFormatArray(napi_env env, const std::vector& hdrFormats) +{ + WLOGI("JsDisplay::CreateJsHDRFormatArray is called"); + std::set nativeHDRFormats; + for (const auto hdrFormat : hdrFormats) { + ScreenHDRFormat hdrFormatValue = static_cast(hdrFormat); + if (NATIVE_TO_JS_HDR_FORMAT_TYPE_MAP.count(hdrFormatValue) == 0) { + WLOGFE("Get HDR format name %{public}u, but not in api type", hdrFormat); + napi_throw(env, CreateJsError(env, static_cast(DMError::DM_ERROR_DEVICE_NOT_SUPPORT))); + return NapiGetUndefined(env); + } + nativeHDRFormats.insert(static_cast(NATIVE_TO_JS_HDR_FORMAT_TYPE_MAP.at(hdrFormatValue))); + } + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, hdrFormats.size(), &arrayValue); + if (arrayValue == nullptr) { + WLOGFE("Failed to create HDR format array"); + return NapiGetUndefined(env); + } + uint32_t index = 0; + for (const auto nativeHDRFormat : nativeHDRFormats) { + napi_set_element(env, arrayValue, index++, CreateJsValue(env, nativeHDRFormat)); + } + return arrayValue; +} + +napi_value JsDisplay::OnGetSupportedHDRFormats(napi_env env, napi_callback_info info) +{ + WLOGI("OnGetSupportedHDRFormats is called"); + NapiAsyncTask::CompleteCallback complete = + [=](napi_env env, NapiAsyncTask& task, int32_t status) { + std::vector hdrFormats; + DmErrorCode ret = DM_JS_TO_ERROR_CODE_MAP.at(display_->GetSupportedHDRFormats(hdrFormats)); + if (ret == DmErrorCode::DM_OK) { + task.Resolve(env, CreateJsHDRFormatArray(env, hdrFormats)); + WLOGI("OnGetSupportedHDRFormats success"); + } else { + task.Reject(env, CreateJsError(env, static_cast(ret), + "JsDisplay::OnGetSupportedHDRFormats failed.")); + WLOGFE("OnGetSupportedHDRFormats failed"); + } + }; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value lastParam = nullptr; + if (argc >= ARGC_ONE && argv[ARGC_ONE - 1] != nullptr && + GetType(env, argv[ARGC_ONE - 1]) == napi_function) { + lastParam = argv[ARGC_ONE - 1]; + } + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsDisplay::OnGetSupportedHDRFormats", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + std::shared_ptr FindJsDisplayObject(DisplayId displayId) { WLOGI("[NAPI]Try to find display %{public}" PRIu64" in g_JsDisplayMap", displayId); @@ -278,6 +502,8 @@ napi_value CreateJsDisplayObject(napi_env env, sptr& display) napi_wrap(env, objValue, jsDisplay.release(), JsDisplay::Finalizer, nullptr, nullptr); BindNativeFunction(env, objValue, "getCutoutInfo", "JsDisplay", JsDisplay::GetCutoutInfo); BindNativeFunction(env, objValue, "hasImmersiveWindow", "JsDisplay", JsDisplay::HasImmersiveWindow); + BindNativeFunction(env, objValue, "getSupportedColorSpaces", "JsDisplay", JsDisplay::GetSupportedColorSpaces); + BindNativeFunction(env, objValue, "getSupportedHDRFormats", "JsDisplay", JsDisplay::GetSupportedHDRFormats); std::shared_ptr jsDisplayRef; napi_ref result = nullptr; napi_create_reference(env, objValue, 1, &result); diff --git a/interfaces/kits/napi/display_runtime/js_display.h b/interfaces/kits/napi/display_runtime/js_display.h index 03d983941e..6b6247bea3 100644 --- a/interfaces/kits/napi/display_runtime/js_display.h +++ b/interfaces/kits/napi/display_runtime/js_display.h @@ -25,6 +25,34 @@ namespace OHOS { namespace Rosen { +enum class ColorSpace : uint32_t { + UNKNOWN = 0, + ADOBE_RGB = 1, + BT2020_HLG = 2, + BT2020_PQ = 3, + BT601_EBU = 4, + BT601_SMPTE_C = 5, + BT709 = 6, + P3_HLG = 7, + P3_PQ = 8, + DISPLAY_P3 = 9, + SRGB = 10, + LINEAR_SRGB = 11, + LINEAR_P3 = 12, + LINEAR_BT2020 = 13, +}; + +enum class HDRFormat : uint32_t { + NONE = 0, + VIDEO_HLG = 1, + VIDEO_HDR10 = 2, + VIDEO_HDR_VIVID = 3, + IMAGE_HDR_VIVID_DUAL = 4, + IMAGE_HDR_VIVID_SINGLE = 5, + IMAGE_HDR_ISO_DUAL = 6, + IMAGE_HDR_ISO_SINGLE = 7, +}; + std::shared_ptr FindJsDisplayObject(DisplayId displayId); napi_value CreateJsDisplayObject(napi_env env, sptr& display); napi_value CreateJsCutoutInfoObject(napi_env env, sptr cutoutInfo); @@ -41,11 +69,15 @@ public: static void Finalizer(napi_env env, void* data, void* hint); static napi_value GetCutoutInfo(napi_env env, napi_callback_info info); static napi_value HasImmersiveWindow(napi_env env, napi_callback_info info); + static napi_value GetSupportedColorSpaces(napi_env env, napi_callback_info info); + static napi_value GetSupportedHDRFormats(napi_env env, napi_callback_info info); private: sptr display_ = nullptr; napi_value OnGetCutoutInfo(napi_env env, napi_callback_info info); napi_value OnHasImmersiveWindow(napi_env env, napi_callback_info info); + napi_value OnGetSupportedColorSpaces(napi_env env, napi_callback_info info); + napi_value OnGetSupportedHDRFormats(napi_env env, napi_callback_info info); }; enum class DisplayStateMode : uint32_t { STATE_UNKNOWN = 0, diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 22eb844c37..64b03b4fe1 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -803,6 +803,88 @@ napi_value InitFoldDisplayMode(napi_env env) return objValue; } +napi_value InitColorSpace(napi_env env) +{ + WLOGI("InitColorSpace called"); + + if (env == nullptr) { + WLOGFE("env is nullptr"); + return nullptr; + } + + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + WLOGFE("Failed to get object"); + return nullptr; + } + + napi_set_named_property(env, objValue, "UNKNOWN", + CreateJsValue(env, static_cast(ColorSpace::UNKNOWN))); + napi_set_named_property(env, objValue, "ADOBE_RGB", + CreateJsValue(env, static_cast(ColorSpace::ADOBE_RGB))); + napi_set_named_property(env, objValue, "BT2020_HLG", + CreateJsValue(env, static_cast(ColorSpace::BT2020_HLG))); + napi_set_named_property(env, objValue, "BT2020_PQ", + CreateJsValue(env, static_cast(ColorSpace::BT2020_PQ))); + napi_set_named_property(env, objValue, "BT601_EBU", + CreateJsValue(env, static_cast(ColorSpace::BT601_EBU))); + napi_set_named_property(env, objValue, "BT601_SMPTE_C", + CreateJsValue(env, static_cast(ColorSpace::BT601_SMPTE_C))); + napi_set_named_property(env, objValue, "BT709", + CreateJsValue(env, static_cast(ColorSpace::BT709))); + napi_set_named_property(env, objValue, "P3_HLG", + CreateJsValue(env, static_cast(ColorSpace::P3_HLG))); + napi_set_named_property(env, objValue, "P3_PQ", + CreateJsValue(env, static_cast(ColorSpace::P3_PQ))); + napi_set_named_property(env, objValue, "DISPLAY_P3", + CreateJsValue(env, static_cast(ColorSpace::DISPLAY_P3))); + napi_set_named_property(env, objValue, "SRGB", + CreateJsValue(env, static_cast(ColorSpace::SRGB))); + napi_set_named_property(env, objValue, "LINEAR_SRGB", + CreateJsValue(env, static_cast(ColorSpace::LINEAR_SRGB))); + napi_set_named_property(env, objValue, "LINEAR_P3", + CreateJsValue(env, static_cast(ColorSpace::LINEAR_P3))); + napi_set_named_property(env, objValue, "LINEAR_BT2020", + CreateJsValue(env, static_cast(ColorSpace::LINEAR_BT2020))); + return objValue; +} + +napi_value InitHDRFormat(napi_env env) +{ + WLOGI("InitHDRFormat called"); + + if (env == nullptr) { + WLOGFE("env is nullptr"); + return nullptr; + } + + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + WLOGFE("Failed to get object"); + return nullptr; + } + + napi_set_named_property(env, objValue, "NONE", + CreateJsValue(env, static_cast(HDRFormat::NONE))); + napi_set_named_property(env, objValue, "VIDEO_HLG", + CreateJsValue(env, static_cast(HDRFormat::VIDEO_HLG))); + napi_set_named_property(env, objValue, "VIDEO_HDR10", + CreateJsValue(env, static_cast(HDRFormat::VIDEO_HDR10))); + napi_set_named_property(env, objValue, "VIDEO_HDR_VIVID", + CreateJsValue(env, static_cast(HDRFormat::VIDEO_HDR_VIVID))); + napi_set_named_property(env, objValue, "IMAGE_HDR_VIVID_DUAL", + CreateJsValue(env, static_cast(HDRFormat::IMAGE_HDR_VIVID_DUAL))); + napi_set_named_property(env, objValue, "IMAGE_HDR_VIVID_SINGLE", + CreateJsValue(env, static_cast(HDRFormat::IMAGE_HDR_VIVID_SINGLE))); + napi_set_named_property(env, objValue, "IMAGE_HDR_ISO_DUAL", + CreateJsValue(env, static_cast(HDRFormat::IMAGE_HDR_ISO_DUAL))); + napi_set_named_property(env, objValue, "IMAGE_HDR_ISO_SINGLE", + CreateJsValue(env, static_cast(HDRFormat::IMAGE_HDR_ISO_SINGLE))); + return objValue; +} + napi_value JsDisplayManagerInit(napi_env env, napi_value exportObj) { WLOGI("JsDisplayManagerInit is called"); @@ -821,6 +903,8 @@ napi_value JsDisplayManagerInit(napi_env env, napi_value exportObj) napi_set_named_property(env, exportObj, "DMError", InitDisplayError(env)); napi_set_named_property(env, exportObj, "FoldStatus", InitFoldStatus(env)); napi_set_named_property(env, exportObj, "FoldDisplayMode", InitFoldDisplayMode(env)); + napi_set_named_property(env, exportObj, "ColorSpace", InitColorSpace(env)); + napi_set_named_property(env, exportObj, "HDRFormat", InitHDRFormat(env)); const char *moduleName = "JsDisplayManager"; BindNativeFunction(env, exportObj, "getDefaultDisplay", moduleName, JsDisplayManager::GetDefaultDisplay); diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 18283e9dae..cd91403ff3 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -102,6 +102,15 @@ public: DMError SetScreenGamutMap(ScreenGamutMap gamutMap); DMError SetScreenColorTransform(); + DMError GetPixelFormat(GraphicPixelFormat& pixelFormat); + DMError SetPixelFormat(GraphicPixelFormat pixelFormat); + DMError GetSupportedHDRFormats(std::vector& hdrFormats); + DMError GetScreenHDRFormat(ScreenHDRFormat& hdrFormat); + DMError SetScreenHDRFormat(int32_t modeIdx); + DMError GetSupportedColorSpaces(std::vector& colorSpaces); + DMError GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace); + DMError SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace); + bool HasPrivateSessionForeground() const; void SetPrivateSessionForeground(bool hasPrivate); void SetDisplayBoundary(const RectF& rect, const uint32_t& offsetY); diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 9d280b68c6..a1389c0d02 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -613,6 +613,130 @@ DMError ScreenSession::SetScreenColorTransform() return DMError::DM_OK; } +DMError ScreenSession::GetPixelFormat(GraphicPixelFormat& pixelFormat) +{ + auto ret = RSInterfaces::GetInstance().GetPixelFormat(rsId_, pixelFormat); + if (ret != StatusCode::SUCCESS) { + WLOGE("GetPixelFormat fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("GetPixelFormat ok! rsId %{public}" PRIu64 ", pixelFormat %{public}u", + rsId_, static_cast(pixelFormat)); + return DMError::DM_OK; +} + +DMError ScreenSession::SetPixelFormat(GraphicPixelFormat pixelFormat) +{ + if (pixelFormat > GRAPHIC_PIXEL_FMT_VENDER_MASK) { + return DMError::DM_ERROR_INVALID_PARAM; + } + auto ret = RSInterfaces::GetInstance().SetPixelFormat(rsId_, pixelFormat); + if (ret != StatusCode::SUCCESS) { + WLOGE("SetPixelFormat fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("SetPixelFormat ok! rsId %{public}" PRIu64 ", gamutMap %{public}u", + rsId_, static_cast(pixelFormat)); + return DMError::DM_OK; +} + +DMError ScreenSession::GetSupportedHDRFormats(std::vector& hdrFormats) +{ + auto ret = RSInterfaces::GetInstance().GetScreenSupportedHDRFormats(rsId_, hdrFormats); + if (ret != StatusCode::SUCCESS) { + WLOGE("SCB: ScreenSession::GetSupportedHDRFormats fail! rsId %{public}" PRIu64 ", ret:%{public}d", + rsId_, ret); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("SCB: ScreenSession::GetSupportedHDRFormats ok! rsId %{public}" PRIu64 ", size %{public}u", + rsId_, static_cast(hdrFormats.size())); + + return DMError::DM_OK; +} + +DMError ScreenSession::GetScreenHDRFormat(ScreenHDRFormat& hdrFormat) +{ + auto ret = RSInterfaces::GetInstance().GetScreenHDRFormat(rsId_, hdrFormat); + if (ret != StatusCode::SUCCESS) { + WLOGE("GetScreenHDRFormat fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("GetScreenHDRFormat ok! rsId %{public}" PRIu64 ", colorSpace %{public}u", + rsId_, static_cast(hdrFormat)); + return DMError::DM_OK; +} + +DMError ScreenSession::SetScreenHDRFormat(int32_t modeIdx) +{ + std::vector hdrFormats; + DMError res = GetSupportedHDRFormats(hdrFormats); + if (res != DMError::DM_OK) { + WLOGE("SetScreenHDRFormat fail! rsId %{public}" PRIu64, rsId_); + return res; + } + if (modeIdx < 0 || modeIdx >= static_cast(hdrFormats.size())) { + WLOGE("SetScreenHDRFormat fail! rsId %{public}" PRIu64 " modeIdx %{public}d invalid.", + rsId_, modeIdx); + return DMError::DM_ERROR_INVALID_PARAM; + } + auto ret = RSInterfaces::GetInstance().SetScreenHDRFormat(rsId_, modeIdx); + if (ret != StatusCode::SUCCESS) { + WLOGE("SetScreenHDRFormat fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("SetScreenHDRFormat ok! rsId %{public}" PRIu64 ", modeIdx %{public}u", + rsId_, modeIdx); + return DMError::DM_OK; +} + +DMError ScreenSession::GetSupportedColorSpaces(std::vector& colorSpaces) +{ + auto ret = RSInterfaces::GetInstance().GetScreenSupportedColorSpaces(rsId_, colorSpaces); + if (ret != StatusCode::SUCCESS) { + WLOGE("SCB: ScreenSession::GetSupportedColorSpaces fail! rsId %{public}" PRIu64 ", ret:%{public}d", + rsId_, ret); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("SCB: ScreenSession::GetSupportedColorSpaces ok! rsId %{public}" PRIu64 ", size %{public}u", + rsId_, static_cast(colorSpaces.size())); + return DMError::DM_OK; +} + +DMError ScreenSession::GetScreenColorSpace(GraphicCM_ColorSpaceType& colorSpace) +{ + auto ret = RSInterfaces::GetInstance().GetScreenColorSpace(rsId_, colorSpace); + if (ret != StatusCode::SUCCESS) { + WLOGE("GetScreenColorSpace fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("GetScreenColorSpace ok! rsId %{public}" PRIu64 ", colorSpace %{public}u", + rsId_, static_cast(colorSpace)); + return DMError::DM_OK; +} + +DMError ScreenSession::SetScreenColorSpace(GraphicCM_ColorSpaceType colorSpace) +{ + std::vector colorSpaces; + DMError res = GetSupportedColorSpaces(colorSpaces); + if (res != DMError::DM_OK) { + WLOGE("SetScreenColorSpace fail! rsId %{public}" PRIu64, rsId_); + return res; + } + if (colorSpace < 0 || static_cast(colorSpace) >= static_cast(colorSpaces.size())) { + WLOGE("SetScreenColorSpace fail! rsId %{public}" PRIu64 " colorSpace %{public}d invalid.", + rsId_, colorSpace); + return DMError::DM_ERROR_INVALID_PARAM; + } + auto ret = RSInterfaces::GetInstance().SetScreenColorSpace(rsId_, colorSpace); + if (ret != StatusCode::SUCCESS) { + WLOGE("SetScreenColorSpace fail! rsId %{public}" PRIu64, rsId_); + return DMError::DM_ERROR_RENDER_SERVICE_FAILED; + } + WLOGI("SetScreenColorSpace ok! rsId %{public}" PRIu64 ", colorSpace %{public}u", + rsId_, colorSpace); + return DMError::DM_OK; +} + bool ScreenSession::HasPrivateSessionForeground() const { return hasPrivateWindowForeground_; diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 4e3c9537d0..885c8f7b11 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.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; + void DumpAllScreensInfo(std::string& dumpInfo) override; void DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo) override; diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h index 740faa8f00..4cc53e2615 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h @@ -40,6 +40,15 @@ public: virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override; virtual 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; + virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index ab4dacf064..b29b6b292d 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1228,6 +1228,114 @@ DMError ScreenSessionManager::GetScreenSupportedColorGamuts(ScreenId screenId, return screen->GetScreenSupportedColorGamuts(colorGamuts); } +DMError ScreenSessionManager::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) +{ + WLOGFI("GetPixelFormat::ScreenId: %{public}" PRIu64, screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->GetPixelFormat(pixelFormat); +} + +DMError ScreenSessionManager::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) +{ + WLOGFI("SetPixelFormat::ScreenId: %{public}" PRIu64 ", pixelFormat %{public}d", screenId, pixelFormat); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->SetPixelFormat(pixelFormat); +} + +DMError ScreenSessionManager::GetSupportedHDRFormats(ScreenId screenId, + std::vector& hdrFormats) +{ + WLOGFI("SCB: ScreenSessionManager::GetSupportedHDRFormats %{public}" PRIu64, screenId); + sptr screen = GetScreenSession(screenId); + if (screen == nullptr) { + WLOGFE("SCB: ScreenSessionManager::GetSupportedHDRFormats nullptr"); + return DMError::DM_ERROR_INVALID_PARAM; + } + return screen->GetSupportedHDRFormats(hdrFormats); +} + +DMError ScreenSessionManager::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) +{ + WLOGFI("GetScreenHDRFormat::ScreenId: %{public}" PRIu64, screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->GetScreenHDRFormat(hdrFormat); +} + +DMError ScreenSessionManager::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) +{ + WLOGFI("SetScreenHDRFormat::ScreenId: %{public}" PRIu64 ", modeIdx %{public}d", screenId, modeIdx); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->SetScreenHDRFormat(modeIdx); +} + +DMError ScreenSessionManager::GetSupportedColorSpaces(ScreenId screenId, + std::vector& colorSpaces) +{ + WLOGFI("SCB: ScreenSessionManager::GetSupportedColorSpaces %{public}" PRIu64, screenId); + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + WLOGFE("SCB: ScreenSessionManager::GetSupportedColorSpaces nullptr"); + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->GetSupportedColorSpaces(colorSpaces); +} + +DMError ScreenSessionManager::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) +{ + WLOGFI("GetScreenColorSpace::ScreenId: %{public}" PRIu64, screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->GetScreenColorSpace(colorSpace); +} + +DMError ScreenSessionManager::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) +{ + WLOGFI("SetScreenColorSpace::ScreenId: %{public}" PRIu64 ", colorSpace %{public}d", screenId, colorSpace); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return screenSession->SetScreenColorSpace(colorSpace); +} + ScreenId ScreenSessionManager::CreateVirtualScreen(VirtualScreenOption option, const sptr& displayManagerAgent) { diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index c6251065ca..e99895df3d 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -257,6 +257,262 @@ DMError ScreenSessionManagerProxy::SetScreenColorTransform(ScreenId screenId) return static_cast(reply.ReadInt32()); } +DMError ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::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 ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) { diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp index 13efd4c6e3..acaff4f949 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp @@ -362,6 +362,90 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteInt32(static_cast(ret)); break; } + case DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT: { + ScreenId screenId = static_cast(data.ReadUint64()); + GraphicPixelFormat pixelFormat; + DMError ret = GetPixelFormat(screenId, pixelFormat); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + reply.WriteInt32(static_cast(pixelFormat)); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT: { + ScreenId screenId = static_cast(data.ReadUint64()); + GraphicPixelFormat pixelFormat = static_cast(data.ReadUint32()); + DMError ret = SetPixelFormat(screenId, pixelFormat); + reply.WriteInt32(static_cast(ret)); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT: { + ScreenId screenId = static_cast(data.ReadUint64()); + std::vector hdrFormats; + DMError ret = GetSupportedHDRFormats(screenId, hdrFormats); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + MarshallingHelper::MarshallingVectorObj(reply, hdrFormats, + [](Parcel& parcel, const ScreenHDRFormat& hdrFormat) { + return parcel.WriteUint32(static_cast(hdrFormat)); + } + ); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_GET_HDR_FORMAT: { + ScreenId screenId = static_cast(data.ReadUint64()); + ScreenHDRFormat hdrFormat; + DMError ret = GetScreenHDRFormat(screenId, hdrFormat); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + reply.WriteInt32(static_cast(hdrFormat)); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT: { + ScreenId screenId = static_cast(data.ReadUint64()); + int32_t modeIdx = data.ReadInt32(); + DMError ret = SetScreenHDRFormat(screenId, modeIdx); + reply.WriteInt32(static_cast(ret)); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE: { + ScreenId screenId = static_cast(data.ReadUint64()); + std::vector colorSpaces; + DMError ret = GetSupportedColorSpaces(screenId, colorSpaces); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + MarshallingHelper::MarshallingVectorObj(reply, colorSpaces, + [](Parcel& parcel, const GraphicCM_ColorSpaceType& color) { + return parcel.WriteUint32(static_cast(color)); + } + ); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_SPACE: { + ScreenId screenId = static_cast(data.ReadUint64()); + GraphicCM_ColorSpaceType colorSpace; + DMError ret = GetScreenColorSpace(screenId, colorSpace); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + reply.WriteInt32(static_cast(colorSpace)); + break; + } + case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE: { + ScreenId screenId = static_cast(data.ReadUint64()); + GraphicCM_ColorSpaceType colorSpace = static_cast(data.ReadUint32()); + DMError ret = SetScreenColorSpace(screenId, colorSpace); + reply.WriteInt32(static_cast(ret)); + break; + } case DisplayManagerMessage::TRANS_ID_SET_ORIENTATION: { ScreenId screenId = static_cast(data.ReadUint64()); Orientation orientation = static_cast(data.ReadUint32()); -- Gitee