summaryrefslogtreecommitdiff
path: root/gfx/cairo/dasharray-zero-gap.patch
blob: e26580ae1487fd6a4d76238488c1e9e44f892410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
@@ -2573,29 +2573,43 @@ static cairo_int_status_t
 
     if (style->dash && style->num_dashes) {
 #define STATIC_DASH 32
 	cairo_quartz_float_t sdash[STATIC_DASH];
 	cairo_quartz_float_t *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 (cairo_quartz_float_t));
-	if (fdash == NULL)
-	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-	for (k = 0; k < max_dashes; k++)
-	    fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes];
-
-	CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes);
-	if (fdash != sdash)
-	    free (fdash);
+	bool set_line_dash = false;
+	if (style->num_dashes % 2 == 0) {
+	    for (k = 1; k < max_dashes; k++) {
+		if (style->dash[k]) {
+		    set_line_dash = true;
+		    break;
+		}
+	    }
+	} else
+	    set_line_dash = true;
+
+	if (set_line_dash) {
+	    if (style->num_dashes%2)
+		max_dashes *= 2;
+	    if (max_dashes > STATIC_DASH)
+		fdash = _cairo_malloc_ab (max_dashes, sizeof (cairo_quartz_float_t));
+	    if (fdash == NULL)
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+	    for (k = 0; k < max_dashes; k++)
+		fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes];
+
+	    CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes);
+	    if (fdash != sdash)
+		free (fdash);
+	} else
+	    CGContextSetLineDash (state.context, 0, NULL, 0);
     } else
 	CGContextSetLineDash (state.context, 0, NULL, 0);
 
 
     _cairo_quartz_cairo_path_to_quartz_context (path, state.context);
 
     _cairo_quartz_cairo_matrix_to_quartz (ctm, &strokeTransform);
     CGContextConcatCTM (state.context, strokeTransform);