[cairo-bugs] [Bug 4846] Performance problems for GTK+/Cairo on MacOS X

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Oct 27 16:43:28 PDT 2005


Please do not reply to this email: if you want to comment on the bug, go to    
       
the URL shown below and enter yourcomments there.     
   
https://bugs.freedesktop.org/show_bug.cgi?id=4846          
     




------- Additional Comments From bogdanni at hotmail.com  2005-10-27 16:43 -------
I took a closer look at what Bill Spitzak actually proposed, i.e. it does rounding of 65536 * val, and I 
think the code is correct. The one I put in comment #16 does actually chopping like on http://
www.stereopsis.com/FPU.html. Now I _really_ feel like an idiot.

The rounding is done in the sense of second definition in comment #16, i.e. half-way numbers are 
rounded to the closest even.

It's easy to overflow this operation, so some kind of input checking is useful. I reported I was getting 
huge numbers as input to _cairo_fixed_from_double(), it was because of the code mentioned in https://
bugs.freedesktop.org/show_bug.cgi?id=2675, comment #9:
     y_intersect = _cairo_fixed_from_double ((b2 - b1) / (m1 - m2));

I think is better to do the operation through a union, but check with a C language lawyer.
So the code would be like that:

#if __BIG_ENDIAN_
#define iman_ 1
#else
#define iman_ 0
#endif

cairo_fixed_t
_cairo_fixed_from_double (double d)
{
    union { double d; int32_t i[2]; } u;

    u.d = d + 68719476736. * 1.5;
    return u.i[iman_];
}

Sorry for any confusion I caused.
          
     
     
--           
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email         
     
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.


More information about the cairo-bugs mailing list