[cairo-commit] 2 commits - src/cairo-xlib-visual.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Jun 12 11:18:30 PDT 2008


 src/cairo-xlib-visual.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit d47142907f01ae610fa06987c20741ae1382a4b7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Mar 25 17:33:47 2008 +0430

    [xlib-visual] Make the 5x5x5 color cube better approximate the rgb333 space
    
    That is, instead of uniformly spreading the colors at 0/4, 1/4, 2/4, 3/4, 4/4
    intensities, we do 0/7, 1.5/7, 3.5/7, 5.5/7, 7/7 now.  Those better
    approximate the 0/7..7/7 of the rgb333 space that we first convert to.

diff --git a/src/cairo-xlib-visual.c b/src/cairo-xlib-visual.c
index 4979da8..3a7b586 100644
--- a/src/cairo-xlib-visual.c
+++ b/src/cairo-xlib-visual.c
@@ -69,7 +69,7 @@ _cairo_xlib_visual_info_create (Display *dpy,
     int i, index, distance, min_distance = 0;
 
     const unsigned short index5_to_short[5] = {
-	0x0000, 0x4000, 0x8000, 0xc000, 0xffff
+	0x0000, 0x36db, 0x8000, 0xc925, 0xffff
     };
     const unsigned short index8_to_short[8] = {
 	0x0000, 0x2492, 0x4924, 0x6db6,
commit 4fcef1a490508f0b489a4035dd7951f3ae2e6649
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Mar 25 17:26:51 2008 +0430

    [xlib-visual] Allocate 8-entry gray ramp instead of 16-entry
    
    We convert to rgb333 before doing pseudo-color lookup, so we cannot
    get more than 8 gray levels anyway.

diff --git a/src/cairo-xlib-visual.c b/src/cairo-xlib-visual.c
index a45be53..4979da8 100644
--- a/src/cairo-xlib-visual.c
+++ b/src/cairo-xlib-visual.c
@@ -82,12 +82,10 @@ _cairo_xlib_visual_info_create (Display *dpy,
 
     info->visualid = visualid;
 
-    /* Allocate a 16-entry gray ramp and a 5x5x5 color cube. Give up
+    /* Allocate a 8-entry gray ramp and a 5x5x5 color cube. Give up
      * as soon as failures start. */
-    for (gray = 0; gray < 16; gray++) {
-	color.red   = (gray << 12) | (gray << 8) | (gray << 4) | gray;
-	color.green = (gray << 12) | (gray << 8) | (gray << 4) | gray;
-	color.blue  = (gray << 12) | (gray << 8) | (gray << 4) | gray;
+    for (gray = 0; gray < 8; gray++) {
+	color.red = color.green = color.blue = index8_to_short[gray];
 	if (! XAllocColor (dpy, colormap, &color))
 	    goto DONE_ALLOCATE;
     }


More information about the cairo-commit mailing list