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.
This commit is contained in:
Andrea Canciani 2011-01-07 13:27:27 +02:00 committed by Alexandros Frantzis
parent 45331fe87c
commit b0e1c837ac
3 changed files with 9 additions and 3 deletions

View file

@ -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);

View file

@ -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 {

View file

@ -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