From f66500d8b052251ea3ce06f06d2fa4c8dec2ff3b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 2 Jun 2010 15:53:48 +0200 Subject: gl: Only resetup textures if we need to --- src/cairo-gl-composite.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 42eacf69..ef0c2ac5 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -675,15 +675,60 @@ _cairo_gl_operand_setup_fixed (cairo_gl_operand_t *operand, } } +static cairo_bool_t +_cairo_gl_operand_needs_setup (cairo_gl_operand_t *dest, + cairo_gl_operand_t *source, + unsigned int vertex_offset) +{ + if (dest->type != source->type) + return TRUE; + if (dest->vertex_offset != vertex_offset) + return TRUE; + + switch (source->type) { + case CAIRO_GL_OPERAND_NONE: + case CAIRO_GL_OPERAND_SPANS: + return FALSE; + case CAIRO_GL_OPERAND_CONSTANT: + return dest->constant.color[0] != source->constant.color[0] || + dest->constant.color[1] != source->constant.color[1] || + dest->constant.color[2] != source->constant.color[2] || + dest->constant.color[3] != source->constant.color[3]; + case CAIRO_GL_OPERAND_TEXTURE: + return dest->texture.surface != source->texture.surface || + dest->texture.attributes.extend != source->texture.attributes.extend || + dest->texture.attributes.filter != source->texture.attributes.filter || + dest->texture.attributes.has_component_alpha != source->texture.attributes.has_component_alpha; + case CAIRO_GL_OPERAND_LINEAR_GRADIENT: + case CAIRO_GL_OPERAND_RADIAL_GRADIENT: + /* XXX: improve this */ + return TRUE; + default: + case CAIRO_GL_OPERAND_COUNT: + ASSERT_NOT_REACHED; + break; + } + return TRUE; +} + static void _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, cairo_gl_tex_t tex_unit, cairo_gl_operand_t *operand, unsigned int vertex_offset) { + cairo_bool_t needs_setup; + + needs_setup = _cairo_gl_operand_needs_setup (&ctx->operands[tex_unit], + operand, + vertex_offset); + memcpy (&ctx->operands[tex_unit], operand, sizeof (cairo_gl_operand_t)); ctx->operands[tex_unit].vertex_offset = vertex_offset; + if (! needs_setup) + return; + switch (operand->type) { default: case CAIRO_GL_OPERAND_COUNT: -- cgit v1.2.3