support wide gamut for screen

Change-Id: Ib03dc47aa38b1d291a684df367ad3c810a334b8b
Signed-off-by: fanby01 <yaojian7@huawei.com>
This commit is contained in:
fanby01 2022-02-04 16:59:44 +08:00
parent 058768a089
commit 5c378a3306
14 changed files with 610 additions and 2 deletions

View File

@ -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",
]

View File

@ -43,6 +43,14 @@ public:
virtual DMError DestroyVirtualScreen(ScreenId screenId);
virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId);
// colorspace, gamut
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& 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<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type);
virtual bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,

View File

@ -78,6 +78,85 @@ std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetDisplaySnapshot(Displ
return dispalySnapshot;
}
DMError DisplayManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId,
std::vector<ScreenColorGamut>& colorGamuts)
{
std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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()) {

View File

@ -116,6 +116,36 @@ bool Screen::RequestRotation(Rotation rotation)
return false;
}
DMError Screen::GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& colorGamuts) const
{
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenSupportedColorGamuts(pImpl_->id_, colorGamuts);
}
DMError Screen::GetScreenColorGamut(ScreenColorGamut& colorGamut) const
{
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenColorGamut(pImpl_->id_, colorGamut);
}
DMError Screen::SetScreenColorGamut(int32_t colorGamutIdx)
{
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenColorGamut(pImpl_->id_, colorGamutIdx);
}
DMError Screen::GetScreenGamutsMap(ScreenGamutMap& gamutMap) const
{
return SingletonContainer::Get<DisplayManagerAdapter>().GetScreenGamutsMap(pImpl_->id_, gamutMap);
}
DMError Screen::SetScreenGamutsMap(ScreenGamutMap gamutMap)
{
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenGamutsMap(pImpl_->id_, gamutMap);
}
DMError Screen::SetScreenColorTransform()
{
return SingletonContainer::Get<DisplayManagerAdapter>().SetScreenColorTransform(pImpl_->id_);
}
ScreenId Screen::GetParentId() const
{
return pImpl_->parent_;

View File

@ -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 = [

View File

@ -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 <gtest/gtest.h>
#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<Screen> defaultScreen_;
};
sptr<Screen> 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<ScreenColorGamut> 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

View File

@ -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<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) = 0;
// colorspace, gamut
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& 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<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type) = 0;
virtual bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,

View File

@ -38,6 +38,14 @@ public:
DMError DestroyVirtualScreen(ScreenId screenId) override;
std::shared_ptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
// colorspace, gamut
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& 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<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type) override;
bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,

View File

@ -49,6 +49,14 @@ public:
DisplayInfo GetDisplayInfoById(DisplayId displayId) override;
std::shared_ptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
// colorspace, gamut
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& 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<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type) override;
bool UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,

View File

@ -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<uint64_t>(screenId));
if (!data.WriteUint64(static_cast<uint64_t>(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<Media::PixelMap> DisplayManagerProxy::GetDispalySnapshot(Display
return pixelMap;
}
DMError DisplayManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId,
std::vector<ScreenColorGamut>& colorGamuts)
{
sptr<IRemoteObject> 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<uint64_t>(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<DMError>(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<ScreenColorGamut>(reply.ReadUint32());
colorGamuts.push_back(colorGamut);
}
return ret;
}
DMError DisplayManagerProxy::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut)
{
sptr<IRemoteObject> 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<uint64_t>(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<DMError>(reply.ReadInt32());
if (ret != DMError::DM_OK) {
return ret;
}
colorGamut = static_cast<ScreenColorGamut>(reply.ReadUint32());
return ret;
}
DMError DisplayManagerProxy::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx)
{
sptr<IRemoteObject> 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<uint64_t>(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<DMError>(reply.ReadInt32());
return ret;
}
DMError DisplayManagerProxy::GetScreenGamutsMap(ScreenId screenId, ScreenGamutMap& gamutMap)
{
sptr<IRemoteObject> 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<uint64_t>(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<DMError>(reply.ReadInt32());
if (ret != DMError::DM_OK) {
return ret;
}
gamutMap = static_cast<ScreenGamutMap>(reply.ReadUint32());
return ret;
}
DMError DisplayManagerProxy::SetScreenGamutsMap(ScreenId screenId, ScreenGamutMap gamutMap)
{
sptr<IRemoteObject> 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<uint64_t>(screenId)) || !data.WriteUint32(static_cast<uint32_t>(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<DMError>(reply.ReadInt32());
return ret;
}
DMError DisplayManagerProxy::SetScreenColorTransform(ScreenId screenId)
{
sptr<IRemoteObject> 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<uint64_t>(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<DMError>(reply.ReadInt32());
return ret;
}
bool DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
DisplayManagerAgentType type)
{

View File

@ -144,6 +144,86 @@ std::shared_ptr<Media::PixelMap> DisplayManagerService::GetDispalySnapshot(Displ
return screenSnapshot;
}
DMError DisplayManagerService::GetScreenSupportedColorGamuts(ScreenId screenId,
std::vector<ScreenColorGamut>& 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<uint32_t>(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.");

View File

@ -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<ScreenId>(data.ReadUint64());
std::vector<ScreenColorGamut> colorGamuts;
DMError ret = GetScreenSupportedColorGamuts(screenId, colorGamuts);
reply.WriteInt32(static_cast<int32_t>(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<uint32_t>(colorGamuts[i]));
}
break;
}
case TRANS_ID_SCREEN_GET_COLOR_GAMUT: {
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
ScreenColorGamut colorGamut;
DMError ret = GetScreenColorGamut(screenId, colorGamut);
reply.WriteInt32(static_cast<int32_t>(ret));
if (ret != DMError::DM_OK) {
break;
}
reply.WriteUint32(static_cast<uint32_t>(colorGamut));
break;
}
case TRANS_ID_SCREEN_SET_COLOR_GAMUT: {
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
int32_t colorGamutIdx = data.ReadInt32();
DMError ret = SetScreenColorGamut(screenId, colorGamutIdx);
reply.WriteInt32(static_cast<int32_t>(ret));
break;
}
case TRANS_ID_SCREEN_GET_GAMUT_MAP: {
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
ScreenGamutMap gamutMap;
DMError ret = GetScreenGamutsMap(screenId, gamutMap);
reply.WriteInt32(static_cast<int32_t>(ret));
if (ret != DMError::DM_OK) {
break;
}
reply.WriteInt32(static_cast<uint32_t>(gamutMap));
break;
}
case TRANS_ID_SCREEN_SET_GAMUT_MAP: {
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
ScreenGamutMap gamutMap = static_cast<ScreenGamutMap>(data.ReadUint32());
DMError ret = SetScreenGamutsMap(screenId, gamutMap);
reply.WriteInt32(static_cast<int32_t>(ret));
break;
}
case TRANS_ID_SCREEN_SET_COLOR_TRANSFORM: {
ScreenId screenId = static_cast<ScreenId>(data.ReadUint64());
DMError ret = SetScreenColorTransform(screenId);
reply.WriteInt32(static_cast<int32_t>(ret));
break;
}
default:
WLOGFW("unknown transaction code");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);

View File

@ -17,9 +17,11 @@
#define FOUNDATION_DM_SCREEN_H
#include <string>
#include <vector>
#include <refbase.h>
#include <surface.h>
#include <screen_manager/screen_types.h>
#include "dm_common.h"
@ -66,6 +68,14 @@ public:
std::vector<sptr<SupportedScreenModes>> GetSupportedModes() const;
bool SetScreenActiveMode(uint32_t modeId);
// colorspace, gamut
DMError GetScreenSupportedColorGamuts(std::vector<ScreenColorGamut>& 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<Impl> pImpl_;

View File

@ -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",