6685465 Xephyr uses wrong or bad colortable in 8-bit mode
authorJeremy Y Uejio <Jeremy.Uejio@Sun.COM>
Tue, 01 Jul 2008 13:14:49 -0700
changeset 453 7ff47fb63000
parent 452 bc52a8f117fe
child 454 1b3bd10d7087
6685465 Xephyr uses wrong or bad colortable in 8-bit mode
open-src/xserver/xorg/6685465.patch
open-src/xserver/xorg/patch-list
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/xserver/xorg/6685465.patch	Tue Jul 01 13:14:49 2008 -0700
@@ -0,0 +1,73 @@
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use subject to license terms.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, and/or sell copies of the Software, and to permit persons
+# to whom the Software is furnished to do so, provided that the above
+# copyright notice(s) and this permission notice appear in all copies of
+# the Software and that both the above copyright notice(s) and this
+# permission notice appear in supporting documentation.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in this Software without prior written authorization
+# of the copyright holder.
+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
+     }
+ }
+ 
++static int 
++hostx_calculate_color_shift(unsigned long mask,
++			    int bits_per_rgb)
++{
++  int shift=0;
++  while(mask) {
++    mask=mask >> bits_per_rgb;
++    if (mask) shift+=bits_per_rgb;
++  }
++  return shift;
++}
++
+ void
+ hostx_set_cmap_entry(unsigned char idx, 
+ 		     unsigned char r, 
+ 		     unsigned char g, 
+ 		     unsigned char b)
+ {
+-  /* XXX Will likely break for 8 on 16, not sure if this is correct */
+-  HostX.cmap[idx] = (r << 16) | (g << 8) | (b);
++  /* need to calculate the shifts for RGB because server could be BGR. */
++  /* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/
++  static int rshift, bshift, gshift = 0;
++  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);
++  }
++  HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) | 
++		    ((g << gshift) & HostX.visual->green_mask) |
++		    ((b << bshift) & HostX.visual->blue_mask);
+ }
+ 
+ /**
--- a/open-src/xserver/xorg/patch-list	Mon Jun 30 15:01:33 2008 -0700
+++ b/open-src/xserver/xorg/patch-list	Tue Jul 01 13:14:49 2008 -0700
@@ -62,3 +62,4 @@
 6668806.patch
 driver-autoconfig.patch
 6683567.patch
+6685465.patch