… | |
… | |
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]) |
… | |
… | |
284 | } /* done parsing ops */ |
302 | } /* done parsing ops */ |
285 | |
303 | |
286 | rxvt_free_strsplit (arr); |
304 | rxvt_free_strsplit (arr); |
287 | } |
305 | } |
288 | |
306 | |
|
|
307 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
|
|
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; |
293 | else if (!(geom_flags & YValue)) |
313 | else if (!(geom_flags & YValue)) |
… | |
… | |
372 | if (tr_flags & BG_NEEDS_TINT) |
392 | if (tr_flags & BG_NEEDS_TINT) |
373 | { |
393 | { |
374 | ShadingInfo as_shade; |
394 | ShadingInfo as_shade; |
375 | as_shade.shading = shade; |
395 | as_shade.shading = shade; |
376 | |
396 | |
377 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
397 | rgba c; |
378 | if (bg_flags & BG_TINT_SET) |
|
|
379 | tint.get (c); |
398 | tint.get (c); |
380 | as_shade.tintColor.red = c.r; |
399 | as_shade.tintColor.red = c.r; |
381 | as_shade.tintColor.green = c.g; |
400 | as_shade.tintColor.green = c.g; |
382 | as_shade.tintColor.blue = c.b; |
401 | as_shade.tintColor.blue = c.b; |
383 | |
402 | |
384 | background_tint = shading2tint32 (&as_shade); |
403 | background_tint = shading2tint32 (&as_shade); |
… | |
… | |
800 | } |
819 | } |
801 | |
820 | |
802 | #if XRENDER |
821 | #if XRENDER |
803 | if (tr_flags) |
822 | if (tr_flags) |
804 | { |
823 | { |
805 | XRenderPictureAttributes pa; |
|
|
806 | |
|
|
807 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); |
824 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
|
|
825 | |
808 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
826 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
809 | |
827 | |
810 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
|
|
811 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
828 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
812 | |
829 | |
813 | pa.repeat = True; |
830 | 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 | |
831 | |
819 | XRenderColor mask_c; |
832 | XRenderColor mask_c; |
820 | |
833 | |
821 | mask_c.alpha = 0x8000; |
834 | mask_c.alpha = 0x8000; |
822 | mask_c.red = 0; |
835 | mask_c.red = 0; |
… | |
… | |
958 | rgba c; |
971 | rgba c; |
959 | bool has_shade = shade != 100; |
972 | bool has_shade = shade != 100; |
960 | |
973 | |
961 | bg_flags &= ~BG_TINT_FLAGS; |
974 | bg_flags &= ~BG_TINT_FLAGS; |
962 | |
975 | |
963 | if (bg_flags & BG_TINT_SET) |
|
|
964 | { |
|
|
965 | tint.get (c); |
976 | tint.get (c); |
|
|
977 | |
966 | if (!has_shade |
978 | if (!has_shade |
967 | && (c.r <= 0x00ff || c.r >= 0xff00) |
979 | && (c.r <= 0x00ff || c.r >= 0xff00) |
968 | && (c.g <= 0x00ff || c.g >= 0xff00) |
980 | && (c.g <= 0x00ff || c.g >= 0xff00) |
969 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
981 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
970 | bg_flags |= BG_TINT_BITAND; |
982 | bg_flags |= BG_TINT_BITAND; |
971 | } |
|
|
972 | |
983 | |
973 | if (has_shade || (bg_flags & BG_TINT_SET)) |
984 | if (has_shade |
|
|
985 | || c.r < 0xff00 |
|
|
986 | || c.g < 0xff00 |
|
|
987 | || c.b < 0xff00) |
974 | bg_flags |= BG_NEEDS_TINT; |
988 | bg_flags |= BG_NEEDS_TINT; |
975 | } |
989 | } |
976 | |
990 | |
977 | bool |
991 | bool |
978 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
992 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
979 | { |
993 | { |
980 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
994 | if (tint != new_tint) |
981 | { |
995 | { |
982 | tint = new_tint; |
996 | tint = new_tint; |
983 | bg_flags |= BG_TINT_SET; |
|
|
984 | set_tint_shade_flags (); |
997 | set_tint_shade_flags (); |
985 | return true; |
998 | return true; |
986 | } |
999 | } |
987 | |
1000 | |
988 | return false; |
1001 | return false; |
989 | } |
1002 | } |
990 | |
1003 | |
991 | bool |
1004 | bool |
992 | rxvt_term::bg_set_shade (const char *shade_str) |
1005 | rxvt_term::bg_set_shade (const char *shade_str) |
993 | { |
1006 | { |
994 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1007 | int new_shade = atoi (shade_str); |
995 | |
1008 | |
996 | clamp_it (new_shade, -100, 200); |
1009 | clamp_it (new_shade, -100, 200); |
997 | if (new_shade < 0) |
1010 | if (new_shade < 0) |
998 | new_shade = 200 - (100 + new_shade); |
1011 | new_shade = 200 - (100 + new_shade); |
999 | |
1012 | |
… | |
… | |
1040 | |
1053 | |
1041 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1054 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1042 | double *kernel = (double *)malloc (size * sizeof (double)); |
1055 | double *kernel = (double *)malloc (size * sizeof (double)); |
1043 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1056 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1044 | |
1057 | |
1045 | XRenderPictureAttributes pa; |
|
|
1046 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1058 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1047 | |
1059 | |
1048 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1060 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1049 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1061 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1050 | |
1062 | |
1051 | if (kernel && params) |
1063 | if (kernel && params) |
1052 | { |
1064 | { |
1053 | if (h_blurRadius) |
1065 | if (h_blurRadius) |
1054 | { |
1066 | { |
… | |
… | |
1121 | } |
1133 | } |
1122 | } |
1134 | } |
1123 | # if XRENDER |
1135 | # if XRENDER |
1124 | else if (bg_flags & BG_HAS_RENDER) |
1136 | else if (bg_flags & BG_HAS_RENDER) |
1125 | { |
1137 | { |
1126 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1138 | rgba c; |
1127 | |
1139 | |
1128 | if (bg_flags & BG_TINT_SET) |
|
|
1129 | tint.get (c); |
1140 | tint.get (c); |
1130 | |
1141 | |
1131 | if (shade <= 100) |
1142 | if (shade <= 100) |
1132 | { |
1143 | { |
1133 | c.r = c.r * shade / 100; |
1144 | c.r = c.r * shade / 100; |
1134 | c.g = c.g * shade / 100; |
1145 | c.g = c.g * shade / 100; |
… | |
… | |
1139 | c.r = c.r * (200 - shade) / 100; |
1150 | c.r = c.r * (200 - shade) / 100; |
1140 | c.g = c.g * (200 - shade) / 100; |
1151 | c.g = c.g * (200 - shade) / 100; |
1141 | c.b = c.b * (200 - shade) / 100; |
1152 | c.b = c.b * (200 - shade) / 100; |
1142 | } |
1153 | } |
1143 | |
1154 | |
1144 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1145 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1155 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1146 | XRenderPictureAttributes pa; |
|
|
1147 | |
1156 | |
1148 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1157 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
1149 | |
1158 | |
1150 | pa.repeat = True; |
1159 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
1151 | |
1160 | |
1152 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1161 | 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 | |
1162 | |
1161 | XRenderColor mask_c; |
1163 | XRenderColor mask_c; |
1162 | |
1164 | |
1163 | mask_c.alpha = 0xffff; |
1165 | mask_c.alpha = 0xffff; |
1164 | mask_c.red = |
1166 | mask_c.red = |
… | |
… | |
1247 | #if XRENDER |
1249 | #if XRENDER |
1248 | if (bg_flags & BG_HAS_RENDER) |
1250 | if (bg_flags & BG_HAS_RENDER) |
1249 | { |
1251 | { |
1250 | 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); |
1251 | |
1253 | |
1252 | XRenderPictureAttributes pa; |
|
|
1253 | |
|
|
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
1256 | |
1256 | |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, 0); |
1259 | |
1259 | |
1260 | 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); |
1261 | |
1261 | |
1262 | XRenderFreePicture (dpy, src); |
1262 | XRenderFreePicture (dpy, src); |
1263 | XRenderFreePicture (dpy, dst); |
1263 | XRenderFreePicture (dpy, dst); |
… | |
… | |
1293 | |
1293 | |
1294 | if (gc) |
1294 | if (gc) |
1295 | { |
1295 | { |
1296 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1296 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1298 | XFreeGC (dpy, gc); |
|
|
1299 | |
1298 | |
1300 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1299 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1301 | { |
1300 | { |
1302 | if (bg_flags & BG_NEEDS_BLUR) |
1301 | if (bg_flags & BG_NEEDS_BLUR) |
1303 | { |
1302 | { |
… | |
… | |
1307 | if (bg_flags & BG_NEEDS_TINT) |
1306 | if (bg_flags & BG_NEEDS_TINT) |
1308 | { |
1307 | { |
1309 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1308 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1310 | result &= ~BG_NEEDS_TINT; |
1309 | result &= ~BG_NEEDS_TINT; |
1311 | } |
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 |
1312 | } /* server side rendering completed */ |
1325 | } /* server side rendering completed */ |
|
|
1326 | |
|
|
1327 | XFreeGC (dpy, gc); |
1313 | } |
1328 | } |
1314 | |
1329 | |
1315 | if (recoded_root_pmap != root_pixmap) |
1330 | if (recoded_root_pmap != root_pixmap) |
1316 | XFreePixmap (dpy, recoded_root_pmap); |
1331 | XFreePixmap (dpy, recoded_root_pmap); |
1317 | |
1332 | |
… | |
… | |
1353 | if (render_image (tr_flags)) |
1368 | if (render_image (tr_flags)) |
1354 | bg_flags |= BG_IS_VALID; |
1369 | bg_flags |= BG_IS_VALID; |
1355 | } |
1370 | } |
1356 | # endif |
1371 | # endif |
1357 | |
1372 | |
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)) |
1373 | if (!(bg_flags & BG_IS_VALID)) |
1387 | { |
1374 | { |
1388 | if (bg_pixmap != None) |
1375 | if (bg_pixmap != None) |
1389 | { |
1376 | { |
1390 | XFreePixmap (dpy, bg_pixmap); |
1377 | XFreePixmap (dpy, bg_pixmap); |
… | |
… | |
1402 | |
1389 | |
1403 | void |
1390 | void |
1404 | rxvt_term::bg_init () |
1391 | rxvt_term::bg_init () |
1405 | { |
1392 | { |
1406 | #ifdef ENABLE_TRANSPARENCY |
1393 | #ifdef ENABLE_TRANSPARENCY |
|
|
1394 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1395 | tint.set (this, c); |
1407 | shade = 100; |
1396 | shade = 100; |
1408 | #endif |
1397 | #endif |
1409 | |
1398 | |
1410 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1399 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1411 | #if XRENDER |
1400 | #if XRENDER |
… | |
… | |
1514 | break; |
1503 | break; |
1515 | default: |
1504 | default: |
1516 | return; /* we do not support this color depth */ |
1505 | return; /* we do not support this color depth */ |
1517 | } |
1506 | } |
1518 | |
1507 | |
1519 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1508 | rgba c; |
1520 | |
1509 | |
1521 | if (bg_flags & BG_TINT_SET) |
|
|
1522 | tint.get (c); |
1510 | tint.get (c); |
1523 | |
1511 | |
1524 | /* prepare limits for color transformation (each channel is handled separately) */ |
1512 | /* prepare limits for color transformation (each channel is handled separately) */ |
1525 | if (shade > 100) |
1513 | if (shade > 100) |
1526 | { |
1514 | { |
1527 | c.r = c.r * (200 - shade) / 100; |
1515 | c.r = c.r * (200 - shade) / 100; |