Changeset 96470 in webkit


Ignore:
Timestamp:
Oct 2, 2011 12:15:08 AM (13 years ago)
Author:
krit@webkit.org
Message:

SVG Mask should take 'color-interpolation' into account to determine the color space of the mask image
https://bugs.webkit.org/show_bug.cgi?id=69076

Source/WebCore:

Reviewed by Simon Fraser.

SVG Masks should take 'color-interpolation' into account to determine the color space of the mask image.
The behavior was changed in SVG 1.1 SE. The color space of the mask image gets defined by the computed value of the
'color-interpolation' property. This will switch the default color space from linearRGB to sRGB for mask images and
is a performance improvement for platforms without native support for linearRGB color space. The
color space transformation can be avoided.

Test: svg/custom/grayscale-gradient-mask-2.svg

  • rendering/svg/RenderSVGResourceMasker.cpp:

(WebCore::RenderSVGResourceMasker::applyResource):
(WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):

  • rendering/svg/RenderSVGResourceMasker.h:

LayoutTests:

Reviewed by Simon Fraser.

Added a new test case to check the behavior of SVG Masks on different values for the 'color-interpolation' property.
Since the default color space of the mask image changes from linearRGB to sRGB, a test needed an update.

  • platform/mac/svg/custom/grayscale-gradient-mask-2-expected.png: Added.
  • platform/mac/svg/custom/grayscale-gradient-mask-2-expected.txt: Added.
  • platform/mac/svg/custom/grayscale-gradient-mask-expected.png:
  • platform/mac/svg/custom/grayscale-gradient-mask-expected.txt:
  • svg/custom/grayscale-gradient-mask-2.svg: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96469 r96470  
     12011-10-02  Dirk Schulze  <krit@webkit.org>
     2
     3        SVG Mask should take 'color-interpolation' into account to determine the color space of the mask image
     4        https://bugs.webkit.org/show_bug.cgi?id=69076
     5
     6        Reviewed by Simon Fraser.
     7       
     8        Added a new test case to check the behavior of SVG Masks on different values for the 'color-interpolation' property.
     9        Since the default color space of the mask image changes from linearRGB to sRGB, a test needed an update.
     10
     11        * platform/mac/svg/custom/grayscale-gradient-mask-2-expected.png: Added.
     12        * platform/mac/svg/custom/grayscale-gradient-mask-2-expected.txt: Added.
     13        * platform/mac/svg/custom/grayscale-gradient-mask-expected.png:
     14        * platform/mac/svg/custom/grayscale-gradient-mask-expected.txt:
     15        * svg/custom/grayscale-gradient-mask-2.svg: Added.
     16
    1172011-10-01  Adam Barth  <abarth@webkit.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r96467 r96470  
     12011-10-02  Dirk Schulze  <krit@webkit.org>
     2
     3        SVG Mask should take 'color-interpolation' into account to determine the color space of the mask image
     4        https://bugs.webkit.org/show_bug.cgi?id=69076
     5
     6        Reviewed by Simon Fraser.
     7       
     8        SVG Masks should take 'color-interpolation' into account to determine the color space of the mask image.
     9        The behavior was changed in SVG 1.1 SE. The color space of the mask image gets defined by the computed value of the
     10        'color-interpolation' property. This will switch the default color space from linearRGB to sRGB for mask images and
     11        is a performance improvement for platforms without native support for linearRGB color space. The
     12        color space transformation can be avoided.
     13
     14        Test: svg/custom/grayscale-gradient-mask-2.svg
     15
     16        * rendering/svg/RenderSVGResourceMasker.cpp:
     17        (WebCore::RenderSVGResourceMasker::applyResource):
     18        (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
     19        * rendering/svg/RenderSVGResourceMasker.h:
     20
    1212011-10-01  Vangelis Kokkevis  <vangelis@chromium.org>
    222
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

    r96155 r96470  
    107107            return false;
    108108
    109         if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, ColorSpaceLinearRGB))
     109        ASSERT(style());
     110        const SVGRenderStyle* svgStyle = style()->svgStyle();
     111        ASSERT(svgStyle);
     112        ColorSpace colorSpace = svgStyle->colorInterpolation() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB;
     113        if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, colorSpace))
    110114            return false;
    111115
     
    118122        maskImageContext->concatCTM(absoluteTransform);
    119123
    120         drawContentIntoMaskImage(maskerData, maskElement, object);
     124        drawContentIntoMaskImage(maskerData, colorSpace, maskElement, object);
    121125    }
    122126
     
    128132}
    129133
    130 void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, const SVGMaskElement* maskElement, RenderObject* object)
     134void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object)
    131135{
    132136    GraphicsContext* maskImageContext = maskerData->maskImage->context();
     
    156160
    157161#if !USE(CG)
    158     maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, ColorSpaceLinearRGB);
     162    maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace);
     163#else
     164    UNUSED_PARAM(colorSpace);
    159165#endif
    160166
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h

    r95901 r96470  
    5858
    5959private:
    60     void drawContentIntoMaskImage(MaskerData*, const SVGMaskElement*, RenderObject*);
     60    void drawContentIntoMaskImage(MaskerData*, ColorSpace, const SVGMaskElement*, RenderObject*);
    6161    void calculateMaskContentRepaintRect();
    6262
Note: See TracChangeset for help on using the changeset viewer.