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.
This commit is contained in:
Benjamin Otte 2010-05-28 10:24:33 +02:00
parent a05f062c80
commit 5db362dd67
2 changed files with 18 additions and 4 deletions

View file

@ -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;

View file

@ -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;