From 044de7fa7aa0da19ead348094697b2227e882417 Mon Sep 17 00:00:00 2001 From: Brian Ewins Date: Sun, 24 Jun 2007 23:53:47 +0100 Subject: [PATCH] fix dash-zero-length test Quartz was failing the dash-zero-length test for odd numbers of dashes; it seems cairo wants 3 dashes to be on-off-on, off-on-off, wheras quartz uses on-off-on, on-off-on. Fixed by doubling the number of dashes used. (cherry picked from commit b9c065df74027b06e15e105fee5e4a4d350e0abf) --- src/cairo-quartz-surface.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 21ed34d32..7e577a650 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1288,15 +1288,21 @@ _cairo_quartz_surface_stroke (void *abstract_surface, #define STATIC_DASH 32 float sdash[STATIC_DASH]; float *fdash = sdash; + unsigned int max_dashes = style->num_dashes; unsigned int k; - if (style->num_dashes > STATIC_DASH) + + if (style->num_dashes%2) + max_dashes *= 2; + if (max_dashes > STATIC_DASH) fdash = _cairo_malloc_ab (style->num_dashes, sizeof (float)); - for (k = 0; k < style->num_dashes; k++) - fdash[k] = (float) style->dash[k]; - - CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, style->num_dashes); + if (max_dashes > STATIC_DASH) + fdash = malloc (sizeof(float)*max_dashes); + for (k = 0; k < max_dashes; k++) + fdash[k] = (float) style->dash[k % style->num_dashes]; + + CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes); if (fdash != sdash) free (fdash); }