… | |
… | |
33 | #ifndef FilterConvolution |
33 | #ifndef FilterConvolution |
34 | #define FilterConvolution "convolution" |
34 | #define FilterConvolution "convolution" |
35 | #endif |
35 | #endif |
36 | |
36 | |
37 | #ifdef HAVE_BG_PIXMAP |
37 | #ifdef HAVE_BG_PIXMAP |
|
|
38 | # if XRENDER |
|
|
39 | static Picture |
|
|
40 | create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha) |
|
|
41 | { |
|
|
42 | Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8); |
|
|
43 | |
|
|
44 | XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8); |
|
|
45 | XRenderPictureAttributes pa; |
|
|
46 | pa.repeat = True; |
|
|
47 | pa.component_alpha = component_alpha; |
|
|
48 | Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat | CPComponentAlpha, &pa); |
|
|
49 | |
|
|
50 | XFreePixmap (dpy, pixmap); |
|
|
51 | |
|
|
52 | return mask; |
|
|
53 | } |
|
|
54 | # endif |
|
|
55 | |
38 | void |
56 | void |
39 | rxvt_term::bg_destroy () |
57 | rxvt_term::bg_destroy () |
40 | { |
58 | { |
41 | #ifdef HAVE_AFTERIMAGE |
59 | #ifdef HAVE_AFTERIMAGE |
42 | if (original_asim) |
60 | if (original_asim) |
… | |
… | |
181 | { |
199 | { |
182 | bool changed = false; |
200 | bool changed = false; |
183 | int geom_flags = 0; |
201 | int geom_flags = 0; |
184 | int x = 0, y = 0; |
202 | int x = 0, y = 0; |
185 | unsigned int w = 0, h = 0; |
203 | unsigned int w = 0, h = 0; |
186 | unsigned long new_flags = bg_flags & ~BG_GEOMETRY_FLAGS; |
204 | unsigned long new_flags = 0; |
187 | |
205 | |
188 | if (geom == NULL) |
206 | if (geom == NULL) |
189 | return false; |
207 | return false; |
190 | |
208 | |
191 | if (geom[0]) |
209 | if (geom[0]) |
… | |
… | |
283 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
301 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
284 | } /* done parsing ops */ |
302 | } /* done parsing ops */ |
285 | |
303 | |
286 | rxvt_free_strsplit (arr); |
304 | rxvt_free_strsplit (arr); |
287 | } |
305 | } |
|
|
306 | |
|
|
307 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
288 | |
308 | |
289 | if (!update) |
309 | if (!update) |
290 | { |
310 | { |
291 | if (!(geom_flags & XValue)) |
311 | if (!(geom_flags & XValue)) |
292 | x = y = defaultAlign; |
312 | x = y = defaultAlign; |
… | |
… | |
800 | } |
820 | } |
801 | |
821 | |
802 | #if XRENDER |
822 | #if XRENDER |
803 | if (tr_flags) |
823 | if (tr_flags) |
804 | { |
824 | { |
805 | XRenderPictureAttributes pa; |
|
|
806 | |
|
|
807 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); |
825 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
|
|
826 | |
808 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
827 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
809 | |
828 | |
810 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
|
|
811 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
829 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
812 | |
830 | |
813 | pa.repeat = True; |
831 | 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 | |
832 | |
819 | XRenderColor mask_c; |
833 | XRenderColor mask_c; |
820 | |
834 | |
821 | mask_c.alpha = 0x8000; |
835 | mask_c.alpha = 0x8000; |
822 | mask_c.red = 0; |
836 | mask_c.red = |
823 | mask_c.green = 0; |
837 | mask_c.green = |
824 | mask_c.blue = 0; |
838 | mask_c.blue = 0; |
825 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
839 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
|
|
840 | |
826 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
841 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
827 | |
842 | |
828 | XRenderFreePicture (dpy, src); |
843 | XRenderFreePicture (dpy, src); |
829 | XRenderFreePicture (dpy, dst); |
844 | XRenderFreePicture (dpy, dst); |
830 | XRenderFreePicture (dpy, mask); |
845 | XRenderFreePicture (dpy, mask); |
… | |
… | |
942 | { |
957 | { |
943 | changed = true; |
958 | changed = true; |
944 | v_blurRadius = vr; |
959 | v_blurRadius = vr; |
945 | } |
960 | } |
946 | |
961 | |
947 | if (v_blurRadius == 0 && h_blurRadius == 0) |
962 | if (h_blurRadius == 0 || v_blurRadius == 0) |
948 | bg_flags &= ~BG_NEEDS_BLUR; |
963 | bg_flags &= ~BG_NEEDS_BLUR; |
949 | else |
964 | else |
950 | bg_flags |= BG_NEEDS_BLUR; |
965 | bg_flags |= BG_NEEDS_BLUR; |
951 | |
966 | |
952 | return changed; |
967 | return changed; |
953 | } |
968 | } |
954 | |
969 | |
955 | void |
970 | void |
956 | rxvt_term::set_tint_shade_flags () |
971 | rxvt_term::set_tint_shade_flags () |
957 | { |
972 | { |
958 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
973 | rgba c; |
959 | bool has_shade = shade != 100; |
974 | bool has_shade = shade != 100; |
960 | |
975 | |
961 | bg_flags &= ~BG_TINT_FLAGS; |
976 | bg_flags &= ~BG_TINT_FLAGS; |
962 | |
977 | |
963 | if (bg_flags & BG_TINT_SET) |
978 | if (bg_flags & BG_TINT_SET) |
… | |
… | |
989 | } |
1004 | } |
990 | |
1005 | |
991 | bool |
1006 | bool |
992 | rxvt_term::bg_set_shade (const char *shade_str) |
1007 | rxvt_term::bg_set_shade (const char *shade_str) |
993 | { |
1008 | { |
994 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1009 | int new_shade = atoi (shade_str); |
995 | |
1010 | |
996 | clamp_it (new_shade, -100, 200); |
1011 | clamp_it (new_shade, -100, 200); |
997 | if (new_shade < 0) |
1012 | if (new_shade < 0) |
998 | new_shade = 200 - (100 + new_shade); |
1013 | new_shade = 200 - (100 + new_shade); |
999 | |
1014 | |
… | |
… | |
1033 | bool |
1048 | bool |
1034 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1049 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1035 | { |
1050 | { |
1036 | bool ret = false; |
1051 | bool ret = false; |
1037 | #if XRENDER |
1052 | #if XRENDER |
|
|
1053 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1054 | return false; |
|
|
1055 | |
1038 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1056 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1039 | double *kernel = (double *)malloc (size * sizeof (double)); |
1057 | double *kernel = (double *)malloc (size * sizeof (double)); |
1040 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1058 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1041 | |
1059 | |
1042 | XRenderPictureAttributes pa; |
|
|
1043 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1060 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1044 | |
1061 | |
1045 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1062 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1046 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1063 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1047 | |
1064 | |
1048 | if (kernel && params) |
1065 | if (kernel && params) |
1049 | { |
1066 | { |
1050 | if (h_blurRadius) |
|
|
1051 | { |
|
|
1052 | size = h_blurRadius * 2 + 1; |
1067 | size = h_blurRadius * 2 + 1; |
1053 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1068 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1054 | |
1069 | |
1055 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1070 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1056 | XRenderComposite (dpy, |
1071 | XRenderComposite (dpy, |
1057 | PictOpSrc, |
1072 | PictOpSrc, |
1058 | src, |
1073 | src, |
1059 | None, |
1074 | None, |
1060 | dst, |
1075 | dst, |
1061 | 0, 0, |
1076 | 0, 0, |
1062 | 0, 0, |
1077 | 0, 0, |
1063 | 0, 0, |
1078 | 0, 0, |
1064 | width, height); |
1079 | width, height); |
1065 | } |
|
|
1066 | |
1080 | |
1067 | if (v_blurRadius) |
|
|
1068 | { |
|
|
1069 | size = v_blurRadius * 2 + 1; |
1081 | size = v_blurRadius * 2 + 1; |
1070 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1082 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1071 | ::swap (params[0], params[1]); |
1083 | ::swap (params[0], params[1]); |
1072 | |
1084 | |
1073 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1085 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1074 | XRenderComposite (dpy, |
1086 | XRenderComposite (dpy, |
1075 | PictOpSrc, |
1087 | PictOpSrc, |
1076 | src, |
1088 | src, |
1077 | None, |
1089 | None, |
1078 | dst, |
1090 | dst, |
1079 | 0, 0, |
1091 | 0, 0, |
1080 | 0, 0, |
1092 | 0, 0, |
1081 | 0, 0, |
1093 | 0, 0, |
1082 | width, height); |
1094 | width, height); |
1083 | } |
|
|
1084 | |
1095 | |
1085 | ret = true; |
1096 | ret = true; |
1086 | } |
1097 | } |
1087 | |
1098 | |
1088 | free (kernel); |
1099 | free (kernel); |
… | |
… | |
1115 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1126 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1116 | ret = true; |
1127 | ret = true; |
1117 | XFreeGC (dpy, gc); |
1128 | XFreeGC (dpy, gc); |
1118 | } |
1129 | } |
1119 | } |
1130 | } |
1120 | else |
|
|
1121 | { |
|
|
1122 | # if XRENDER |
1131 | # if XRENDER |
|
|
1132 | else if (bg_flags & BG_HAS_RENDER) |
|
|
1133 | { |
1123 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1134 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1124 | |
1135 | |
1125 | if (bg_flags & BG_TINT_SET) |
1136 | if (bg_flags & BG_TINT_SET) |
1126 | tint.get (c); |
1137 | tint.get (c); |
1127 | |
1138 | |
… | |
… | |
1136 | c.r = c.r * (200 - shade) / 100; |
1147 | c.r = c.r * (200 - shade) / 100; |
1137 | c.g = c.g * (200 - shade) / 100; |
1148 | c.g = c.g * (200 - shade) / 100; |
1138 | c.b = c.b * (200 - shade) / 100; |
1149 | c.b = c.b * (200 - shade) / 100; |
1139 | } |
1150 | } |
1140 | |
1151 | |
1141 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1142 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1152 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1143 | XRenderPictureAttributes pa; |
|
|
1144 | |
1153 | |
1145 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1154 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1146 | |
1155 | |
1147 | pa.repeat = True; |
1156 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
1148 | |
1157 | |
1149 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1158 | Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True); |
1150 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1151 | XFreePixmap (dpy, overlay_pmap); |
|
|
1152 | |
|
|
1153 | pa.component_alpha = True; |
|
|
1154 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
|
|
1155 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); |
|
|
1156 | XFreePixmap (dpy, mask_pmap); |
|
|
1157 | |
1159 | |
1158 | XRenderColor mask_c; |
1160 | XRenderColor mask_c; |
1159 | |
1161 | |
1160 | mask_c.alpha = 0xffff; |
1162 | mask_c.alpha = 0xffff; |
1161 | mask_c.red = |
1163 | mask_c.red = |
… | |
… | |
1166 | mask_c.alpha = 0; |
1168 | mask_c.alpha = 0; |
1167 | mask_c.red = 0xffff - c.r; |
1169 | mask_c.red = 0xffff - c.r; |
1168 | mask_c.green = 0xffff - c.g; |
1170 | mask_c.green = 0xffff - c.g; |
1169 | mask_c.blue = 0xffff - c.b; |
1171 | mask_c.blue = 0xffff - c.b; |
1170 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1172 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1173 | |
1171 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1174 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1172 | |
1175 | |
1173 | if (shade > 100) |
1176 | if (shade > 100) |
1174 | { |
1177 | { |
1175 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1176 | mask_c.alpha = 0; |
1178 | mask_c.alpha = 0; |
|
|
1179 | mask_c.red = |
|
|
1180 | mask_c.green = |
|
|
1181 | mask_c.blue = 0xffff * (shade - 100) / 100; |
1177 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1182 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1178 | |
1183 | |
1179 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1184 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1180 | } |
1185 | } |
1181 | |
1186 | |
1182 | ret = true; |
1187 | ret = true; |
1183 | |
1188 | |
1184 | XRenderFreePicture (dpy, mask_pic); |
1189 | XRenderFreePicture (dpy, mask_pic); |
1185 | XRenderFreePicture (dpy, overlay_pic); |
1190 | XRenderFreePicture (dpy, overlay_pic); |
1186 | XRenderFreePicture (dpy, back_pic); |
1191 | XRenderFreePicture (dpy, back_pic); |
|
|
1192 | } |
1187 | # endif |
1193 | # endif |
1188 | } |
|
|
1189 | |
1194 | |
1190 | return ret; |
1195 | return ret; |
1191 | } |
1196 | } |
1192 | |
1197 | |
1193 | /* |
1198 | /* |
… | |
… | |
1244 | #if XRENDER |
1249 | #if XRENDER |
1245 | if (bg_flags & BG_HAS_RENDER) |
1250 | if (bg_flags & BG_HAS_RENDER) |
1246 | { |
1251 | { |
1247 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1252 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1248 | |
1253 | |
1249 | XRenderPictureAttributes pa; |
|
|
1250 | |
|
|
1251 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1252 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
1253 | |
1256 | |
1254 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1255 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, 0); |
1256 | |
1259 | |
1257 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1260 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1258 | |
1261 | |
1259 | XRenderFreePicture (dpy, src); |
1262 | XRenderFreePicture (dpy, src); |
1260 | XRenderFreePicture (dpy, dst); |
1263 | XRenderFreePicture (dpy, dst); |
… | |
… | |
1290 | |
1293 | |
1291 | if (gc) |
1294 | if (gc) |
1292 | { |
1295 | { |
1293 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1296 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1294 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1295 | XFreeGC (dpy, gc); |
|
|
1296 | |
1298 | |
1297 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1299 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1298 | { |
1300 | { |
1299 | if ((bg_flags & BG_NEEDS_BLUR) |
1301 | if (bg_flags & BG_NEEDS_BLUR) |
1300 | && (bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1301 | { |
1302 | { |
1302 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1303 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1303 | result &= ~BG_NEEDS_BLUR; |
1304 | result &= ~BG_NEEDS_BLUR; |
1304 | } |
1305 | } |
1305 | if ((bg_flags & BG_NEEDS_TINT) |
1306 | if (bg_flags & BG_NEEDS_TINT) |
1306 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
|
|
1307 | { |
1307 | { |
1308 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1308 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1309 | result &= ~BG_NEEDS_TINT; |
1309 | result &= ~BG_NEEDS_TINT; |
1310 | } |
1310 | } |
|
|
1311 | # ifndef HAVE_AFTERIMAGE |
|
|
1312 | if (result & BG_NEEDS_TINT) |
|
|
1313 | { |
|
|
1314 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1315 | if (ximage) |
|
|
1316 | { |
|
|
1317 | /* our own client-side tinting */ |
|
|
1318 | tint_ximage (DefaultVisual (dpy, display->screen), ximage); |
|
|
1319 | |
|
|
1320 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
|
|
1321 | XDestroyImage (ximage); |
|
|
1322 | } |
|
|
1323 | } |
|
|
1324 | # endif |
1311 | } /* server side rendering completed */ |
1325 | } /* server side rendering completed */ |
|
|
1326 | |
|
|
1327 | XFreeGC (dpy, gc); |
1312 | } |
1328 | } |
1313 | |
1329 | |
1314 | if (recoded_root_pmap != root_pixmap) |
1330 | if (recoded_root_pmap != root_pixmap) |
1315 | XFreePixmap (dpy, recoded_root_pmap); |
1331 | XFreePixmap (dpy, recoded_root_pmap); |
1316 | |
1332 | |
… | |
… | |
1325 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1341 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1326 | |
1342 | |
1327 | root_pixmap = new_root_pixmap; |
1343 | root_pixmap = new_root_pixmap; |
1328 | } |
1344 | } |
1329 | # endif /* ENABLE_TRANSPARENCY */ |
1345 | # endif /* ENABLE_TRANSPARENCY */ |
1330 | |
|
|
1331 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1332 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
|
|
1333 | # endif |
|
|
1334 | |
1346 | |
1335 | bool |
1347 | bool |
1336 | rxvt_term::bg_render () |
1348 | rxvt_term::bg_render () |
1337 | { |
1349 | { |
1338 | unsigned long tr_flags = 0; |
1350 | unsigned long tr_flags = 0; |
… | |
… | |
1353 | if ((bg_flags & BG_IS_FROM_FILE) |
1365 | if ((bg_flags & BG_IS_FROM_FILE) |
1354 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1366 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1355 | { |
1367 | { |
1356 | if (render_image (tr_flags)) |
1368 | if (render_image (tr_flags)) |
1357 | bg_flags |= BG_IS_VALID; |
1369 | bg_flags |= BG_IS_VALID; |
1358 | } |
|
|
1359 | # endif |
|
|
1360 | |
|
|
1361 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1362 | XImage *result = NULL; |
|
|
1363 | |
|
|
1364 | if (tr_flags & BG_NEEDS_TINT) |
|
|
1365 | { |
|
|
1366 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1367 | } |
|
|
1368 | |
|
|
1369 | if (result) |
|
|
1370 | { |
|
|
1371 | /* our own client-side tinting */ |
|
|
1372 | //if (tr_flags & BG_NEEDS_TINT) |
|
|
1373 | if (1) |
|
|
1374 | { |
|
|
1375 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1376 | if (bg_flags & BG_TINT_SET) |
|
|
1377 | tint.get (c); |
|
|
1378 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
|
|
1379 | } |
|
|
1380 | |
|
|
1381 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
|
|
1382 | |
|
|
1383 | if (gc) |
|
|
1384 | { |
|
|
1385 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
|
|
1386 | |
|
|
1387 | XFreeGC (dpy, gc); |
|
|
1388 | } |
|
|
1389 | |
|
|
1390 | XDestroyImage (result); |
|
|
1391 | } |
1370 | } |
1392 | # endif |
1371 | # endif |
1393 | |
1372 | |
1394 | if (!(bg_flags & BG_IS_VALID)) |
1373 | if (!(bg_flags & BG_IS_VALID)) |
1395 | { |
1374 | { |
… | |
… | |
1447 | tmp += (mask >> sh) * low; |
1426 | tmp += (mask >> sh) * low; |
1448 | lookup[i] = (tmp / 0xffff) << sh; |
1427 | lookup[i] = (tmp / 0xffff) << sh; |
1449 | } |
1428 | } |
1450 | } |
1429 | } |
1451 | |
1430 | |
1452 | static void |
1431 | void |
1453 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1432 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1454 | { |
1433 | { |
1455 | int sh_r, sh_g, sh_b; |
1434 | int sh_r, sh_g, sh_b; |
1456 | uint32_t mask_r, mask_g, mask_b; |
1435 | uint32_t mask_r, mask_g, mask_b; |
1457 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1436 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1458 | unsigned short low; |
1437 | unsigned short low; |
1459 | rgba high; |
|
|
1460 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1438 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1461 | |
1439 | |
1462 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1440 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1463 | |
1441 | |
1464 | /* for convenience */ |
1442 | /* for convenience */ |
… | |
… | |
1523 | break; |
1501 | break; |
1524 | default: |
1502 | default: |
1525 | return; /* we do not support this color depth */ |
1503 | return; /* we do not support this color depth */ |
1526 | } |
1504 | } |
1527 | |
1505 | |
|
|
1506 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1507 | |
|
|
1508 | if (bg_flags & BG_TINT_SET) |
|
|
1509 | tint.get (c); |
|
|
1510 | |
1528 | /* prepare limits for color transformation (each channel is handled separately) */ |
1511 | /* prepare limits for color transformation (each channel is handled separately) */ |
1529 | if (shade > 100) |
1512 | if (shade > 100) |
1530 | { |
1513 | { |
1531 | shade = 200 - shade; |
1514 | c.r = c.r * (200 - shade) / 100; |
|
|
1515 | c.g = c.g * (200 - shade) / 100; |
|
|
1516 | c.b = c.b * (200 - shade) / 100; |
1532 | |
1517 | |
1533 | high.r = c.r * shade / 100; |
|
|
1534 | high.g = c.g * shade / 100; |
|
|
1535 | high.b = c.b * shade / 100; |
|
|
1536 | |
|
|
1537 | low = 0xffff * (100 - shade) / 100; |
1518 | low = 0xffff * (shade - 100) / 100; |
1538 | } |
1519 | } |
1539 | else |
1520 | else |
1540 | { |
1521 | { |
1541 | high.r = c.r * shade / 100; |
1522 | c.r = c.r * shade / 100; |
1542 | high.g = c.g * shade / 100; |
1523 | c.g = c.g * shade / 100; |
1543 | high.b = c.b * shade / 100; |
1524 | c.b = c.b * shade / 100; |
1544 | |
1525 | |
1545 | low = 0; |
1526 | low = 0; |
1546 | } |
1527 | } |
1547 | |
1528 | |
1548 | /* fill our lookup tables */ |
1529 | /* fill our lookup tables */ |
1549 | fill_lut (lookup_r, mask_r, sh_r, low, high.r); |
1530 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1550 | fill_lut (lookup_g, mask_g, sh_g, low, high.g); |
1531 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1551 | fill_lut (lookup_b, mask_b, sh_b, low, high.b); |
1532 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1552 | |
1533 | |
1553 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1534 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1554 | if (ximage->bits_per_pixel == 32 |
1535 | if (ximage->bits_per_pixel == 32 |
1555 | && (ximage->depth == 24 || ximage->depth == 32) |
1536 | && (ximage->depth == 24 || ximage->depth == 32) |
1556 | && ximage->byte_order == host_byte_order) |
1537 | && ximage->byte_order == host_byte_order) |