Here's a second pass of patches for GDK to deal with ARGB drawables. This replaces the previous patches and suffices to make Metacity actually work in the cases I tried. There may well be more places to fix; I didn't make an exhaustive search. Better patches for metacity will follow to desktop-devel -keith
Index: gdkrgb.c =================================================================== RCS file: /cvs/gnome/gtk+/gdk/gdkrgb.c,v retrieving revision 1.57 diff -u -r1.57 gdkrgb.c --- gdkrgb.c 6 Mar 2004 03:36:59 -0000 1.57 +++ gdkrgb.c 26 Jun 2004 04:21:53 -0000 @@ -718,6 +718,17 @@ return image_info; } +#define FullMask(depth) ((depth == 32) ? (guint32) ~0 : ((guint32) 1 << (depth)) - 1) + +static guint32 +gdk_rgb_info_alpha (GdkRgbInfo *image_info) +{ + return (~(image_info->visual->red_mask | + image_info->visual->green_mask | + image_info->visual->blue_mask) & + FullMask (image_info->visual->depth)); +} + static gulong gdk_rgb_xpixel_from_rgb_internal (GdkColormap *colormap, guint16 r, guint16 g, guint16 b) @@ -757,6 +768,7 @@ pixel = (((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) + ((g >> (16 - image_info->visual->green_prec)) << image_info->visual->green_shift) + ((b >> (16 - image_info->visual->blue_prec)) << image_info->visual->blue_shift)); + pixel |= gdk_rgb_info_alpha (image_info); } else if (image_info->visual->type == GDK_VISUAL_STATIC_GRAY || image_info->visual->type == GDK_VISUAL_GRAYSCALE) @@ -2065,6 +2077,7 @@ gint b_right, b_left; gint bpp; guint32 pixel; + guint32 alpha = gdk_rgb_info_alpha (image_info); gint i; r_right = 8 - image_info->visual->red_prec; @@ -2088,7 +2101,7 @@ b = bp2[2]; pixel = ((r >> r_right) << r_left) | ((g >> g_right) << g_left) | - ((b >> b_right) << b_left); + ((b >> b_right) << b_left) | alpha; for (i = 0; i < bpp; i++) { *obptr++ = pixel & 0xff; @@ -2118,6 +2131,7 @@ gint b_right, b_left, b_prec; gint bpp; guint32 pixel; + guint32 alpha = gdk_rgb_info_alpha (image_info); gint i; gint dith; gint r1, g1, b1; @@ -2152,7 +2166,7 @@ b1 = b + (dith >> b_prec); pixel = (((r1 - (r1 >> r_prec)) >> r_right) << r_left) | (((g1 - (g1 >> g_prec)) >> g_right) << g_left) | - (((b1 - (b1 >> b_prec)) >> b_right) << b_left); + (((b1 - (b1 >> b_prec)) >> b_right) << b_left) | alpha; for (i = 0; i < bpp; i++) { *obptr++ = pixel & 0xff; @@ -2182,6 +2196,7 @@ gint b_right, b_left; gint bpp; guint32 pixel; + guint32 alpha = gdk_rgb_info_alpha (image_info); gint shift, shift_init; r_right = 8 - image_info->visual->red_prec; @@ -2206,7 +2221,7 @@ b = bp2[2]; pixel = ((r >> r_right) << r_left) | ((g >> g_right) << g_left) | - ((b >> b_right) << b_left); + ((b >> b_right) << b_left) | alpha; for (shift = shift_init; shift >= 0; shift -= 8) { *obptr++ = (pixel >> shift) & 0xff; @@ -2235,6 +2250,7 @@ gint b_right, b_left, b_prec; gint bpp; guint32 pixel; + guint32 alpha = gdk_rgb_info_alpha (image_info); gint shift, shift_init; gint dith; gint r1, g1, b1; @@ -2270,7 +2286,7 @@ b1 = b + (dith >> b_prec); pixel = (((r1 - (r1 >> r_prec)) >> r_right) << r_left) | (((g1 - (g1 >> g_prec)) >> g_right) << g_left) | - (((b1 - (b1 >> b_prec)) >> b_right) << b_left); + (((b1 - (b1 >> b_prec)) >> b_right) << b_left) | alpha; for (shift = shift_init; shift >= 0; shift -= 8) { *obptr++ = (pixel >> shift) & 0xff; Index: x11/gdkcolor-x11.c =================================================================== RCS file: /cvs/gnome/gtk+/gdk/x11/gdkcolor-x11.c,v retrieving revision 1.57 diff -u -r1.57 gdkcolor-x11.c --- x11/gdkcolor-x11.c 27 May 2004 20:46:58 -0000 1.57 +++ x11/gdkcolor-x11.c 26 Jun 2004 04:21:53 -0000 @@ -1129,8 +1129,8 @@ /* If bits not used for color are used for something other than padding, * it's likely alpha, so we set them to 1s. */ - guint32 unused = ~ (visual->red_mask | visual->green_mask | visual->blue_mask | - (((~(guint32)0)) << visual->depth)); + guint32 beyond = visual->depth >= 32 ? 0 : (((~(guint32)0)) << visual->depth); + guint32 unused = ~ (visual->red_mask | visual->green_mask | visual->blue_mask | beyond); colors[i].pixel = (unused + ((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) + ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
Attachment:
pgpKP4VraCmWY.pgp
Description: PGP signature