Skip to content

Commit

Permalink
[cairo] FLush surface on cairo_destroy()
Browse files Browse the repository at this point in the history
When discussing the implications of snapshot cow, one of the questions
that we raised was what happens on cairo_destroy()? The lifetime of the
context implicitly marks the extents of the drawing operations, typically
the expose event (or perhaps one phase of it). Therefore at the end of the
sequence we implicitly wish to flush the graphics events to the surface.
  • Loading branch information
Chris Wilson committed Nov 16, 2008
1 parent 032be98 commit db9ed77
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cairo.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ cairo_reference (cairo_t *cr)
void
cairo_destroy (cairo_t *cr)
{
cairo_surface_t *surface;

if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
return;

Expand All @@ -225,6 +227,15 @@ cairo_destroy (cairo_t *cr)
break;
}

/* The context is expected (>99% of all use cases) to be held for the
* duration of a single expose event/sequence of graphic operations.
* Therefore, on destroy we explicitly flush the Cairo pipeline of any
* pending operations.
*/
surface = _cairo_gstate_get_original_target (cr->gstate);
if (surface != NULL)
cairo_surface_flush (surface);

_cairo_gstate_fini (cr->gstate);
while (cr->gstate_freelist != NULL) {
cairo_gstate_t *gstate = cr->gstate_freelist;
Expand Down

0 comments on commit db9ed77

Please sign in to comment.