diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xfns.c | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 21bd69c7a7e..be2974332dc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2003-08-29 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * xfns.c (lookup_rgb_color): Handle TrueColor visuals specially. | ||
| 4 | |||
| 1 | 2003-08-28 David Abrahams <dave@boost-consulting.com> (tiny change) | 5 | 2003-08-28 David Abrahams <dave@boost-consulting.com> (tiny change) |
| 2 | 6 | ||
| 3 | * coding.c (decode_coding_iso2022): Initialized local variable c2. | 7 | * coding.c (decode_coding_iso2022): Initialized local variable c2. |
diff --git a/src/xfns.c b/src/xfns.c index 65747dbe1b9..0a87cc5950e 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -6755,7 +6755,43 @@ lookup_rgb_color (f, r, g, b) | |||
| 6755 | unsigned hash = CT_HASH_RGB (r, g, b); | 6755 | unsigned hash = CT_HASH_RGB (r, g, b); |
| 6756 | int i = hash % CT_SIZE; | 6756 | int i = hash % CT_SIZE; |
| 6757 | struct ct_color *p; | 6757 | struct ct_color *p; |
| 6758 | Visual *visual; | ||
| 6758 | 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 | |||
| 6759 | for (p = ct_table[i]; p; p = p->next) | 6795 | for (p = ct_table[i]; p; p = p->next) |
| 6760 | if (p->r == r && p->g == g && p->b == b) | 6796 | if (p->r == r && p->g == g && p->b == b) |
| 6761 | break; | 6797 | break; |