From b437cff8e6cab57f19aee9965577e0b7cc87725f Mon Sep 17 00:00:00 2001 From: fanby01 Date: Fri, 4 Feb 2022 16:59:44 +0800 Subject: [PATCH] support wide gamut for screen Change-Id: Ib03dc47aa38b1d291a684df367ad3c810a334b8b Signed-off-by: fanby01 --- dm/BUILD.gn | 1 + dm/include/display_manager_adapter.h | 8 + dm/src/display_manager_adapter.cpp | 79 ++++++++ dm/src/screen.cpp | 30 +++ dm/test/systemtest/BUILD.gn | 12 ++ dm/test/systemtest/screen_gamut_test.cpp | 112 +++++++++++ dmserver/include/display_manager_interface.h | 15 ++ dmserver/include/display_manager_proxy.h | 8 + dmserver/include/display_manager_service.h | 8 + dmserver/src/display_manager_proxy.cpp | 190 ++++++++++++++++++- dmserver/src/display_manager_service.cpp | 80 ++++++++ dmserver/src/display_manager_stub.cpp | 57 ++++++ interfaces/innerkits/dm/screen.h | 10 + utils/BUILD.gn | 2 + 14 files changed, 610 insertions(+), 2 deletions(-) create mode 100644 dm/test/systemtest/screen_gamut_test.cpp diff --git a/dm/BUILD.gn b/dm/BUILD.gn index 4f14b5c0..a7a9caf5 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("libdm") { public_configs = [ ":libdm_public_config" ] deps = [ + "//foundation/graphic/standard/rosen/modules/render_service_base:librender_service_base", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", "//foundation/windowmanager/utils:libwmutil", ] diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index fa3ffa52..c81d28f8 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -43,6 +43,14 @@ public: virtual DMError DestroyVirtualScreen(ScreenId screenId); virtual std::shared_ptr GetDisplaySnapshot(DisplayId displayId); + // colorspace, gamut + virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts); + virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut); + virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx); + virtual DMError GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap); + virtual DMError SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap); + virtual DMError SetScreenColorTransform(ScreenId screenId); + virtual bool RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type); virtual bool UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 6e000002..fdd45ddd 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -78,6 +78,85 @@ std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshot(Displ return dispalySnapshot; } +DMError DisplayManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId, + std::vector& colorGamuts) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::GetScreenSupportedColorGamuts: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts); + return ret; +} + +DMError DisplayManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::GetScreenColorGamut: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut); + return ret; +} + +DMError DisplayManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::SetScreenColorGamut: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx); + return ret; +} + +DMError DisplayManagerAdapter::GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::GetScreenGamutsMap: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->GetScreenGamutsMap(screenId, gamutMap); + return ret; +} + +DMError DisplayManagerAdapter::SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::SetScreenGamutsMap: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->SetScreenGamutsMap(screenId, gamutMap); + return ret; +} + +DMError DisplayManagerAdapter::SetScreenColorTransform(ScreenId screenId) +{ + std::lock_guard lock(mutex_); + + if (!InitDMSProxyLocked()) { + WLOGFE("displayManagerAdapter::SetScreenColorTransform: InitDMSProxyLocked failed!"); + return DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED; + } + + DMError ret = displayManagerServiceProxy_->SetScreenColorTransform(screenId); + return ret; +} + ScreenId DisplayManagerAdapter::CreateVirtualScreen(VirtualScreenOption option) { if (!InitDMSProxyLocked()) { diff --git a/dm/src/screen.cpp b/dm/src/screen.cpp index bfd9c5fd..d98e6b34 100644 --- a/dm/src/screen.cpp +++ b/dm/src/screen.cpp @@ -116,6 +116,36 @@ bool Screen::RequestRotation(Rotation rotation) return false; } +DMError Screen::GetScreenSupportedColorGamuts(std::vector& colorGamuts) const +{ + return SingletonContainer::Get().GetScreenSupportedColorGamuts(pImpl_->id_, colorGamuts); +} + +DMError Screen::GetScreenColorGamut(ScreenColorGamut& colorGamut) const +{ + return SingletonContainer::Get().GetScreenColorGamut(pImpl_->id_, colorGamut); +} + +DMError Screen::SetScreenColorGamut(int32_t colorGamutIdx) +{ + return SingletonContainer::Get().SetScreenColorGamut(pImpl_->id_, colorGamutIdx); +} + +DMError Screen::GetScreenGamutsMap(ScreenGamutMap& gamutMap) const +{ + return SingletonContainer::Get().GetScreenGamutsMap(pImpl_->id_, gamutMap); +} + +DMError Screen::SetScreenGamutsMap(ScreenGamutMap gamutMap) +{ + return SingletonContainer::Get().SetScreenGamutsMap(pImpl_->id_, gamutMap); +} + +DMError Screen::SetScreenColorTransform() +{ + return SingletonContainer::Get().SetScreenColorTransform(pImpl_->id_); +} + ScreenId Screen::GetParentId() const { return pImpl_->parent_; diff --git a/dm/test/systemtest/BUILD.gn b/dm/test/systemtest/BUILD.gn index baaf7cb5..dfb83a60 100644 --- a/dm/test/systemtest/BUILD.gn +++ b/dm/test/systemtest/BUILD.gn @@ -21,6 +21,7 @@ group("systemtest") { deps = [ ":dm_display_minimal_test", ":dm_display_power_test", + ":dm_screen_gamut_test", ":dm_screen_manager_test", ":dm_screenshot_cmd_test", ":dm_screenshot_test", @@ -80,6 +81,17 @@ ohos_systemtest("dm_screen_manager_test") { ## SystemTest dm_screen_manager_test }}} +## SystemTest dm_screen_gamut_test {{{ +ohos_systemtest("dm_screen_gamut_test") { + module_out_path = module_out_path + + sources = [ "screen_gamut_test.cpp" ] + + deps = [ ":dm_systemtest_common" ] +} + +## SystemTest dm_screen_gamut_test }}} + ## Build dm_systemtest_common.a {{{ config("dm_systemtest_common_public_config") { include_dirs = [ diff --git a/dm/test/systemtest/screen_gamut_test.cpp b/dm/test/systemtest/screen_gamut_test.cpp new file mode 100644 index 00000000..a9aa962c --- /dev/null +++ b/dm/test/systemtest/screen_gamut_test.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// gtest +#include +#include "dm_common.h" +#include "screen_manager.h" +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class ScreenGamutTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; + static sptr defaultScreen_; +}; + +sptr ScreenGamutTest::defaultScreen_ = nullptr; + +void ScreenGamutTest::SetUpTestCase() +{ + auto screens = ScreenManager::GetInstance().GetAllScreens(); + if (screens.size() > 0) { + defaultScreen_ = screens[0]; + } +} + +void ScreenGamutTest::TearDownTestCase() +{ + defaultScreen_ = nullptr; +} + +void ScreenGamutTest::SetUp() +{ +} + +void ScreenGamutTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: ScreenGamut01 + * @tc.desc: gamut + * @tc.type: FUNC + */ +HWTEST_F(ScreenGamutTest, ScreenGamut01, Function | MediumTest | Level1) +{ + ASSERT_NE(defaultScreen_, nullptr); + DMError ret; + std::vector colorGamuts; + ret = defaultScreen_->GetScreenSupportedColorGamuts(colorGamuts); + ASSERT_EQ(ret, DMError::DM_OK); + + ScreenColorGamut colorGamut; + ret = defaultScreen_->GetScreenColorGamut(colorGamut); + ASSERT_EQ(ret, DMError::DM_OK); + + ret = defaultScreen_->SetScreenColorGamut(0); + ASSERT_EQ(ret, DMError::DM_OK); +} + +/** + * @tc.name: ScreenGamut02 + * @tc.desc: gamut + * @tc.type: FUNC + */ +HWTEST_F(ScreenGamutTest, ScreenGamut02, Function | MediumTest | Level1) +{ + ASSERT_NE(defaultScreen_, nullptr); + DMError ret; + ScreenGamutMap gamutMap; + + ret = defaultScreen_->GetScreenGamutsMap(gamutMap); + ASSERT_EQ(ret, DMError::DM_OK); + + ret = defaultScreen_->SetScreenGamutsMap(gamutMap); + ASSERT_EQ(ret, DMError::DM_OK); +} + +/** + * @tc.name: ScreenGamut03 + * @tc.desc: gamut + * @tc.type: FUNC + */ +HWTEST_F(ScreenGamutTest, ScreenGamut03, Function | MediumTest | Level1) +{ + ASSERT_NE(defaultScreen_, nullptr); + DMError ret; + + ret = defaultScreen_->SetScreenColorTransform(); + ASSERT_EQ(ret, DMError::DM_OK); +} +} +} // namespace Rosen +} // namespace OHOS diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index f3e2b764..d2b6a007 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -55,6 +55,13 @@ public: TRANS_ID_SCREENGROUP_BASE = 1100, TRANS_ID_SCREEN_MAKE_MIRROR = TRANS_ID_SCREENGROUP_BASE, TRANS_ID_SCREEN_MAKE_EXPAND, + TRANS_ID_SCREEN_GAMUT_BASE = 1200, + TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS = TRANS_ID_SCREEN_GAMUT_BASE, + TRANS_ID_SCREEN_GET_COLOR_GAMUT, + TRANS_ID_SCREEN_SET_COLOR_GAMUT, + TRANS_ID_SCREEN_GET_GAMUT_MAP, + TRANS_ID_SCREEN_SET_GAMUT_MAP, + TRANS_ID_SCREEN_SET_COLOR_TRANSFORM, }; virtual DisplayId GetDefaultDisplayId() = 0; @@ -64,6 +71,14 @@ public: virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0; virtual std::shared_ptr GetDispalySnapshot(DisplayId displayId) = 0; + // colorspace, gamut + virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) = 0; + virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) = 0; + virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) = 0; + virtual DMError GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) = 0; + virtual DMError SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0; + virtual DMError SetScreenColorTransform(ScreenId screenId) = 0; + virtual bool RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) = 0; virtual bool UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/dmserver/include/display_manager_proxy.h b/dmserver/include/display_manager_proxy.h index c79fb998..fd3cb2d2 100644 --- a/dmserver/include/display_manager_proxy.h +++ b/dmserver/include/display_manager_proxy.h @@ -38,6 +38,14 @@ public: DMError DestroyVirtualScreen(ScreenId screenId) override; std::shared_ptr GetDispalySnapshot(DisplayId displayId) override; + // colorspace, gamut + DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) override; + DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) override; + DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) override; + DMError GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) override; + DMError SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) override; + DMError SetScreenColorTransform(ScreenId screenId) override; + bool RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; bool UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index f09352c0..8c828c8c 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -49,6 +49,14 @@ public: DisplayInfo GetDisplayInfoById(DisplayId displayId) override; std::shared_ptr GetDispalySnapshot(DisplayId displayId) override; + // colorspace, gamut + DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) override; + DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) override; + DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) override; + DMError GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) override; + DMError SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) override; + DMError SetScreenColorTransform(ScreenId screenId) override; + bool RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; bool UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, diff --git a/dmserver/src/display_manager_proxy.cpp b/dmserver/src/display_manager_proxy.cpp index 3f7be109..b705dcb0 100644 --- a/dmserver/src/display_manager_proxy.cpp +++ b/dmserver/src/display_manager_proxy.cpp @@ -67,7 +67,10 @@ DisplayInfo DisplayManagerProxy::GetDisplayInfoById(DisplayId displayId) WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed"); return DisplayInfo(); } - data.WriteUint64(displayId); + if (!data.WriteUint64(displayId)) { + WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed"); + return DisplayInfo(); + } if (remote->SendRequest(TRANS_ID_GET_DISPLAY_BY_ID, data, reply, option) != ERR_NONE) { WLOGFW("GetDisplayInfoById: SendRequest failed"); return DisplayInfo(); @@ -129,7 +132,10 @@ DMError DisplayManagerProxy::DestroyVirtualScreen(ScreenId screenId) WLOGFE("DisplayManagerProxy::DestroyVirtualScreen: WriteInterfaceToken failed"); return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; } - data.WriteUint64(static_cast(screenId)); + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("DisplayManagerProxy::DestroyVirtualScreen: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } if (remote->SendRequest(TRANS_ID_DESTROY_VIRTUAL_SCREEN, data, reply, option) != ERR_NONE) { WLOGFW("DisplayManagerProxy::DestroyVirtualScreen: SendRequest failed"); return DMError::DM_ERROR_IPC_FAILED; @@ -171,6 +177,186 @@ std::shared_ptr DisplayManagerProxy::GetDispalySnapshot(Display return pixelMap; } +DMError DisplayManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId, + std::vector& colorGamuts) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + uint32_t size = reply.ReadUint32(); + colorGamuts.clear(); + for (uint32_t i = 0; i < size; i++) { + ScreenColorGamut colorGamut = static_cast(reply.ReadUint32()); + colorGamuts.push_back(colorGamut); + } + return ret; +} + +DMError DisplayManagerProxy::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::GetScreenColorGamut: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteUint64 uint64_t failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_GET_COLOR_GAMUT, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::GetScreenColorGamut: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + colorGamut = static_cast(reply.ReadUint32()); + return ret; +} + +DMError DisplayManagerProxy::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::SetScreenColorGamut: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::SetScreenColorGamut: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(colorGamutIdx)) { + WLOGFW("DisplayManagerProxy::SetScreenColorGamut: Write failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_SET_COLOR_GAMUT, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::SetScreenColorGamut: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + return ret; +} + +DMError DisplayManagerProxy::GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::GetScreenGamutsMap: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::GetScreenGamutsMap: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("DisplayManagerProxy::GetScreenGamutsMap: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_GET_GAMUT_MAP, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::GetScreenGamutsMap: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + if (ret != DMError::DM_OK) { + return ret; + } + gamutMap = static_cast(reply.ReadUint32()); + return ret; +} + +DMError DisplayManagerProxy::SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::SetScreenGamutsMap: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::SetScreenGamutsMap: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId)) || !data.WriteUint32(static_cast(gamutMap))) { + WLOGFW("DisplayManagerProxy::SetScreenGamutsMap: Writ failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_SET_GAMUT_MAP, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::SetScreenGamutsMap: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + return ret; +} + +DMError DisplayManagerProxy::SetScreenColorTransform(ScreenId screenId) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFW("DisplayManagerProxy::SetScreenColorTransform: remote is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(static_cast(screenId))) { + WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteUint64 screenId failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(TRANS_ID_SCREEN_SET_COLOR_TRANSFORM, data, reply, option) != ERR_NONE) { + WLOGFW("DisplayManagerProxy::SetScreenColorTransform: SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + DMError ret = static_cast(reply.ReadInt32()); + return ret; +} + bool DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) { diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 0f2c827f..937b4139 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -144,6 +144,86 @@ std::shared_ptr DisplayManagerService::GetDispalySnapshot(Displ return screenSnapshot; } + +DMError DisplayManagerService::GetScreenSupportedColorGamuts(ScreenId screenId, + std::vector& colorGamuts) +{ + WLOGFI("GetScreenSupportedColorGamuts::ScreenId: %{public}" PRIu64 "", screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:GetScreenSupportedColorGamuts(%" PRIu64")", screenId); + + colorGamuts.clear(); + colorGamuts.push_back(COLOR_GAMUT_NATIVE); + return DMError::DM_OK; +} + +DMError DisplayManagerService::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) +{ + WLOGFI("GetScreenColorGamut::ScreenId: %{public}" PRIu64 "", screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:GetScreenColorGamut(%" PRIu64")", screenId); + + colorGamut = COLOR_GAMUT_NATIVE; + return DMError::DM_OK; +} + +DMError DisplayManagerService::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) +{ + WLOGFI("SetScreenColorGamut::ScreenId: %{public}" PRIu64 ", colorGamutIdx %{public}d", screenId, colorGamutIdx); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:SetScreenColorGamut(%" PRIu64")", screenId); + + return DMError::DM_OK; +} + +DMError DisplayManagerService::GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap) +{ + WLOGFI("GetScreenGamutsMap::ScreenId: %{public}" PRIu64 "", screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:GetScreenGamutsMap(%" PRIu64")", screenId); + + gamutMap = GAMUT_MAP_CONSTANT; + return DMError::DM_OK; +} + +DMError DisplayManagerService::SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap) +{ + WLOGFI("SetScreenGamutsMap::ScreenId: %{public}" PRIu64 ", ScreenGamutMap %{public}u", + screenId, static_cast(gamutMap)); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:SetScreenGamutsMap(%" PRIu64")", screenId); + + return DMError::DM_OK; +} + +DMError DisplayManagerService::SetScreenColorTransform(ScreenId screenId) +{ + WLOGFI("SetScreenColorTransform::ScreenId: %{public}" PRIu64 "", screenId); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("DisplayManagerService: ScreenId is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + WM_SCOPED_TRACE("dms:SetScreenColorTransform(%" PRIu64")", screenId); + + return DMError::DM_OK; +} + + void DisplayManagerService::OnStop() { WLOGFI("ready to stop display service."); diff --git a/dmserver/src/display_manager_stub.cpp b/dmserver/src/display_manager_stub.cpp index 189027a5..43c5f3c8 100644 --- a/dmserver/src/display_manager_stub.cpp +++ b/dmserver/src/display_manager_stub.cpp @@ -194,6 +194,63 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, reply.WriteBool(res); break; } + case TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS: { + ScreenId screenId = static_cast(data.ReadUint64()); + std::vector colorGamuts; + DMError ret = GetScreenSupportedColorGamuts(screenId, colorGamuts); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + uint32_t size = colorGamuts.size(); + reply.WriteUint32(size); + for (uint32_t i = 0; i < size; i++) { + reply.WriteUint32(static_cast(colorGamuts[i])); + } + break; + } + case TRANS_ID_SCREEN_GET_COLOR_GAMUT: { + ScreenId screenId = static_cast(data.ReadUint64()); + ScreenColorGamut colorGamut; + DMError ret = GetScreenColorGamut(screenId, colorGamut); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + reply.WriteUint32(static_cast(colorGamut)); + break; + } + case TRANS_ID_SCREEN_SET_COLOR_GAMUT: { + ScreenId screenId = static_cast(data.ReadUint64()); + int32_t colorGamutIdx = data.ReadInt32(); + DMError ret = SetScreenColorGamut(screenId, colorGamutIdx); + reply.WriteInt32(static_cast(ret)); + break; + } + case TRANS_ID_SCREEN_GET_GAMUT_MAP: { + ScreenId screenId = static_cast(data.ReadUint64()); + ScreenGamutMap gamutMap; + DMError ret = GetScreenGamutsMap(screenId, gamutMap); + reply.WriteInt32(static_cast(ret)); + if (ret != DMError::DM_OK) { + break; + } + reply.WriteInt32(static_cast(gamutMap)); + break; + } + case TRANS_ID_SCREEN_SET_GAMUT_MAP: { + ScreenId screenId = static_cast(data.ReadUint64()); + ScreenGamutMap gamutMap = static_cast(data.ReadUint32()); + DMError ret = SetScreenGamutsMap(screenId, gamutMap); + reply.WriteInt32(static_cast(ret)); + break; + } + case TRANS_ID_SCREEN_SET_COLOR_TRANSFORM: { + ScreenId screenId = static_cast(data.ReadUint64()); + DMError ret = SetScreenColorTransform(screenId); + reply.WriteInt32(static_cast(ret)); + break; + } default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); diff --git a/interfaces/innerkits/dm/screen.h b/interfaces/innerkits/dm/screen.h index 4d0ab1d3..cee8f44d 100644 --- a/interfaces/innerkits/dm/screen.h +++ b/interfaces/innerkits/dm/screen.h @@ -17,9 +17,11 @@ #define FOUNDATION_DM_SCREEN_H #include +#include #include #include +#include #include "dm_common.h" @@ -66,6 +68,14 @@ public: std::vector> GetSupportedModes() const; bool SetScreenActiveMode(uint32_t modeId); + // colorspace, gamut + DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts) const; + DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const; + DMError SetScreenColorGamut(int32_t colorGamutIdx); + DMError GetScreenGamutsMap(ScreenGamutMap& gamutMap) const; + DMError SetScreenGamutsMap(ScreenGamutMap gamutMap); + DMError SetScreenColorTransform(); + private: class Impl; sptr pImpl_; diff --git a/utils/BUILD.gn b/utils/BUILD.gn index d187d990..cd42616a 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -42,6 +42,8 @@ ohos_shared_library("libwmutil") { public_configs = [ ":libwmutil_public_config" ] + deps = [ "//foundation/graphic/standard/rosen/modules/render_service_base:librender_service_base" ] + external_deps = [ "bytrace_standard:bytrace_core", "graphic_standard:surface",