diff options
author | Emmanuel Pacaud <emmanuel.pacaud@free.fr> | 2006-04-20 22:07:52 +0200 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-04-27 06:36:16 -0700 |
commit | a7320589207088351c035df55644f1d94600f313 (patch) | |
tree | fa95c8c867a9e35cc10fe09a1609b318fc580333 | |
parent | e1be80b02080955e29d17c50118471158593b86f (diff) |
Implement paginated create_similar, moving similar images down to PS and PDF.
The new paginated create_similar simply forwards to target backend create_similar.
We maintain the fact that PS and PDF surfaces are returning image
surfaces for create_similar by moving that explicitly to their own
create_similar functions.
(This commit is the combination of the following original commits:
6b69e8c012adb4f2fc2ee9c1579fed8214e8f510
2589db92a4395f8e900dbc4eafc45982f0d985d3
)
-rw-r--r-- | src/cairo-paginated-surface.c | 9 | ||||
-rw-r--r-- | src/cairo-pdf-surface.c | 7 | ||||
-rw-r--r-- | src/cairo-ps-surface.c | 15 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index da6a60bb5..080102b01 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -79,12 +79,6 @@ const cairo_private cairo_surface_backend_t cairo_paginated_surface_backend; static cairo_int_status_t _cairo_paginated_surface_show_page (void *abstract_surface); -/* XXX: This would seem the natural thing to do here. But currently, - * PDF and PS surfaces do not yet work as source surfaces. So instead, - * we don't implement create_similar for the paginate_surface which - * means that any create_similar() call on a paginated_surfacae will - * result in a new image surface. */ -#if 0 static cairo_surface_t * _cairo_paginated_surface_create_similar (void *abstract_surface, cairo_content_t content, @@ -95,7 +89,6 @@ _cairo_paginated_surface_create_similar (void *abstract_surface, return cairo_surface_create_similar (surface->target, content, width, height); } -#endif cairo_surface_t * _cairo_paginated_surface_create (cairo_surface_t *target, @@ -471,7 +464,7 @@ _cairo_paginated_surface_snapshot (void *abstract_other) const cairo_surface_backend_t cairo_paginated_surface_backend = { CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED, - NULL, /* create_similar --- see note for _cairo_paginated_surface_create_similar */ + _cairo_paginated_surface_create_similar, _cairo_paginated_surface_finish, _cairo_paginated_surface_acquire_source_image, _cairo_paginated_surface_release_source_image, diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 93a8217e0..4d557aaf9 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -456,10 +456,11 @@ _cairo_pdf_surface_create_similar (void *abstract_src, int width, int height) { - cairo_pdf_surface_t *template = abstract_src; + cairo_format_t format = _cairo_format_from_content (content); - return _cairo_pdf_surface_create_for_document (template->document, - width, height); + /* Just return an image for now, until PDF surface can be used + * as source. */ + return cairo_image_surface_create (format, width, height); } static cairo_pdf_stream_t * diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index cf77db206..f84a57ad6 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -780,6 +780,19 @@ _word_wrap_stream_create (cairo_output_stream_t *output, int max_column) NULL, stream); } +static cairo_surface_t * +_cairo_ps_surface_create_similar (void *abstract_src, + cairo_content_t content, + int width, + int height) +{ + cairo_format_t format = _cairo_format_from_content (content); + + /* Just return an image for now, until PS surface can be used + * as source. */ + return cairo_image_surface_create (format, width, height); +} + static cairo_status_t _cairo_ps_surface_finish (void *abstract_surface) { @@ -1634,7 +1647,7 @@ _cairo_ps_surface_set_paginated_mode (void *abstract_surface, static const cairo_surface_backend_t cairo_ps_surface_backend = { CAIRO_SURFACE_TYPE_PS, - NULL, /* create_similar */ + _cairo_ps_surface_create_similar, _cairo_ps_surface_finish, NULL, /* acquire_source_image */ NULL, /* release_source_image */ |