mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 18:08:03 +02:00
gl: Simplify mask operand setup code
Component alpha just has one different value
This commit is contained in:
parent
e20261ddda
commit
d038003136
1 changed files with 7 additions and 33 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue