|
@@ -1,239 +0,0 @@
|
|
|
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
-From: Birunthan Mohanathas <[email protected]>
|
|
|
-Date: Fri, 30 Nov 2018 12:44:12 +0200
|
|
|
-Subject: disable_color_correct_rendering.patch
|
|
|
-
|
|
|
-This adds a --disable-color-correct-rendering switch. In Electron 2.0,
|
|
|
-`--disable-features=ColorCorrectRendering` could be
|
|
|
-used to make the app use the display color space (e.g. P3 on Macs)
|
|
|
-instead of color correcting to sRGB. Because color correct rendering is
|
|
|
-always enabled on Chromium 62 and later and because
|
|
|
-`--force-color-profile` has no effect on macOS, apps that need e.g. P3
|
|
|
-colors are currently stuck on Electron 2.0.
|
|
|
-
|
|
|
-This restores the functionality removed in
|
|
|
-https://chromium-review.googlesource.com/698347 in the form of the
|
|
|
-`--disable-color-correct-rendering` switch.
|
|
|
-
|
|
|
-This can be removed once web content (including WebGL) learn how
|
|
|
-to deal with color spaces. That is being tracked at
|
|
|
-https://crbug.com/634542 and https://crbug.com/711107.
|
|
|
-
|
|
|
-diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
|
|
|
-index 9066427f903cb78b75ff72f3653495c4f66028c8..41511b0d089598c505cac3b6197b0e63089eaf06 100644
|
|
|
---- a/cc/trees/layer_tree_host_impl.cc
|
|
|
-+++ b/cc/trees/layer_tree_host_impl.cc
|
|
|
-@@ -1888,6 +1888,10 @@ void LayerTreeHostImpl::SetIsLikelyToRequireADraw(
|
|
|
- TargetColorParams LayerTreeHostImpl::GetTargetColorParams(
|
|
|
- gfx::ContentColorUsage content_color_usage) const {
|
|
|
- TargetColorParams params;
|
|
|
-+ if (!settings_.enable_color_correct_rendering) {
|
|
|
-+ params.color_space = gfx::ColorSpace();
|
|
|
-+ return params;
|
|
|
-+ }
|
|
|
-
|
|
|
- // If we are likely to software composite the resource, we use sRGB because
|
|
|
- // software compositing is unable to perform color conversion.
|
|
|
-diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
|
|
|
-index e43b58e7458336f914662d026a24e774fbe647ba..68c8f235f6afb412ebc65604c7b39109d9842d23 100644
|
|
|
---- a/cc/trees/layer_tree_settings.h
|
|
|
-+++ b/cc/trees/layer_tree_settings.h
|
|
|
-@@ -101,6 +101,8 @@ class CC_EXPORT LayerTreeSettings {
|
|
|
- bool use_rgba_4444 = false;
|
|
|
- bool unpremultiply_and_dither_low_bit_depth_tiles = false;
|
|
|
-
|
|
|
-+ bool enable_color_correct_rendering = true;
|
|
|
-+
|
|
|
- // If set to true, the compositor may selectively defer image decodes to the
|
|
|
- // Image Decode Service and raster tiles without images until the decode is
|
|
|
- // ready.
|
|
|
-diff --git a/components/viz/common/display/renderer_settings.h b/components/viz/common/display/renderer_settings.h
|
|
|
-index 66564fbc928d28af97d7afaa2cfea03ce7ebc04c..cdd32d25eab50cbc2910f92eca92b9f6c8c7b5fe 100644
|
|
|
---- a/components/viz/common/display/renderer_settings.h
|
|
|
-+++ b/components/viz/common/display/renderer_settings.h
|
|
|
-@@ -24,6 +24,7 @@ class VIZ_COMMON_EXPORT RendererSettings {
|
|
|
- RendererSettings(const RendererSettings& other);
|
|
|
- ~RendererSettings();
|
|
|
-
|
|
|
-+ bool enable_color_correct_rendering = true;
|
|
|
- bool allow_antialiasing = true;
|
|
|
- bool force_antialiasing = false;
|
|
|
- bool force_blending_with_shaders = false;
|
|
|
-diff --git a/components/viz/host/renderer_settings_creation.cc b/components/viz/host/renderer_settings_creation.cc
|
|
|
-index e4deb71ea3afa1ef9d6ddac9c61f5916ff608514..d2e6854ac2aaa3cc83c0b72ebc03193b5dc54149 100644
|
|
|
---- a/components/viz/host/renderer_settings_creation.cc
|
|
|
-+++ b/components/viz/host/renderer_settings_creation.cc
|
|
|
-@@ -17,6 +17,7 @@
|
|
|
- #include "components/viz/common/features.h"
|
|
|
- #include "components/viz/common/switches.h"
|
|
|
- #include "ui/base/ui_base_switches.h"
|
|
|
-+#include "ui/gfx/switches.h"
|
|
|
-
|
|
|
- #if BUILDFLAG(IS_OZONE)
|
|
|
- #include "ui/ozone/public/ozone_platform.h"
|
|
|
-@@ -49,6 +50,8 @@ bool GetSwitchValueAsInt(const base::CommandLine* command_line,
|
|
|
- RendererSettings CreateRendererSettings() {
|
|
|
- RendererSettings renderer_settings;
|
|
|
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
-+ renderer_settings.enable_color_correct_rendering =
|
|
|
-+ !command_line->HasSwitch(switches::kDisableColorCorrectRendering);
|
|
|
- renderer_settings.partial_swap_enabled =
|
|
|
- !command_line->HasSwitch(switches::kUIDisablePartialSwap);
|
|
|
-
|
|
|
-diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
|
|
|
-index 53e23c2b791b9f8851ecac455c3adefd8fc37688..857b648acf17742e7d904ece93ee113f4dc553b6 100644
|
|
|
---- a/content/browser/gpu/gpu_process_host.cc
|
|
|
-+++ b/content/browser/gpu/gpu_process_host.cc
|
|
|
-@@ -227,6 +227,7 @@ GpuTerminationStatus ConvertToGpuTerminationStatus(
|
|
|
-
|
|
|
- // Command-line switches to propagate to the GPU process.
|
|
|
- static const char* const kSwitchNames[] = {
|
|
|
-+ switches::kDisableColorCorrectRendering,
|
|
|
- sandbox::policy::switches::kDisableSeccompFilterSandbox,
|
|
|
- sandbox::policy::switches::kGpuSandboxAllowSysVShm,
|
|
|
- sandbox::policy::switches::kGpuSandboxFailuresFatal,
|
|
|
-diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
|
|
-index 82b4a00f9c66627ef897c717a0f2e93ac0f13e08..195b147c927c1b09dc24928ec4e3755b3ee1af14 100644
|
|
|
---- a/content/browser/renderer_host/render_process_host_impl.cc
|
|
|
-+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
|
|
-@@ -3357,6 +3357,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
|
|
|
- // Propagate the following switches to the renderer command line (along
|
|
|
- // with any associated values) if present in the browser command line.
|
|
|
- static const char* const kSwitchNames[] = {
|
|
|
-+ switches::kDisableColorCorrectRendering,
|
|
|
- switches::kDisableInProcessStackTraces,
|
|
|
- sandbox::policy::switches::kDisableSeccompFilterSandbox,
|
|
|
- sandbox::policy::switches::kNoSandbox,
|
|
|
-diff --git a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
|
|
|
-index 6892376fa33d006453977c354734d880a7ef7c91..4cd7b762d5fe1c54f5b06cc0d8f50560d6431a2f 100644
|
|
|
---- a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
|
|
|
-+++ b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
|
|
|
-@@ -4,6 +4,7 @@
|
|
|
-
|
|
|
- #include "third_party/blink/renderer/platform/graphics/canvas_color_params.h"
|
|
|
-
|
|
|
-+#include "base/command_line.h"
|
|
|
- #include "cc/paint/skia_paint_canvas.h"
|
|
|
- #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
|
|
|
- #include "third_party/khronos/GLES2/gl2.h"
|
|
|
-@@ -11,6 +12,7 @@
|
|
|
- #include "third_party/khronos/GLES3/gl3.h"
|
|
|
- #include "third_party/skia/include/core/SkSurfaceProps.h"
|
|
|
- #include "ui/gfx/color_space.h"
|
|
|
-+#include "ui/gfx/switches.h"
|
|
|
-
|
|
|
- namespace blink {
|
|
|
-
|
|
|
-@@ -18,6 +20,10 @@ namespace blink {
|
|
|
- // Level 4 specification.
|
|
|
- gfx::ColorSpace PredefinedColorSpaceToGfxColorSpace(
|
|
|
- PredefinedColorSpace color_space) {
|
|
|
-+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
|
|
-+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
|
|
|
-+ return gfx::ColorSpace();
|
|
|
-+ }
|
|
|
- switch (color_space) {
|
|
|
- case PredefinedColorSpace::kSRGB:
|
|
|
- return gfx::ColorSpace::CreateSRGB();
|
|
|
-@@ -117,6 +123,11 @@ uint8_t CanvasColorParams::BytesPerPixel() const {
|
|
|
- }
|
|
|
-
|
|
|
- gfx::ColorSpace CanvasColorParams::GetStorageGfxColorSpace() const {
|
|
|
-+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
|
|
-+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
|
|
|
-+ return gfx::ColorSpace();
|
|
|
-+ }
|
|
|
-+
|
|
|
- return PredefinedColorSpaceToGfxColorSpace(color_space_);
|
|
|
- }
|
|
|
-
|
|
|
-diff --git a/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc b/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc
|
|
|
-index ab5742a30a9d8319ec4596bb99313ea05841e316..5ffc2a38f66f3ab2c82102e996f8e9314da1286e 100644
|
|
|
---- a/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc
|
|
|
-+++ b/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc
|
|
|
-@@ -30,6 +30,7 @@
|
|
|
- #include "third_party/blink/renderer/platform/web_test_support.h"
|
|
|
- #include "ui/base/ui_base_features.h"
|
|
|
- #include "ui/base/ui_base_switches.h"
|
|
|
-+#include "ui/gfx/switches.h"
|
|
|
- #include "ui/native_theme/native_theme_features.h"
|
|
|
- #include "ui/native_theme/overlay_scrollbar_constants_aura.h"
|
|
|
-
|
|
|
-@@ -266,6 +267,9 @@ cc::LayerTreeSettings GenerateLayerTreeSettings(
|
|
|
- settings.main_frame_before_activation_enabled =
|
|
|
- cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation);
|
|
|
-
|
|
|
-+ settings.enable_color_correct_rendering =
|
|
|
-+ !cmd.HasSwitch(::switches::kDisableColorCorrectRendering);
|
|
|
-+
|
|
|
- // Checkerimaging is not supported for synchronous single-threaded mode, which
|
|
|
- // is what the renderer uses if its not threaded.
|
|
|
- settings.enable_checker_imaging =
|
|
|
-diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
|
|
|
-index 8a4e2f567831f5a295346062302470d2705ad9a4..2f9d13f03fc943342c156b676a7244348943d85f 100644
|
|
|
---- a/ui/gfx/mac/io_surface.cc
|
|
|
-+++ b/ui/gfx/mac/io_surface.cc
|
|
|
-@@ -21,6 +21,7 @@
|
|
|
- #include "ui/gfx/color_space.h"
|
|
|
- #include "ui/gfx/icc_profile.h"
|
|
|
- #include "ui/gfx/mac/color_space_util.h"
|
|
|
-+#include "ui/gfx/switches.h"
|
|
|
-
|
|
|
- namespace gfx {
|
|
|
-
|
|
|
-@@ -147,6 +148,14 @@ void IOSurfaceMachPortTraits::Release(mach_port_t port) {
|
|
|
- // Common method used by IOSurfaceSetColorSpace and IOSurfaceCanSetColorSpace.
|
|
|
- bool IOSurfaceSetColorSpace(IOSurfaceRef io_surface,
|
|
|
- const ColorSpace& color_space) {
|
|
|
-+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
|
|
-+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
|
|
|
-+ base::apple::ScopedCFTypeRef<CFDataRef> system_icc(
|
|
|
-+ CGColorSpaceCopyICCData(base::mac::GetSystemColorSpace()));
|
|
|
-+ IOSurfaceSetValue(io_surface, CFSTR("IOSurfaceColorSpace"), system_icc.get());
|
|
|
-+ return true;
|
|
|
-+ }
|
|
|
-+
|
|
|
- // Allow but ignore invalid color spaces.
|
|
|
- if (!color_space.IsValid())
|
|
|
- return true;
|
|
|
-@@ -342,6 +351,15 @@ base::apple::ScopedCFTypeRef<IOSurfaceRef> CreateIOSurface(
|
|
|
- DCHECK_EQ(kIOReturnSuccess, r);
|
|
|
- }
|
|
|
-
|
|
|
-+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
|
|
-+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
|
|
|
-+ CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
|
|
|
-+ base::apple::ScopedCFTypeRef<CFDataRef> color_space_icc(
|
|
|
-+ CGColorSpaceCopyICCData(color_space));
|
|
|
-+ IOSurfaceSetValue(surface.get(), CFSTR("IOSurfaceColorSpace"), color_space_icc.get());
|
|
|
-+ return surface;
|
|
|
-+ }
|
|
|
-+
|
|
|
- // Ensure that all IOSurfaces start as sRGB.
|
|
|
- IOSurfaceSetValue(surface.get(), CFSTR("IOSurfaceColorSpace"),
|
|
|
- kCGColorSpaceSRGB);
|
|
|
-diff --git a/ui/gfx/switches.cc b/ui/gfx/switches.cc
|
|
|
-index 1bf6fffae161414d650be3210c427dcc47ac1cf8..64a6e263c693b17b26a538219ab681000b98cb9a 100644
|
|
|
---- a/ui/gfx/switches.cc
|
|
|
-+++ b/ui/gfx/switches.cc
|
|
|
-@@ -13,6 +13,8 @@ namespace switches {
|
|
|
- // only apply to LinearAnimation and its subclasses.
|
|
|
- const char kAnimationDurationScale[] = "animation-duration-scale";
|
|
|
-
|
|
|
-+const char kDisableColorCorrectRendering[] = "disable-color-correct-rendering";
|
|
|
-+
|
|
|
- // Force disables font subpixel positioning. This affects the character glyph
|
|
|
- // sharpness, kerning, hinting and layout.
|
|
|
- const char kDisableFontSubpixelPositioning[] =
|
|
|
-diff --git a/ui/gfx/switches.h b/ui/gfx/switches.h
|
|
|
-index 98697d908f507e30ffbe0e5f5996afb7856f7c12..039024924c7fc10d8311746b88369dec1732a9d0 100644
|
|
|
---- a/ui/gfx/switches.h
|
|
|
-+++ b/ui/gfx/switches.h
|
|
|
-@@ -13,6 +13,7 @@
|
|
|
- namespace switches {
|
|
|
-
|
|
|
- GFX_SWITCHES_EXPORT extern const char kAnimationDurationScale[];
|
|
|
-+GFX_SWITCHES_EXPORT extern const char kDisableColorCorrectRendering[];
|
|
|
- GFX_SWITCHES_EXPORT extern const char kDisableFontSubpixelPositioning[];
|
|
|
- GFX_SWITCHES_EXPORT extern const char kEnableNativeGpuMemoryBuffers[];
|
|
|
- GFX_SWITCHES_EXPORT extern const char kForcePrefersReducedMotion[];
|