… | |
… | |
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 |
|
|
43 | static Picture |
|
|
44 | create_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 | |
38 | void |
60 | void |
39 | rxvt_term::bg_destroy () |
61 | rxvt_term::bg_destroy () |
40 | { |
62 | { |
41 | #ifdef HAVE_AFTERIMAGE |
63 | #ifdef HAVE_AFTERIMAGE |
42 | if (original_asim) |
64 | if (original_asim) |
… | |
… | |
181 | { |
203 | { |
182 | bool changed = false; |
204 | bool changed = false; |
183 | int geom_flags = 0; |
205 | int geom_flags = 0; |
184 | int x = 0, y = 0; |
206 | int x = 0, y = 0; |
185 | unsigned int w = 0, h = 0; |
207 | unsigned int w = 0, h = 0; |
186 | unsigned long new_flags = bg_flags & ~BG_GEOMETRY_FLAGS; |
208 | unsigned long new_flags = 0; |
187 | |
209 | |
188 | if (geom == NULL) |
210 | if (geom == NULL) |
189 | return false; |
211 | return false; |
190 | |
212 | |
191 | if (geom[0]) |
213 | if (geom[0]) |
… | |
… | |
283 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
305 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
284 | } /* done parsing ops */ |
306 | } /* done parsing ops */ |
285 | |
307 | |
286 | rxvt_free_strsplit (arr); |
308 | rxvt_free_strsplit (arr); |
287 | } |
309 | } |
|
|
310 | |
|
|
311 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
288 | |
312 | |
289 | if (!update) |
313 | if (!update) |
290 | { |
314 | { |
291 | if (!(geom_flags & XValue)) |
315 | if (!(geom_flags & XValue)) |
292 | x = y = defaultAlign; |
316 | x = y = defaultAlign; |
… | |
… | |
800 | } |
824 | } |
801 | |
825 | |
802 | #if XRENDER |
826 | #if XRENDER |
803 | if (tr_flags) |
827 | if (tr_flags) |
804 | { |
828 | { |
805 | XRenderPictureAttributes pa; |
|
|
806 | |
|
|
807 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); |
829 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
|
|
830 | |
808 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
831 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
809 | |
832 | |
810 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
|
|
811 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
833 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
812 | |
834 | |
813 | pa.repeat = True; |
835 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
814 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
|
|
815 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
|
|
816 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
|
|
817 | XFreePixmap (dpy, mask_pmap); |
|
|
818 | |
836 | |
819 | XRenderColor mask_c; |
837 | XRenderColor mask_c; |
820 | |
838 | |
821 | mask_c.alpha = 0x8000; |
839 | mask_c.alpha = 0x8000; |
822 | mask_c.red = 0; |
840 | mask_c.red = |
823 | mask_c.green = 0; |
841 | mask_c.green = |
824 | mask_c.blue = 0; |
842 | mask_c.blue = 0; |
825 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
843 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
|
|
844 | |
826 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
845 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
827 | |
846 | |
828 | XRenderFreePicture (dpy, src); |
847 | XRenderFreePicture (dpy, src); |
829 | XRenderFreePicture (dpy, dst); |
848 | XRenderFreePicture (dpy, dst); |
830 | XRenderFreePicture (dpy, mask); |
849 | XRenderFreePicture (dpy, mask); |
… | |
… | |
942 | { |
961 | { |
943 | changed = true; |
962 | changed = true; |
944 | v_blurRadius = vr; |
963 | v_blurRadius = vr; |
945 | } |
964 | } |
946 | |
965 | |
947 | if (v_blurRadius == 0 && h_blurRadius == 0) |
966 | if (h_blurRadius == 0 || v_blurRadius == 0) |
948 | bg_flags &= ~BG_NEEDS_BLUR; |
967 | bg_flags &= ~BG_NEEDS_BLUR; |
949 | else |
968 | else |
950 | bg_flags |= BG_NEEDS_BLUR; |
969 | bg_flags |= BG_NEEDS_BLUR; |
951 | |
970 | |
952 | return changed; |
971 | return changed; |
953 | } |
972 | } |
954 | |
973 | |
955 | void |
974 | void |
956 | rxvt_term::set_tint_shade_flags () |
975 | rxvt_term::set_tint_shade_flags () |
957 | { |
976 | { |
958 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
977 | rgba c; |
959 | bool has_shade = shade != 100; |
978 | bool has_shade = shade != 100; |
960 | |
979 | |
961 | bg_flags &= ~BG_TINT_FLAGS; |
980 | bg_flags &= ~BG_TINT_FLAGS; |
962 | |
981 | |
963 | if (bg_flags & BG_TINT_SET) |
982 | if (bg_flags & BG_TINT_SET) |
… | |
… | |
989 | } |
1008 | } |
990 | |
1009 | |
991 | bool |
1010 | bool |
992 | rxvt_term::bg_set_shade (const char *shade_str) |
1011 | rxvt_term::bg_set_shade (const char *shade_str) |
993 | { |
1012 | { |
994 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1013 | int new_shade = atoi (shade_str); |
995 | |
1014 | |
996 | clamp_it (new_shade, -100, 200); |
1015 | clamp_it (new_shade, -100, 200); |
997 | if (new_shade < 0) |
1016 | if (new_shade < 0) |
998 | new_shade = 200 - (100 + new_shade); |
1017 | new_shade = 200 - (100 + new_shade); |
999 | |
1018 | |
… | |
… | |
1029 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1048 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1030 | } |
1049 | } |
1031 | #endif |
1050 | #endif |
1032 | |
1051 | |
1033 | bool |
1052 | bool |
1034 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1053 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth) |
1035 | { |
1054 | { |
1036 | bool ret = false; |
1055 | bool ret = false; |
1037 | #if XRENDER |
1056 | #if XRENDER |
1038 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
1057 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
1039 | return false; |
1058 | return false; |
… | |
… | |
1043 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1062 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1044 | |
1063 | |
1045 | XRenderPictureAttributes pa; |
1064 | XRenderPictureAttributes pa; |
1046 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1065 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1047 | |
1066 | |
|
|
1067 | pa.repeat = RepeatPad; |
1048 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1068 | Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); |
|
|
1069 | Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth); |
1049 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1070 | Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); |
|
|
1071 | XFreePixmap (dpy, tmp); |
1050 | |
1072 | |
1051 | if (kernel && params) |
1073 | if (kernel && params) |
1052 | { |
1074 | { |
1053 | if (h_blurRadius) |
|
|
1054 | { |
|
|
1055 | size = h_blurRadius * 2 + 1; |
1075 | size = h_blurRadius * 2 + 1; |
1056 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1076 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1057 | |
1077 | |
1058 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1078 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1059 | XRenderComposite (dpy, |
1079 | XRenderComposite (dpy, |
1060 | PictOpSrc, |
1080 | PictOpSrc, |
1061 | src, |
1081 | src, |
1062 | None, |
1082 | None, |
1063 | dst, |
1083 | dst, |
1064 | 0, 0, |
1084 | 0, 0, |
1065 | 0, 0, |
1085 | 0, 0, |
1066 | 0, 0, |
1086 | 0, 0, |
1067 | width, height); |
1087 | width, height); |
1068 | } |
|
|
1069 | |
1088 | |
1070 | if (v_blurRadius) |
1089 | ::swap (src, dst); |
1071 | { |
1090 | |
1072 | size = v_blurRadius * 2 + 1; |
1091 | size = v_blurRadius * 2 + 1; |
1073 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1092 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1074 | ::swap (params[0], params[1]); |
1093 | ::swap (params[0], params[1]); |
1075 | |
1094 | |
1076 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1095 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1077 | XRenderComposite (dpy, |
1096 | XRenderComposite (dpy, |
1078 | PictOpSrc, |
1097 | PictOpSrc, |
1079 | src, |
1098 | src, |
1080 | None, |
1099 | None, |
1081 | dst, |
1100 | dst, |
1082 | 0, 0, |
1101 | 0, 0, |
1083 | 0, 0, |
1102 | 0, 0, |
1084 | 0, 0, |
1103 | 0, 0, |
1085 | width, height); |
1104 | width, height); |
1086 | } |
|
|
1087 | |
1105 | |
1088 | ret = true; |
1106 | ret = true; |
1089 | } |
1107 | } |
1090 | |
1108 | |
1091 | free (kernel); |
1109 | free (kernel); |
… | |
… | |
1139 | c.r = c.r * (200 - shade) / 100; |
1157 | c.r = c.r * (200 - shade) / 100; |
1140 | c.g = c.g * (200 - shade) / 100; |
1158 | c.g = c.g * (200 - shade) / 100; |
1141 | c.b = c.b * (200 - shade) / 100; |
1159 | c.b = c.b * (200 - shade) / 100; |
1142 | } |
1160 | } |
1143 | |
1161 | |
1144 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1145 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1162 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1146 | XRenderPictureAttributes pa; |
|
|
1147 | |
1163 | |
1148 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1164 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1149 | |
1165 | |
1150 | pa.repeat = True; |
1166 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
1151 | |
1167 | |
1152 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1168 | 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 | |
1169 | |
1161 | XRenderColor mask_c; |
1170 | XRenderColor mask_c; |
1162 | |
1171 | |
1163 | mask_c.alpha = 0xffff; |
1172 | mask_c.alpha = 0xffff; |
1164 | mask_c.red = |
1173 | mask_c.red = |
… | |
… | |
1169 | mask_c.alpha = 0; |
1178 | mask_c.alpha = 0; |
1170 | mask_c.red = 0xffff - c.r; |
1179 | mask_c.red = 0xffff - c.r; |
1171 | mask_c.green = 0xffff - c.g; |
1180 | mask_c.green = 0xffff - c.g; |
1172 | mask_c.blue = 0xffff - c.b; |
1181 | mask_c.blue = 0xffff - c.b; |
1173 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1182 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1183 | |
1174 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1184 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1175 | |
1185 | |
1176 | if (shade > 100) |
1186 | if (shade > 100) |
1177 | { |
1187 | { |
1178 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1179 | mask_c.alpha = 0; |
1188 | mask_c.alpha = 0; |
|
|
1189 | mask_c.red = |
|
|
1190 | mask_c.green = |
|
|
1191 | mask_c.blue = 0xffff * (shade - 100) / 100; |
1180 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1192 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1181 | |
1193 | |
1182 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1194 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1183 | } |
1195 | } |
1184 | |
1196 | |
… | |
… | |
1247 | #if XRENDER |
1259 | #if XRENDER |
1248 | if (bg_flags & BG_HAS_RENDER) |
1260 | if (bg_flags & BG_HAS_RENDER) |
1249 | { |
1261 | { |
1250 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1262 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1251 | |
1263 | |
1252 | XRenderPictureAttributes pa; |
|
|
1253 | |
|
|
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1264 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1265 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
1256 | |
1266 | |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1267 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1268 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, 0); |
1259 | |
1269 | |
1260 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1270 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1261 | |
1271 | |
1262 | XRenderFreePicture (dpy, src); |
1272 | XRenderFreePicture (dpy, src); |
1263 | XRenderFreePicture (dpy, dst); |
1273 | XRenderFreePicture (dpy, dst); |
… | |
… | |
1293 | |
1303 | |
1294 | if (gc) |
1304 | if (gc) |
1295 | { |
1305 | { |
1296 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1306 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1307 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1298 | XFreeGC (dpy, gc); |
|
|
1299 | |
1308 | |
1300 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1309 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1301 | { |
1310 | { |
1302 | if (bg_flags & BG_NEEDS_BLUR) |
1311 | if (bg_flags & BG_NEEDS_BLUR) |
1303 | { |
1312 | { |
1304 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1313 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height, depth)) |
1305 | result &= ~BG_NEEDS_BLUR; |
1314 | result &= ~BG_NEEDS_BLUR; |
1306 | } |
1315 | } |
1307 | if (bg_flags & BG_NEEDS_TINT) |
1316 | if (bg_flags & BG_NEEDS_TINT) |
1308 | { |
1317 | { |
1309 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1318 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1310 | result &= ~BG_NEEDS_TINT; |
1319 | result &= ~BG_NEEDS_TINT; |
1311 | } |
1320 | } |
|
|
1321 | # ifndef HAVE_AFTERIMAGE |
|
|
1322 | if (result & BG_NEEDS_TINT) |
|
|
1323 | { |
|
|
1324 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1325 | if (ximage) |
|
|
1326 | { |
|
|
1327 | /* our own client-side tinting */ |
|
|
1328 | tint_ximage (DefaultVisual (dpy, display->screen), ximage); |
|
|
1329 | |
|
|
1330 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
|
|
1331 | XDestroyImage (ximage); |
|
|
1332 | } |
|
|
1333 | } |
|
|
1334 | # endif |
1312 | } /* server side rendering completed */ |
1335 | } /* server side rendering completed */ |
|
|
1336 | |
|
|
1337 | XFreeGC (dpy, gc); |
1313 | } |
1338 | } |
1314 | |
1339 | |
1315 | if (recoded_root_pmap != root_pixmap) |
1340 | if (recoded_root_pmap != root_pixmap) |
1316 | XFreePixmap (dpy, recoded_root_pmap); |
1341 | XFreePixmap (dpy, recoded_root_pmap); |
1317 | |
1342 | |
… | |
… | |
1326 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1351 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1327 | |
1352 | |
1328 | root_pixmap = new_root_pixmap; |
1353 | root_pixmap = new_root_pixmap; |
1329 | } |
1354 | } |
1330 | # endif /* ENABLE_TRANSPARENCY */ |
1355 | # endif /* ENABLE_TRANSPARENCY */ |
1331 | |
|
|
1332 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1333 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
|
|
1334 | # endif |
|
|
1335 | |
1356 | |
1336 | bool |
1357 | bool |
1337 | rxvt_term::bg_render () |
1358 | rxvt_term::bg_render () |
1338 | { |
1359 | { |
1339 | unsigned long tr_flags = 0; |
1360 | unsigned long tr_flags = 0; |
… | |
… | |
1354 | if ((bg_flags & BG_IS_FROM_FILE) |
1375 | if ((bg_flags & BG_IS_FROM_FILE) |
1355 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1376 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1356 | { |
1377 | { |
1357 | if (render_image (tr_flags)) |
1378 | if (render_image (tr_flags)) |
1358 | bg_flags |= BG_IS_VALID; |
1379 | bg_flags |= BG_IS_VALID; |
1359 | } |
|
|
1360 | # endif |
|
|
1361 | |
|
|
1362 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1363 | XImage *result = NULL; |
|
|
1364 | |
|
|
1365 | if (tr_flags & BG_NEEDS_TINT) |
|
|
1366 | { |
|
|
1367 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1368 | } |
|
|
1369 | |
|
|
1370 | if (result) |
|
|
1371 | { |
|
|
1372 | /* our own client-side tinting */ |
|
|
1373 | //if (tr_flags & BG_NEEDS_TINT) |
|
|
1374 | if (1) |
|
|
1375 | { |
|
|
1376 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1377 | if (bg_flags & BG_TINT_SET) |
|
|
1378 | tint.get (c); |
|
|
1379 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
|
|
1380 | } |
|
|
1381 | |
|
|
1382 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
|
|
1383 | |
|
|
1384 | if (gc) |
|
|
1385 | { |
|
|
1386 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
|
|
1387 | |
|
|
1388 | XFreeGC (dpy, gc); |
|
|
1389 | } |
|
|
1390 | |
|
|
1391 | XDestroyImage (result); |
|
|
1392 | } |
1380 | } |
1393 | # endif |
1381 | # endif |
1394 | |
1382 | |
1395 | if (!(bg_flags & BG_IS_VALID)) |
1383 | if (!(bg_flags & BG_IS_VALID)) |
1396 | { |
1384 | { |
… | |
… | |
1448 | tmp += (mask >> sh) * low; |
1436 | tmp += (mask >> sh) * low; |
1449 | lookup[i] = (tmp / 0xffff) << sh; |
1437 | lookup[i] = (tmp / 0xffff) << sh; |
1450 | } |
1438 | } |
1451 | } |
1439 | } |
1452 | |
1440 | |
1453 | static void |
1441 | void |
1454 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1442 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1455 | { |
1443 | { |
1456 | int sh_r, sh_g, sh_b; |
1444 | int sh_r, sh_g, sh_b; |
1457 | uint32_t mask_r, mask_g, mask_b; |
1445 | uint32_t mask_r, mask_g, mask_b; |
1458 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1446 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1459 | unsigned short low; |
1447 | unsigned short low; |
1460 | rgba high; |
|
|
1461 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1448 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1462 | |
1449 | |
1463 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1450 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1464 | |
1451 | |
1465 | /* for convenience */ |
1452 | /* for convenience */ |
… | |
… | |
1524 | break; |
1511 | break; |
1525 | default: |
1512 | default: |
1526 | return; /* we do not support this color depth */ |
1513 | return; /* we do not support this color depth */ |
1527 | } |
1514 | } |
1528 | |
1515 | |
|
|
1516 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1517 | |
|
|
1518 | if (bg_flags & BG_TINT_SET) |
|
|
1519 | tint.get (c); |
|
|
1520 | |
1529 | /* prepare limits for color transformation (each channel is handled separately) */ |
1521 | /* prepare limits for color transformation (each channel is handled separately) */ |
1530 | if (shade > 100) |
1522 | if (shade > 100) |
1531 | { |
1523 | { |
1532 | shade = 200 - shade; |
1524 | c.r = c.r * (200 - shade) / 100; |
|
|
1525 | c.g = c.g * (200 - shade) / 100; |
|
|
1526 | c.b = c.b * (200 - shade) / 100; |
1533 | |
1527 | |
1534 | high.r = c.r * shade / 100; |
|
|
1535 | high.g = c.g * shade / 100; |
|
|
1536 | high.b = c.b * shade / 100; |
|
|
1537 | |
|
|
1538 | low = 0xffff * (100 - shade) / 100; |
1528 | low = 0xffff * (shade - 100) / 100; |
1539 | } |
1529 | } |
1540 | else |
1530 | else |
1541 | { |
1531 | { |
1542 | high.r = c.r * shade / 100; |
1532 | c.r = c.r * shade / 100; |
1543 | high.g = c.g * shade / 100; |
1533 | c.g = c.g * shade / 100; |
1544 | high.b = c.b * shade / 100; |
1534 | c.b = c.b * shade / 100; |
1545 | |
1535 | |
1546 | low = 0; |
1536 | low = 0; |
1547 | } |
1537 | } |
1548 | |
1538 | |
1549 | /* fill our lookup tables */ |
1539 | /* fill our lookup tables */ |
1550 | fill_lut (lookup_r, mask_r, sh_r, low, high.r); |
1540 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1551 | fill_lut (lookup_g, mask_g, sh_g, low, high.g); |
1541 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1552 | fill_lut (lookup_b, mask_b, sh_b, low, high.b); |
1542 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1553 | |
1543 | |
1554 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1544 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1555 | if (ximage->bits_per_pixel == 32 |
1545 | if (ximage->bits_per_pixel == 32 |
1556 | && (ximage->depth == 24 || ximage->depth == 32) |
1546 | && (ximage->depth == 24 || ximage->depth == 32) |
1557 | && ximage->byte_order == host_byte_order) |
1547 | && ximage->byte_order == host_byte_order) |