Changeset 287982 in webkit


Ignore:
Timestamp:
Jan 13, 2022 10:58:47 AM (6 months ago)
Author:
Said Abou-Hallawa
Message:

Referenced SVG filter uses always sRGB color space for its result
https://bugs.webkit.org/show_bug.cgi?id=235159

Reviewed by Simon Fraser.

Source/WebCore:

Do not setOperatingColorSpace() of the lastEffect() of the referenced
SVGFilter to DestinationColorSpace::SRGB(). This will have the pixels
of the result FilterImage of the lastEffect() in the color space which
is defined by the color-interpolation style of the effect SVGElement.

Test: css3/filters/reference-filter-color-space.html

  • platform/graphics/filters/Filter.h:
  • rendering/CSSFilter.cpp:

(WebCore::CSSFilter::create):
Move checking the CoreImage support to this function.

(WebCore::CSSFilter::buildFilterFunctions):
Remove resetting m_functions and m_outsets from this function since it
is now called only once from CSSFilter::create().

(WebCore::CSSFilter::lastEffect const): Deleted.

  • rendering/CSSFilter.h:
  • svg/graphics/filters/SVGFilter.h:

LayoutTests:

The new test defines a <feComponentTransfer> effect with linear component
functions. The values of these functions make the lookup tables have zeros
in the first 65 elements. The test applies the filter to a <div> with green
background.

-- With sRGB color-space, the green channel value is 0x80. So the value

in the lookup table is not zero. So the result filter image in this
case is a some green square.

-- With linearRGB color-space , the green channel value is 0x37. So the

value in the lookup table is zero. So the result filter image in this
case is a black square.

Because the color-space will be linearRGB, the expected test case should
have black squares.

  • css3/filters/reference-filter-color-space-expected.html: Added.
  • css3/filters/reference-filter-color-space.html: Added.
  • css3/filters/reference-filter-set-filter-regions.html:
  • fast/gradients/conic-gradient-alpha-unpremultiplied.html:
  • fast/gradients/conic-gradient-extended-stops.html:
  • fast/gradients/conic-gradient.html:
  • fast/gradients/conic-repeating-last-stop.html:
  • fast/hidpi/filters-turbulence.html:

Add color-interpolation-filters="sRGB" to get the old result so they match
the expected pages.

  • platform/win/TestExpectations:

LinearSRGB color space is not supported on Windows.

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r287981 r287982  
     12022-01-13  Said Abou-Hallawa  <said@apple.com>
     2
     3        Referenced SVG filter uses always sRGB color space for its result
     4        https://bugs.webkit.org/show_bug.cgi?id=235159
     5
     6        Reviewed by Simon Fraser.
     7
     8        The new test defines a <feComponentTransfer> effect with linear component
     9        functions. The values of these functions make the lookup tables have zeros
     10        in the first 65 elements. The test applies the filter to a <div> with green
     11        background.
     12
     13        -- With sRGB color-space, the green channel value is 0x80. So the value
     14           in the lookup table is not zero. So the result filter image in this
     15           case is a some green square.
     16
     17        -- With linearRGB color-space , the green channel value is 0x37. So the
     18           value in the lookup table is zero. So the result filter image in this
     19           case is a black square.
     20
     21        Because the color-space will be linearRGB, the expected test case should
     22        have black squares.
     23
     24        * css3/filters/reference-filter-color-space-expected.html: Added.
     25        * css3/filters/reference-filter-color-space.html: Added.
     26
     27        * css3/filters/reference-filter-set-filter-regions.html:
     28        * fast/gradients/conic-gradient-alpha-unpremultiplied.html:
     29        * fast/gradients/conic-gradient-extended-stops.html:
     30        * fast/gradients/conic-gradient.html:
     31        * fast/gradients/conic-repeating-last-stop.html:
     32        * fast/hidpi/filters-turbulence.html:
     33        Add color-interpolation-filters="sRGB" to get the old result so they match
     34        the expected pages.
     35
     36        * platform/win/TestExpectations:
     37        LinearSRGB color space is not supported on Windows.
     38
    1392022-01-13  Alan Bujtas  <zalan@apple.com>
    240
  • trunk/LayoutTests/css3/filters/reference-filter-set-filter-regions.html

    r235644 r287982  
    1919            <feTurbulence type="turbulence" baseFrequency="0.01" numOctaves="1" seed="5" stitchTiles="stitch"/>
    2020            <feColorMatrix type="saturate" values="0"/>
    21             <feComponentTransfer>
     21            <feComponentTransfer color-interpolation-filters="sRGB">
    2222                <feFuncR type="linear" slope="0" intercept="0"/>
    2323                <feFuncG type="linear" slope="0" intercept="0.5"/>
  • trunk/LayoutTests/fast/gradients/conic-gradient-alpha-unpremultiplied.html

    r287310 r287982  
    3939<defs>
    4040    <filter id="posterize" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
    41         <feComponentTransfer>
     41        <feComponentTransfer color-interpolation-filters="sRGB">
    4242            <feFuncR type="discrete" tableValues="0 0.125 0.25 0.375 0.5 0.625 0.75 0.875"/>
    4343            <feFuncG type="discrete" tableValues="0 0.125 0.25 0.375 0.5 0.625 0.75 0.875"/>
  • trunk/LayoutTests/fast/gradients/conic-gradient-extended-stops.html

    r245250 r287982  
    3939<defs>
    4040    <filter id="posterize" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
    41         <feComponentTransfer>
     41        <feComponentTransfer color-interpolation-filters="sRGB">
    4242            <feFuncR type="discrete" tableValues="0 0.0625 0.125 0.1875 0.25 0.3125 0.375 0.4375 0.5 0.5625 0.625 0.6875 0.75 0.8125 0.875 0.9375"/>
    4343            <feFuncG type="discrete" tableValues="0 0.0625 0.125 0.1875 0.25 0.3125 0.375 0.4375 0.5 0.5625 0.625 0.6875 0.75 0.8125 0.875 0.9375"/>
  • trunk/LayoutTests/fast/gradients/conic-gradient.html

    r245250 r287982  
    3939<defs>
    4040    <filter id="posterize" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
    41         <feComponentTransfer>
     41        <feComponentTransfer color-interpolation-filters="sRGB">
    4242            <feFuncR type="discrete" tableValues="0 0.125 0.25 0.375 0.5 0.625 0.75 0.875"/>
    4343            <feFuncG type="discrete" tableValues="0 0.125 0.25 0.375 0.5 0.625 0.75 0.875"/>
  • trunk/LayoutTests/fast/gradients/conic-repeating-last-stop.html

    r235999 r287982  
    2828<defs>
    2929    <filter id="posterize" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
    30         <feComponentTransfer>
     30        <feComponentTransfer color-interpolation-filters="sRGB">
    3131            <feFuncR type="discrete" tableValues="0 1"/>
    3232            <feFuncG type="discrete" tableValues="0 1"/>
  • trunk/LayoutTests/fast/hidpi/filters-turbulence.html

    r231485 r287982  
    1212    <svg>
    1313        <filter id="filter" x="0" y="0" width="100%" height="100%">
    14             <feTurbulence type="fractalNoise" numOctaves="0" />
     14            <feTurbulence type="fractalNoise" numOctaves="0" color-interpolation-filters="sRGB" />
    1515        </filter>
    1616  </svg>
  • trunk/LayoutTests/platform/win/TestExpectations

    r287942 r287982  
    47934793
    47944794webkit.org/b/235126 webanimations/accelerated-animation-after-forward-filling-animation.html [ ImageOnlyFailure ]
     4795
     4796# LinearSRGB color space is not supported on Windows.
     4797css3/filters/reference-filter-color-space.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r287981 r287982  
     12022-01-13  Said Abou-Hallawa  <said@apple.com>
     2
     3        Referenced SVG filter uses always sRGB color space for its result
     4        https://bugs.webkit.org/show_bug.cgi?id=235159
     5
     6        Reviewed by Simon Fraser.
     7
     8        Do not setOperatingColorSpace() of the lastEffect() of the referenced
     9        SVGFilter to DestinationColorSpace::SRGB(). This will have the pixels
     10        of the result FilterImage of the lastEffect() in the color space which
     11        is defined by the color-interpolation style of the effect SVGElement.
     12
     13        Test: css3/filters/reference-filter-color-space.html
     14
     15        * platform/graphics/filters/Filter.h:
     16        * rendering/CSSFilter.cpp:
     17        (WebCore::CSSFilter::create):
     18        Move checking the CoreImage support to this function.
     19
     20        (WebCore::CSSFilter::buildFilterFunctions):
     21        Remove resetting m_functions and m_outsets from this function since it
     22        is now called only once from CSSFilter::create().
     23
     24        (WebCore::CSSFilter::lastEffect const): Deleted.
     25        * rendering/CSSFilter.h:
     26        * svg/graphics/filters/SVGFilter.h:
     27
    1282022-01-13  Alan Bujtas  <zalan@apple.com>
    229
  • trunk/Source/WebCore/platform/graphics/filters/Filter.h

    r287782 r287982  
    6262    FloatRect clipToMaxEffectRect(const FloatRect& imageRect, const FloatRect& primitiveSubregion) const;
    6363
    64     virtual RefPtr<FilterEffect> lastEffect() const = 0;
    6564    virtual FilterEffectVector effectsOfType(FilterFunction::Type) const = 0;
    6665
  • trunk/Source/WebCore/rendering/CSSFilter.cpp

    r287892 r287982  
    5555        return nullptr;
    5656
     57#if USE(CORE_IMAGE)
     58    if (!filter->supportsCoreImageRendering())
     59        filter->setRenderingMode(RenderingMode::Unaccelerated);
     60#endif
    5761    return filter;
    5862}
     
    238242bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations, const FloatRect& targetBoundingBox)
    239243{
    240     m_functions.clear();
    241     m_outsets = { };
    242 
     244    RefPtr<FilterEffect> effect;
    243245    RefPtr<SVGFilter> filter;
    244    
     246
    245247    for (auto& operation : operations.operations()) {
    246         RefPtr<FilterEffect> effect;
    247 
    248248        switch (operation->type()) {
    249249        case FilterOperation::APPLE_INVERT_LIGHTNESS:
     
    293293        case FilterOperation::REFERENCE:
    294294            filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox);
    295             effect = nullptr;
    296295            break;
    297296
     
    300299        }
    301300
    302         if ((filter || effect) && m_functions.isEmpty())
     301        if (!filter && !effect)
     302            continue;
     303
     304        if (m_functions.isEmpty())
    303305            m_functions.append(SourceGraphic::create());
    304        
    305         if (filter) {
    306             effect = filter->lastEffect();
    307             effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
     306
     307        if (filter)
    308308            m_functions.append(filter.releaseNonNull());
    309             continue;
    310         }
    311 
    312         if (effect) {
    313             effect->setOperatingColorSpace(DestinationColorSpace::SRGB());
     309        else
    314310            m_functions.append(effect.releaseNonNull());
    315         }
    316311    }
    317312
     
    321316
    322317    m_functions.shrinkToFit();
    323 
    324 #if USE(CORE_IMAGE)
    325     if (!supportsCoreImageRendering())
    326         setRenderingMode(RenderingMode::Unaccelerated);
    327 #endif
    328 
    329318    return true;
    330 }
    331 
    332 RefPtr<FilterEffect> CSSFilter::lastEffect() const
    333 {
    334     if (m_functions.isEmpty())
    335         return nullptr;
    336 
    337     auto& function = m_functions.last();
    338     if (function->isSVGFilter())
    339         return downcast<SVGFilter>(function.ptr())->lastEffect();
    340 
    341     return downcast<FilterEffect>(function.ptr());
    342319}
    343320
  • trunk/Source/WebCore/rendering/CSSFilter.h

    r287782 r287982  
    5151    bool hasFilterThatShouldBeRestrictedBySecurityOrigin() const { return m_hasFilterThatShouldBeRestrictedBySecurityOrigin; }
    5252
    53     RefPtr<FilterEffect> lastEffect() const final;
    5453    FilterEffectVector effectsOfType(FilterFunction::Type) const final;
    5554
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h

    r287892 r287982  
    4545    const SVGFilterExpression& expression() const { return m_expression; }
    4646   
    47     RefPtr<FilterEffect> lastEffect() const final;
    4847    FilterEffectVector effectsOfType(FilterFunction::Type) const final;
    4948
     
    5756
    5857    void setExpression(SVGFilterExpression&& expression) { m_expression = WTFMove(expression); }
     58
     59    RefPtr<FilterEffect> lastEffect() const;
    5960
    6061#if USE(CORE_IMAGE)
Note: See TracChangeset for help on using the changeset viewer.