Skip to content

Commit 886e636

Browse files
poirunornagon
authored andcommitted
fix: Make the --disable-color-correct-rendering switch work again (backport) (electron#20358)
1 parent 0450ee9 commit 886e636

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

patches/common/chromium/disable_color_correct_rendering.patch

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ This can be removed once web content (including WebGL) learn how
1818
to deal with color spaces. That is being tracked at
1919
https://crbug.com/634542 and https://crbug.com/711107.
2020

21+
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
22+
index e2921219d253dbb198bd089811cc102aeec594cc..62290a30dee8d51df6e1f771894832b4105c2dd3 100644
23+
--- a/cc/trees/layer_tree_host_impl.cc
24+
+++ b/cc/trees/layer_tree_host_impl.cc
25+
@@ -1625,6 +1625,12 @@ const gfx::ColorSpace& LayerTreeHostImpl::GetRasterColorSpace() const {
26+
27+
const gfx::ColorSpace& LayerTreeHostImpl::GetRasterColorSpaceAndId(
28+
int* id) const {
29+
+ if (!settings_.enable_color_correct_rendering) {
30+
+ static gfx::ColorSpace invalid_color_space;
31+
+ *id = -1;
32+
+ return invalid_color_space;
33+
+ }
34+
+
35+
const gfx::ColorSpace* result = nullptr;
36+
// The pending tree will have the most recently updated color space, so
37+
// prefer that.
2138
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
2239
index 092fb1b7ea3626b7649472c35ec20bf1a6aaf4cd..fed8dd322faba387ebd0508228f847766a76011e 100644
2340
--- a/cc/trees/layer_tree_settings.h
@@ -248,6 +265,42 @@ index a450561913e274b36ece94c22bae7b14930db36e..3b9a0a5cef0ec2fc02d4e2d1b0e4e1da
248265
// Checkerimaging is not supported for synchronous single-threaded mode, which
249266
// is what the renderer uses if its not threaded.
250267
settings.enable_checker_imaging =
268+
diff --git a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
269+
index 9e5b58dc78b05491d1154b25b5b9c8c55b883b07..8524fd9f090fbb5cb0e37b1a6205d77917e9f221 100644
270+
--- a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
271+
+++ b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
272+
@@ -11,6 +11,7 @@
273+
#include "third_party/khronos/GLES3/gl3.h"
274+
#include "third_party/skia/include/core/SkSurfaceProps.h"
275+
#include "ui/gfx/color_space.h"
276+
+#include "ui/gfx/switches.h"
277+
278+
namespace blink {
279+
280+
@@ -81,6 +82,11 @@ uint8_t CanvasColorParams::BytesPerPixel() const {
281+
}
282+
283+
gfx::ColorSpace CanvasColorParams::GetSamplerGfxColorSpace() const {
284+
+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
285+
+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
286+
+ return gfx::ColorSpace();
287+
+ }
288+
+
289+
gfx::ColorSpace::PrimaryID primary_id = GetPrimaryID(color_space_);
290+
291+
// TODO(ccameron): This needs to take into account whether or not this texture
292+
@@ -94,6 +100,11 @@ gfx::ColorSpace CanvasColorParams::GetSamplerGfxColorSpace() const {
293+
}
294+
295+
gfx::ColorSpace CanvasColorParams::GetStorageGfxColorSpace() const {
296+
+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
297+
+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
298+
+ return gfx::ColorSpace();
299+
+ }
300+
+
301+
gfx::ColorSpace::PrimaryID primary_id = GetPrimaryID(color_space_);
302+
303+
gfx::ColorSpace::TransferID transfer_id =
251304
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
252305
index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553eed61587 100644
253306
--- a/ui/gfx/mac/io_surface.cc

0 commit comments

Comments
 (0)