[cairo-bugs] [Bug 25814] New: Cairo Quartz should be using CGFloat

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Dec 28 13:44:51 PST 2009


           Summary: Cairo Quartz should be using CGFloat
           Product: cairo
           Version: 1.9.5
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: quartz backend
        AssignedTo: vladimir at pobox.com
        ReportedBy: kris at gtk.org
         QAContact: cairo-bugs at cairographics.org

Since Mac OS 10.6, CoreGraphics has switched to using CGFloat.  CGFloat is
defined to be a float on 32-bit systems and a double on 64-bit systems. 
Currently the Cairo Quartz backend uses plain floats, which causes issues with
64-bit builds.  For example, calls to CGContextSetLineDash() pass an array of
floats now, where an array of doubles is expected on 64-bit.  This particular
case breaks GTK+'s drawing of the dashed focus rectangles on 64-bit Mac OS.

Now that CGFloat is only available on Mac OS 10.6 and higher, we have to
proceed with caution.  Something likewise to "#ifdef NSINTEGER_DEFINED" can
likely be done, if CGFloat has not been defined by system headers Cairo can
define it to be float by default.  Then, in all of the cairo-quartz-surface.c
source code CGFloat should be used.

An example that fixes the dashed line case for me:

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 44b25a3..a48e6d3 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -2039,20 +2039,20 @@ _cairo_quartz_surface_stroke (void *abstract_surface,

     if (style->dash && style->num_dashes) {
 #define STATIC_DASH 32
-       float sdash[STATIC_DASH];
-       float *fdash = sdash;
+       CGFloat sdash[STATIC_DASH];
+       CGFloat *fdash = sdash;
        unsigned int max_dashes = style->num_dashes;
        unsigned int k;

        if (style->num_dashes%2)
            max_dashes *= 2;
        if (max_dashes > STATIC_DASH)
-           fdash = _cairo_malloc_ab (max_dashes, sizeof (float));
+           fdash = _cairo_malloc_ab (max_dashes, sizeof (CGFloat));
        if (fdash == NULL)
            return _cairo_error (CAIRO_STATUS_NO_MEMORY);

        for (k = 0; k < max_dashes; k++)
-           fdash[k] = (float) style->dash[k % style->num_dashes];
+           fdash[k] = (CGFloat) style->dash[k % style->num_dashes];

        CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash,
        if (fdash != sdash)

If wished I can work on a patch that fully migrates the Cairo Quartz backend to
CGFloat and test this on an old school 32-bit Tiger machine and a new school
64-bit machine.

Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the cairo-bugs mailing list