Commit 3a94be9d authored by Jao-ke Chin-Lee's avatar Jao-ke Chin-Lee Committed by Commit Bot

[ui/display] Use native color space for SDR content.

As part fixing washed out colors due to changes to a
combination of chromaticity and luminosity changes,
color spaces were pinned to sRGB for SDR content instead
of using the full native color space to boost saturation.

Now that other fixes have stabilized the situation, use
the native color space.

Bug: b:158126931
Change-Id: I57140d31897a3aaf5d8a4debeff99e4db5ea76d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415269
Commit-Queue: Jao-ke Chin-Lee <jchinlee@chromium.org>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808507}
parent 6d6f4de1
......@@ -89,20 +89,30 @@ gfx::DisplayColorSpaces FillDisplayColorSpaces(
DisplaySnapshot::PrimaryFormat());
}
// TODO(b/158126931): |snapshot_color_space| Primaries/Transfer function
// cannot be used directly, as users prefer saturated colors to accurate ones.
// Instead, clamp at DCI-P3 and clamp at that level or with a small overshoot.
gfx::DisplayColorSpaces display_color_spaces(
gfx::ColorSpace::CreateSRGB(), DisplaySnapshot::PrimaryFormat());
const auto primary_id = snapshot_color_space.GetPrimaryID();
skcms_Matrix3x3 primary_matrix{};
if (primary_id == gfx::ColorSpace::PrimaryID::CUSTOM)
snapshot_color_space.GetPrimaryMatrix(&primary_matrix);
// Reconstruct the native colorspace with an IEC61966 2.1 transfer function
// for SDR content (matching that of sRGB).
gfx::ColorSpace sdr_color_space;
if (primary_id == gfx::ColorSpace::PrimaryID::CUSTOM) {
sdr_color_space = gfx::ColorSpace::CreateCustom(
primary_matrix, gfx::ColorSpace::TransferID::IEC61966_2_1);
} else {
sdr_color_space =
gfx::ColorSpace(primary_id, gfx::ColorSpace::TransferID::IEC61966_2_1);
}
gfx::DisplayColorSpaces display_color_spaces = gfx::DisplayColorSpaces(
sdr_color_space, DisplaySnapshot::PrimaryFormat());
if (allow_high_bit_depth && snapshot_color_space.IsHDR()) {
constexpr float kSDRJoint = 0.75;
constexpr float kHDRLevel = 4.0;
const auto primary_id = snapshot_color_space.GetPrimaryID();
gfx::ColorSpace hdr_color_space;
if (primary_id == gfx::ColorSpace::PrimaryID::CUSTOM) {
skcms_Matrix3x3 primary_matrix{};
snapshot_color_space.GetPrimaryMatrix(&primary_matrix);
hdr_color_space = gfx::ColorSpace::CreatePiecewiseHDR(
primary_id, kSDRJoint, kHDRLevel, &primary_matrix);
} else {
......
......@@ -380,6 +380,40 @@ TEST_P(DisplayChangeObserverTest, SDRDisplayColorSpaces) {
gfx::ColorSpace::TransferID::IEC61966_2_1);
}
TEST_P(DisplayChangeObserverTest, WCGDisplayColorSpaces) {
const std::unique_ptr<DisplaySnapshot> display_snapshot =
FakeDisplaySnapshot::Builder()
.SetId(123)
.SetName("AmazingFakeDisplay")
.SetNativeMode(MakeDisplayMode(1920, 1080, true, 60))
.SetColorSpace(gfx::ColorSpace::CreateDisplayP3D65())
.Build();
ui::DeviceDataManager::CreateInstance();
DisplayManager manager(nullptr);
const auto display_mode = MakeDisplayMode(1920, 1080, true, 60);
DisplayChangeObserver observer(&manager);
const ManagedDisplayInfo display_info = CreateManagedDisplayInfo(
&observer, display_snapshot.get(), display_mode.get());
EXPECT_EQ(display_info.bits_per_channel(), 8u);
const auto display_color_spaces = display_info.display_color_spaces();
EXPECT_FALSE(display_color_spaces.SupportsHDR());
EXPECT_EQ(
DisplaySnapshot::PrimaryFormat(),
display_color_spaces.GetOutputBufferFormat(gfx::ContentColorUsage::kSRGB,
/*needs_alpha=*/true));
const auto color_space = display_color_spaces.GetRasterColorSpace();
EXPECT_TRUE(color_space.IsValid());
EXPECT_EQ(color_space.GetPrimaryID(),
gfx::ColorSpace::PrimaryID::SMPTEST432_1);
EXPECT_EQ(color_space.GetTransferID(),
gfx::ColorSpace::TransferID::IEC61966_2_1);
}
#if defined(OS_CHROMEOS)
TEST_P(DisplayChangeObserverTest, HDRDisplayColorSpaces) {
// TODO(crbug.com/1012846): Remove this flag and provision when HDR is fully
......@@ -387,12 +421,13 @@ TEST_P(DisplayChangeObserverTest, HDRDisplayColorSpaces) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kUseHDRTransferFunction);
const auto display_color_space = gfx::ColorSpace::CreateHDR10(100.0f);
const std::unique_ptr<DisplaySnapshot> display_snapshot =
FakeDisplaySnapshot::Builder()
.SetId(123)
.SetName("AmazingFakeDisplay")
.SetNativeMode(MakeDisplayMode(1920, 1080, true, 60))
.SetColorSpace(gfx::ColorSpace::CreateHDR10(100.0f))
.SetColorSpace(display_color_space)
.SetBitsPerChannel(10u)
.Build();
......@@ -418,7 +453,7 @@ TEST_P(DisplayChangeObserverTest, HDRDisplayColorSpaces) {
display_color_spaces.GetOutputColorSpace(gfx::ContentColorUsage::kSRGB,
/*needs_alpha=*/true);
EXPECT_TRUE(sdr_color_space.IsValid());
EXPECT_EQ(sdr_color_space.GetPrimaryID(), gfx::ColorSpace::PrimaryID::BT709);
EXPECT_EQ(sdr_color_space.GetPrimaryID(), display_color_space.GetPrimaryID());
EXPECT_EQ(sdr_color_space.GetTransferID(),
gfx::ColorSpace::TransferID::IEC61966_2_1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment