summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-private.h
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2008-03-19 13:00:47 -0700
committerCarl Worth <cworth@cworth.org>2008-03-20 11:51:57 -0700
commite96f382549eb3411d461162fdd8989f4ade8b448 (patch)
tree3981955e80d314132ab850c877f6ea291b2cab4e /src/cairo-xlib-private.h
parentd413c5ab21efb2ccc6a4847ff387f8e39ba2f3e1 (diff)
downloadcairo-e96f382549eb3411d461162fdd8989f4ade8b448.tar.gz
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.
Diffstat (limited to 'src/cairo-xlib-private.h')
-rw-r--r--src/cairo-xlib-private.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h
index 3e04ecd80..09f06aaad 100644
--- a/src/cairo-xlib-private.h
+++ b/src/cairo-xlib-private.h
@@ -70,6 +70,12 @@ struct _cairo_xlib_display {
unsigned int closed :1;
};
+typedef struct _cairo_xlib_visual_info {
+ VisualID visualid;
+ XColor colors[256];
+ unsigned long rgb333_to_pseudocolor[512];
+} cairo_xlib_visual_info_t;
+
struct _cairo_xlib_screen_info {
cairo_xlib_screen_info_t *next;
cairo_reference_count_t ref_count;
@@ -82,6 +88,8 @@ struct _cairo_xlib_screen_info {
GC gc[9];
unsigned int gc_needs_clip_reset;
+
+ cairo_array_t visuals;
};
cairo_private cairo_xlib_display_t *
@@ -125,4 +133,11 @@ _cairo_xlib_screen_get_gc (cairo_xlib_screen_info_t *info, int depth);
cairo_private cairo_status_t
_cairo_xlib_screen_put_gc (cairo_xlib_screen_info_t *info, int depth, GC gc, cairo_bool_t reset_clip);
+cairo_xlib_visual_info_t *
+_cairo_xlib_screen_get_visual_info (cairo_xlib_screen_info_t *info,
+ Visual *visual);
+
+cairo_xlib_visual_info_t *
+_cairo_xlib_visual_info_create (Display *dpy, int screen, VisualID visualid);
+
#endif /* CAIRO_XLIB_PRIVATE_H */