Bug 885585 - Work around Quartz issue where a stroke with a dasharray whose gaps add up to zero does not render. r=vlad,longsonr

This commit is contained in:
Cameron McCormack 2013-06-23 15:10:44 +10:00
parent a0b411af4b
commit baadccc2ab
6 changed files with 114 additions and 11 deletions

View File

@ -206,6 +206,8 @@ fix-win32-font-assertion.patch: Bug 838617, fix assertion from bug 717178 that w
xlib-flush-glyphs.patch: bug 839745, flush glyphs when necessary
dasharray-zero-gap.patch: bug 885585, ensure strokes get painted when the gaps in a dash array are all zero length
==== pixman patches ====
pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.

View File

@ -2578,19 +2578,33 @@ _cairo_quartz_surface_stroke_cg (void *abstract_surface,
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);
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;
for (k = 0; k < max_dashes; k++)
fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes];
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);
CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes);
if (fdash != sdash)
free (fdash);
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);

View File

@ -0,0 +1,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);

View File

@ -309,6 +309,7 @@ pref(svg.text.css-frames.enabled,true) == text-layout-08.svg text-layout-08-ref.
HTTP(..) == text-scale-02.svg text-scale-02-ref.svg
HTTP(..) == text-scale-03.svg text-scale-03-ref.svg
== text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
== stroke-dasharray-01.svg stroke-dasharray-01-ref.svg
== stroke-dasharray-and-pathLength-01.svg pass.svg
== stroke-dasharray-and-text-01.svg stroke-dasharray-and-text-01-ref.svg
== stroke-linecap-square-w-zero-length-segs-01.svg pass.svg

View File

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<title>Reference for a stroke with a dasharray whose gaps add up to 0 still painting</title>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=885585 -->
<g fill="none" stroke="black" stroke-width="2">
<path d="M 100,100 v 100"/>
<path d="M 110,100 h 100"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 446 B

View File

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<title>Test for a stroke with a dasharray whose gaps add up to 0 still painting</title>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=885585 -->
<g fill="none" stroke="black" stroke-width="2" stroke-dasharray="10 0">
<path d="M 100,100 v 100"/>
<path d="M 110,100 h 100"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 465 B