Commit graph

7 commits

Author SHA1 Message Date
Chris Wilson
e6963a5bfe Mark allocation failures as unlikely.
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
2008-11-29 11:20:34 +00:00
Behdad Esfahbod
e7c1fc5bf5 [xlib] Implement dithering
Remove the intermediate rgb333 for PseudoColor and work on the
cube directly.  Also upgrade to a 6x6x6 cube instead of 5x5x5.
Do dithering on both PseudoColor and TrueColor, using a 4x4 pattern.

This only affects X servers with no XRender.
2008-06-19 21:54:23 -04:00
Behdad Esfahbod
d47142907f [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.
2008-06-12 14:18:06 -04:00
Behdad Esfahbod
4fcef1a490 [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.
2008-06-12 14:16:47 -04:00
Chris Wilson
37c69c0d54 [cairo-xlib] Handle malloc failures for cairo_xlib_visual_info_t.
Tidy the error paths whilst handling visuals, in particular avoiding a
couple of potential NULL deferences, missed status checks and fresh
leaks.
2008-04-02 10:50:48 +01:00
Carl Worth
afc6e3b69d Quiet some trivial unused and potentially-uninitialized compiler warnings 2008-04-01 14:40:18 -07:00
Carl Worth
e96f382549 Add support for 8-bit PseudoColor visuals
This support involves allocating a 16-bit grayscale ramp as well
as a 5x5x5 RGB color cube. Afterwards, the 256 colors are queried
and an array is generated mapping from r3g3b3 colors to the closest
available color. Both the queried colors and the reverse mapping
are stored in a new visual-specific cairo_xlib_visual_info_t
structure which hangs off of the cairo_xlib_screen_info_t.

Both the color-cube allocation and the distance metric could be
improved by someone sufficiently motivated, (for example, allocating
and matching in a perceptually linear color space rather than just
in RGB space). Also, making this work well in the face of a changing
color map, or in the case of GrayScale, StaticGray, or DirectColor
visuals are left entirely as exercises for the reader. StaticColor
support should be fine as is, but is entirely untested.
2008-03-20 11:51:57 -07:00