From b0e1c837acea2d6a78d5e5b1a011b1d43354b3ac Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Fri, 7 Jan 2011 13:27:27 +0200 Subject: [PATCH] gl: Ensure that gl surface resizes are properly applied If a gl surface is resized (with cairo_gl_surface_set_size()) while being the current target, the resize does not take effect until the target changes to a different surface and back to the original one. This patch allows a gl_context to track when the current target surface has been changed and ensures that a resize always take effect the next time a resized surface is used as the target. --- src/cairo-gl-device.c | 3 ++- src/cairo-gl-private.h | 1 + src/cairo-gl-surface.c | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 3793f9d61..048d48b8e 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -279,12 +279,13 @@ void _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { - if (ctx->current_target == surface) + if (ctx->current_target == surface && ! surface->needs_update) return; _cairo_gl_composite_flush (ctx); ctx->current_target = surface; + surface->needs_update = FALSE; if (_cairo_gl_surface_is_texture (surface)) { _cairo_gl_ensure_framebuffer (ctx, surface); diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 2f47b9a4d..3eb7e0901 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -93,6 +93,7 @@ typedef struct _cairo_gl_surface { GLuint fb; /* GL framebuffer object wrapping our data. */ GLuint depth; /* GL framebuffer object holding depth */ int owns_tex; + cairo_bool_t needs_update; } cairo_gl_surface_t; typedef struct cairo_gl_glyph_cache { diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index 0e4d275a7..211fe0287 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -214,6 +214,7 @@ _cairo_gl_surface_init (cairo_device_t *device, surface->width = width; surface->height = height; + surface->needs_update = FALSE; } static cairo_surface_t * @@ -465,8 +466,11 @@ cairo_gl_surface_set_size (cairo_surface_t *abstract_surface, return; } - surface->width = width; - surface->height = height; + if (surface->width != width || surface->height != height) { + surface->needs_update = TRUE; + surface->width = width; + surface->height = height; + } } int