summaryrefslogtreecommitdiff
path: root/src/cairo-pdf-operators.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-09-23 20:00:18 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-09-23 20:08:38 +0100
commitae0511fbbe6c01b5fe8dfa531b3eaa791314931f (patch)
tree1fe2baa215690987986b123fc76a3905616cc5aa /src/cairo-pdf-operators.c
parentb7ab1fc791139f5d0fd38692b63514ed02bc8b51 (diff)
downloadcairo-ae0511fbbe6c01b5fe8dfa531b3eaa791314931f.tar.gz
[pdf] Do not modify the dashes in-place.
As PS has different semantics regarding a zero-length dash, we need to adjust the dash array before emitting. However, we need to modify a copy of the dash array since the same array may be used by the meta-surface when replaying to an image fallback.
Diffstat (limited to 'src/cairo-pdf-operators.c')
-rw-r--r--src/cairo-pdf-operators.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 0b6c00e51..baa36de19 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -571,6 +571,16 @@ _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t *pdf_operators,
for (i = 0; i < num_dashes; i += 2) {
if (dash[i] == 0.0) {
+ /* Do not modify the dashes in-place, as we may need to also
+ * replay this stroke to an image fallback.
+ */
+ if (dash == style->dash) {
+ dash = _cairo_malloc_ab (num_dashes, sizeof (double));
+ if (dash == NULL)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ memcpy (dash, style->dash, num_dashes * sizeof (double));
+ }
+
/* If we're at the front of the list, we first rotate
* two elements from the end of the list to the front
* of the list before folding away the 0.0. Or, if
@@ -581,10 +591,10 @@ _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t *pdf_operators,
double last_two[2];
if (num_dashes == 2) {
- if (dash != style->dash)
- free (dash);
+ free (dash);
return CAIRO_INT_STATUS_NOTHING_TO_DO;
}
+
/* The cases of num_dashes == 0, 1, or 3 elements
* cannot exist, so the rotation of 2 elements
* will always be safe */