summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cairo-gl-composite.c6
-rw-r--r--src/cairo-gl-gradient.c6
-rw-r--r--src/cairo-gl-operand.c24
-rw-r--r--src/cairo-gl-private.h4
4 files changed, 33 insertions, 7 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index c59501ec..64132558 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -69,7 +69,7 @@ _cairo_gl_composite_set_source_operand (cairo_gl_composite_t *setup,
const cairo_gl_operand_t *source)
{
_cairo_gl_operand_destroy (&setup->src);
- setup->src = *source;
+ _cairo_gl_operand_copy (&setup->src, source);
}
void
@@ -104,7 +104,7 @@ _cairo_gl_composite_set_mask_operand (cairo_gl_composite_t *setup,
{
_cairo_gl_operand_destroy (&setup->mask);
if (mask)
- setup->mask = *mask;
+ _cairo_gl_operand_copy (&setup->mask, mask);
}
void
@@ -242,7 +242,6 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
- _cairo_gl_gradient_reference (operand->gradient.gradient);
glActiveTexture (GL_TEXTURE0 + tex_unit);
glBindTexture (ctx->tex_target, operand->gradient.gradient->tex);
_cairo_gl_texture_set_extend (ctx, ctx->tex_target, operand->gradient.extend);
@@ -292,7 +291,6 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
- _cairo_gl_gradient_destroy (ctx->operands[tex_unit].gradient.gradient);
dispatch->DisableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
break;
}
diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c
index a429257f..aad2773c 100644
--- a/src/cairo-gl-gradient.c
+++ b/src/cairo-gl-gradient.c
@@ -226,7 +226,7 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx,
tex_width = _cairo_gl_gradient_sample_width (n_stops, stops);
- CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 1);
+ CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 2);
gradient->cache_entry.hash = hash;
gradient->cache_entry.size = tex_width;
gradient->device = &ctx->base;
@@ -272,8 +272,8 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx,
}
/* we ignore errors here and just return an uncached gradient */
- if (likely (! _cairo_cache_insert (&ctx->gradients, &gradient->cache_entry)))
- _cairo_gl_gradient_reference (gradient);
+ if (unlikely (_cairo_cache_insert (&ctx->gradients, &gradient->cache_entry)))
+ CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 1);
*gradient_out = gradient;
return CAIRO_STATUS_SUCCESS;
diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c
index 86a96df5..f0f76563 100644
--- a/src/cairo-gl-operand.c
+++ b/src/cairo-gl-operand.c
@@ -313,6 +313,30 @@ _cairo_gl_gradient_operand_init (cairo_gl_operand_t *operand,
}
void
+_cairo_gl_operand_copy (cairo_gl_operand_t *dst,
+ const cairo_gl_operand_t *src)
+{
+ *dst = *src;
+ switch (dst->type) {
+ case CAIRO_GL_OPERAND_CONSTANT:
+ break;
+ case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
+ _cairo_gl_gradient_reference (dst->gradient.gradient);
+ break;
+ case CAIRO_GL_OPERAND_TEXTURE:
+ break;
+ default:
+ case CAIRO_GL_OPERAND_COUNT:
+ ASSERT_NOT_REACHED;
+ case CAIRO_GL_OPERAND_NONE:
+ break;
+ }
+}
+
+void
_cairo_gl_operand_destroy (cairo_gl_operand_t *operand)
{
switch (operand->type) {
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 70023922..6d8aab86 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -640,6 +640,10 @@ _cairo_gl_operand_emit (cairo_gl_operand_t *operand,
uint8_t alpha);
cairo_private void
+_cairo_gl_operand_copy (cairo_gl_operand_t *dst,
+ const cairo_gl_operand_t *src);
+
+cairo_private void
_cairo_gl_operand_destroy (cairo_gl_operand_t *operand);
cairo_private const cairo_compositor_t *