diff options
| author | Po Lu | 2022-02-14 18:39:56 +0800 |
|---|---|---|
| committer | Po Lu | 2022-02-14 18:43:44 +0800 |
| commit | 9844b152a5c96d7aa0203a0573767241a1bbd043 (patch) | |
| tree | 1c91d703893af8245ddc7786523c708e4a1e5d4f /src | |
| parent | 4c2701fad1e7554908cecb7ee74dc7e85484e13e (diff) | |
| download | emacs-9844b152a5c96d7aa0203a0573767241a1bbd043.tar.gz emacs-9844b152a5c96d7aa0203a0573767241a1bbd043.zip | |
Premultiply background color by alpha for images
* src/xterm.c (x_query_frame_background_color): Premultiply
colors as X wants them when built without Cairo.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c index 9cde6c9a683..cff4b07c6ea 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3146,13 +3146,35 @@ static void | |||
| 3146 | x_query_frame_background_color (struct frame *f, XColor *bgcolor) | 3146 | x_query_frame_background_color (struct frame *f, XColor *bgcolor) |
| 3147 | { | 3147 | { |
| 3148 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); | 3148 | unsigned long background = FRAME_BACKGROUND_PIXEL (f); |
| 3149 | #ifndef USE_CAIRO | ||
| 3150 | XColor bg; | ||
| 3151 | #endif | ||
| 3149 | 3152 | ||
| 3150 | if (FRAME_DISPLAY_INFO (f)->alpha_bits) | 3153 | if (FRAME_DISPLAY_INFO (f)->alpha_bits) |
| 3151 | { | 3154 | { |
| 3155 | #ifdef USE_CAIRO | ||
| 3152 | background = (background & ~FRAME_DISPLAY_INFO (f)->alpha_mask); | 3156 | background = (background & ~FRAME_DISPLAY_INFO (f)->alpha_mask); |
| 3153 | background |= (((unsigned long) (f->alpha_background * 0xffff) | 3157 | background |= (((unsigned long) (f->alpha_background * 0xffff) |
| 3154 | >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits)) | 3158 | >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits)) |
| 3155 | << FRAME_DISPLAY_INFO (f)->alpha_offset); | 3159 | << FRAME_DISPLAY_INFO (f)->alpha_offset); |
| 3160 | #else | ||
| 3161 | if (FRAME_DISPLAY_INFO (f)->alpha_bits | ||
| 3162 | && f->alpha_background < 1.0) | ||
| 3163 | { | ||
| 3164 | bg.pixel = background; | ||
| 3165 | x_query_colors (f, &bg, 1); | ||
| 3166 | bg.red *= f->alpha_background; | ||
| 3167 | bg.green *= f->alpha_background; | ||
| 3168 | bg.blue *= f->alpha_background; | ||
| 3169 | |||
| 3170 | background = x_make_truecolor_pixel (FRAME_DISPLAY_INFO (f), | ||
| 3171 | bg.red, bg.green, bg.blue); | ||
| 3172 | background &= ~FRAME_DISPLAY_INFO (f)->alpha_mask; | ||
| 3173 | background |= (((unsigned long) (f->alpha_background * 0xffff) | ||
| 3174 | >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits)) | ||
| 3175 | << FRAME_DISPLAY_INFO (f)->alpha_offset); | ||
| 3176 | } | ||
| 3177 | #endif | ||
| 3156 | } | 3178 | } |
| 3157 | 3179 | ||
| 3158 | bgcolor->pixel = background; | 3180 | bgcolor->pixel = background; |