mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
* clutter/cogl/gl(es)/cogl.c: New internal function
cogl_blend_func caches blending setup much like cogl_enable does with the enable flags. This separates blending factors setup from the enable/disable operation in preparation of the texture image retrieval fix for alpha channel on GLES. (cogl_enable:) Does not modify blending factors anymore. * clutter/cogl/gl(es)/cogl-context.h: CoglContext holds two new variables to cache blending src and dst factors. * clutter/cogl/gl(es)/cogl-context.c: (cogl_create_context:) Initialize blending factors. * clutter/cogl/gles/cogl-texture.c: (cogl_texture_download_from_gl:) Set blending factors to CGL_ONE, CGL_ZERO which fixes the slighlty improper behavior where source colour was actually multiplied with its alpha value in the result (not noticable on current tests).
This commit is contained in:
parent
ae444ad679
commit
d049d9ead4
@ -60,6 +60,9 @@ cogl_create_context ()
|
||||
|
||||
_context->fbo_handles = NULL;
|
||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||
|
||||
_context->blend_src_factor = CGL_SRC_ALPHA;
|
||||
_context->blend_dst_factor = CGL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
_context->shader_handles = NULL;
|
||||
|
||||
@ -91,8 +94,9 @@ cogl_create_context ()
|
||||
_context->pf_glUniform1fARB = NULL;
|
||||
|
||||
/* Init OpenGL state */
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColorMask (TRUE, TRUE, TRUE, FALSE);
|
||||
GE( glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) );
|
||||
GE( glColorMask (TRUE, TRUE, TRUE, FALSE) );
|
||||
GE( glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) );
|
||||
cogl_enable (0);
|
||||
|
||||
return TRUE;
|
||||
|
@ -37,6 +37,8 @@ typedef struct
|
||||
/* Enable cache */
|
||||
gulong enable_flags;
|
||||
guint8 color_alpha;
|
||||
COGLenum blend_src_factor;
|
||||
COGLenum blend_dst_factor;
|
||||
|
||||
/* Primitives */
|
||||
CoglFixedVec2 path_start;
|
||||
|
65
gl/cogl.c
65
gl/cogl.c
@ -306,12 +306,9 @@ cogl_enable (gulong flags)
|
||||
*/
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_BLEND,
|
||||
GL_BLEND))
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_BLEND,
|
||||
GL_BLEND);
|
||||
|
||||
cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_TEXTURE_2D,
|
||||
@ -340,59 +337,23 @@ cogl_get_enable ()
|
||||
return ctx->enable_flags;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
cogl_enable (gulong flags)
|
||||
cogl_blend_func (COGLenum src_factor, COGLenum dst_factor)
|
||||
{
|
||||
/* This function caches the blending setup in the
|
||||
* hope of lessening GL traffic.
|
||||
*/
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (flags & COGL_ENABLE_BLEND)
|
||||
if (ctx->blend_src_factor != src_factor ||
|
||||
ctx->blend_dst_factor != dst_factor)
|
||||
{
|
||||
if (!(ctx->enable_flags & COGL_ENABLE_BLEND))
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
ctx->enable_flags |= COGL_ENABLE_BLEND;
|
||||
}
|
||||
glBlendFunc (src_factor, dst_factor);
|
||||
ctx->blend_src_factor = src_factor;
|
||||
ctx->blend_dst_factor = dst_factor;
|
||||
}
|
||||
else if (ctx->enable_flags & COGL_ENABLE_BLEND)
|
||||
{
|
||||
glDisable (GL_BLEND);
|
||||
ctx->enable_flags &= ~COGL_ENABLE_BLEND;
|
||||
}
|
||||
|
||||
if (flags & COGL_ENABLE_TEXTURE_2D)
|
||||
{
|
||||
if (!(ctx->enable_flags & COGL_ENABLE_TEXTURE_2D))
|
||||
{
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
ctx->enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||
}
|
||||
}
|
||||
else if (ctx->enable_flags & COGL_ENABLE_TEXTURE_2D)
|
||||
{
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
ctx->enable_flags &= ~COGL_ENABLE_TEXTURE_2D;
|
||||
}
|
||||
|
||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||
if (flags & COGL_ENABLE_TEXTURE_RECT)
|
||||
{
|
||||
if (!(ctx->enable_flags & COGL_ENABLE_TEXTURE_RECT))
|
||||
{
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
ctx->enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
||||
}
|
||||
}
|
||||
else if (ctx->enable_flags & COGL_ENABLE_TEXTURE_RECT)
|
||||
{
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
ctx->enable_flags &= ~COGL_ENABLE_TEXTURE_RECT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
cogl_enable_depth_test (gboolean setting)
|
||||
{
|
||||
|
@ -65,9 +65,13 @@ cogl_create_context ()
|
||||
_context->fbo_handles = NULL;
|
||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||
|
||||
_context->blend_src_factor = CGL_SRC_ALPHA;
|
||||
_context->blend_dst_factor = CGL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
/* Init OpenGL state */
|
||||
glTexEnvx (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColorMask (TRUE, TRUE, TRUE, FALSE);
|
||||
GE( glTexEnvx (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) );
|
||||
GE( glColorMask (TRUE, TRUE, TRUE, FALSE) );
|
||||
GE( glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) );
|
||||
cogl_enable (0);
|
||||
|
||||
return TRUE;
|
||||
|
@ -44,6 +44,8 @@ typedef struct
|
||||
/* Enable cache */
|
||||
gulong enable_flags;
|
||||
guint8 color_alpha;
|
||||
COGLenum blend_src_factor;
|
||||
COGLenum blend_dst_factor;
|
||||
|
||||
/* Primitives */
|
||||
CoglFixedVec2 path_start;
|
||||
|
@ -297,6 +297,7 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
|
||||
for direct copy to framebuffer */
|
||||
cogl_paint_init (&cback);
|
||||
cogl_color (&cwhite);
|
||||
cogl_blend_func (CGL_ONE, CGL_ZERO);
|
||||
|
||||
/* Draw the texture image */
|
||||
cogl_texture_rectangle (handle,
|
||||
@ -349,6 +350,7 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
|
||||
for direct copy to framebuffer */
|
||||
cogl_paint_init (&cback);
|
||||
cogl_color (&cwhite);
|
||||
cogl_blend_func (CGL_ONE, CGL_ZERO);
|
||||
|
||||
/* Draw a portion of texture */
|
||||
cogl_texture_rectangle (handle,
|
||||
|
26
gles/cogl.c
26
gles/cogl.c
@ -214,12 +214,9 @@ cogl_enable (gulong flags)
|
||||
*/
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_BLEND,
|
||||
GL_BLEND))
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_BLEND,
|
||||
GL_BLEND);
|
||||
|
||||
cogl_toggle_flag (ctx, flags,
|
||||
COGL_ENABLE_TEXTURE_2D,
|
||||
@ -246,6 +243,23 @@ cogl_get_enable ()
|
||||
return ctx->enable_flags;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_blend_func (COGLenum src_factor, COGLenum dst_factor)
|
||||
{
|
||||
/* This function caches the blending setup in the
|
||||
* hope of lessening GL traffic.
|
||||
*/
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (ctx->blend_src_factor != src_factor ||
|
||||
ctx->blend_dst_factor != dst_factor)
|
||||
{
|
||||
glBlendFunc (src_factor, dst_factor);
|
||||
ctx->blend_src_factor = src_factor;
|
||||
ctx->blend_dst_factor = dst_factor;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cogl_enable_depth_test (gboolean setting)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user