From 26eeb1c7ee2416e4029e1ceee7afe779cca6dfc5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 May 2008 21:59:45 -0400 Subject: [PATCH] [cairo-surface] Allow flush and finish calls after surface is finished Flushing and finishing a surface after it has already been finished is a very well-defined operation: no-op. Allow and document that. --- src/cairo-surface.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/cairo-surface.c b/src/cairo-surface.c index cacb6e529..ba39b9bf8 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -474,8 +474,9 @@ cairo_surface_get_reference_count (cairo_surface_t *surface) * external resources. For example, for the Xlib backend it means * that cairo will no longer access the drawable, which can be freed. * After calling cairo_surface_finish() the only valid operations on a - * surface are getting and setting user data and referencing and - * destroying it. Further drawing to the surface will not affect the + * surface are getting and setting user, referencing and + * destroying, and flushing and finishing it. + * Further drawing to the surface will not affect the * surface but will instead trigger a %CAIRO_STATUS_SURFACE_FINISHED * error. * @@ -495,28 +496,18 @@ cairo_surface_finish (cairo_surface_t *surface) if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) return; - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + if (surface->finished) return; - } - if (!surface->status && surface->backend->flush) { - status = surface->backend->flush (surface); - if (status) { + cairo_surface_flush (surface); + + /* call finish even if in error mode */ + if (surface->backend->finish) { + status = surface->backend->finish (surface); + if (status) status = _cairo_surface_set_error (surface, status); - return; - } } - if (surface->backend->finish == NULL) { - surface->finished = TRUE; - return; - } - - status = surface->backend->finish (surface); - if (status) - status = _cairo_surface_set_error (surface, status); - surface->finished = TRUE; } slim_hidden_def (cairo_surface_finish); @@ -662,10 +653,8 @@ cairo_surface_flush (cairo_surface_t *surface) if (surface->status) return; - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + if (surface->finished) return; - } if (surface->backend->flush) { status = surface->backend->flush (surface);