summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-05-26 17:41:01 +0200
committerBenjamin Otte <otte@redhat.com>2010-06-07 13:37:47 +0200
commitb2d709b5c7e463437189b8e4a2c53a3317437825 (patch)
tree4093eaca67cd05f9d92f7ef84162df65e4872e7e
parent53fd451f85974d2ed0d6f29a0a0549fd4c7035fe (diff)
gl: Switch src alpha handling to a tiny on/off function
Instead of doing setup every time, we just set this one flag. Much nicer.
-rw-r--r--src/cairo-gl-composite.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index d21a4cb7..e74d5553 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -719,27 +719,19 @@ _cairo_gl_set_src_operand (cairo_gl_context_t *ctx,
_cairo_gl_operand_setup_fixed (&setup->src, 0);
}
-/* This is like _cairo_gl_set_src_operand, but instead swizzles the source
- * for creating the "source alpha" value (src.aaaa * mask.argb) required by
- * component alpha rendering.
+/* Swizzles the source for creating the "source alpha" value
+ * (src.aaaa * mask.argb) required by component alpha rendering.
*/
static void
-_cairo_gl_set_src_alpha_operand (cairo_gl_context_t *ctx,
- cairo_gl_composite_t *setup)
+_cairo_gl_set_src_alpha (cairo_gl_context_t *ctx,
+ cairo_bool_t activate)
{
if (ctx->current_shader)
return;
glActiveTexture (GL_TEXTURE0);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
-
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_ALPHA);
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- _cairo_gl_operand_setup_fixed (&setup->src, 0);
+ glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, activate ? GL_SRC_ALPHA : GL_SRC_COLOR);
}
/* This is like _cairo_gl_set_src_alpha_operand, for component alpha setup
@@ -1054,12 +1046,12 @@ _cairo_gl_composite_draw (cairo_gl_context_t *ctx,
_cairo_gl_set_shader (ctx, ctx->pre_shader);
_cairo_gl_set_operator (setup->dst, CAIRO_OPERATOR_DEST_OUT, TRUE);
- _cairo_gl_set_src_alpha_operand (ctx, setup);
+ _cairo_gl_set_src_alpha (ctx, TRUE);
glDrawArrays (GL_TRIANGLES, 0, count);
+ _cairo_gl_set_src_alpha (ctx, FALSE);
_cairo_gl_set_shader (ctx, prev_shader);
_cairo_gl_set_operator (setup->dst, setup->op, TRUE);
- _cairo_gl_set_src_operand (ctx, setup);
glDrawArrays (GL_TRIANGLES, 0, count);
}
}