Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 6ea4c67ba24194b4411897af07bf8a9584e26edc Mon Sep 17 00:00:00 2001
- From: Neil Roberts <neil@linux.intel.com>
- Date: Thu, 13 May 2010 13:17:19 +0100
- Subject: [PATCH] cogl-material: Enable blending if a transparent blend constant is used
- If the blend constant is used by one of the blending factors and the
- constant is not fully opaque then blending will now be enabled.
- ---
- clutter/cogl/cogl/cogl-material.c | 55 +++++++++++++++++++++++++-----------
- 1 files changed, 38 insertions(+), 17 deletions(-)
- diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c
- index 5c6b93b..0bd071f 100644
- --- a/clutter/cogl/cogl/cogl-material.c
- +++ b/clutter/cogl/cogl/cogl-material.c
- @@ -166,6 +166,28 @@ _cogl_material_free (CoglMaterial *material)
- g_slice_free (CoglMaterial, material);
- }
- +#ifndef HAVE_COGL_GLES
- +
- +static gboolean
- +blend_factor_uses_constant (GLenum blend_factor)
- +{
- + return (blend_factor == GL_CONSTANT_COLOR ||
- + blend_factor == GL_ONE_MINUS_CONSTANT_COLOR ||
- + blend_factor == GL_CONSTANT_ALPHA ||
- + blend_factor == GL_ONE_MINUS_CONSTANT_ALPHA);
- +}
- +
- +static gboolean
- +_cogl_material_any_blend_factor_uses_constant (CoglMaterial *material)
- +{
- + return (blend_factor_uses_constant (material->blend_src_factor_rgb) ||
- + blend_factor_uses_constant (material->blend_src_factor_alpha) ||
- + blend_factor_uses_constant (material->blend_dst_factor_rgb) ||
- + blend_factor_uses_constant (material->blend_dst_factor_alpha));
- +}
- +
- +#endif /* HAVE_COGL_GLES */
- +
- static gboolean
- _cogl_material_needs_blending_enabled (CoglMaterial *material,
- GLubyte *override_color)
- @@ -188,6 +210,12 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material,
- material->emission[3] != 1.0f)
- return TRUE;
- +#ifndef HAVE_COGL_GLES
- + if (_cogl_material_any_blend_factor_uses_constant (material) &&
- + material->blend_constant[3] != 1.0f)
- + return TRUE;
- +#endif
- +
- for (tmp = material->layers; tmp != NULL; tmp = tmp->next)
- {
- CoglMaterialLayer *layer = tmp->data;
- @@ -707,6 +735,10 @@ cogl_material_set_blend (CoglHandle handle,
- material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_BLEND;
- + /* If the blend mode is changed to use a the blend constant for one
- + of the factors then it may now need blending enabled */
- + handle_automatic_blend_enable (material);
- +
- return TRUE;
- }
- @@ -732,6 +764,11 @@ cogl_material_set_blend_constant (CoglHandle handle,
- constant[3] = cogl_color_get_alpha_float (constant_color);
- material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_BLEND;
- +
- + /* If the constant is not fully opaque then the material may now
- + need blending enabled */
- + handle_automatic_blend_enable (material);
- +
- #endif
- }
- @@ -1636,19 +1673,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
- }
- }
- -#ifndef HAVE_COGL_GLES
- -
- -static gboolean
- -blend_factor_uses_constant (GLenum blend_factor)
- -{
- - return (blend_factor == GL_CONSTANT_COLOR ||
- - blend_factor == GL_ONE_MINUS_CONSTANT_COLOR ||
- - blend_factor == GL_CONSTANT_ALPHA ||
- - blend_factor == GL_ONE_MINUS_CONSTANT_ALPHA);
- -}
- -
- -#endif
- -
- static void
- _cogl_material_flush_base_gl_state (CoglMaterial *material,
- gboolean skip_gl_color)
- @@ -1717,10 +1741,7 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material,
- else
- GE (glBlendEquation (material->blend_equation_rgb));
- - if (blend_factor_uses_constant (material->blend_src_factor_rgb) ||
- - blend_factor_uses_constant (material->blend_src_factor_alpha) ||
- - blend_factor_uses_constant (material->blend_dst_factor_rgb) ||
- - blend_factor_uses_constant (material->blend_dst_factor_alpha))
- + if (_cogl_material_any_blend_factor_uses_constant (material))
- GE (glBlendColor (material->blend_constant[0],
- material->blend_constant[1],
- material->blend_constant[2],
- --
- 1.6.5.rc1.46.g4d818
Add Comment
Please, Sign In to add comment