GdkColorContext description



Hello, everyone

I have ported the color context code from XmHTML to Gdk, resulting in
the GdkColorContext functionality.

The color context was originally written by John Cwikla, who is
responsible for the X11 front-end to Mathematica.  It is very well
written.

The idea of that all color allocation is done through a CC.  The nice
thing about the CC is that it handles all visual/depth combinations,
something that Gdk does not do right now.  For pseudocolor displays,
it will allocate colors on demand to a color cube, rather than
pre-allocating everything like GtkPreview does.  This should make
Gtk/Gdk much more friendly to stuff like Netscape.

You create a color context with gdk_color_context_new().  Then you can
simply request for a pixel value with gdk_color_context_get_pixel(),
to which you pass the desired RGB values.  This function takes care of
mapping the color to the nearest thing in the colormap, allocating the
color, and all that yucky X stuff.

GdkColorContext also calculates proper dithering matrices for whoever
wants to use them.  This should be used by GtkPreview.

GdkColorContext is supposed to support all visuals in all depths, but
the rest of Gdk does not support this.  Here is what needs to be done:

	- Make the gdk_visual_init() support all visual/depth combinations.

	- I am not sure if any changes need to be made to
	  gdk_color_alloc() and friends.  Now that the GdkColorContext
	  handles all color mapping, maybe gdk_color_alloc() should
	  be only a simple wrapper over XAllocColor()?

	- Add support for XImages with depths less than 8 bits per
	  pixel to GdkImage.  XmHTML uses this, and our port of it to
	  Gtk will later use that functionality.

	- Most of GtkPreview's code will simply go away.  It should
	  use a GdkColorContext for its work.  GdkColorContext already
	  provides the dithering matrices; GtkPreview should only
	  perform the actual dithering process.

	- Eventually, fix the bits of Gtk that assume it is running on
	  8-bit and better displays.  Shawn Amundson already has code
	  for this.  

	  If we only had Gtk allocate its gray shades using
	  gdk_color_context_get_pixel(), it would work fine, but it
	  would look less than pretty on 1-bit displays.  Shawn's code
	  is supposed to fix this.

All this should make Gtk/Gdk friendly to displays with less than 8
bits per pixel, and it should also make programming much easier for
people who have to deal with color allocation themselves.

I would really appreciate if somebody could give a hand with this.
Right now the GdkColorContext is *completely* untested.  We want to
test it using the port to Gtk of the XmHTML widget.  I would
appreciate if anyone could do separate testing.  It should be possible
to do as the rest of Gdk is modified to use GdkColorContext.

  Quartic



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]