Title: [96470] trunk
Revision
96470
Author
[email protected]
Date
2011-10-02 00:15:08 -0700 (Sun, 02 Oct 2011)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96469 => 96470)


--- trunk/LayoutTests/ChangeLog	2011-10-02 06:49:32 UTC (rev 96469)
+++ trunk/LayoutTests/ChangeLog	2011-10-02 07:15:08 UTC (rev 96470)
@@ -1,3 +1,19 @@
+2011-10-02  Dirk Schulze  <[email protected]>
+
+        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
+
+        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.
+
 2011-10-01  Adam Barth  <[email protected]>
 
         Tweak expectations for leopard some more.

Added: trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-2-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-2-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-2-expected.txt (0 => 96470)


--- trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-2-expected.txt	2011-10-02 07:15:08 UTC (rev 96470)
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,143) size 781x294
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceLinearGradient {linearGradient} [id="Gradient"] [gradientUnits=userSpaceOnUse] [start=(0,0)] [end=(800,0)]
+        RenderSVGGradientStop {stop} [offset=0.00] [color=#FFFFFF]
+        RenderSVGGradientStop {stop} [offset=1.00] [color=#000000]
+    RenderSVGResourceMasker {mask} [id="Mask1"] [maskUnits=userSpaceOnUse] [maskContentUnits=userSpaceOnUse]
+      RenderSVGPath {rect} at (0,143) size 781x99 [fill={[type=LINEAR-GRADIENT] [id="Gradient"]}] [x=0.00] [y=0.00] [width=800.00] [height=100.00]
+    RenderSVGResourceMasker {mask} [id="Mask2"] [maskUnits=userSpaceOnUse] [maskContentUnits=userSpaceOnUse]
+      RenderSVGPath {rect} at (0,241) size 781x99 [fill={[type=LINEAR-GRADIENT] [id="Gradient"]}] [x=0.00] [y=100.00] [width=800.00] [height=100.00]
+    RenderSVGResourceMasker {mask} [id="Mask3"] [maskUnits=userSpaceOnUse] [maskContentUnits=userSpaceOnUse]
+      RenderSVGPath {rect} at (0,339) size 781x98 [fill={[type=LINEAR-GRADIENT] [id="Gradient"]}] [x=0.00] [y=200.00] [width=800.00] [height=100.00]
+    RenderSVGPath {rect} at (0,143) size 781x294 [fill={[type=SOLID] [color=#FF8080]}] [x=0.00] [y=0.00] [width=800.00] [height=300.00]
+    RenderSVGPath {rect} at (0,143) size 781x99 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=0.00] [width=800.00] [height=100.00]
+      [masker="Mask1"] RenderSVGResourceMasker {mask} at (0,0) size 800x100
+    RenderSVGPath {rect} at (0,241) size 781x99 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=100.00] [width=800.00] [height=100.00]
+      [masker="Mask2"] RenderSVGResourceMasker {mask} at (0,100) size 800x100
+    RenderSVGPath {rect} at (0,339) size 781x98 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=200.00] [width=800.00] [height=100.00]
+      [masker="Mask3"] RenderSVGResourceMasker {mask} at (0,200) size 800x100

Modified: trunk/LayoutTests/platform/mac/svg/custom/grayscale-gradient-mask-expected.png


(Binary files differ)

Added: trunk/LayoutTests/svg/custom/grayscale-gradient-mask-2.svg (0 => 96470)


--- trunk/LayoutTests/svg/custom/grayscale-gradient-mask-2.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/grayscale-gradient-mask-2.svg	2011-10-02 07:15:08 UTC (rev 96470)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg viewBox="0 0 820 320" version="1.1" xmlns="http://www.w3.org/2000/svg">
+  <desc>Example mask01 - blue text masked with gradient against red background
+  </desc>
+  <defs>
+    <linearGradient id="Gradient" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="800" y2="0">
+      <stop offset="0" stop-color="white" stop-opacity="1"/> <!-- this end is filled -->
+      <stop offset="1" stop-color="black" stop-opacity="1"/>
+    </linearGradient>
+  </defs>
+  <mask id="Mask1" maskUnits="userSpaceOnUse" x="0" y="0" width="800" height="100">
+     <rect x="0" y="0" width="800" height="100" fill="url(#Gradient)"/>
+  </mask>
+  <mask id="Mask2" maskUnits="userSpaceOnUse" x="0" y="100" width="800" height="100" color-interpolation="linearRGB">
+     <rect x="0" y="100" width="800" height="100" fill="url(#Gradient)"/>
+  </mask>
+  <mask id="Mask3" maskUnits="userSpaceOnUse" x="0" y="200" width="800" height="100" color-interpolation="sRGB">
+     <rect x="0" y="200" width="800" height="100" fill="url(#Gradient)"/>
+  </mask>
+  <rect x="0" y="0" width="800" height="300" fill="#FF8080"/>
+  <rect x="0" y="0" width="800" height="100" fill="blue" mask="url(#Mask1)"/>
+  <rect x="0" y="100" width="800" height="100" fill="blue" mask="url(#Mask2)"/>
+  <rect x="0" y="200" width="800" height="100" fill="blue" mask="url(#Mask3)"/>
+</svg>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (96469 => 96470)


--- trunk/Source/WebCore/ChangeLog	2011-10-02 06:49:32 UTC (rev 96469)
+++ trunk/Source/WebCore/ChangeLog	2011-10-02 07:15:08 UTC (rev 96470)
@@ -1,3 +1,23 @@
+2011-10-02  Dirk Schulze  <[email protected]>
+
+        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
+
+        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:
+
 2011-10-01  Vangelis Kokkevis  <[email protected]>
 
         [chromium] Fixing draw matrix for composited layers. This

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (96469 => 96470)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2011-10-02 06:49:32 UTC (rev 96469)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2011-10-02 07:15:08 UTC (rev 96470)
@@ -106,7 +106,11 @@
         if (!maskElement)
             return false;
 
-        if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, ColorSpaceLinearRGB))
+        ASSERT(style());
+        const SVGRenderStyle* svgStyle = style()->svgStyle();
+        ASSERT(svgStyle);
+        ColorSpace colorSpace = svgStyle->colorInterpolation() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB;
+        if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskerData->maskImage, colorSpace))
             return false;
 
         GraphicsContext* maskImageContext = maskerData->maskImage->context();
@@ -117,7 +121,7 @@
         maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
         maskImageContext->concatCTM(absoluteTransform);
 
-        drawContentIntoMaskImage(maskerData, maskElement, object);
+        drawContentIntoMaskImage(maskerData, colorSpace, maskElement, object);
     }
 
     if (!maskerData->maskImage)
@@ -127,7 +131,7 @@
     return true;
 }
 
-void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, const SVGMaskElement* maskElement, RenderObject* object)
+void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object)
 {
     GraphicsContext* maskImageContext = maskerData->maskImage->context();
     ASSERT(maskImageContext);
@@ -155,7 +159,9 @@
     maskImageContext->restore();
 
 #if !USE(CG)
-    maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, ColorSpaceLinearRGB);
+    maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace);
+#else
+    UNUSED_PARAM(colorSpace);
 #endif
 
     // Create the luminance mask.

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h (96469 => 96470)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h	2011-10-02 06:49:32 UTC (rev 96469)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h	2011-10-02 07:15:08 UTC (rev 96470)
@@ -57,7 +57,7 @@
     static RenderSVGResourceType s_resourceType;
 
 private:
-    void drawContentIntoMaskImage(MaskerData*, const SVGMaskElement*, RenderObject*);
+    void drawContentIntoMaskImage(MaskerData*, ColorSpace, const SVGMaskElement*, RenderObject*);
     void calculateMaskContentRepaintRect();
 
     FloatRect m_maskContentBoundaries;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to