Reviewed by Said Abou-Hallawa and Nikolas Zimmermann.
Turn off the support for linearRGB color space in case of Cairo (251234@main) causes, that SVG with filter, where linearRGB as inputs is demanded, generates darker output.
In case of Cairo (which operates in SRGB color space) the image source (SourceGraphic) should be created in SRGB and before passing it to filters, it should be transformed to linearRGB color space.
LayoutTests/TestExpectations:
LayoutTests/platform/glib/TestExpectations: Remove some tests which pass with this change
LayoutTests/fast/gradients/conic-gradient-extended-stops.html: Add possible differences in outputs
Source/WebCore/platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::filteredNativeImage):
Pass color space to endDrawSourceImage
Source/WebCore/platform/graphics/filters/FEDropShadow.h: Force to use SRGB as operating color space for DropShadow in case of Cairo.
Source/WebCore/platform/graphics/filters/FilterImageTargetSwitcher.cpp: (WebCore::FilterImageTargetSwitcher::endClipAndDrawSourceImage): (WebCore::FilterImageTargetSwitcher::endDrawSourceImage): Before applying all filter, the source image has to be translated to requested color space (only valid for Cairo).
Source/WebCore/platform/graphics/filters/FilterStyleTargetSwitcher.h: Added color space as additional parameter.
Source/WebCore/platform/graphics/filters/FilterStyleTargetSwitcher.cpp: (WebCore::FilterStyleTargetSwitcher::endDrawSourceImage): WebCore::FilterStyleTargetSwitcher::endDrawSourceImage does not use color space so just ignore it
Source/WebCore/rendering/RenderLayerFilters.cpp: (WebCore::RenderLayerFilters::applyFilterEffect):
Just pass DestinationColorSpace::SRGB() to endClipAndDrawSourceImage.
Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp: (WebCore::LegacyRenderSVGResourceFilter::applyResource): In case of Cairo, the sourceImage has to be created with sRGB color space, because Cairo operates in sRGB. The linearRGB color space will be passed to TargetSwitcher in WebCore::LegacyRenderSVGResourceFilter::postApplyResource and the sourceImage will be transformed to linearRGB before all filter applying. (WebCore::LegacyRenderSVGResourceFilter::postApplyResource): Before applying all filter, the source image has to be translated to requested color space.
Source/WebCore/svg/graphics/filters/SVGFilter.cpp: (WebCore::buildFilterEffectsGraph):
Create SourceGraphic and SourceAlpha with LinearRGB color space if color-interpolation_filter attribute of the Filter has LinearRGB value (only in case of Cairo).
…filters fediffuselighting
https://bugs.webkit.org/show_bug.cgi?id=268537
Reviewed by Said Abou-Hallawa and Nikolas Zimmermann.
Turn off the support for linearRGB color space in case of Cairo (251234@main) causes, that SVG with filter, where linearRGB as inputs is demanded, generates darker output.
The SVG spec says that SourceGraphic has to be in linearRGB color space: https://www.w3.org/TR/filter-effects-1/#attr-valuedef-in-sourcegraphic
In case of Cairo (which operates in SRGB color space) the image source (SourceGraphic) should be created in SRGB and before passing it to filters, it should be transformed to linearRGB color space.
LayoutTests/TestExpectations:
LayoutTests/platform/glib/TestExpectations: Remove some tests which pass with this change
LayoutTests/svg/filters/feConvolveMatrix-clipped.svg:
LayoutTests/svg/filters/feGaussianBlur-clipped.svg:
LayoutTests/fast/gradients/conic-gradient-extended-stops.html: Add possible differences in outputs
Source/WebCore/platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::filteredNativeImage): Pass color space to endDrawSourceImage
Source/WebCore/platform/graphics/filters/FEDropShadow.h: Force to use SRGB as operating color space for DropShadow in case of Cairo.
Source/WebCore/platform/graphics/filters/FilterImageTargetSwitcher.cpp: (WebCore::FilterImageTargetSwitcher::endClipAndDrawSourceImage): (WebCore::FilterImageTargetSwitcher::endDrawSourceImage): Before applying all filter, the source image has to be translated to requested color space (only valid for Cairo).
Source/WebCore/platform/graphics/filters/FilterTargetSwitcher.h:
Source/WebCore/platform/graphics/filters/FilterImageTargetSwitcher.h:
Source/WebCore/platform/graphics/filters/FilterStyleTargetSwitcher.h: Added color space as additional parameter.
Source/WebCore/platform/graphics/filters/FilterStyleTargetSwitcher.cpp: (WebCore::FilterStyleTargetSwitcher::endDrawSourceImage): WebCore::FilterStyleTargetSwitcher::endDrawSourceImage does not use color space so just ignore it
Source/WebCore/rendering/RenderLayerFilters.cpp: (WebCore::RenderLayerFilters::applyFilterEffect): Just pass DestinationColorSpace::SRGB() to endClipAndDrawSourceImage.
Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp: (WebCore::LegacyRenderSVGResourceFilter::applyResource): In case of Cairo, the sourceImage has to be created with sRGB color space, because Cairo operates in sRGB. The linearRGB color space will be passed to TargetSwitcher in WebCore::LegacyRenderSVGResourceFilter::postApplyResource and the sourceImage will be transformed to linearRGB before all filter applying. (WebCore::LegacyRenderSVGResourceFilter::postApplyResource): Before applying all filter, the source image has to be translated to requested color space.
Source/WebCore/svg/graphics/filters/SVGFilter.cpp: (WebCore::buildFilterEffectsGraph): Create SourceGraphic and SourceAlpha with LinearRGB color space if color-interpolation_filter attribute of the Filter has LinearRGB value (only in case of Cairo).
Canonical link: https://commits.webkit.org/275091@main