Skip to content

Commit

Permalink
PDF: Fix regression in EXTEND_NONE gradients
Browse files Browse the repository at this point in the history
The test for opaque gradients in _cairo_pdf_surface_add_pdf_pattern()
must be identical to the test in
_cairo_pdf_surface_emit_pattern_stops() other wise the PDF file will
reference a smask that does not exist.

The _cairo_pattern_is_opaque() test is too strict for PDF as PDF can
draw EXTEND_NONE gradients with opaque color stops without requiring a
smask.
  • Loading branch information
Adrian Johnson committed Oct 15, 2010
1 parent 6fecbb0 commit 7a17ef3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/cairo-pdf-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,18 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface,
return status;
}

static cairo_bool_t
_gradient_stops_are_opaque (const cairo_gradient_pattern_t *gradient)
{
unsigned int i;

for (i = 0; i < gradient->n_stops; i++)
if (! CAIRO_COLOR_IS_OPAQUE (&gradient->stops[i].color))
return FALSE;

return TRUE;
}

static cairo_status_t
_cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface,
const cairo_pattern_t *pattern,
Expand Down Expand Up @@ -1237,7 +1249,8 @@ _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface,
if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR ||
pattern->type == CAIRO_PATTERN_TYPE_RADIAL)
{
if (_cairo_pattern_is_opaque (pattern, extents) == FALSE) {
cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
if (! _gradient_stops_are_opaque (gradient)) {
pdf_pattern.gstate_res = _cairo_pdf_surface_new_object (surface);
if (pdf_pattern.gstate_res.id == 0) {
cairo_pattern_destroy (pdf_pattern.pattern);
Expand Down

0 comments on commit 7a17ef3

Please sign in to comment.