From bda0f90d6e1368e2414235ef84da2dc5390d89cd Mon Sep 17 00:00:00 2001 From: George Matsumura Date: Thu, 18 Jun 2020 18:13:37 -0600 Subject: cogl: Correct behavior of boilerplate surface finishing functions Without this, a buffer-swapping function only usable on onscreen framebuffers would have been used on offscreen framebuffers. Signed-off-by: George Matsumura --- boilerplate/cairo-boilerplate-cogl.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'boilerplate') diff --git a/boilerplate/cairo-boilerplate-cogl.c b/boilerplate/cairo-boilerplate-cogl.c index 77bdb7972..540df19d2 100644 --- a/boilerplate/cairo-boilerplate-cogl.c +++ b/boilerplate/cairo-boilerplate-cogl.c @@ -159,11 +159,11 @@ _cairo_boilerplate_cogl_finish_onscreen (cairo_surface_t *surface) { cogl_closure_t *closure = cairo_surface_get_user_data (surface, &cogl_closure_key); - if (!closure->onscreen) { - fprintf(stderr, "Attempted to close an offscreen surface " - "using onscreen closure function\n"); - return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; - } + if (!closure->onscreen) { + fprintf(stderr, "Attempted to close an offscreen surface " + "using onscreen closure function\n"); + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + } cairo_cogl_surface_end_frame (surface); @@ -172,6 +172,22 @@ _cairo_boilerplate_cogl_finish_onscreen (cairo_surface_t *surface) return CAIRO_STATUS_SUCCESS; } +static cairo_status_t +_cairo_boilerplate_cogl_finish_offscreen (cairo_surface_t *surface) +{ + cogl_closure_t *closure = cairo_surface_get_user_data (surface, &cogl_closure_key); + + if (!closure->offscreen) { + fprintf(stderr, "Attempted to close an onscreen surface " + "using offscreen closure function\n"); + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + } + + cairo_cogl_surface_end_frame (surface); + + return CAIRO_STATUS_SUCCESS; +} + static void _cairo_boilerplate_cogl_synchronize (void *abstract_closure) { @@ -186,7 +202,8 @@ static const cairo_boilerplate_target_t targets[] = { "cairo_cogl_device_create", _cairo_boilerplate_cogl_create_offscreen_color_surface, cairo_surface_create_similar, - NULL, NULL, + NULL, + _cairo_boilerplate_cogl_finish_offscreen, _cairo_boilerplate_get_image_surface, cairo_surface_write_to_png, _cairo_boilerplate_cogl_cleanup, -- cgit v1.2.1