Reviewed by keithp

Implement copy_page for paginated surface. Fix show_page to destroy the meta-surface and create a new one.
Change these functions to advertise when they are not supported, so that _cairo_paginated_copy_page can implement things differently depending on whether or not it is personal.
Check return values from _cairo_surface_show/copy_page.
This commit is contained in:
Carl Worth 2006-01-06 14:11:07 +00:00
parent 88875100d6
commit fbb8a62797
5 changed files with 104 additions and 11 deletions

View file

@ -1,3 +1,24 @@
2006-01-06 Carl Worth <cworth@cworth.org>
Reviewed by keithp
* src/cairo-paginated-surface.c: (_cairo_paginated_surface_create),
(_cairo_paginated_surface_copy_page),
(_cairo_paginated_surface_show_page): Implement copy_page for
paginated surface. Fix show_page to destroy the meta-surface and
create a new one.
* src/cairoint.h:
* src/cairo-surface.c: (_cairo_surface_copy_page),
(_cairo_surface_show_page): Change these functions to advertise
when they are not supported, so that _cairo_paginated_copy_page
can implement things differently depending on whether or not it is
personal.
* src/cairo-gstate.c: (_cairo_gstate_copy_page),
(_cairo_gstate_show_page): Check return values from
_cairo_surface_show/copy_page.
2006-01-05 Carl Worth <cworth@cworth.org>
* ROADMAP: Slip 1.2.0 projected data (again) out to

View file

@ -1040,13 +1040,29 @@ BAIL:
cairo_status_t
_cairo_gstate_copy_page (cairo_gstate_t *gstate)
{
return _cairo_surface_copy_page (gstate->target);
cairo_int_status_t status;
status = _cairo_surface_copy_page (gstate->target);
/* It's fine if some surfaces just don't support this. */
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
return CAIRO_STATUS_SUCCESS;
return status;
}
cairo_status_t
_cairo_gstate_show_page (cairo_gstate_t *gstate)
{
return _cairo_surface_show_page (gstate->target);
cairo_int_status_t status;
status = _cairo_surface_show_page (gstate->target);
/* It's fine if some surfaces just don't support this. */
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
return CAIRO_STATUS_SUCCESS;
return status;
}
cairo_status_t

View file

@ -72,6 +72,14 @@
typedef struct _cairo_paginated_surface {
cairo_surface_t base;
/* XXX: These shouldn't actually exist. We inherit this ugliness
* from _cairo_meta_surface_create. The width/height parameters
* from that function also should not exist. The fix that will
* allow us to remove all of these is to fix acquire_source_image
* to pass an interest rectangle. */
int width;
int height;
/* The target surface to hold the final result. */
cairo_surface_t *target;
@ -100,6 +108,9 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
_cairo_surface_init (&surface->base, &cairo_paginated_surface_backend);
surface->width = width;
surface->height = height;
surface->target = target;
surface->meta = _cairo_meta_surface_create (width, height);
@ -157,6 +168,39 @@ _cairo_paginated_surface_release_source_image (void *abstract_surface,
cairo_surface_destroy (&image->base);
}
static cairo_int_status_t
_cairo_paginated_surface_copy_page (void *abstract_surface)
{
cairo_paginated_surface_t *surface = abstract_surface;
cairo_int_status_t status;
_cairo_meta_surface_replay (surface->meta, surface->target);
status = _cairo_surface_copy_page (surface->target);
/* If the surface does not support copy_page then we use show_page
* instead, and we leave the meta-surface untouched so that its
* contents will remain for the next page. */
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
status = _cairo_surface_show_page (surface->target);
/* And if the surface doesn't support show_page either, we
* also fall through and clear the meta-surface. */
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
return status;
}
/* Otherwise, we clear the meta-surface since the target surface
* has already taken care of any copying in its implementation of
* copy_page. */
cairo_surface_destroy (surface->meta);
surface->meta = _cairo_meta_surface_create (surface->width, surface->height);
if (cairo_surface_status (surface->meta))
return cairo_surface_status (surface->meta);
return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t
_cairo_paginated_surface_show_page (void *abstract_surface)
{
@ -164,6 +208,14 @@ _cairo_paginated_surface_show_page (void *abstract_surface)
_cairo_meta_surface_replay (surface->meta, surface->target);
_cairo_surface_show_page (surface->target);
cairo_surface_destroy (surface->meta);
surface->meta = _cairo_meta_surface_create (surface->width, surface->height);
if (cairo_surface_status (surface->meta))
return cairo_surface_status (surface->meta);
return CAIRO_STATUS_SUCCESS;
}
@ -308,7 +360,7 @@ const cairo_surface_backend_t cairo_paginated_surface_backend = {
NULL, /* composite */
NULL, /* fill_rectangles */
NULL, /* composite_trapezoids */
NULL, /* copy_page */
_cairo_paginated_surface_copy_page,
_cairo_paginated_surface_show_page,
NULL, /* set_clip_region */
_cairo_paginated_surface_intersect_clip_path,

View file

@ -1091,7 +1091,10 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op,
traps, num_traps);
}
cairo_status_t
/* _copy_page and _show_page are unique among _cairo_surface functions
* in that they will actually return CAIRO_INT_STATUS_UNSUPPORTED
* rather than performing any fallbacks. */
cairo_int_status_t
_cairo_surface_copy_page (cairo_surface_t *surface)
{
assert (! surface->is_snapshot);
@ -1102,14 +1105,16 @@ _cairo_surface_copy_page (cairo_surface_t *surface)
if (surface->finished)
return CAIRO_STATUS_SURFACE_FINISHED;
/* It's fine if some backends just don't support this. */
if (surface->backend->copy_page == NULL)
return CAIRO_STATUS_SUCCESS;
return CAIRO_INT_STATUS_UNSUPPORTED;
return surface->backend->copy_page (surface);
}
cairo_status_t
/* _show_page and _copy_page are unique among _cairo_surface functions
* in that they will actually return CAIRO_INT_STATUS_UNSUPPORTED
* rather than performing any fallbacks. */
cairo_int_status_t
_cairo_surface_show_page (cairo_surface_t *surface)
{
assert (! surface->is_snapshot);
@ -1120,9 +1125,8 @@ _cairo_surface_show_page (cairo_surface_t *surface)
if (surface->finished)
return CAIRO_STATUS_SURFACE_FINISHED;
/* It's fine if some backends just don't support this. */
if (surface->backend->show_page == NULL)
return CAIRO_STATUS_SUCCESS;
return CAIRO_INT_STATUS_UNSUPPORTED;
return surface->backend->show_page (surface);
}

View file

@ -1688,10 +1688,10 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op,
cairo_trapezoid_t *traps,
int ntraps);
cairo_private cairo_status_t
cairo_private cairo_int_status_t
_cairo_surface_copy_page (cairo_surface_t *surface);
cairo_private cairo_status_t
cairo_private cairo_int_status_t
_cairo_surface_show_page (cairo_surface_t *surface);
cairo_private cairo_status_t