From 7745ea21e104d0a5eec1814f19bacb7334f42185 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 14 Apr 2010 15:59:36 +0200 Subject: gl: acquire/release properly in _cairo_gl_draw_image() Fixes various testsuite failures, in particular ones related to masks. --- src/cairo-gl-surface.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index ccad4c6d..df50db08 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -680,8 +680,14 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) } if (! surface->fb) { - cairo_gl_context_t *ctx = (cairo_gl_context_t *) surface->base.device; + cairo_gl_context_t *ctx; + + if (_cairo_gl_context_acquire (surface->base.device, &ctx)) + return; + ctx->swap_buffers (ctx, surface); + + _cairo_gl_context_release (ctx); } } @@ -721,7 +727,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, GLenum internal_format, format, type; cairo_bool_t has_alpha; cairo_image_surface_t *clone = NULL; - cairo_gl_context_t *ctx = (cairo_gl_context_t *) dst->base.device; + cairo_gl_context_t *ctx; int cpp; cairo_status_t status = CAIRO_STATUS_SUCCESS; @@ -749,6 +755,10 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, cpp = PIXMAN_FORMAT_BPP (src->pixman_format) / 8; + status = _cairo_gl_context_acquire (dst->base.device, &ctx); + if (unlikely (status)) + return status; + glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glPixelStorei (GL_UNPACK_ROW_LENGTH, src->stride / cpp); if (dst->fb) { @@ -876,6 +886,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, fail: glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + _cairo_gl_context_release (ctx); + cairo_surface_destroy (&clone->base); return CAIRO_STATUS_SUCCESS; -- cgit v1.2.3