6685465: Xephyr uses wrong or bad colortable in 8-bit mode (refix)
authorJeremy Y Uejio <Jeremy.Uejio@Sun.COM>
Wed, 23 Jul 2008 13:45:48 -0700
changeset 471 c9a54fd5c405
parent 470 77e77d76a7c9
child 472 c6afe0d6b651
6685465: Xephyr uses wrong or bad colortable in 8-bit mode (refix)
open-src/xserver/xorg/6685465.patch
--- a/open-src/xserver/xorg/6685465.patch	Tue Jul 22 16:37:31 2008 -0700
+++ b/open-src/xserver/xorg/6685465.patch	Wed Jul 23 13:45:48 2008 -0700
@@ -28,19 +28,19 @@
 diff -urp -x '*~'  hw/kdrive/ephyr/hostx.c hw/kdrive/ephyr/hostx.c
 --- hw/kdrive/ephyr/hostx.c	2008-06-05 14:53:51.603935000 -0700
 +++ hw/kdrive/ephyr/hostx.c	2008-06-10 11:26:28.531089800 -0700
-@@ -430,14 +430,40 @@ hostx_get_visual_masks (unsigned long *r
+@@ -430,14 +430,37 @@
      }
  }
  
 +static int 
-+hostx_calculate_color_shift(unsigned long mask,
-+			    int bits_per_rgb)
++hostx_calculate_color_shift(unsigned long mask)
 +{
-+  int shift=0;
-+  while(mask) {
-+    mask=mask >> bits_per_rgb;
-+    if (mask) shift+=bits_per_rgb;
-+  }
++  int shift=1;
++  /* count # of bits in mask */
++  while(mask=(mask>>1)) shift++;
++  /* cmap entry is an unsigned char so adjust it by size of that */
++  shift = shift - sizeof(unsigned char) * 8;
++  if (shift < 0) shift=0;
 +  return shift;
 +}
 +
@@ -58,12 +58,9 @@
 +  static int first_time=1;
 +  if (first_time) {
 +    first_time=0;
-+    rshift = hostx_calculate_color_shift(HostX.visual->red_mask,
-+					HostX.visual->bits_per_rgb);
-+    gshift = hostx_calculate_color_shift(HostX.visual->green_mask,
-+					HostX.visual->bits_per_rgb);
-+    bshift = hostx_calculate_color_shift(HostX.visual->blue_mask,
-+					HostX.visual->bits_per_rgb);
++    rshift = hostx_calculate_color_shift(HostX.visual->red_mask);
++    gshift = hostx_calculate_color_shift(HostX.visual->green_mask);
++    bshift = hostx_calculate_color_shift(HostX.visual->blue_mask);
 +  }
 +  HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) | 
 +		    ((g << gshift) & HostX.visual->green_mask) |