diff options
author | Benjamin Otte <otte@redhat.com> | 2010-05-19 22:03:18 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-05-20 11:02:49 +0200 |
commit | 4c7dd1be4526c85b47f1fe1d4663e7fbec0926b1 (patch) | |
tree | 6bac792b56837b02a47c30aca0d7ac53f7d686c4 | |
parent | d9d5976bdf333a5a7ea7707bc3076696f3c079d2 (diff) |
gl: Move vertex array setup code into the texture setup code
-rw-r--r-- | src/cairo-gl-composite.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 76b6da04..0df0502c 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -609,14 +609,19 @@ _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, - GLuint tex_unit) + GLuint tex_unit, + unsigned int vertex_offset) { switch (operand->type) { default: case CAIRO_GL_OPERAND_COUNT: ASSERT_NOT_REACHED; case CAIRO_GL_OPERAND_NONE: + break; case CAIRO_GL_OPERAND_SPANS: + glColorPointer (4, GL_UNSIGNED_BYTE, ctx->vertex_size, + (void *) (uintptr_t) vertex_offset); + glEnableClientState (GL_COLOR_ARRAY); break; case CAIRO_GL_OPERAND_CONSTANT: if (ctx->current_shader == NULL) { @@ -633,6 +638,11 @@ _cairo_gl_operand_setup_texture (cairo_gl_context_t *ctx, glBindTexture (ctx->tex_target, operand->texture.tex); glEnable (ctx->tex_target); _cairo_gl_texture_set_attributes (ctx, &operand->texture.attributes); + + glClientActiveTexture (GL_TEXTURE0 + tex_unit); + glTexCoordPointer (2, GL_FLOAT, ctx->vertex_size, + (void *) (uintptr_t) vertex_offset); + glEnableClientState (GL_TEXTURE_COORD_ARRAY); break; case CAIRO_GL_OPERAND_LINEAR_GRADIENT: glActiveTexture (GL_TEXTURE0 + tex_unit); @@ -1108,37 +1118,20 @@ _cairo_gl_composite_begin (cairo_gl_context_t *ctx, _cairo_gl_composite_bind_to_shader (ctx, setup); - _cairo_gl_operand_setup_texture (ctx, &setup->src, 0); - _cairo_gl_operand_setup_texture (ctx, &setup->mask, 1); - glBindBufferARB (GL_ARRAY_BUFFER_ARB, ctx->vbo); 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_set_src_operand (ctx, setup); - if (setup->src.type == CAIRO_GL_OPERAND_TEXTURE) { - glClientActiveTexture (GL_TEXTURE0); - glTexCoordPointer (2, GL_FLOAT, ctx->vertex_size, - (void *) (uintptr_t) dst_size); - glEnableClientState (GL_TEXTURE_COORD_ARRAY); - } if (setup->has_component_alpha) _cairo_gl_set_component_alpha_mask_operand (ctx, setup); else _cairo_gl_set_mask_operand (ctx, setup); - if (setup->mask.type == CAIRO_GL_OPERAND_TEXTURE) { - glClientActiveTexture (GL_TEXTURE1); - glTexCoordPointer (2, GL_FLOAT, ctx->vertex_size, - (void *) (uintptr_t) (dst_size + src_size)); - glEnableClientState (GL_TEXTURE_COORD_ARRAY); - } else if (setup->mask.type == CAIRO_GL_OPERAND_SPANS) { - glColorPointer (4, GL_UNSIGNED_BYTE, ctx->vertex_size, - (void *) (uintptr_t) (dst_size + src_size)); - glEnableClientState (GL_COLOR_ARRAY); - } - if (setup->clip_region) glEnable (GL_SCISSOR_TEST); |