blob: c445d937fe4227e5c39639d058b727e7195fa5b1 [file] [log] [blame]
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="100">
<defs>
<!-- This filter produces results that are invalid pre-multiplied rgba pixels. Specifically, after the 4th step an -->
<!-- interior pixel will contain approximately (0, 0.8, 0, 0.6) which is invalid because g > a. When used in -->
<!-- other operations this may generate bad results but we only want to clamp the values when passed on to other -->
<!-- operations, not for intermediate arithmetic results. -->
<filter id="arithmetic">
<feComposite operator="arithmetic" in="SourceGraphic" in2="SourceGraphic" k1="0" k2="0.2" k3="0" k4="0" result="rgba02" />
<feComposite operator="arithmetic" in="SourceAlpha" in2="SourceAlpha" k1="0" k2="0.2" k3="0" k4="0" result="alpha05" />
<feComposite operator="arithmetic" in="rgba02" in2="alpha05" k1="0" k2="1" k3="1" k4="0" result="tmp" />
<feComposite operator="arithmetic" in="SourceGraphic" in2="tmp" k1="0" k2="1" k3="-1" k4="0" />
<feComposite operator="arithmetic" in="tmp" k1="0" k2="1" k3="1" k4="0" />
</filter>
<!-- This filter will produce images with zero alpha but non-zero color components. -->
<filter id="zero-alpha">
<feComposite operator="arithmetic" in="SourceAlpha" in2="SourceAlpha" k1="0" k2="1.0" k3="0" k4="0" result="alpha" />
<feComposite operator="arithmetic" in="SourceGraphic" in2="alpha" k1="0" k2="1.0" k3="-1.0" k4="0" />
</filter>
</defs>
<!-- Background for color comparison. The border of the final rectangle should be the same as the interior color. -->
<rect x="20" y="20" width="60" height="60" fill="rgba(0,255,0,1)" />
<!-- The content of interest -->
<rect filter="url(#arithmetic)" x="25" y="25" width="50" height="50" fill="rgba(0,255,0,1)" stroke="none" />
<!-- Border to show expected non-drawing area. -->
<rect x="125" y="25" width="50" height="50" fill="none" stroke="rgb(0,255,0)" />
<!-- This should produce nothing, and not cause a crash. -->
<rect filter="url(#zero-alpha)" x="125" y="25" width="50" height="50" fill="rgba(0,255,0,1)" stroke="none" />
</svg>