Title: [276875] trunk/Source
Revision
276875
Author
wei...@apple.com
Date
2021-05-01 11:06:08 -0700 (Sat, 01 May 2021)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (276874 => 276875)


--- 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)
@@ -1,3 +1,18 @@
+2021-05-01  Sam Weinig  <wei...@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:
+
 2021-04-30  Darin Adler  <da...@apple.com>
 
         Optimize SortedArrayMap by using linear search for small arrays

Modified: trunk/Source/WTF/wtf/PlatformEnable.h (276874 => 276875)


--- 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)
@@ -245,6 +245,10 @@
 #define ENABLE_DEVICE_ORIENTATION 0
 #endif
 
+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1
+#endif
+
 #if !defined(ENABLE_DOWNLOAD_ATTRIBUTE)
 #define ENABLE_DOWNLOAD_ATTRIBUTE 1
 #endif
@@ -816,6 +820,14 @@
 #define ENABLE_GC_VALIDATION 1
 #endif
 
+#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
+
 #if !defined(ENABLE_BINDING_INTEGRITY) && !OS(WINDOWS)
 #define ENABLE_BINDING_INTEGRITY 1
 #endif
@@ -887,10 +899,10 @@
 #error "ENABLE(WHLSL_COMPILER) requires ENABLE(WEBGPU)"
 #endif
 
-#if OS(DARWIN) && ENABLE(JIT) && USE(APPLE_INTERNAL_SDK) && CPU(ARM64E) && HAVE(JIT_CAGE)
-#define ENABLE_JIT_CAGE 1
+#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"
 #endif
 
-#if OS(DARWIN) && CPU(ADDRESS64) && ENABLE(JIT) && (ENABLE(JIT_CAGE) || ASSERT_ENABLED)
-#define ENABLE_JIT_OPERATION_VALIDATION 1
 #endif

Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (276874 => 276875)


--- 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)
@@ -670,3 +670,7 @@
 #if !defined(ENABLE_APP_BOUND_REQUESTS) && PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000
 #define ENABLE_APP_BOUND_REQUESTS 1
 #endif
+
+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 1
+#endif

Modified: trunk/Source/WTF/wtf/PlatformEnableWinApple.h (276874 => 276875)


--- 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)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
  * Copyright (C) 2007-2009 Torch Mobile, Inc.
  * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
@@ -54,3 +54,7 @@
 #if !defined(ENABLE_GEOLOCATION)
 #define ENABLE_GEOLOCATION 1
 #endif
+
+#if !defined(ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB) && !HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
+#define ENABLE_DESTINATION_COLOR_SPACE_LINEAR_SRGB 0
+#endif

Modified: trunk/Source/WebCore/ChangeLog (276874 => 276875)


--- 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)
@@ -1,5 +1,41 @@
 2021-05-01  Sam Weinig  <wei...@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.
+
+        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  <wei...@apple.com>
+
         Generated JS bindings for JSValue -> IDL dictionary don't take into account runtime settings
         https://bugs.webkit.org/show_bug.cgi?id=225271
 

Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (276874 => 276875)


--- 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)
@@ -162,6 +162,18 @@
     return { asInline(), Flags::Semantic };
 }
 
+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);
+}
+
 std::pair<ColorSpace, ColorComponents<float, 4>> Color::colorSpaceAndComponents() const
 {
     if (isOutOfLine())

Modified: trunk/Source/WebCore/platform/graphics/Color.h (276874 => 276875)


--- 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)
@@ -120,6 +120,9 @@
     // wrapper around toColorTypeLossy<>().
     template<typename T> SRGBA<T> toSRGBALossy() const { return toColorTypeLossy<SRGBA<T>>(); }
 
+    ColorComponents<float, 4> toColorComponentsInColorSpace(ColorSpace) const;
+    ColorComponents<float, 4> toColorComponentsInColorSpace(DestinationColorSpace) const;
+
     WEBCORE_EXPORT std::pair<ColorSpace, ColorComponents<float, 4>> colorSpaceAndComponents() const;
 
     WEBCORE_EXPORT Color lightened() const;

Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.cpp (276874 => 276875)


--- 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)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ColorConversion.h"
 
+#include "ColorSpace.h"
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
@@ -286,4 +287,52 @@
     }));
 }
 
+// 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));
+    });
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/ColorConversion.h (276874 => 276875)


--- 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)
@@ -29,6 +29,17 @@
 
 namespace WebCore {
 
+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);
+
+
 // All color types, other than XYZA or those inheriting from RGBType, must implement
 // the following conversions to and from their "Reference" color.
 //

Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.cpp (276874 => 276875)


--- 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)
@@ -67,12 +67,14 @@
 TextStream& operator<<(TextStream& ts, DestinationColorSpace colorSpace)
 {
     switch (colorSpace) {
+    case DestinationColorSpace::SRGB:
+        ts << "sRGB";
+        break;
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
     case DestinationColorSpace::LinearSRGB:
         ts << "LinearSRGB";
         break;
-    case DestinationColorSpace::SRGB:
-        ts << "sRGB";
-        break;
+#endif
     }
     return ts;
 }

Modified: trunk/Source/WebCore/platform/graphics/ColorSpace.h (276874 => 276875)


--- 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)
@@ -48,8 +48,10 @@
 };
 
 enum class DestinationColorSpace : uint8_t {
-    LinearSRGB,
-    SRGB,
+    SRGB
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    , LinearSRGB
+#endif
 };
 
 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ColorSpace);
@@ -97,6 +99,22 @@
     return std::invoke(std::forward<Functor>(functor), makeFromComponents<SRGBA<T>>(components));
 }
 
+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));
+}
+
+
 } // namespace WebCore
 
 namespace WTF {
@@ -119,8 +137,10 @@
 template<> struct EnumTraits<WebCore::DestinationColorSpace> {
     using values = EnumValues<
         WebCore::DestinationColorSpace,
-        WebCore::DestinationColorSpace::LinearSRGB,
         WebCore::DestinationColorSpace::SRGB
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+        , WebCore::DestinationColorSpace::LinearSRGB
+#endif
     >;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (276874 => 276875)


--- 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)
@@ -123,17 +123,13 @@
 static inline CGColorSpaceRef cachedCGColorSpace(DestinationColorSpace colorSpace)
 {
     switch (colorSpace) {
-    case DestinationColorSpace::LinearSRGB: {
-#if HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
+    case DestinationColorSpace::SRGB:
+        return sRGBColorSpaceRef();
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    case DestinationColorSpace::LinearSRGB:
         return linearSRGBColorSpaceRef();
-#else
-        // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000.
-        return sRGBColorSpaceRef();
 #endif
     }
-    case DestinationColorSpace::SRGB:
-        return sRGBColorSpaceRef();
-    }
     ASSERT_NOT_REACHED();
     return sRGBColorSpaceRef();
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp (276874 => 276875)


--- 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)
@@ -403,14 +403,10 @@
     data.widthMultipliedByPixelSize = width * cPixelSize;
     data.widthDecreasedByOne = width - 1;
     data.heightDecreasedByOne = height - 1;
-    
-    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);
-    }
+
+    auto [r, g, b, a] = m_lightingColor.toColorComponentsInColorSpace(operatingColorSpace());
+    paintingData.initialLightingData.colorVector = FloatPoint3D(r, g, b);
+
     m_lightSource->initPaintingData(*this, paintingData);
 
     // Top left.

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (276874 => 276875)


--- 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)
@@ -241,7 +241,13 @@
     // Should the effect clip to its primitive region, or expand to use the combined region of its inputs.
     bool m_clipsToBounds { true };
 
-    DestinationColorSpace m_operatingColorSpace { DestinationColorSpace::LinearSRGB };
+#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 };
     DestinationColorSpace m_resultColorSpace { DestinationColorSpace::SRGB };
     
     const Type m_filterEffectClassType;

Modified: trunk/Source/WebCore/rendering/CSSFilter.cpp (276874 => 276875)


--- 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)
@@ -109,9 +109,13 @@
         }
 
         effectElement.setStandardAttributes(effect.get());
-        if (effectElement.renderer())
+        if (effectElement.renderer()) {
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
             effect->setOperatingColorSpace(effectElement.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB);
-
+#else
+            effect->setOperatingColorSpace(DestinationColorSpace::SRGB);
+#endif
+        }
         builder->add(effectElement.result(), effect);
         referenceEffects.append(*effect);
     }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp (276874 => 276875)


--- 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)
@@ -102,8 +102,13 @@
         builder->appendEffectToEffectReferences(effect.copyRef(), element.renderer());
         element.setStandardAttributes(effect.get());
         effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(&element, filterElement().primitiveUnits(), targetBoundingBox));
-        if (element.renderer())
+        if (element.renderer()) {
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
             effect->setOperatingColorSpace(element.renderer()->style().svgStyle().colorInterpolationFilters() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB);
+#else
+            effect->setOperatingColorSpace(DestinationColorSpace::SRGB);
+#endif
+        }
         builder->add(element.result(), WTFMove(effect));
     }
     return builder;
@@ -191,8 +196,13 @@
     effectiveTransform.scale(scale.width(), scale.height());
     effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform);
 
-    RenderingMode renderingMode = renderer.settings().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
-    auto sourceGraphic = SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, DestinationColorSpace::LinearSRGB, renderingMode, context);
+    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);
     if (!sourceGraphic) {
         ASSERT(!m_rendererFilterDataMap.contains(&renderer));
         filterData->savedContext = context;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (276874 => 276875)


--- 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)
@@ -69,7 +69,13 @@
 
     if (!maskerData->maskImage && !repaintRect.isEmpty()) {
         const SVGRenderStyle& svgStyle = style().svgStyle();
+
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
         auto colorSpace = svgStyle.colorInterpolation() == ColorInterpolation::LinearRGB ? DestinationColorSpace::LinearSRGB : DestinationColorSpace::SRGB;
+#else
+        auto colorSpace = DestinationColorSpace::SRGB;
+#endif
+
         // FIXME (149470): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks alpha masking, though.
         maskerData->maskImage = SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, colorSpace, RenderingMode::Unaccelerated, context);
         if (!maskerData->maskImage)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to