From 006573ac61bc32e2d46a8146358c56392abe8536 Mon Sep 17 00:00:00 2001 From: Ivan Leben Date: Mon, 19 May 2008 15:21:56 +0000 Subject: [PATCH] * clutter/cogl/gles/cogl-texture.c: (cogl_texture_download_from_gl:) Store old blending factors and restore them when done. The lack of ability to retrieve the alpha channel now more noticable in test-cogl-tex-getset since the edges of the hand are not antialiased. * clutter/cogl/gl(es)/cogl-internal.h: Declare cogl_blend_func to avoid "implicit implementation" compile warning. --- gl/cogl-internal.h | 4 ++++ gles/cogl-internal.h | 4 ++++ gles/cogl-texture.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gl/cogl-internal.h b/gl/cogl-internal.h index 1f6b8639e..20f4996af 100644 --- a/gl/cogl-internal.h +++ b/gl/cogl-internal.h @@ -58,4 +58,8 @@ cogl_enable (gulong flags); gulong cogl_get_enable (); +void +cogl_blend_func (COGLenum src_factor, + COGLenum dst_factor); + #endif /* __COGL_INTERNAL_H */ diff --git a/gles/cogl-internal.h b/gles/cogl-internal.h index 69baa4a9a..819ec0d60 100644 --- a/gles/cogl-internal.h +++ b/gles/cogl-internal.h @@ -60,4 +60,8 @@ cogl_enable (gulong flags); gulong cogl_get_enable (); +void +cogl_blend_func (COGLenum src_factor, + COGLenum dst_factor); + #endif /* __COGL_INTERNAL_H */ diff --git a/gles/cogl-texture.c b/gles/cogl-texture.c index 992f1b6d6..07a736c2c 100644 --- a/gles/cogl-texture.c +++ b/gles/cogl-texture.c @@ -255,6 +255,10 @@ _cogl_texture_download_from_gl (CoglTexture *tex, ClutterFixed tx1, ty1; ClutterFixed tx2, ty2; int bw, bh; + COGLenum old_src_factor; + COGLenum old_dst_factor; + + _COGL_GET_CONTEXT (ctx, FALSE); handle = _cogl_texture_handle_from_pointer (tex); bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888); @@ -286,6 +290,10 @@ _cogl_texture_download_from_gl (CoglTexture *tex, /* Draw to all channels */ cogl_draw_buffer (COGL_WINDOW_BUFFER | COGL_MASK_BUFFER, 0); + /* Store old blending factors and setup direct copy operation */ + old_src_factor = ctx->blend_src_factor; + old_dst_factor = ctx->blend_dst_factor; + cogl_blend_func (CGL_ONE, CGL_ZERO); /* If whole image fits into the viewport and target buffer has got no special rowstride, we can do it in one pass */ @@ -297,7 +305,6 @@ _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, @@ -350,7 +357,6 @@ _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, @@ -397,6 +403,7 @@ _cogl_texture_download_from_gl (CoglTexture *tex, glPopMatrix (); cogl_draw_buffer (COGL_WINDOW_BUFFER, 0); + cogl_blend_func (old_src_factor, old_dst_factor); return TRUE; }