[cairo] [PATCH] Some rounding fixes

Uli Schlachter psychon at znc.in
Fri Nov 5 11:33:45 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi list,

Attached are the non-xcb-specific patches I got laying around. The first patch
should be obvious. It just fixes a wrong comment.


The second one changes the default implementation of _cairo_lround. This change
makes the implementation match the expected and documented behavior.
This is necessary because the rounding mode if _cairo_lround changed over time.

Since the dawn of time, _cairo_lround was using away-from-zero rounding, just
like lround. This was changed in 2006 by commit ce58f874fe253 to fix bug #214819
[1]. Ever since then, _cairo_lround was supposed to use arithmetic rounding to
fix this exact bug. However, January commit c000824 turned _cairo_lround into a
#define to lround for performance reasons (unless DISABLE_SOME_FLOATING_POINT
was enabled). This effectively reverted the commit from 2006.

My second patch now makes _cairo_lround use _cairo_round unless
DISABLE_SOME_FLOATING_POINT is defined which means it uses floor (r + 0.5) to do
its job. I hope the above makes clear why this should be correct and it fixes a
text position error in the Xlib backend here.

Chris Wilson already looked at this patch once and had a problem with a compiler
warning (_cairo_round returns a double while _cairo_lround returns an int). I
changed something and then Andrea Canciani got a compiler warning. I didn't have
any compiler warnings with this at all, so if the compiler warns about a cast,
please provide the whole compiler warning.


The third patch is a simpler one again. The dash-state test needs a surface with
a width of 1500. This means that for xlib-window and xcb-window, the screen has
to be at least 1500 pixel wide. The Xvfb call from the README is updated to be
large enough for this test.


Let's see how much stuff I broke and if I can get some of these patches through. :)

Cheers,
Uli

[1] https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=217819
- -- 
Q: Because it reverses the logical flow of conversation.
A: Why is putting a reply at the top of the message frowned upon?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBCAAGBQJM1E4HAAoJECLkKOvLj8sG4NwH/1x0+rgpe7VO2O7T0jttlWf7
gLy5S2i9bDikIWwuW7gaxb4rsS61Lnooruoz+BrapEahkq4TroXgib3A/r5y9Tl3
Q5NpmUo+ROfAdwV7ZB5tguwkJ9lFLnLA1X5DCQjkv/+5nWVTbTf2/AWU9txaFZQ+
djPmCwLbx07olK/FapS+qvc1TjBcGFD+EsN77Cr9MNz2ttKDZf+US7WnqW35yzte
nRWTM6C7MPhyY3spGD4x1giUAEIJkbB4hntAa+5Yefz8p9tw3wlIiAU2z/8nDh4K
EzaTx/5M4THy8elw7qglyerVa1vnwXjf+u8HCE9t9F+WjXDdXL/Cm1d21H9LrI8=
=CAy8
-----END PGP SIGNATURE-----


More information about the cairo mailing list