diff options
author | Benjamin Otte <otte@redhat.com> | 2010-05-28 10:24:33 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-06-07 13:37:47 +0200 |
commit | 5db362dd6792af20282e0e9a2805ee6f1b921e44 (patch) | |
tree | 8b847e219f355af6c8e7507decab39f9efa2a8a4 | |
parent | a05f062c806ac014d0daffa1d74bdb0dd90a8a26 (diff) |
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.
-rw-r--r-- | src/cairo-gl-composite.c | 20 | ||||
-rw-r--r-- | 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 760aabbc..55154c3a 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: @@ -657,6 +659,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 434b1b1f..070f79ce 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; |