[cairo-commit] 2 commits - src/cairo-gl-operand.c src/cairo-gl-private.h src/cairo-gl-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Dec 9 01:26:11 PST 2011


 src/cairo-gl-operand.c |    5 ++++-
 src/cairo-gl-private.h |    1 +
 src/cairo-gl-surface.c |    2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit f446e57f350190f3ecc4758fe5cc2c6e949ff7b9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Dec 9 09:20:23 2011 +0000

    gl: Track surface references through operands
    
    In the case where we created a surface to handle an operand, it needs to
    be freed when we release the operand. However, we also have to be
    careful not to introduce reference cycles into ordinary surfaces, so
    always remember to teardown the composite setup!
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c
index 1cfd415..989f4ce 100644
--- a/src/cairo-gl-operand.c
+++ b/src/cairo-gl-operand.c
@@ -124,6 +124,7 @@ _cairo_gl_subsurface_clone_operand_init (cairo_gl_operand_t *operand,
 
     operand->type = CAIRO_GL_OPERAND_TEXTURE;
     operand->texture.surface = surface;
+    operand->texture.owns_surface = surface;
     operand->texture.tex = surface->tex;
 
     if (_cairo_gl_device_requires_power_of_two_textures (dst->base.device)) {
@@ -254,6 +255,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
     }
 
     *operand = surface->operand;
+    operand->texture.owns_surface = surface;
     operand->texture.attributes.matrix.x0 -= extents->x * operand->texture.attributes.matrix.xx;
     operand->texture.attributes.matrix.y0 -= extents->y * operand->texture.attributes.matrix.yy;
     return CAIRO_STATUS_SUCCESS;
@@ -375,6 +377,7 @@ _cairo_gl_operand_copy (cairo_gl_operand_t *dst,
 	_cairo_gl_gradient_reference (dst->gradient.gradient);
 	break;
     case CAIRO_GL_OPERAND_TEXTURE:
+	cairo_surface_reference (&dst->texture.owns_surface->base);
 	break;
     default:
     case CAIRO_GL_OPERAND_COUNT:
@@ -397,6 +400,7 @@ _cairo_gl_operand_destroy (cairo_gl_operand_t *operand)
 	_cairo_gl_gradient_destroy (operand->gradient.gradient);
 	break;
     case CAIRO_GL_OPERAND_TEXTURE:
+	cairo_surface_destroy (&operand->texture.owns_surface->base);
 	break;
     default:
     case CAIRO_GL_OPERAND_COUNT:
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 05d1567..a0cf50b 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -132,6 +132,7 @@ typedef struct cairo_gl_operand {
 	struct {
 	    GLuint tex;
 	    cairo_gl_surface_t *surface;
+	    cairo_gl_surface_t *owns_surface;
 	    cairo_surface_attributes_t attributes;
 	} texture;
 	struct {
commit 8d4425053d126ead3087fe59c69063bce3b42cb5
Author: Chuanbo Weng <strgnm at gmail.com>
Date:   Fri Dec 9 16:13:59 2011 +0800

    gl: fix bug in _cairo_gl_surface_embedded_operand_init()
    
    The operand->texture.surface should be set to right value, not
    NULL. Otherwise, when doing _cairo_gl_surface_operand_init(),
    the texture.surface in operand struct will also be NULL, which
    is incorrect. This fix regression suite in 43 test cases(such
    as source-clip) in cairo/test/.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c
index 9b53b2f..1cfd415 100644
--- a/src/cairo-gl-operand.c
+++ b/src/cairo-gl-operand.c
@@ -254,7 +254,6 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
     }
 
     *operand = surface->operand;
-    operand->texture.surface = surface;
     operand->texture.attributes.matrix.x0 -= extents->x * operand->texture.attributes.matrix.xx;
     operand->texture.attributes.matrix.y0 -= extents->y * operand->texture.attributes.matrix.yy;
     return CAIRO_STATUS_SUCCESS;
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 90b2594..ed43a51 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -360,7 +360,7 @@ _cairo_gl_surface_embedded_operand_init (cairo_gl_surface_t *surface)
     memset (operand, 0, sizeof (cairo_gl_operand_t));
 
     operand->type = CAIRO_GL_OPERAND_TEXTURE;
-    operand->texture.surface = NULL;
+    operand->texture.surface = surface;
     operand->texture.tex = surface->tex;
 
     if (_cairo_gl_device_requires_power_of_two_textures (surface->base.device)) {


More information about the cairo-commit mailing list