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
)
This commit is contained in:
Emmanuel Pacaud 2006-04-20 22:07:52 +02:00 committed by Carl Worth
parent e1be80b020
commit a732058920
3 changed files with 19 additions and 12 deletions

View file

@ -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,

View file

@ -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 *

View file

@ -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 */