<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[276875] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/276875">276875</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2021-05-01 11:06:08 -0700 (Sat, 01 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make destination color space enumeration match supported destination color spaces for the port
https://bugs.webkit.org/show_bug.cgi?id=225237

Reviewed by Simon Fraser.

Add ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB and enabled it for all ports
except the Apple Windows port, which is the only one doesn't have any support
for it.

Source/WebCore:

Removes existing behavior of returning SRGB when LinearSRGB was requested in
the Apple Windows port. Now, the callers are responisble for dealing with a
ports lack of support of LinearSRGB, making it very clear at those call sites
that something is different and wrong.

* platform/graphics/Color.cpp:
* platform/graphics/Color.h:
* platform/graphics/ColorConversion.cpp:
* platform/graphics/ColorConversion.h:
Add new functions to perform color conversion to and from an color space
denoted by the ColorSpace or DestinationColorSpace enum. Previously, we
only had convient ways to convert if the color was strongly typed (and this
is implemented using that mechanism). This is useful when converting for
final ouput, such in as the caller in FELighting::drawLighting.

* platform/graphics/cg/ColorSpaceCG.h:
* platform/graphics/ColorSpace.cpp:
* platform/graphics/ColorSpace.h:
* platform/graphics/filters/FELighting.cpp:
* platform/graphics/filters/FilterEffect.h:
* rendering/CSSFilter.cpp:
* rendering/svg/RenderSVGResourceFilter.cpp:
* rendering/svg/RenderSVGResourceMasker.cpp:
Wrap uses of DestinationColorSpace::LinearSRGB in ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB).

Source/WTF:

* wtf/PlatformEnable.h:
* wtf/PlatformEnableCocoa.h:
* wtf/PlatformEnableWinApple.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformEnableh">trunk/Source/WTF/wtf/PlatformEnable.h</a></li>
<li><a href="#trunkSourceWTFwtfPlatformEnableCocoah">trunk/Source/WTF/wtf/PlatformEnableCocoa.h</a></li>
<li><a href="#trunkSourceWTFwtfPlatformEnableWinAppleh">trunk/Source/WTF/wtf/PlatformEnableWinApple.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorcpp">trunk/Source/WebCore/platform/graphics/Color.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorh">trunk/Source/WebCore/platform/graphics/Color.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorConversioncpp">trunk/Source/WebCore/platform/graphics/ColorConversion.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorConversionh">trunk/Source/WebCore/platform/graphics/ColorConversion.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorSpacecpp">trunk/Source/WebCore/platform/graphics/ColorSpace.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorSpaceh">trunk/Source/WebCore/platform/graphics/ColorSpace.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgColorSpaceCGh">trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFELightingcpp">trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterEffecth">trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h</a></li>
<li><a href="#trunkSourceWebCorerenderingCSSFiltercpp">trunk/Source/WebCore/rendering/CSSFilter.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGResourceFiltercpp">trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGResourceMaskercpp">trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WTF/ChangeLog  2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-05-01  Sam Weinig  <weinig@apple.com>
+
+        Make destination color space enumeration match supported destination color spaces for the port
+        https://bugs.webkit.org/show_bug.cgi?id=225237
+
+        Reviewed by Simon Fraser.
+
+        Add ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB and enabled it for all ports
+        except the Apple Windows port, which is the only one doesn't have any support
+        for it.
+
+        * wtf/PlatformEnable.h:
+        * wtf/PlatformEnableCocoa.h:
+        * wtf/PlatformEnableWinApple.h:
+
</ins><span class="cx"> 2021-04-30  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Optimize SortedArrayMap by using linear search for small arrays
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformEnableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformEnable.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformEnable.h    2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WTF/wtf/PlatformEnable.h       2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -245,6 +245,10 @@
</span><span class="cx"> #define ENABLE_DEVICE_ORIENTATION 0
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1
+#endif
+
</ins><span class="cx"> #if !defined(ENABLE_DOWNLOAD_ATTRIBUTE)
</span><span class="cx"> #define ENABLE_DOWNLOAD_ATTRIBUTE 1
</span><span class="cx"> #endif
</span><span class="lines">@@ -816,6 +820,14 @@
</span><span class="cx"> #define ENABLE_GC_VALIDATION 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if OS(DARWIN) && ENABLE(JIT) && USE(APPLE_INTERNAL_SDK) && CPU(ARM64E) && HAVE(JIT_CAGE)
+#define ENABLE_JIT_CAGE 1
+#endif
+
+#if OS(DARWIN) && CPU(ADDRESS64) && ENABLE(JIT) && (ENABLE(JIT_CAGE) || ASSERT_ENABLED)
+#define ENABLE_JIT_OPERATION_VALIDATION 1
+#endif
+
</ins><span class="cx"> #if !defined(ENABLE_BINDING_INTEGRITY) && !OS(WINDOWS)
</span><span class="cx"> #define ENABLE_BINDING_INTEGRITY 1
</span><span class="cx"> #endif
</span><span class="lines">@@ -887,10 +899,10 @@
</span><span class="cx"> #error "ENABLE(WHLSL_COMPILER) requires ENABLE(WEBGPU)"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if OS(DARWIN) && ENABLE(JIT) && USE(APPLE_INTERNAL_SDK) && CPU(ARM64E) && HAVE(JIT_CAGE)
-#define ENABLE_JIT_CAGE 1
</del><ins>+#if USE(CG)
+
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) && !HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
+#error "ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB) requires HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) on platforms using CoreGraphics"
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if OS(DARWIN) && CPU(ADDRESS64) && ENABLE(JIT) && (ENABLE(JIT_CAGE) || ASSERT_ENABLED)
-#define ENABLE_JIT_OPERATION_VALIDATION 1
</del><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformEnableCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h       2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h  2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -670,3 +670,7 @@
</span><span class="cx"> #if !defined(ENABLE_APP_BOUND_REQUESTS) && PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000
</span><span class="cx"> #define ENABLE_APP_BOUND_REQUESTS 1
</span><span class="cx"> #endif
</span><ins>+
+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1
+#endif
</ins></span></pre></div>
<a id="trunkSourceWTFwtfPlatformEnableWinAppleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformEnableWinApple.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformEnableWinApple.h    2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WTF/wtf/PlatformEnableWinApple.h       2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2007-2009 Torch Mobile, Inc.
</span><span class="cx">  * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
</span><span class="cx">  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
</span><span class="lines">@@ -54,3 +54,7 @@
</span><span class="cx"> #if !defined(ENABLE_GEOLOCATION)
</span><span class="cx"> #define ENABLE_GEOLOCATION 1
</span><span class="cx"> #endif
</span><ins>+
+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB) && !HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 0
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/ChangeLog      2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -1,5 +1,41 @@
</span><span class="cx"> 2021-05-01  Sam Weinig  <weinig@apple.com>
</span><span class="cx"> 
</span><ins>+        Make destination color space enumeration match supported destination color spaces for the port
+        https://bugs.webkit.org/show_bug.cgi?id=225237
+
+        Reviewed by Simon Fraser.
+
+        Add ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB and enabled it for all ports
+        except the Apple Windows port, which is the only one doesn't have any support
+        for it.
+
+        Removes existing behavior of returning SRGB when LinearSRGB was requested in
+        the Apple Windows port. Now, the callers are responisble for dealing with a
+        ports lack of support of LinearSRGB, making it very clear at those call sites
+        that something is different and wrong.
+
+        * platform/graphics/Color.cpp:
+        * platform/graphics/Color.h:
+        * platform/graphics/ColorConversion.cpp:
+        * platform/graphics/ColorConversion.h:
+        Add new functions to perform color conversion to and from an color space
+        denoted by the ColorSpace or DestinationColorSpace enum. Previously, we
+        only had convient ways to convert if the color was strongly typed (and this
+        is implemented using that mechanism). This is useful when converting for
+        final ouput, such in as the caller in FELighting::drawLighting.
+
+        * platform/graphics/cg/ColorSpaceCG.h:
+        * platform/graphics/ColorSpace.cpp:
+        * platform/graphics/ColorSpace.h:
+        * platform/graphics/filters/FELighting.cpp:
+        * platform/graphics/filters/FilterEffect.h:
+        * rendering/CSSFilter.cpp:
+        * rendering/svg/RenderSVGResourceFilter.cpp:
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        Wrap uses of DestinationColorSpace::LinearSRGB in ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB).
+
+2021-05-01  Sam Weinig  <weinig@apple.com>
+
</ins><span class="cx">         Generated JS bindings for JSValue -> IDL dictionary don't take into account runtime settings
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=225271
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Color.cpp 2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp    2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -162,6 +162,18 @@
</span><span class="cx">     return { asInline(), Flags::Semantic };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ColorComponents<float, 4> Color::toColorComponentsInColorSpace(ColorSpace outputColorSpace) const
+{
+    auto [inputColorSpace, components] = colorSpaceAndComponents();
+    return converColorComponents(inputColorSpace, components, outputColorSpace);
+}
+
+ColorComponents<float, 4> Color::toColorComponentsInColorSpace(DestinationColorSpace outputColorSpace) const
+{
+    auto [inputColorSpace, components] = colorSpaceAndComponents();
+    return converColorComponents(inputColorSpace, components, outputColorSpace);
+}
+
</ins><span class="cx"> std::pair<ColorSpace, ColorComponents<float, 4>> Color::colorSpaceAndComponents() const
</span><span class="cx"> {
</span><span class="cx">     if (isOutOfLine())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Color.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Color.h   2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/Color.h      2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -120,6 +120,9 @@
</span><span class="cx">     // wrapper around toColorTypeLossy<>().
</span><span class="cx">     template<typename T> SRGBA<T> toSRGBALossy() const { return toColorTypeLossy<SRGBA<T>>(); }
</span><span class="cx"> 
</span><ins>+    ColorComponents<float, 4> toColorComponentsInColorSpace(ColorSpace) const;
+    ColorComponents<float, 4> toColorComponentsInColorSpace(DestinationColorSpace) const;
+
</ins><span class="cx">     WEBCORE_EXPORT std::pair<ColorSpace, ColorComponents<float, 4>> colorSpaceAndComponents() const;
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT Color lightened() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ColorConversion.cpp       2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/ColorConversion.cpp  2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "ColorConversion.h"
</span><span class="cx"> 
</span><ins>+#include "ColorSpace.h"
</ins><span class="cx"> #include <wtf/MathExtras.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -286,4 +287,52 @@
</span><span class="cx">     }));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// MARK: Conversion functions for raw color components with associated color spaces.
+
+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, ColorSpace outputColorSpace)
+{
+    return callWithColorType(inputColorComponents, inputColorSpace, [outputColorSpace] (const auto& inputColor) {
+        switch (outputColorSpace) {
+        case ColorSpace::A98RGB:
+            return asColorComponents(convertColor<A98RGB<float>>(inputColor));
+        case ColorSpace::DisplayP3:
+            return asColorComponents(convertColor<DisplayP3<float>>(inputColor));
+        case ColorSpace::LCH:
+            return asColorComponents(convertColor<LCHA<float>>(inputColor));
+        case ColorSpace::Lab:
+            return asColorComponents(convertColor<Lab<float>>(inputColor));
+        case ColorSpace::LinearSRGB:
+            return asColorComponents(convertColor<LinearSRGBA<float>>(inputColor));
+        case ColorSpace::ProPhotoRGB:
+            return asColorComponents(convertColor<ProPhotoRGB<float>>(inputColor));
+        case ColorSpace::Rec2020:
+            return asColorComponents(convertColor<Rec2020<float>>(inputColor));
+        case ColorSpace::SRGB:
+            return asColorComponents(convertColor<SRGBA<float>>(inputColor));
+        case ColorSpace::XYZ_D50:
+            return asColorComponents(convertColor<XYZA<float, WhitePoint::D50>>(inputColor));
+        }
+
+        ASSERT_NOT_REACHED();
+        return asColorComponents(convertColor<SRGBA<float>>(inputColor));
+    });
+}
+
+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, DestinationColorSpace outputColorSpace)
+{
+    return callWithColorType(inputColorComponents, inputColorSpace, [outputColorSpace] (const auto& inputColor) {
+        switch (outputColorSpace) {
+        case DestinationColorSpace::SRGB:
+            return asColorComponents(convertColor<SRGBA<float>>(inputColor));
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+        case DestinationColorSpace::LinearSRGB:
+            return asColorComponents(convertColor<LinearSRGBA<float>>(inputColor));
+#endif
+        }
+
+        ASSERT_NOT_REACHED();
+        return asColorComponents(convertColor<SRGBA<float>>(inputColor));
+    });
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorConversionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ColorConversion.h 2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/ColorConversion.h    2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -29,6 +29,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+enum class ColorSpace : uint8_t;
+enum class DestinationColorSpace : uint8_t;
+
+// Conversion function for typed colors.
+template<typename Output, typename Input> Output convertColor(const Input& color);
+
+// Conversion functions for raw color components with associated color spaces.
+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, ColorSpace outputColorSpace);
+ColorComponents<float, 4> converColorComponents(ColorSpace inputColorSpace, ColorComponents<float, 4> inputColorComponents, DestinationColorSpace outputColorSpace);
+
+
</ins><span class="cx"> // All color types, other than XYZA or those inheriting from RGBType, must implement
</span><span class="cx"> // the following conversions to and from their "Reference" color.
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorSpacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ColorSpace.cpp    2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.cpp       2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -67,12 +67,14 @@
</span><span class="cx"> TextStream& operator<<(TextStream& ts, DestinationColorSpace colorSpace)
</span><span class="cx"> {
</span><span class="cx">     switch (colorSpace) {
</span><ins>+    case DestinationColorSpace::SRGB:
+        ts << "sRGB";
+        break;
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
</ins><span class="cx">     case DestinationColorSpace::LinearSRGB:
</span><span class="cx">         ts << "LinearSRGB";
</span><span class="cx">         break;
</span><del>-    case DestinationColorSpace::SRGB:
-        ts << "sRGB";
-        break;
</del><ins>+#endif
</ins><span class="cx">     }
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorSpaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ColorSpace.h      2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/ColorSpace.h 2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -48,8 +48,10 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum class DestinationColorSpace : uint8_t {
</span><del>-    LinearSRGB,
-    SRGB,
</del><ins>+    SRGB
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    , LinearSRGB
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ColorSpace);
</span><span class="lines">@@ -97,6 +99,22 @@
</span><span class="cx">     return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template<typename T, typename Functor> constexpr decltype(auto) callWithColorType(const ColorComponents<T, 4>& components, DestinationColorSpace colorSpace, Functor&& functor)
+{
+    switch (colorSpace) {
+    case DestinationColorSpace::SRGB:
+        return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    case DestinationColorSpace::LinearSRGB:
+        return std::invoke(std::forward<Functor>(functor), makeFromComponents<LinearSRGBA<T>>(components));
+#endif
+    }
+
+    ASSERT_NOT_REACHED();
+    return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
+}
+
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="lines">@@ -119,8 +137,10 @@
</span><span class="cx"> template<> struct EnumTraits<WebCore::DestinationColorSpace> {
</span><span class="cx">     using values = EnumValues<
</span><span class="cx">         WebCore::DestinationColorSpace,
</span><del>-        WebCore::DestinationColorSpace::LinearSRGB,
</del><span class="cx">         WebCore::DestinationColorSpace::SRGB
</span><ins>+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+        , WebCore::DestinationColorSpace::LinearSRGB
+#endif
</ins><span class="cx">     >;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgColorSpaceCGh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h 2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h    2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -123,17 +123,13 @@
</span><span class="cx"> static inline CGColorSpaceRef cachedCGColorSpace(DestinationColorSpace colorSpace)
</span><span class="cx"> {
</span><span class="cx">     switch (colorSpace) {
</span><del>-    case DestinationColorSpace::LinearSRGB: {
-#if HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
</del><ins>+    case DestinationColorSpace::SRGB:
+        return sRGBColorSpaceRef();
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    case DestinationColorSpace::LinearSRGB:
</ins><span class="cx">         return linearSRGBColorSpaceRef();
</span><del>-#else
-        // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000.
-        return sRGBColorSpaceRef();
</del><span class="cx"> #endif
</span><span class="cx">     }
</span><del>-    case DestinationColorSpace::SRGB:
-        return sRGBColorSpaceRef();
-    }
</del><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return sRGBColorSpaceRef();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFELightingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp    2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp       2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -403,14 +403,10 @@
</span><span class="cx">     data.widthMultipliedByPixelSize = width * cPixelSize;
</span><span class="cx">     data.widthDecreasedByOne = width - 1;
</span><span class="cx">     data.heightDecreasedByOne = height - 1;
</span><del>-    
-    if (operatingColorSpace() == DestinationColorSpace::LinearSRGB) {
-        auto [r, g, b, a] = m_lightingColor.toColorTypeLossy<LinearSRGBA<float>>();
-        paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b);
-    } else {
-        auto [r, g, b, a] = m_lightingColor.toSRGBALossy<float>();
-        paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b);
-    }
</del><ins>+
+    auto [r, g, b, a] = m_lightingColor.toColorComponentsInColorSpace(operatingColorSpace());
+    paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b);
+
</ins><span class="cx">     m_lightSource->initPaintingData(*this, paintingData);
</span><span class="cx"> 
</span><span class="cx">     // Top left.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterEffecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h    2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h       2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -241,7 +241,13 @@
</span><span class="cx">     // Should the effect clip to its primitive region, or expand to use the combined region of its inputs.
</span><span class="cx">     bool m_clipsToBounds { true };
</span><span class="cx"> 
</span><del>-    DestinationColorSpace m_operatingColorSpace { DestinationColorSpace::LinearSRGB };
</del><ins>+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    static constexpr auto defaultOperatingColorSpace = DestinationColorSpace::LinearSRGB;
+#else
+    static constexpr auto defaultOperatingColorSpace = DestinationColorSpace::SRGB;
+#endif
+
+    DestinationColorSpace m_operatingColorSpace { defaultOperatingColorSpace };
</ins><span class="cx">     DestinationColorSpace m_resultColorSpace { DestinationColorSpace::SRGB };
</span><span class="cx">     
</span><span class="cx">     const Type m_filterEffectClassType;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingCSSFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/CSSFilter.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/CSSFilter.cpp     2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/rendering/CSSFilter.cpp        2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -109,9 +109,13 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         effectElement.setStandardAttributes(effect.get());
</span><del>-        if (effectElement.renderer())
</del><ins>+        if (effectElement.renderer()) {
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
</ins><span class="cx">             effect->setOperatingColorSpace(effectElement.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB);
</span><del>-
</del><ins>+#else
+            effect->setOperatingColorSpace(DestinationColorSpace::SRGB);
+#endif
+        }
</ins><span class="cx">         builder->add(effectElement.result(), effect);
</span><span class="cx">         referenceEffects.append(*effect);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGResourceFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp   2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp      2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -102,8 +102,13 @@
</span><span class="cx">         builder->appendEffectToEffectReferences(effect.copyRef(), element.renderer());
</span><span class="cx">         element.setStandardAttributes(effect.get());
</span><span class="cx">         effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(&element, filterElement().primitiveUnits(), targetBoundingBox));
</span><del>-        if (element.renderer())
</del><ins>+        if (element.renderer()) {
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
</ins><span class="cx">             effect->setOperatingColorSpace(element.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB);
</span><ins>+#else
+            effect->setOperatingColorSpace(DestinationColorSpace::SRGB);
+#endif
+        }
</ins><span class="cx">         builder->add(element.result(), WTFMove(effect));
</span><span class="cx">     }
</span><span class="cx">     return builder;
</span><span class="lines">@@ -191,8 +196,13 @@
</span><span class="cx">     effectiveTransform.scale(scale.width(), scale.height());
</span><span class="cx">     effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform);
</span><span class="cx"> 
</span><del>-    RenderingMode renderingMode = renderer.settings().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
-    auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, DestinationColorSpace::LinearSRGB, renderingMode, context);
</del><ins>+    auto renderingMode = renderer.settings().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    auto colorSpace = DestinationColorSpace::LinearSRGB;
+#else
+    auto colorSpace = DestinationColorSpace::SRGB;
+#endif
+    auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, colorSpace, renderingMode, context);
</ins><span class="cx">     if (!sourceGraphic) {
</span><span class="cx">         ASSERT(!m_rendererFilterDataMap.contains(&renderer));
</span><span class="cx">         filterData->savedContext = context;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGResourceMaskercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (276874 => 276875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp   2021-05-01 17:15:01 UTC (rev 276874)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp      2021-05-01 18:06:08 UTC (rev 276875)
</span><span class="lines">@@ -69,7 +69,13 @@
</span><span class="cx"> 
</span><span class="cx">     if (!maskerData->maskImage && !repaintRect.isEmpty()) {
</span><span class="cx">         const SVGRenderStyle& svgStyle = style().svgStyle();
</span><ins>+
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
</ins><span class="cx">         auto colorSpace = svgStyle.colorInterpolation() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB;
</span><ins>+#else
+        auto colorSpace = DestinationColorSpace::SRGB;
+#endif
+
</ins><span class="cx">         // FIXME (149470): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks alpha masking, though.
</span><span class="cx">         maskerData->maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, colorSpace, RenderingMode::Unaccelerated, context);
</span><span class="cx">         if (!maskerData->maskImage)
</span></span></pre>
</div>
</div>

</body>
</html>