Calculation of feComposite "arithmetic"

I am having difficulty in determining the correct formula for the
"arithmetic" operator with the feComposite filter primitive.   

According to the spec 15.12:

"...a component-wise arithmetic operation (with the result clamped between
[0..1]) can be applied..."

An example SVG file is included at the end of this message.  Using the SVG
filter primitives, I use feComposite "arithmetic" to add red square with 50%
opacity (result "I1") to a green square with 50% opacity (result "I2").  The
result of this operation ("I3") is blended on top of a black square using
the feComposite "over" operation.   (The red and green outputs are generated
using the feColorMatrix operation.)

If straight addition of the RGBA channels were applied, the result would be
yellow with 100% opacity: 
	[1.0  0.0  0.0  0.5] + [0.0  1.0  0.0  0.5] = [1.0  1.0  0.0  1.0]

The color of the final result (over black rectangle) would then be the same:
	[1.0  1.0  0.0  1.0]

If the operation were applied to premultiplied RGBA channels, the result
would be:
	[0.5  0.0  0.0  0.5] + [0.0  0.5  0.0  0.5] = [0.5  0.5  0.0  1.0]

In this case, the color of the final result would also be the same:
	[0.5  0.5  0.0  1.0]

The color of the final result I'm getting from the the Adobe SVG Viewer is:
	[~0.73  ~0.73  0  1.0] 

In terms of 0-255 RBG values the result is RGB(187, 187, 0).

My guess is that Adobe is calculating the alpha value resulting from
"arithmetic" as follows:

	A1 + A2 - A1*A2

In the specific case presented above with red 50% and green 50%:

	0.5 + 0.5 - 0.5*0.5 = 0.75

When [1.0  1.0  0.0  0.75] is blended over [0.0  0.0  0.0  1.0] the result
is [0.75  0.75  0.0  1.0] and that's in line with Adobe's results.

But from the information provided in the spec, I can't determine exactly how
feComposite "arithmetic" should be calculated.

Any enlightenment on this subject will be greatly appreciated.

Thanks in advance,

James Mork
Principle Software Engineer
Jasc Software Inc.

---snip---
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
	"http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">
<svg width="100" height="100">
	<filter id="TestFilter" filterUnits="objectBoundingBox" x="0%"
y="0%"
		width="100%" height="100%">
		<feColorMatrix in="SourceGraphic" result="I1" type="matrix"
			values="0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5"/>
		<feColorMatrix in="SourceGraphic" result="I2" type="matrix"
			values="0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0.5"/>
		<feComposite operator="arithmetic" in="I1" in2="I2"
result="I3" k2="1" k3="1"/>
		<feComposite operator="over" in="I3" in2="SourceGraphic"/>
	</filter>
	<rect x="0" y="0" width="100" height="100" rx="0" ry="0"
style="stroke-miterlimit:4;stroke-linejoin:miter;stroke-width:1;stroke-opaci
ty:1;stroke:none;
	
fill-opacity:1;fill:rgb(0,0,0);opacity:1;filter:url(#TestFilter)"/>
</svg>
---snip---

Received on Wednesday, 28 February 2001 16:46:37 UTC