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