From f09b221ade120c16a4696f3160509ea98adfada3 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 12 Jan 2009 13:02:19 +0000 Subject: [PATCH] [ClutterGLXTexturePixmap] Use an RGB texture (not ARGB) for 24bpp pixmaps By creating an ARGB texture for 24bpp pixmaps we were exposing an undefined alpha channel to the blending and texture combine stages which resulted in nasty artefacts. (This issue was seen on i945 + DRI2) --- clutter/glx/clutter-glx-texture-pixmap.c | 30 ++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/glx/clutter-glx-texture-pixmap.c index 280f34216..0dfe23941 100644 --- a/clutter/glx/clutter-glx-texture-pixmap.c +++ b/clutter/glx/clutter-glx-texture-pixmap.c @@ -317,8 +317,25 @@ create_cogl_texture (ClutterTexture *texture, { ClutterGLXTexturePixmap *texture_glx = CLUTTER_GLX_TEXTURE_PIXMAP (texture); ClutterGLXTexturePixmapPrivate *priv = texture_glx->priv; - CoglHandle handle; - gboolean using_rectangle; + CoglHandle handle; + gboolean using_rectangle; + GLint gl_format; + CoglPixelFormat cogl_format; + guint depth; + + g_object_get (G_OBJECT (texture_glx), "pixmap-depth", &depth, NULL); + if (depth == 32) + { + gl_format = GL_RGBA; + cogl_format = COGL_PIXEL_FORMAT_RGBA_8888; + } + else if (depth == 24) + { + gl_format = GL_RGB; + cogl_format = COGL_PIXEL_FORMAT_RGB_888; + } + else + g_critical ("Can't create a TFP cogl texture for pixmap with depth < 24"); /* We want to use the GL_ARB_texture_rectangle extension on some chipsets because GL_ARB_texture_non_power_of_two is not always @@ -332,21 +349,20 @@ create_cogl_texture (ClutterTexture *texture, glGenTextures (1, &tex); glBindTexture (CGL_TEXTURE_RECTANGLE_ARB, tex); glTexImage2D (CGL_TEXTURE_RECTANGLE_ARB, 0, - GL_RGBA, width, height, - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + GL_RGB, width, height, + 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); handle = cogl_texture_new_from_foreign (tex, CGL_TEXTURE_RECTANGLE_ARB, width, height, 0, 0, - COGL_PIXEL_FORMAT_RGBA_8888 - | COGL_BGR_BIT); + cogl_format | COGL_BGR_BIT); } else { handle = cogl_texture_new_with_size (width, height, -1, FALSE, - COGL_PIXEL_FORMAT_RGBA_8888|COGL_BGR_BIT); + cogl_format | COGL_BGR_BIT); using_rectangle = FALSE; }