/[emacs]/emacs/src/xfns.c
ViewVC logotype

Diff of /emacs/src/xfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.592 by lute, Tue Aug 26 08:44:35 2003 UTC revision 1.593 by gerd, Fri Aug 29 09:29:16 2003 UTC
# Line 6755  lookup_rgb_color (f, r, g, b) Line 6755  lookup_rgb_color (f, r, g, b)
6755    unsigned hash = CT_HASH_RGB (r, g, b);    unsigned hash = CT_HASH_RGB (r, g, b);
6756    int i = hash % CT_SIZE;    int i = hash % CT_SIZE;
6757    struct ct_color *p;    struct ct_color *p;
6758      Visual *visual;
6759    
6760      /* Handle TrueColor visuals specially, which improves performance by
6761         two orders of magnitude.  Freeing colors on TrueColor visuals is
6762         a nop, and pixel colors specify RGB values directly.  See also
6763         the Xlib spec, chapter 3.1.  */
6764      visual = FRAME_X_DISPLAY_INFO (f)->visual;
6765      if (visual->class == TrueColor)
6766        {
6767          int bits = visual->bits_per_rgb;
6768          unsigned long pr, pg, pb;
6769    
6770          /* Apply gamma-correction like normal color allocation does.  */
6771          if (f->gamma)
6772            {
6773              XColor color;
6774              color.red = r, color.green = g, color.blue = b;
6775              gamma_correct (f, &color);
6776              r = color.red, g = color.green, b = color.blue;
6777            }
6778    
6779          /* Scale down RGB values to the visual's bits per RGB, and shift
6780             them to the right position in the pixel color.  Note that the
6781             original RGB values are 16-bit values, as usual in X.  */
6782          pr = (r >> (16 - bits)) << 2 * bits;
6783          pg = (g >> (16 - bits)) << 1 * bits;
6784          pb = (b >> (16 - bits)) << 0 * bits;
6785    
6786          /* Apply RGB masks of the visual.  */
6787          pr &= visual->red_mask;
6788          pg &= visual->green_mask;
6789          pb &= visual->blue_mask;
6790    
6791          /* Assemble the pixel color.  */
6792          return pr | pg | pb;
6793        }
6794      
6795    for (p = ct_table[i]; p; p = p->next)    for (p = ct_table[i]; p; p = p->next)
6796      if (p->r == r && p->g == g && p->b == b)      if (p->r == r && p->g == g && p->b == b)
6797        break;        break;

Legend:
Removed from v.1.592  
changed lines
  Added in v.1.593

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26