summaryrefslogtreecommitdiff
path: root/src/cairo-gl-composite.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-05-28 12:51:08 +0200
committerBenjamin Otte <otte@redhat.com>2010-06-07 13:37:47 +0200
commitd03800313623fb2b9e7d15c6a659ceaaee2882e8 (patch)
tree9467db1ed79c0e7e90ff3781ac1bb793aad60993 /src/cairo-gl-composite.c
parente20261dddaa194ab4e980da8681e9378d7fd7ef1 (diff)
gl: Simplify mask operand setup code
Component alpha just has one different value
Diffstat (limited to 'src/cairo-gl-composite.c')
-rw-r--r--src/cairo-gl-composite.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 59381f7b..0268ba5a 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -727,36 +727,10 @@ _cairo_gl_set_src_alpha (cairo_gl_context_t *ctx,
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
- * of the mask part of IN to produce a "source alpha" value.
- */
-static void
-_cairo_gl_set_component_alpha_mask_operand (cairo_gl_context_t *ctx,
- cairo_gl_composite_t *setup)
-{
- if (ctx->current_shader)
- return;
-
- glActiveTexture (GL_TEXTURE1);
-
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
-
- glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
- glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS);
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
-
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- _cairo_gl_operand_setup_fixed (&setup->mask, CAIRO_GL_TEX_MASK);
-}
-
static void
_cairo_gl_set_mask_operand (cairo_gl_context_t *ctx,
- cairo_gl_composite_t *setup)
+ cairo_gl_composite_t *setup,
+ cairo_bool_t component_alpha)
{
if (ctx->current_shader)
return;
@@ -772,7 +746,10 @@ _cairo_gl_set_mask_operand (cairo_gl_context_t *ctx,
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
- glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_ALPHA);
+ if (component_alpha)
+ glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+ else
+ 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->mask, CAIRO_GL_TEX_MASK);
@@ -1008,10 +985,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
_cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_MASK, &setup->mask, dst_size + src_size);
_cairo_gl_set_src_operand (ctx, setup);
- if (setup->has_component_alpha)
- _cairo_gl_set_component_alpha_mask_operand (ctx, setup);
- else
- _cairo_gl_set_mask_operand (ctx, setup);
+ _cairo_gl_set_mask_operand (ctx, setup, setup->has_component_alpha);
cairo_region_destroy (ctx->clip_region);
ctx->clip_region = cairo_region_reference (setup->clip_region);