diff options
author | Carl Worth <cworth@cworth.org> | 2006-04-18 23:24:14 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-04-18 23:31:52 -0700 |
commit | 241c6480cd9a5f63ea67f8cb1407f22503697ca3 (patch) | |
tree | fdaec42ca6aa94c5eae5c24b30669028924cc6c8 /src | |
parent | 8be1697f2bd8026b28f2f24c2fab967ee01b6d8c (diff) |
Add implementation of _cairo_pdf_surface_paint (and fix emit_surface_pattern).
Fix general broken-ness in emit_surface_pattern, enough so that a new
implementation of _cairo_pdf_surface_paint does something useful. With
this commit, the following tests switch from all-fallback to
all-native and still pass the test suite with flying colors:
caps-joins
caps-sub-paths
clip-fill-rule
clip-fill-rule-pixel-aligned
clip-nesting
clip-twice
dash-caps-joins
dash-offset-negative
leaky-polygon
line-width
paint
path-data
transforms
Meanwhile, the following two tests also switch from fallback to
native, but cause the test suite to complain about failures. These
both look like a mostly harmless failure to respect the ANTIALIAS_NONE
hint in the PDF output:
rectangle-rounding-error-pdf-argb32-out.pdf
unantialiased-shapes-pdf-argb32-out.pdf
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-pdf-surface.c | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index ef08ffce7..027e2cb17 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -175,7 +175,7 @@ _cairo_pdf_surface_clear (cairo_pdf_surface_t *surface); static cairo_pdf_stream_t * _cairo_pdf_document_open_stream (cairo_pdf_document_t *document, const char *fmt, - ...); + ...) CAIRO_PRINTF_FORMAT(2, 3); static void _cairo_pdf_document_close_stream (cairo_pdf_document_t *document); @@ -930,7 +930,7 @@ emit_surface_pattern (cairo_pdf_surface_t *dst, void *image_extra; cairo_status_t status; unsigned int id, alpha; - cairo_matrix_t pm; + cairo_matrix_t i2u; /* XXX: This is broken. We need new code here to actually emit the * PDF surface. */ @@ -947,25 +947,27 @@ emit_surface_pattern (cairo_pdf_surface_t *dst, /* BBox must be smaller than XStep by YStep or acroread wont * display the pattern. */ - - cairo_matrix_init_identity (&pm); - cairo_matrix_scale (&pm, image->width, image->height); - pm = pattern->base.matrix; - cairo_matrix_invert (&pm); - stream = _cairo_pdf_document_open_stream (document, - " /BBox [ 0 0 256 256 ]\r\n" - " /XStep 256\r\n" - " /YStep 256\r\n" + " /BBox [ 0 0 %d %d ]\r\n" + " /XStep %d\r\n" + " /YStep %d\r\n" " /PatternType 1\r\n" " /TilingType 1\r\n" " /PaintType 1\r\n" " /Resources << /XObject << /res%d %d 0 R >> >>\r\n", + image->width, image->height, + image->width, image->height, id, id); + i2u = pattern->base.matrix; + cairo_matrix_invert (&i2u); + cairo_matrix_scale (&i2u, image->width, image->height); _cairo_output_stream_printf (output, - " /res%d Do\r\n", + "q %f %f %f %f %f %f cm /res%d Do Q\r\n", + i2u.xx, i2u.yx, + i2u.xy, i2u.yy, + i2u.x0, i2u.y0, id); _cairo_pdf_surface_add_pattern (dst, stream->id); @@ -2096,17 +2098,42 @@ _cairo_pdf_surface_paint (void *abstract_surface, cairo_pattern_t *source) { cairo_pdf_surface_t *surface = abstract_surface; + cairo_pdf_document_t *document = surface->document; + cairo_status_t status; if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) - return CAIRO_INT_STATUS_UNSUPPORTED; + return _analyze_operation (surface, op, source); - /* One would think that since we analyzed this away as unsupported - * that it would never be called after analyzing. But in fact, - * paint is called to paint the actual fallback surface. So we - * must not ASSERT_NOT_REACHED as we do for the other drawing - * operations. */ + /* XXX: It would be nice to be able to assert this condition + * here. But, we actually allow one 'cheat' that is used when + * painting the final image-based fallbacks. The final fallbacks + * do have alpha which we support by blending with white. This is + * possible only because there is nothing between the fallback + * images and the paper, nor is anything painted above. */ + /* + assert (_operation_supported (op, source)); + */ + +#if 0 + if (source->type == CAIRO_PATTERN_TYPE_SURFACE) + return _cairo_pdf_surface_composite_image (surface, (cairo_surface_pattern_t *) source); +#endif - return CAIRO_INT_STATUS_UNSUPPORTED; + status = emit_pattern (surface, source); + if (status) + return status; + + /* After emitting the pattern the current stream should belong to + * this surface, so no need to _cairo_pdf_surface_ensure_stream() + */ + assert (document->current_stream != NULL && + document->current_stream == surface->current_stream); + + _cairo_output_stream_printf (document->output_stream, + "0 0 %f %f re f\r\n", + surface->width, surface->height); + + return _cairo_output_stream_get_status (document->output_stream); } static cairo_int_status_t |