feTurbulence "spec" is invalid code

Hi,

The specification for the feTurbulence filter primitive consists of a 
chunk of code that claims to be C, but contains invalid C++ idioms such 
as constructor-style type casts:

sx = double(s_curve(rx0));
sy = double(s_curve(ry0));

In C these would be correctly written like this:

sx = (double) s_curve(rx0);
sy = (double) s_curve(ry0);

In fact, the type casts are entirely unnecessary, as the s_curve macro 
expands to this expression:

sx = ( rx0 * rx0 * (3. - 2. * rx0) );
sy = ( ry0 * ry0 * (3. - 2. * ry0) );

and all of the values and variables on both sides are already doubles.

The code also contains a number of anachronisms, like the "register" 
keyword, and untyped variables and arrays expected to implicitly be 
typed as ints, which is not valid in ISO C++.

As a result the code as written is not valid C or C++, and will not 
compile in either language without modification.

More annoyingly, the spec does not state how the turbulence function is 
actually used. Because it depends on a persistent random seed value, the 
order of evaluation is significant, and different results will be 
obtained if the image is traversed in a different order. The spec says:

"The following order is used for applying the pseudo random numbers. An 
initial seed value is computed based on attribute ‘seed’. Then the 
implementation computes the lattice points for R, then continues getting 
additional pseudo random numbers relative to the last generated pseudo 
random number and computes the lattice points for G, and so on for B and A."

Does this imply this order:

for (y = 0; y < height; ++y)
   for (x = 0; x < height; ++x)
     for (c = 0; c < 4; ++c)
       turbulence(c, ...);

Or this order:

for (c = 0; c < 4; ++c)
   for (y = 0; y < height; ++y)
     for (x = 0; x < height; ++x)
       turbulence(c, ...);

Or something else entirely?

There is also no specification of the meaning of the nColorChannel 
argument to the turbulence function. Presumably this is 0/1/2/3 for 
R/G/B/A, but it would be nice if this was explicitly stated.

Best regards,

Michael

-- 
Print XML with Prince!
http://www.princexml.com

Received on Wednesday, 1 September 2010 04:12:41 UTC