… | |
… | |
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]) |
… | |
… | |
201 | x = y = 0; |
219 | x = y = 0; |
202 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
220 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
203 | } |
221 | } |
204 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
222 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
205 | { |
223 | { |
206 | new_flags = BG_PROP_SCALE; |
224 | new_flags = BG_KEEP_ASPECT; |
207 | w = h = windowScale; |
225 | w = h = windowScale; |
208 | x = y = centerAlign; |
226 | x = y = centerAlign; |
209 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
227 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
210 | } |
228 | } |
211 | else if (!strcasecmp (arr[i], "style=stretched")) |
229 | else if (!strcasecmp (arr[i], "style=stretched")) |
… | |
… | |
227 | w = h = noScale; |
245 | w = h = noScale; |
228 | geom_flags = WidthValue|HeightValue; |
246 | geom_flags = WidthValue|HeightValue; |
229 | } |
247 | } |
230 | else if (!strcasecmp (arr[i], "op=tile")) |
248 | else if (!strcasecmp (arr[i], "op=tile")) |
231 | new_flags |= BG_TILE; |
249 | new_flags |= BG_TILE; |
232 | else if (!strcasecmp (arr[i], "op=pscale")) |
250 | else if (!strcasecmp (arr[i], "op=keep-aspect")) |
233 | new_flags |= BG_PROP_SCALE; |
251 | new_flags |= BG_KEEP_ASPECT; |
234 | else if (!strcasecmp (arr[i], "op=root")) |
252 | else if (!strcasecmp (arr[i], "op=root-align")) |
235 | new_flags |= BG_ROOT_ALIGN; |
253 | new_flags |= BG_ROOT_ALIGN; |
236 | |
254 | |
237 | // deprecated |
255 | // deprecated |
238 | else if (!strcasecmp (arr[i], "tile")) |
256 | else if (!strcasecmp (arr[i], "tile")) |
239 | { |
257 | { |
… | |
… | |
241 | w = h = noScale; |
259 | w = h = noScale; |
242 | geom_flags |= WidthValue|HeightValue; |
260 | geom_flags |= WidthValue|HeightValue; |
243 | } |
261 | } |
244 | else if (!strcasecmp (arr[i], "propscale")) |
262 | else if (!strcasecmp (arr[i], "propscale")) |
245 | { |
263 | { |
246 | new_flags |= BG_PROP_SCALE; |
264 | new_flags |= BG_KEEP_ASPECT; |
|
|
265 | w = h = windowScale; |
|
|
266 | geom_flags |= WidthValue|HeightValue; |
247 | } |
267 | } |
248 | else if (!strcasecmp (arr[i], "hscale")) |
268 | else if (!strcasecmp (arr[i], "hscale")) |
249 | { |
269 | { |
250 | new_flags |= BG_TILE; |
270 | new_flags |= BG_TILE; |
251 | w = windowScale; |
271 | w = windowScale; |
… | |
… | |
281 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
301 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
282 | } /* done parsing ops */ |
302 | } /* done parsing ops */ |
283 | |
303 | |
284 | rxvt_free_strsplit (arr); |
304 | rxvt_free_strsplit (arr); |
285 | } |
305 | } |
|
|
306 | |
|
|
307 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
286 | |
308 | |
287 | if (!update) |
309 | if (!update) |
288 | { |
310 | { |
289 | if (!(geom_flags & XValue)) |
311 | if (!(geom_flags & XValue)) |
290 | x = y = defaultAlign; |
312 | x = y = defaultAlign; |
… | |
… | |
299 | w = h; |
321 | w = h; |
300 | |
322 | |
301 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
323 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
302 | } |
324 | } |
303 | |
325 | |
304 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w) |
326 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
305 | || check_set_scale_value (geom_flags, HeightValue, v_scale, h) |
327 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
306 | || check_set_align_value (geom_flags, XValue, h_align, x) |
328 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
307 | || check_set_align_value (geom_flags, YValue, v_align, y)) |
329 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
308 | changed = true; |
|
|
309 | |
330 | |
310 | if (new_flags != bg_flags) |
331 | if (new_flags != bg_flags) |
311 | { |
332 | { |
312 | bg_flags = new_flags; |
333 | bg_flags = new_flags; |
313 | changed = true; |
334 | changed = true; |
… | |
… | |
323 | int target_height = szHint.height; |
344 | int target_height = szHint.height; |
324 | |
345 | |
325 | w = h_scale * target_width / 100; |
346 | w = h_scale * target_width / 100; |
326 | h = v_scale * target_height / 100; |
347 | h = v_scale * target_height / 100; |
327 | |
348 | |
328 | if (bg_flags & BG_PROP_SCALE) |
349 | if (bg_flags & BG_KEEP_ASPECT) |
329 | { |
350 | { |
330 | float scale = (float)w / image_width; |
351 | float scale = (float)w / image_width; |
331 | min_it (scale, (float)h / image_height); |
352 | min_it (scale, (float)h / image_height); |
332 | w = image_width * scale + 0.5; |
353 | w = image_width * scale + 0.5; |
333 | h = image_height * scale + 0.5; |
354 | h = image_height * scale + 0.5; |
… | |
… | |
371 | if (tr_flags & BG_NEEDS_TINT) |
392 | if (tr_flags & BG_NEEDS_TINT) |
372 | { |
393 | { |
373 | ShadingInfo as_shade; |
394 | ShadingInfo as_shade; |
374 | as_shade.shading = shade; |
395 | as_shade.shading = shade; |
375 | |
396 | |
376 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
397 | rgba c; |
377 | if (bg_flags & BG_TINT_SET) |
|
|
378 | tint.get (c); |
398 | tint.get (c); |
379 | as_shade.tintColor.red = c.r; |
399 | as_shade.tintColor.red = c.r; |
380 | as_shade.tintColor.green = c.g; |
400 | as_shade.tintColor.green = c.g; |
381 | as_shade.tintColor.blue = c.b; |
401 | as_shade.tintColor.blue = c.b; |
382 | |
402 | |
383 | background_tint = shading2tint32 (&as_shade); |
403 | background_tint = shading2tint32 (&as_shade); |
… | |
… | |
799 | } |
819 | } |
800 | |
820 | |
801 | #if XRENDER |
821 | #if XRENDER |
802 | if (tr_flags) |
822 | if (tr_flags) |
803 | { |
823 | { |
804 | XRenderPictureAttributes pa; |
|
|
805 | |
|
|
806 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); |
824 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
|
|
825 | |
807 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
826 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
808 | |
827 | |
809 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
|
|
810 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
828 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
811 | |
829 | |
812 | pa.repeat = True; |
830 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
813 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
|
|
814 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
|
|
815 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
|
|
816 | XFreePixmap (dpy, mask_pmap); |
|
|
817 | |
831 | |
818 | XRenderColor mask_c; |
832 | XRenderColor mask_c; |
819 | |
833 | |
820 | mask_c.alpha = 0x8000; |
834 | mask_c.alpha = 0x8000; |
821 | mask_c.red = 0; |
835 | mask_c.red = 0; |
… | |
… | |
952 | } |
966 | } |
953 | |
967 | |
954 | void |
968 | void |
955 | rxvt_term::set_tint_shade_flags () |
969 | rxvt_term::set_tint_shade_flags () |
956 | { |
970 | { |
957 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
971 | rgba c; |
958 | bool has_shade = shade != 100; |
972 | bool has_shade = shade != 100; |
959 | |
973 | |
960 | bg_flags &= ~BG_TINT_FLAGS; |
974 | bg_flags &= ~BG_TINT_FLAGS; |
961 | |
975 | |
962 | if (bg_flags & BG_TINT_SET) |
|
|
963 | { |
|
|
964 | tint.get (c); |
976 | tint.get (c); |
|
|
977 | |
965 | if (!has_shade |
978 | if (!has_shade |
966 | && (c.r <= 0x00ff || c.r >= 0xff00) |
979 | && (c.r <= 0x00ff || c.r >= 0xff00) |
967 | && (c.g <= 0x00ff || c.g >= 0xff00) |
980 | && (c.g <= 0x00ff || c.g >= 0xff00) |
968 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
981 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
969 | bg_flags |= BG_TINT_BITAND; |
982 | bg_flags |= BG_TINT_BITAND; |
970 | } |
|
|
971 | |
983 | |
972 | if (has_shade || (bg_flags & BG_TINT_SET)) |
984 | if (has_shade |
|
|
985 | || c.r < 0xff00 |
|
|
986 | || c.g < 0xff00 |
|
|
987 | || c.b < 0xff00) |
973 | bg_flags |= BG_NEEDS_TINT; |
988 | bg_flags |= BG_NEEDS_TINT; |
974 | } |
989 | } |
975 | |
990 | |
976 | bool |
991 | bool |
977 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
992 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
978 | { |
993 | { |
979 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
994 | if (tint != new_tint) |
980 | { |
995 | { |
981 | tint = new_tint; |
996 | tint = new_tint; |
982 | bg_flags |= BG_TINT_SET; |
|
|
983 | set_tint_shade_flags (); |
997 | set_tint_shade_flags (); |
984 | return true; |
998 | return true; |
985 | } |
999 | } |
986 | |
1000 | |
987 | return false; |
1001 | return false; |
988 | } |
1002 | } |
989 | |
1003 | |
990 | bool |
1004 | bool |
991 | rxvt_term::bg_set_shade (const char *shade_str) |
1005 | rxvt_term::bg_set_shade (const char *shade_str) |
992 | { |
1006 | { |
993 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1007 | int new_shade = atoi (shade_str); |
994 | |
1008 | |
995 | clamp_it (new_shade, -100, 200); |
1009 | clamp_it (new_shade, -100, 200); |
996 | if (new_shade < 0) |
1010 | if (new_shade < 0) |
997 | new_shade = 200 - (100 + new_shade); |
1011 | new_shade = 200 - (100 + new_shade); |
998 | |
1012 | |
… | |
… | |
1032 | bool |
1046 | bool |
1033 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1047 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1034 | { |
1048 | { |
1035 | bool ret = false; |
1049 | bool ret = false; |
1036 | #if XRENDER |
1050 | #if XRENDER |
|
|
1051 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1052 | return false; |
|
|
1053 | |
1037 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1054 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1038 | double *kernel = (double *)malloc (size * sizeof (double)); |
1055 | double *kernel = (double *)malloc (size * sizeof (double)); |
1039 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1056 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1040 | |
1057 | |
1041 | XRenderPictureAttributes pa; |
|
|
1042 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1058 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1043 | |
1059 | |
1044 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1060 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1045 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1061 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1046 | |
1062 | |
1047 | if (kernel && params) |
1063 | if (kernel && params) |
1048 | { |
1064 | { |
1049 | if (h_blurRadius) |
1065 | if (h_blurRadius) |
1050 | { |
1066 | { |
… | |
… | |
1114 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1130 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1115 | ret = true; |
1131 | ret = true; |
1116 | XFreeGC (dpy, gc); |
1132 | XFreeGC (dpy, gc); |
1117 | } |
1133 | } |
1118 | } |
1134 | } |
1119 | else |
|
|
1120 | { |
|
|
1121 | # if XRENDER |
1135 | # if XRENDER |
1122 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1136 | else if (bg_flags & BG_HAS_RENDER) |
|
|
1137 | { |
|
|
1138 | rgba c; |
1123 | |
1139 | |
1124 | if (bg_flags & BG_TINT_SET) |
|
|
1125 | tint.get (c); |
1140 | tint.get (c); |
1126 | |
1141 | |
1127 | if (shade <= 100) |
1142 | if (shade <= 100) |
1128 | { |
1143 | { |
1129 | c.r = c.r * shade / 100; |
1144 | c.r = c.r * shade / 100; |
1130 | c.g = c.g * shade / 100; |
1145 | c.g = c.g * shade / 100; |
… | |
… | |
1135 | c.r = c.r * (200 - shade) / 100; |
1150 | c.r = c.r * (200 - shade) / 100; |
1136 | c.g = c.g * (200 - shade) / 100; |
1151 | c.g = c.g * (200 - shade) / 100; |
1137 | c.b = c.b * (200 - shade) / 100; |
1152 | c.b = c.b * (200 - shade) / 100; |
1138 | } |
1153 | } |
1139 | |
1154 | |
1140 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1141 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1155 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1142 | XRenderPictureAttributes pa; |
|
|
1143 | |
1156 | |
1144 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1157 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1145 | |
1158 | |
1146 | pa.repeat = True; |
1159 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
1147 | |
1160 | |
1148 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1161 | Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True); |
1149 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1150 | XFreePixmap (dpy, overlay_pmap); |
|
|
1151 | |
|
|
1152 | pa.component_alpha = True; |
|
|
1153 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
|
|
1154 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); |
|
|
1155 | XFreePixmap (dpy, mask_pmap); |
|
|
1156 | |
1162 | |
1157 | XRenderColor mask_c; |
1163 | XRenderColor mask_c; |
1158 | |
1164 | |
1159 | mask_c.alpha = 0xffff; |
1165 | mask_c.alpha = 0xffff; |
1160 | mask_c.red = |
1166 | mask_c.red = |
… | |
… | |
1181 | ret = true; |
1187 | ret = true; |
1182 | |
1188 | |
1183 | XRenderFreePicture (dpy, mask_pic); |
1189 | XRenderFreePicture (dpy, mask_pic); |
1184 | XRenderFreePicture (dpy, overlay_pic); |
1190 | XRenderFreePicture (dpy, overlay_pic); |
1185 | XRenderFreePicture (dpy, back_pic); |
1191 | XRenderFreePicture (dpy, back_pic); |
|
|
1192 | } |
1186 | # endif |
1193 | # endif |
1187 | } |
|
|
1188 | |
1194 | |
1189 | return ret; |
1195 | return ret; |
1190 | } |
1196 | } |
1191 | |
1197 | |
1192 | /* |
1198 | /* |
… | |
… | |
1243 | #if XRENDER |
1249 | #if XRENDER |
1244 | if (bg_flags & BG_HAS_RENDER) |
1250 | if (bg_flags & BG_HAS_RENDER) |
1245 | { |
1251 | { |
1246 | 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); |
1247 | |
1253 | |
1248 | XRenderPictureAttributes pa; |
|
|
1249 | |
|
|
1250 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1251 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
1252 | |
1256 | |
1253 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1254 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, 0); |
1255 | |
1259 | |
1256 | 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); |
1257 | |
1261 | |
1258 | XRenderFreePicture (dpy, src); |
1262 | XRenderFreePicture (dpy, src); |
1259 | XRenderFreePicture (dpy, dst); |
1263 | XRenderFreePicture (dpy, dst); |
… | |
… | |
1276 | bg_pmap_width = window_width; |
1280 | bg_pmap_width = window_width; |
1277 | bg_pmap_height = window_height; |
1281 | bg_pmap_height = window_height; |
1278 | } |
1282 | } |
1279 | |
1283 | |
1280 | /* straightforward pixmap copy */ |
1284 | /* straightforward pixmap copy */ |
1281 | while (sx < 0) sx += root_width; |
1285 | while (sx < 0) sx += root_pmap_width; |
1282 | while (sy < 0) sy += root_height; |
1286 | while (sy < 0) sy += root_pmap_height; |
1283 | |
1287 | |
1284 | gcv.tile = recoded_root_pmap; |
1288 | gcv.tile = recoded_root_pmap; |
1285 | gcv.fill_style = FillTiled; |
1289 | gcv.fill_style = FillTiled; |
1286 | gcv.ts_x_origin = -sx; |
1290 | gcv.ts_x_origin = -sx; |
1287 | gcv.ts_y_origin = -sy; |
1291 | gcv.ts_y_origin = -sy; |
… | |
… | |
1289 | |
1293 | |
1290 | if (gc) |
1294 | if (gc) |
1291 | { |
1295 | { |
1292 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1296 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1293 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1294 | XFreeGC (dpy, gc); |
|
|
1295 | |
1298 | |
1296 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1299 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1297 | { |
1300 | { |
1298 | if ((bg_flags & BG_NEEDS_BLUR) |
1301 | if (bg_flags & BG_NEEDS_BLUR) |
1299 | && (bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1300 | { |
1302 | { |
1301 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1303 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1302 | result &= ~BG_NEEDS_BLUR; |
1304 | result &= ~BG_NEEDS_BLUR; |
1303 | } |
1305 | } |
1304 | if ((bg_flags & BG_NEEDS_TINT) |
1306 | if (bg_flags & BG_NEEDS_TINT) |
1305 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
|
|
1306 | { |
1307 | { |
1307 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1308 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1308 | result &= ~BG_NEEDS_TINT; |
1309 | result &= ~BG_NEEDS_TINT; |
1309 | } |
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 |
1310 | } /* server side rendering completed */ |
1325 | } /* server side rendering completed */ |
|
|
1326 | |
|
|
1327 | XFreeGC (dpy, gc); |
1311 | } |
1328 | } |
1312 | |
1329 | |
1313 | if (recoded_root_pmap != root_pixmap) |
1330 | if (recoded_root_pmap != root_pixmap) |
1314 | XFreePixmap (dpy, recoded_root_pmap); |
1331 | XFreePixmap (dpy, recoded_root_pmap); |
1315 | |
1332 | |
… | |
… | |
1324 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1341 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1325 | |
1342 | |
1326 | root_pixmap = new_root_pixmap; |
1343 | root_pixmap = new_root_pixmap; |
1327 | } |
1344 | } |
1328 | # endif /* ENABLE_TRANSPARENCY */ |
1345 | # endif /* ENABLE_TRANSPARENCY */ |
1329 | |
|
|
1330 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1331 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
|
|
1332 | # endif |
|
|
1333 | |
1346 | |
1334 | bool |
1347 | bool |
1335 | rxvt_term::bg_render () |
1348 | rxvt_term::bg_render () |
1336 | { |
1349 | { |
1337 | unsigned long tr_flags = 0; |
1350 | unsigned long tr_flags = 0; |
… | |
… | |
1355 | if (render_image (tr_flags)) |
1368 | if (render_image (tr_flags)) |
1356 | bg_flags |= BG_IS_VALID; |
1369 | bg_flags |= BG_IS_VALID; |
1357 | } |
1370 | } |
1358 | # endif |
1371 | # endif |
1359 | |
1372 | |
1360 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1361 | XImage *result = NULL; |
|
|
1362 | |
|
|
1363 | if (tr_flags & BG_NEEDS_TINT) |
|
|
1364 | { |
|
|
1365 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1366 | } |
|
|
1367 | |
|
|
1368 | if (result) |
|
|
1369 | { |
|
|
1370 | /* our own client-side tinting */ |
|
|
1371 | //if (tr_flags & BG_NEEDS_TINT) |
|
|
1372 | if (1) |
|
|
1373 | { |
|
|
1374 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1375 | if (bg_flags & BG_TINT_SET) |
|
|
1376 | tint.get (c); |
|
|
1377 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
|
|
1378 | } |
|
|
1379 | |
|
|
1380 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
|
|
1381 | |
|
|
1382 | if (gc) |
|
|
1383 | { |
|
|
1384 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
|
|
1385 | |
|
|
1386 | XFreeGC (dpy, gc); |
|
|
1387 | } |
|
|
1388 | |
|
|
1389 | XDestroyImage (result); |
|
|
1390 | } |
|
|
1391 | # endif |
|
|
1392 | |
|
|
1393 | if (!(bg_flags & BG_IS_VALID)) |
1373 | if (!(bg_flags & BG_IS_VALID)) |
1394 | { |
1374 | { |
1395 | if (bg_pixmap != None) |
1375 | if (bg_pixmap != None) |
1396 | { |
1376 | { |
1397 | XFreePixmap (dpy, bg_pixmap); |
1377 | XFreePixmap (dpy, bg_pixmap); |
… | |
… | |
1409 | |
1389 | |
1410 | void |
1390 | void |
1411 | rxvt_term::bg_init () |
1391 | rxvt_term::bg_init () |
1412 | { |
1392 | { |
1413 | #ifdef ENABLE_TRANSPARENCY |
1393 | #ifdef ENABLE_TRANSPARENCY |
|
|
1394 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1395 | tint.set (this, c); |
1414 | shade = 100; |
1396 | shade = 100; |
1415 | #endif |
1397 | #endif |
1416 | |
1398 | |
1417 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1399 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1418 | #if XRENDER |
1400 | #if XRENDER |
… | |
… | |
1434 | #endif /* HAVE_BG_PIXMAP */ |
1416 | #endif /* HAVE_BG_PIXMAP */ |
1435 | |
1417 | |
1436 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1418 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1437 | /* based on code from aterm-0.4.2 */ |
1419 | /* based on code from aterm-0.4.2 */ |
1438 | |
1420 | |
1439 | static void |
1421 | static inline void |
1440 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1422 | fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) |
|
|
1423 | { |
|
|
1424 | for (int i = 0; i <= mask >> sh; i++) |
|
|
1425 | { |
|
|
1426 | uint32_t tmp; |
|
|
1427 | tmp = i * high; |
|
|
1428 | tmp += (mask >> sh) * low; |
|
|
1429 | lookup[i] = (tmp / 0xffff) << sh; |
|
|
1430 | } |
|
|
1431 | } |
|
|
1432 | |
|
|
1433 | void |
|
|
1434 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1441 | { |
1435 | { |
1442 | int sh_r, sh_g, sh_b; |
1436 | int sh_r, sh_g, sh_b; |
1443 | uint32_t mask_r, mask_g, mask_b; |
1437 | uint32_t mask_r, mask_g, mask_b; |
1444 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1438 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1445 | rgba low; |
1439 | unsigned short low; |
1446 | rgba high; |
|
|
1447 | int i; |
|
|
1448 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1440 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1449 | |
1441 | |
1450 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1442 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1451 | |
1443 | |
1452 | /* for convenience */ |
1444 | /* for convenience */ |
… | |
… | |
1511 | break; |
1503 | break; |
1512 | default: |
1504 | default: |
1513 | return; /* we do not support this color depth */ |
1505 | return; /* we do not support this color depth */ |
1514 | } |
1506 | } |
1515 | |
1507 | |
|
|
1508 | rgba c; |
|
|
1509 | |
|
|
1510 | tint.get (c); |
|
|
1511 | |
1516 | /* prepare limits for color transformation (each channel is handled separately) */ |
1512 | /* prepare limits for color transformation (each channel is handled separately) */ |
1517 | if (shade > 100) |
1513 | if (shade > 100) |
1518 | { |
1514 | { |
1519 | shade = 200 - shade; |
|
|
1520 | |
|
|
1521 | high.r = c.r * shade / 100; |
|
|
1522 | high.g = c.g * shade / 100; |
|
|
1523 | high.b = c.b * shade / 100; |
|
|
1524 | |
|
|
1525 | low.r = 65535 * (100 - shade) / 100; |
1515 | c.r = c.r * (200 - shade) / 100; |
1526 | low.g = 65535 * (100 - shade) / 100; |
1516 | c.g = c.g * (200 - shade) / 100; |
1527 | low.b = 65535 * (100 - shade) / 100; |
1517 | c.b = c.b * (200 - shade) / 100; |
|
|
1518 | |
|
|
1519 | low = 0xffff * (shade - 100) / 100; |
1528 | } |
1520 | } |
1529 | else |
1521 | else |
1530 | { |
1522 | { |
1531 | high.r = c.r * shade / 100; |
1523 | c.r = c.r * shade / 100; |
1532 | high.g = c.g * shade / 100; |
1524 | c.g = c.g * shade / 100; |
1533 | high.b = c.b * shade / 100; |
1525 | c.b = c.b * shade / 100; |
1534 | |
1526 | |
1535 | low.r = low.g = low.b = 0; |
1527 | low = 0; |
1536 | } |
1528 | } |
1537 | |
1529 | |
1538 | /* fill our lookup tables */ |
1530 | /* fill our lookup tables */ |
1539 | for (i = 0; i <= mask_r>>sh_r; i++) |
1531 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1540 | { |
1532 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1541 | uint32_t tmp; |
1533 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1542 | tmp = i * high.r; |
|
|
1543 | tmp += (mask_r>>sh_r) * low.r; |
|
|
1544 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
1545 | } |
|
|
1546 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
1547 | { |
|
|
1548 | uint32_t tmp; |
|
|
1549 | tmp = i * high.g; |
|
|
1550 | tmp += (mask_g>>sh_g) * low.g; |
|
|
1551 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
1552 | } |
|
|
1553 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
1554 | { |
|
|
1555 | uint32_t tmp; |
|
|
1556 | tmp = i * high.b; |
|
|
1557 | tmp += (mask_b>>sh_b) * low.b; |
|
|
1558 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
1559 | } |
|
|
1560 | |
1534 | |
1561 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1535 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1562 | if (ximage->bits_per_pixel == 32 |
1536 | if (ximage->bits_per_pixel == 32 |
1563 | && (ximage->depth == 24 || ximage->depth == 32) |
1537 | && (ximage->depth == 24 || ximage->depth == 32) |
1564 | && ximage->byte_order == host_byte_order) |
1538 | && ximage->byte_order == host_byte_order) |