ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.187 by sf-exg, Wed Dec 28 13:13:33 2011 UTC vs.
Revision 1.198 by sf-exg, Wed Jan 11 13:51:07 2012 UTC

32 32
33#ifndef FilterConvolution 33#ifndef FilterConvolution
34#define FilterConvolution "convolution" 34#define FilterConvolution "convolution"
35#endif 35#endif
36 36
37#ifndef RepeatPad
38#define RepeatPad True
39#endif
40
37#ifdef HAVE_BG_PIXMAP 41#ifdef HAVE_BG_PIXMAP
42# if XRENDER
43static Picture
44create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha)
45{
46 Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8);
47
48 XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8);
49 XRenderPictureAttributes pa;
50 pa.repeat = True;
51 pa.component_alpha = component_alpha;
52 Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat | CPComponentAlpha, &pa);
53
54 XFreePixmap (dpy, pixmap);
55
56 return mask;
57}
58# endif
59
38void 60void
39rxvt_term::bg_destroy () 61rxvt_term::bg_destroy ()
40{ 62{
41#ifdef HAVE_AFTERIMAGE 63#ifdef HAVE_AFTERIMAGE
42 if (original_asim) 64 if (original_asim)
107 129
108 return false; 130 return false;
109} 131}
110 132
111# ifdef BG_IMAGE_FROM_FILE 133# ifdef BG_IMAGE_FROM_FILE
112static inline bool
113check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value)
114{
115 if (geom_flags & flag)
116 {
117 if (new_value > 1000)
118 new_value = 1000;
119 if (new_value != scale)
120 {
121 scale = new_value;
122 return true;
123 }
124 }
125 return false;
126}
127
128static inline bool
129check_set_align_value (int geom_flags, int flag, int &align, int new_value)
130{
131 if (geom_flags & flag)
132 {
133 if (new_value < -100)
134 new_value = -100;
135 else if (new_value > 200)
136 new_value = 200;
137 if (new_value != align)
138 {
139 align = new_value;
140 return true;
141 }
142 }
143 return false;
144}
145
146static inline int 134static inline int
147make_align_position (int align, int window_size, int image_size) 135make_align_position (int align, int window_size, int image_size)
148{ 136{
149 int diff = window_size - image_size; 137 int diff = window_size - image_size;
150 int smaller = min (image_size, window_size); 138 int smaller = min (image_size, window_size);
169 src_pos = -pos; 157 src_pos = -pos;
170 dst_pos = 0; 158 dst_pos = 0;
171 dst_size += pos; 159 dst_size += pos;
172 } 160 }
173 161
174 if (dst_pos + dst_size > target_size)
175 dst_size = target_size - dst_pos; 162 min_it (dst_size, target_size - dst_pos);
176 return src_pos; 163 return src_pos;
177} 164}
178 165
179bool 166bool
180rxvt_term::bg_set_geometry (const char *geom, bool update) 167rxvt_term::bg_set_geometry (const char *geom, bool update)
181{ 168{
182 bool changed = false; 169 bool changed = false;
183 int geom_flags = 0; 170 int geom_flags = 0;
184 int x = 0, y = 0; 171 int x = h_align;
172 int y = v_align;
185 unsigned int w = 0, h = 0; 173 unsigned int w = h_scale;
174 unsigned int h = v_scale;
186 unsigned long new_flags = 0; 175 unsigned long new_flags = 0;
187 176
188 if (geom == NULL) 177 if (geom == NULL)
189 return false; 178 return false;
190 179
299 w = h = defaultScale; 288 w = h = defaultScale;
300 else if (!(geom_flags & HeightValue)) 289 else if (!(geom_flags & HeightValue))
301 h = w; 290 h = w;
302 else if (!(geom_flags & WidthValue)) 291 else if (!(geom_flags & WidthValue))
303 w = h; 292 w = h;
304
305 geom_flags |= WidthValue|HeightValue|XValue|YValue;
306 } 293 }
307 294
308 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; 295 min_it (w, 1000);
309 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; 296 min_it (h, 1000);
310 if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; 297 clamp_it (x, -100, 200);
311 if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; 298 clamp_it (y, -100, 200);
312 299
313 if (new_flags != bg_flags) 300 if (bg_flags != new_flags
301 || h_scale != w
302 || v_scale != h
303 || h_align != x
304 || v_align != y)
314 { 305 {
315 bg_flags = new_flags; 306 bg_flags = new_flags;
307 h_scale = w;
308 v_scale = h;
309 h_align = x;
310 v_align = y;
316 changed = true; 311 changed = true;
317 } 312 }
318 313
319 return changed; 314 return changed;
320} 315}
374 if (tr_flags & BG_NEEDS_TINT) 369 if (tr_flags & BG_NEEDS_TINT)
375 { 370 {
376 ShadingInfo as_shade; 371 ShadingInfo as_shade;
377 as_shade.shading = shade; 372 as_shade.shading = shade;
378 373
379 rgba c; 374 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
375 if (bg_flags & BG_TINT_SET)
380 tint.get (c); 376 tint.get (c);
381 as_shade.tintColor.red = c.r; 377 as_shade.tintColor.red = c.r;
382 as_shade.tintColor.green = c.g; 378 as_shade.tintColor.green = c.g;
383 as_shade.tintColor.blue = c.b; 379 as_shade.tintColor.blue = c.b;
384 380
385 background_tint = shading2tint32 (&as_shade); 381 background_tint = shading2tint32 (&as_shade);
801 } 797 }
802 798
803#if XRENDER 799#if XRENDER
804 if (tr_flags) 800 if (tr_flags)
805 { 801 {
806 XRenderPictureAttributes pa;
807
808 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 802 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
803
809 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 804 Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0);
810 805
811 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
812 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 806 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0);
813 807
814 pa.repeat = True; 808 Picture mask = create_xrender_mask (dpy, vt, False, False);
815 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
816 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
817 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
818 XFreePixmap (dpy, mask_pmap);
819 809
820 XRenderColor mask_c; 810 XRenderColor mask_c;
821 811
822 mask_c.alpha = 0x8000; 812 mask_c.alpha = 0x8000;
823 mask_c.red = 0; 813 mask_c.red =
824 mask_c.green = 0; 814 mask_c.green =
825 mask_c.blue = 0; 815 mask_c.blue = 0;
826 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 816 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
817
827 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); 818 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
828 819
829 XRenderFreePicture (dpy, src); 820 XRenderFreePicture (dpy, src);
830 XRenderFreePicture (dpy, dst); 821 XRenderFreePicture (dpy, dst);
831 XRenderFreePicture (dpy, mask); 822 XRenderFreePicture (dpy, mask);
943 { 934 {
944 changed = true; 935 changed = true;
945 v_blurRadius = vr; 936 v_blurRadius = vr;
946 } 937 }
947 938
948 if (v_blurRadius == 0 && h_blurRadius == 0) 939 if (h_blurRadius == 0 || v_blurRadius == 0)
949 bg_flags &= ~BG_NEEDS_BLUR; 940 bg_flags &= ~BG_NEEDS_BLUR;
950 else 941 else
951 bg_flags |= BG_NEEDS_BLUR; 942 bg_flags |= BG_NEEDS_BLUR;
952 943
953 return changed; 944 return changed;
959 rgba c; 950 rgba c;
960 bool has_shade = shade != 100; 951 bool has_shade = shade != 100;
961 952
962 bg_flags &= ~BG_TINT_FLAGS; 953 bg_flags &= ~BG_TINT_FLAGS;
963 954
955 if (bg_flags & BG_TINT_SET)
956 {
964 tint.get (c); 957 tint.get (c);
965
966 if (!has_shade 958 if (!has_shade
967 && (c.r <= 0x00ff || c.r >= 0xff00) 959 && (c.r <= 0x00ff || c.r >= 0xff00)
968 && (c.g <= 0x00ff || c.g >= 0xff00) 960 && (c.g <= 0x00ff || c.g >= 0xff00)
969 && (c.b <= 0x00ff || c.b >= 0xff00)) 961 && (c.b <= 0x00ff || c.b >= 0xff00))
970 bg_flags |= BG_TINT_BITAND; 962 bg_flags |= BG_TINT_BITAND;
963 }
971 964
972 if (has_shade 965 if (has_shade || (bg_flags & BG_TINT_SET))
973 || c.r < 0xff00
974 || c.g < 0xff00
975 || c.b < 0xff00)
976 bg_flags |= BG_NEEDS_TINT; 966 bg_flags |= BG_NEEDS_TINT;
977} 967}
978 968
979bool 969bool
980rxvt_term::bg_set_tint (rxvt_color &new_tint) 970rxvt_term::bg_set_tint (rxvt_color &new_tint)
981{ 971{
982 if (tint != new_tint) 972 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
983 { 973 {
984 tint = new_tint; 974 tint = new_tint;
975 bg_flags |= BG_TINT_SET;
985 set_tint_shade_flags (); 976 set_tint_shade_flags ();
986 return true; 977 return true;
987 } 978 }
988 979
989 return false; 980 return false;
1030 params[i+2] = XDoubleToFixed (kernel[i] / sum); 1021 params[i+2] = XDoubleToFixed (kernel[i] / sum);
1031} 1022}
1032#endif 1023#endif
1033 1024
1034bool 1025bool
1035rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1026rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth)
1036{ 1027{
1037 bool ret = false; 1028 bool ret = false;
1038#if XRENDER 1029#if XRENDER
1039 if (!(bg_flags & BG_HAS_RENDER_CONV)) 1030 if (!(bg_flags & BG_HAS_RENDER_CONV))
1040 return false; 1031 return false;
1044 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1035 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1045 1036
1046 XRenderPictureAttributes pa; 1037 XRenderPictureAttributes pa;
1047 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1038 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1048 1039
1040 pa.repeat = RepeatPad;
1049 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1041 Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa);
1042 Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth);
1050 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1043 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa);
1044 XFreePixmap (dpy, tmp);
1051 1045
1052 if (kernel && params) 1046 if (kernel && params)
1053 { 1047 {
1054 if (h_blurRadius)
1055 {
1056 size = h_blurRadius * 2 + 1; 1048 size = h_blurRadius * 2 + 1;
1057 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1049 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1058 1050
1059 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 1051 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
1060 XRenderComposite (dpy, 1052 XRenderComposite (dpy,
1061 PictOpSrc, 1053 PictOpSrc,
1062 src, 1054 src,
1063 None, 1055 None,
1064 dst, 1056 dst,
1065 0, 0, 1057 0, 0,
1066 0, 0, 1058 0, 0,
1067 0, 0, 1059 0, 0,
1068 width, height); 1060 width, height);
1069 }
1070 1061
1071 if (v_blurRadius) 1062 ::swap (src, dst);
1072 { 1063
1073 size = v_blurRadius * 2 + 1; 1064 size = v_blurRadius * 2 + 1;
1074 get_gaussian_kernel (v_blurRadius, size, kernel, params); 1065 get_gaussian_kernel (v_blurRadius, size, kernel, params);
1075 ::swap (params[0], params[1]); 1066 ::swap (params[0], params[1]);
1076 1067
1077 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 1068 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
1078 XRenderComposite (dpy, 1069 XRenderComposite (dpy,
1079 PictOpSrc, 1070 PictOpSrc,
1080 src, 1071 src,
1081 None, 1072 None,
1082 dst, 1073 dst,
1083 0, 0, 1074 0, 0,
1084 0, 0, 1075 0, 0,
1085 0, 0, 1076 0, 0,
1086 width, height); 1077 width, height);
1087 }
1088 1078
1089 ret = true; 1079 ret = true;
1090 } 1080 }
1091 1081
1092 free (kernel); 1082 free (kernel);
1122 } 1112 }
1123 } 1113 }
1124# if XRENDER 1114# if XRENDER
1125 else if (bg_flags & BG_HAS_RENDER) 1115 else if (bg_flags & BG_HAS_RENDER)
1126 { 1116 {
1127 rgba c; 1117 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1128 1118
1119 if (bg_flags & BG_TINT_SET)
1129 tint.get (c); 1120 tint.get (c);
1130 1121
1131 if (shade <= 100) 1122 if (shade <= 100)
1132 { 1123 {
1133 c.r = c.r * shade / 100; 1124 c.r = c.r * shade / 100;
1134 c.g = c.g * shade / 100; 1125 c.g = c.g * shade / 100;
1139 c.r = c.r * (200 - shade) / 100; 1130 c.r = c.r * (200 - shade) / 100;
1140 c.g = c.g * (200 - shade) / 100; 1131 c.g = c.g * (200 - shade) / 100;
1141 c.b = c.b * (200 - shade) / 100; 1132 c.b = c.b * (200 - shade) / 100;
1142 } 1133 }
1143 1134
1144 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1145 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1135 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1146 XRenderPictureAttributes pa;
1147 1136
1148 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1137 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0);
1149 1138
1150 pa.repeat = True; 1139 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False);
1151 1140
1152 Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1141 Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True);
1153 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1154 XFreePixmap (dpy, overlay_pmap);
1155
1156 pa.component_alpha = True;
1157 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1158 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1159 XFreePixmap (dpy, mask_pmap);
1160 1142
1161 XRenderColor mask_c; 1143 XRenderColor mask_c;
1162 1144
1163 mask_c.alpha = 0xffff; 1145 mask_c.alpha = 0xffff;
1164 mask_c.red = 1146 mask_c.red =
1169 mask_c.alpha = 0; 1151 mask_c.alpha = 0;
1170 mask_c.red = 0xffff - c.r; 1152 mask_c.red = 0xffff - c.r;
1171 mask_c.green = 0xffff - c.g; 1153 mask_c.green = 0xffff - c.g;
1172 mask_c.blue = 0xffff - c.b; 1154 mask_c.blue = 0xffff - c.b;
1173 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1155 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1156
1174 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1157 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1175 1158
1176 if (shade > 100) 1159 if (shade > 100)
1177 { 1160 {
1178 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1179 mask_c.alpha = 0; 1161 mask_c.alpha = 0;
1162 mask_c.red =
1163 mask_c.green =
1164 mask_c.blue = 0xffff * (shade - 100) / 100;
1180 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1165 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1181 1166
1182 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1167 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1183 } 1168 }
1184 1169
1247#if XRENDER 1232#if XRENDER
1248 if (bg_flags & BG_HAS_RENDER) 1233 if (bg_flags & BG_HAS_RENDER)
1249 { 1234 {
1250 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1235 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1251 1236
1252 XRenderPictureAttributes pa;
1253
1254 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1237 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1255 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1238 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0);
1256 1239
1257 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1240 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1258 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1241 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, 0);
1259 1242
1260 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1243 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1261 1244
1262 XRenderFreePicture (dpy, src); 1245 XRenderFreePicture (dpy, src);
1263 XRenderFreePicture (dpy, dst); 1246 XRenderFreePicture (dpy, dst);
1293 1276
1294 if (gc) 1277 if (gc)
1295 { 1278 {
1296 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1279 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1297 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1280 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1298 XFreeGC (dpy, gc);
1299 1281
1300 if (!(bg_flags & BG_CLIENT_RENDER)) 1282 if (!(bg_flags & BG_CLIENT_RENDER))
1301 { 1283 {
1302 if (bg_flags & BG_NEEDS_BLUR) 1284 if (bg_flags & BG_NEEDS_BLUR)
1303 { 1285 {
1304 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1286 if (blur_pixmap (bg_pixmap, visual, window_width, window_height, depth))
1305 result &= ~BG_NEEDS_BLUR; 1287 result &= ~BG_NEEDS_BLUR;
1306 } 1288 }
1307 if (bg_flags & BG_NEEDS_TINT) 1289 if (bg_flags & BG_NEEDS_TINT)
1308 { 1290 {
1309 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1291 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1310 result &= ~BG_NEEDS_TINT; 1292 result &= ~BG_NEEDS_TINT;
1311 } 1293 }
1294# ifndef HAVE_AFTERIMAGE
1295 if (result & BG_NEEDS_TINT)
1296 {
1297 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1298 if (ximage)
1299 {
1300 /* our own client-side tinting */
1301 tint_ximage (DefaultVisual (dpy, display->screen), ximage);
1302
1303 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1304 XDestroyImage (ximage);
1305 }
1306 }
1307# endif
1312 } /* server side rendering completed */ 1308 } /* server side rendering completed */
1309
1310 XFreeGC (dpy, gc);
1313 } 1311 }
1314 1312
1315 if (recoded_root_pmap != root_pixmap) 1313 if (recoded_root_pmap != root_pixmap)
1316 XFreePixmap (dpy, recoded_root_pmap); 1314 XFreePixmap (dpy, recoded_root_pmap);
1317 1315
1353 if (render_image (tr_flags)) 1351 if (render_image (tr_flags))
1354 bg_flags |= BG_IS_VALID; 1352 bg_flags |= BG_IS_VALID;
1355 } 1353 }
1356# endif 1354# endif
1357 1355
1358# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1359 XImage *result = NULL;
1360
1361 if (tr_flags & BG_NEEDS_TINT)
1362 {
1363 result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1364 }
1365
1366 if (result)
1367 {
1368 /* our own client-side tinting */
1369 //if (tr_flags & BG_NEEDS_TINT)
1370 if (1)
1371 tint_ximage (DefaultVisual (dpy, display->screen), result);
1372
1373 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1374
1375 if (gc)
1376 {
1377 XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1378
1379 XFreeGC (dpy, gc);
1380 }
1381
1382 XDestroyImage (result);
1383 }
1384# endif
1385
1386 if (!(bg_flags & BG_IS_VALID)) 1356 if (!(bg_flags & BG_IS_VALID))
1387 { 1357 {
1388 if (bg_pixmap != None) 1358 if (bg_pixmap != None)
1389 { 1359 {
1390 XFreePixmap (dpy, bg_pixmap); 1360 XFreePixmap (dpy, bg_pixmap);
1402 1372
1403void 1373void
1404rxvt_term::bg_init () 1374rxvt_term::bg_init ()
1405{ 1375{
1406#ifdef ENABLE_TRANSPARENCY 1376#ifdef ENABLE_TRANSPARENCY
1407 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1408 tint.set (this, c);
1409 shade = 100; 1377 shade = 100;
1410#endif 1378#endif
1411 1379
1412 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); 1380 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1413#if XRENDER 1381#if XRENDER
1516 break; 1484 break;
1517 default: 1485 default:
1518 return; /* we do not support this color depth */ 1486 return; /* we do not support this color depth */
1519 } 1487 }
1520 1488
1521 rgba c; 1489 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1522 1490
1491 if (bg_flags & BG_TINT_SET)
1523 tint.get (c); 1492 tint.get (c);
1524 1493
1525 /* prepare limits for color transformation (each channel is handled separately) */ 1494 /* prepare limits for color transformation (each channel is handled separately) */
1526 if (shade > 100) 1495 if (shade > 100)
1527 { 1496 {
1528 c.r = c.r * (200 - shade) / 100; 1497 c.r = c.r * (200 - shade) / 100;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines