From 5db362dd6792af20282e0e9a2805ee6f1b921e44 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 28 May 2010 10:24:33 +0200 Subject: [PATCH] gl: Keep a copy of the current operand in the context Note that they are currently only valid as long as the cairo_gl_composite_t exists, but that will be changed soon. --- src/cairo-gl-composite.c | 20 ++++++++++++++++---- src/cairo-gl-private.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 760aabbc2..55154c3a8 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -606,11 +606,13 @@ _cairo_gl_texture_set_attributes (cairo_gl_context_t *ctx, } static void -_cairo_gl_operand_setup_texture (cairo_gl_context_t *ctx, - cairo_gl_operand_t *operand, +_cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, GLuint tex_unit, + cairo_gl_operand_t *operand, unsigned int vertex_offset) { + memcpy (&ctx->operands[tex_unit], operand, sizeof (cairo_gl_operand_t)); + switch (operand->type) { default: case CAIRO_GL_OPERAND_COUNT: @@ -656,6 +658,13 @@ _cairo_gl_operand_setup_texture (cairo_gl_context_t *ctx, } } +static void +_cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx, + GLuint tex_unit) +{ + memset (&ctx->operands[tex_unit], 0, sizeof (cairo_gl_operand_t)); +} + static void _cairo_gl_operand_setup_fixed (cairo_gl_operand_t *operand, GLuint tex_unit) @@ -995,8 +1004,8 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup, glVertexPointer (2, GL_FLOAT, ctx->vertex_size, NULL); glEnableClientState (GL_VERTEX_ARRAY); - _cairo_gl_operand_setup_texture (ctx, &setup->src, 0, dst_size); - _cairo_gl_operand_setup_texture (ctx, &setup->mask, 1, dst_size + src_size); + _cairo_gl_context_setup_operand (ctx, 0, &setup->src, dst_size); + _cairo_gl_context_setup_operand (ctx, 1, &setup->mask, dst_size + src_size); _cairo_gl_set_src_operand (ctx, setup); if (setup->has_component_alpha) @@ -1241,6 +1250,9 @@ _cairo_gl_composite_end (cairo_gl_context_t *ctx, glDisable (GL_TEXTURE_1D); glDisable (ctx->tex_target); + _cairo_gl_context_destroy_operand (ctx, 0); + _cairo_gl_context_destroy_operand (ctx, 1); + ctx->pre_shader = NULL; ctx->vertex_size = 0; diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 434b1b1ff..070f79ce8 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -179,6 +179,8 @@ typedef struct _cairo_gl_context { cairo_gl_shader_t *pre_shader; /* for component alpha */ cairo_gl_shader_t *current_shader; + cairo_gl_operand_t operands[2]; + char *vb; unsigned int vb_offset; unsigned int vertex_size;