List Info

Thread: svn commit: r479573 - in /xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt: MultipleGradient




svn commit: r479573 - in /xmlgraphics/batik/trunk/sources/org/apa che/batik/ext/awt: MultipleGradient
user name
2006-11-28 10:48:32
Hi Dieter,

dvholtenapache.org wrote on 11/27/2006 05:13:38 AM:

> +        // the previous implementation used a simple
+0.5d to do some 
rounding.
> +        // but that is just rounding towards
+inifitity.

    Actually the two should give the same result:

        (((int) ((a1 + i * da * stepSize) + .5) <<
24)) |
 
        The quantity (a1 + i * da * stepSize) must always be
positive, so adding +.5 and integerizing will always give 
correct rounding.  That said your extracting part of the
computation is probably a win (depends if compiler is
smart enough, in my experience Java compilers aren't).


> +        // this implementation uses an implied
multiplication by 2 ( in 
tempX )
> +        // and then a signed right-shift to do signed
rounding.
> +        // this also spares a float-add per
color-band.
> +        // we could also save the shift when we use a
different 
and-mask 
> +        // and a different left-shift, but that would
obfuscate too 
much...

   Actually, if this is really a hot spot it would be best
to turn this
into a fixed point calculation. BTW, I don't think saving
the shift
would really obfuscate the code too much.

>          }
> +        Math.round( 2.6 );
>      }

    I think this was left over from testing?




------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-dev-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-dev-helpxmlgraphics.apache.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )