Commit f59fc628 authored by Chris Blume's avatar Chris Blume Committed by Commit Bot

Set DisplayColorSpaces to use dynamically use sRGB

Currently, the display color spaces on Android are set to use sRGB
or P3 depending on wide color gamut support. When wide color gamut
is supported, we composite in P3 always.

For dynamic color gamut, we need to change compositing between
sRGB and P3 on the fly. Most of this is already done. However, the
display color spaces are all set to P3 when wide is supported. This
includes when we ask for the display color space's sRGB usage.

This CL sets the sRGB usage to sRGB when dynamic color spaces are
enabled.

Bug: 955158
Change-Id: Ied9f109f90874eb8b4d83968f81cdb48dafec499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065739
Commit-Queue: Chris Blume <cblume@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743341}
parent f06136e7
...@@ -256,6 +256,7 @@ ...@@ -256,6 +256,7 @@
#include "components/variations/variations_http_header_provider.h" #include "components/variations/variations_http_header_provider.h"
#include "components/variations/variations_switches.h" #include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "components/viz/common/features.h"
#include "components/viz/common/viz_utils.h" #include "components/viz/common/viz_utils.h"
#include "content/public/browser/browser_child_process_host.h" #include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_main_parts.h"
......
...@@ -725,13 +725,6 @@ const base::Feature kHeavyAdIntervention{"HeavyAdIntervention", ...@@ -725,13 +725,6 @@ const base::Feature kHeavyAdIntervention{"HeavyAdIntervention",
const base::Feature kHeavyAdPrivacyMitigations{ const base::Feature kHeavyAdPrivacyMitigations{
"HeavyAdPrivacyMitigations", base::FEATURE_ENABLED_BY_DEFAULT}; "HeavyAdPrivacyMitigations", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_ANDROID)
// When wide color gamut content from the web is encountered, promote our
// display to wide color gamut if supported.
const base::Feature kDynamicColorGamut{"DynamicColorGamut",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Enables or disables the FTL signaling service for CRD sessions in Kiosk mode. // Enables or disables the FTL signaling service for CRD sessions in Kiosk mode.
const base::Feature kUseFtlSignalingForCrdHostDelegate{ const base::Feature kUseFtlSignalingForCrdHostDelegate{
......
...@@ -455,11 +455,6 @@ extern const base::Feature kHeavyAdIntervention; ...@@ -455,11 +455,6 @@ extern const base::Feature kHeavyAdIntervention;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kHeavyAdPrivacyMitigations; extern const base::Feature kHeavyAdPrivacyMitigations;
#if defined(OS_ANDROID)
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kDynamicColorGamut;
#endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kUseFtlSignalingForCrdHostDelegate; extern const base::Feature kUseFtlSignalingForCrdHostDelegate;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "components/viz/common/features.h" #include "components/viz/common/features.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h" #include "build/chromecast_buildflags.h"
#include "components/viz/common/switches.h" #include "components/viz/common/switches.h"
#include "gpu/config/gpu_finch_features.h" #include "gpu/config/gpu_finch_features.h"
...@@ -43,6 +42,13 @@ const base::Feature kRecordSkPicture{"RecordSkPicture", ...@@ -43,6 +42,13 @@ const base::Feature kRecordSkPicture{"RecordSkPicture",
const base::Feature kDisableDeJelly{"DisableDeJelly", const base::Feature kDisableDeJelly{"DisableDeJelly",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
#if defined(OS_ANDROID)
// When wide color gamut content from the web is encountered, promote our
// display to wide color gamut if supported.
const base::Feature kDynamicColorGamut{"DynamicColorGamut",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif
// Viz for WebView architecture. // Viz for WebView architecture.
const base::Feature kVizForWebView{"VizForWebView", const base::Feature kVizForWebView{"VizForWebView",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
...@@ -87,6 +93,12 @@ bool IsRecordingSkPicture() { ...@@ -87,6 +93,12 @@ bool IsRecordingSkPicture() {
base::FeatureList::IsEnabled(kRecordSkPicture); base::FeatureList::IsEnabled(kRecordSkPicture);
} }
#if defined(OS_ANDROID)
bool IsDynamicColorGamutEnabled() {
return base::FeatureList::IsEnabled(kDynamicColorGamut);
}
#endif
bool IsUsingVizForWebView() { bool IsUsingVizForWebView() {
return base::FeatureList::IsEnabled(kVizForWebView); return base::FeatureList::IsEnabled(kVizForWebView);
} }
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
#ifndef COMPONENTS_VIZ_COMMON_FEATURES_H_ #ifndef COMPONENTS_VIZ_COMMON_FEATURES_H_
#define COMPONENTS_VIZ_COMMON_FEATURES_H_ #define COMPONENTS_VIZ_COMMON_FEATURES_H_
#include "base/feature_list.h"
#include "build/build_config.h"
#include "components/viz/common/viz_common_export.h" #include "components/viz/common/viz_common_export.h"
#include "base/feature_list.h"
namespace features { namespace features {
...@@ -15,6 +16,9 @@ VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaForGLReadback; ...@@ -15,6 +16,9 @@ VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaForGLReadback;
VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaRenderer; VIZ_COMMON_EXPORT extern const base::Feature kUseSkiaRenderer;
VIZ_COMMON_EXPORT extern const base::Feature kRecordSkPicture; VIZ_COMMON_EXPORT extern const base::Feature kRecordSkPicture;
VIZ_COMMON_EXPORT extern const base::Feature kDisableDeJelly; VIZ_COMMON_EXPORT extern const base::Feature kDisableDeJelly;
#if defined(OS_ANDROID)
VIZ_COMMON_EXPORT extern const base::Feature kDynamicColorGamut;
#endif
VIZ_COMMON_EXPORT extern const base::Feature kVizForWebView; VIZ_COMMON_EXPORT extern const base::Feature kVizForWebView;
VIZ_COMMON_EXPORT extern const base::Feature kVizFrameSubmissionForWebView; VIZ_COMMON_EXPORT extern const base::Feature kVizFrameSubmissionForWebView;
VIZ_COMMON_EXPORT extern const base::Feature kUsePreferredIntervalForVideo; VIZ_COMMON_EXPORT extern const base::Feature kUsePreferredIntervalForVideo;
...@@ -24,6 +28,9 @@ VIZ_COMMON_EXPORT bool IsVizHitTestingDebugEnabled(); ...@@ -24,6 +28,9 @@ VIZ_COMMON_EXPORT bool IsVizHitTestingDebugEnabled();
VIZ_COMMON_EXPORT bool IsUsingSkiaForGLReadback(); VIZ_COMMON_EXPORT bool IsUsingSkiaForGLReadback();
VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer(); VIZ_COMMON_EXPORT bool IsUsingSkiaRenderer();
VIZ_COMMON_EXPORT bool IsRecordingSkPicture(); VIZ_COMMON_EXPORT bool IsRecordingSkPicture();
#if defined(OS_ANDROID)
VIZ_COMMON_EXPORT bool IsDynamicColorGamutEnabled();
#endif
VIZ_COMMON_EXPORT bool IsUsingVizForWebView(); VIZ_COMMON_EXPORT bool IsUsingVizForWebView();
VIZ_COMMON_EXPORT bool IsUsingVizFrameSubmissionForWebView(); VIZ_COMMON_EXPORT bool IsUsingVizFrameSubmissionForWebView();
VIZ_COMMON_EXPORT bool IsUsingPreferredIntervalForVideo(); VIZ_COMMON_EXPORT bool IsUsingPreferredIntervalForVideo();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/viz/common/features.h"
#include "ui/android/screen_android.h" #include "ui/android/screen_android.h"
#include "ui/android/ui_android_jni_headers/DisplayAndroidManager_jni.h" #include "ui/android/ui_android_jni_headers/DisplayAndroidManager_jni.h"
#include "ui/android/window_android.h" #include "ui/android/window_android.h"
...@@ -83,14 +84,22 @@ void DisplayAndroidManager::DoUpdateDisplay(display::Display* display, ...@@ -83,14 +84,22 @@ void DisplayAndroidManager::DoUpdateDisplay(display::Display* display,
if (!Display::HasForceDeviceScaleFactor()) if (!Display::HasForceDeviceScaleFactor())
display->set_device_scale_factor(dipScale); display->set_device_scale_factor(dipScale);
// TODO: Devices that should dynamically switch between sRGB and P3 should // TODO: Low-end devices should specify RGB_565 as the buffer format for
// specify P3 for WideColorGamut and HDR. Low-end devices should specify // opaque content.
// RGB_565 as the buffer format for opaque content.
gfx::ColorSpace color_space = isWideColorGamut gfx::ColorSpace color_space = isWideColorGamut
? gfx::ColorSpace::CreateDisplayP3D65() ? gfx::ColorSpace::CreateDisplayP3D65()
: gfx::ColorSpace::CreateSRGB(); : gfx::ColorSpace::CreateSRGB();
gfx::DisplayColorSpaces display_color_spaces(color_space, gfx::DisplayColorSpaces display_color_spaces(color_space,
gfx::BufferFormat::RGBA_8888); gfx::BufferFormat::RGBA_8888);
if (isWideColorGamut && features::IsDynamicColorGamutEnabled()) {
auto srgb = gfx::ColorSpace::CreateSRGB();
display_color_spaces.SetOutputColorSpaceAndBufferFormat(
gfx::ContentColorUsage::kSRGB, true /* needs_alpha */, srgb,
gfx::BufferFormat::RGBA_8888);
display_color_spaces.SetOutputColorSpaceAndBufferFormat(
gfx::ContentColorUsage::kSRGB, false /* needs_alpha */, srgb,
gfx::BufferFormat::RGBA_8888);
}
display->set_size_in_pixels(size_in_pixels); display->set_size_in_pixels(size_in_pixels);
display->SetRotationAsDegree(rotationDegrees); display->SetRotationAsDegree(rotationDegrees);
......
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