… | |
… | |
27 | #define DO_TIMING_TEST 0 |
27 | #define DO_TIMING_TEST 0 |
28 | |
28 | |
29 | #if DO_TIMING_TEST |
29 | #if DO_TIMING_TEST |
30 | # include <sys/time.h> |
30 | # include <sys/time.h> |
31 | #define TIMING_TEST_START(id) \ |
31 | #define TIMING_TEST_START(id) \ |
32 | struct timeval timing_test_##id##_stv;\ |
32 | struct timeval timing_test_##id##_stv; \ |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
34 | |
34 | |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
36 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
36 | do { \ |
|
|
37 | struct timeval tv; \ |
|
|
38 | gettimeofday (&tv, NULL); \ |
|
|
39 | tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \ |
37 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
40 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \ |
38 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
41 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \ |
|
|
42 | } while (0) |
39 | |
43 | |
40 | #else |
44 | #else |
41 | #define TIMING_TEST_START(id) do{}while (0) |
45 | #define TIMING_TEST_START(id) do {} while (0) |
42 | #define TIMING_TEST_PRINT_RESULT(id) do{}while (0) |
46 | #define TIMING_TEST_PRINT_RESULT(id) do {} while (0) |
43 | #endif |
47 | #endif |
44 | |
48 | |
45 | /* |
49 | /* |
46 | * Pixmap geometry string interpretation : |
50 | * Pixmap geometry string interpretation : |
47 | * Each geometry string contains zero or one scale/position |
51 | * Each geometry string contains zero or one scale/position |
48 | * adjustment and may optionally be followed by a colon and one or more |
52 | * adjustment and may optionally be followed by a colon and one or more |
49 | * colon-delimited pixmap operations. |
53 | * colon-delimited pixmap operations. |
50 | * The following table shows the valid geometry strings and their |
54 | * The following table shows the valid geometry strings and their |
51 | * affects on the background image : |
55 | * effects on the background image : |
52 | * |
56 | * |
53 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
57 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
54 | * W and H are percentages of the terminal window size. |
58 | * W and H are percentages of the terminal window size. |
55 | * X and Y are also percentages; e.g., +50+50 centers |
59 | * X and Y are also percentages; e.g., +50+50 centers |
56 | * the image in the window. |
60 | * the image in the window. |
… | |
… | |
136 | # endif |
140 | # endif |
137 | |
141 | |
138 | return false; |
142 | return false; |
139 | } |
143 | } |
140 | |
144 | |
141 | bool |
145 | bool |
142 | bgPixmap_t::window_position_sensitive () |
146 | bgPixmap_t::window_position_sensitive () |
143 | { |
147 | { |
144 | # ifdef ENABLE_TRANSPARENCY |
148 | # ifdef ENABLE_TRANSPARENCY |
145 | if (flags & isTransparent) |
149 | if (flags & isTransparent) |
146 | return true; |
150 | return true; |
147 | # endif |
151 | # endif |
… | |
… | |
444 | return (changed > 0); |
448 | return (changed > 0); |
445 | } |
449 | } |
446 | |
450 | |
447 | # ifdef HAVE_AFTERIMAGE |
451 | # ifdef HAVE_AFTERIMAGE |
448 | bool |
452 | bool |
449 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
453 | bgPixmap_t::render_asim (unsigned long background_flags) |
450 | { |
454 | { |
451 | if (target == NULL) |
455 | if (target == NULL) |
452 | return false; |
456 | return false; |
453 | |
457 | |
454 | target->init_asv (); |
458 | target->init_asv (); |
|
|
459 | |
|
|
460 | ASImage *background = NULL; |
|
|
461 | ARGB32 background_tint = TINT_LEAVE_SAME; |
|
|
462 | |
|
|
463 | # ifdef ENABLE_TRANSPARENCY |
|
|
464 | if (background_flags) |
|
|
465 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
466 | |
|
|
467 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
468 | { |
|
|
469 | ShadingInfo as_shade; |
|
|
470 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
471 | |
|
|
472 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
473 | if (flags & tintSet) |
|
|
474 | tint.get (c); |
|
|
475 | as_shade.tintColor.red = c.r; |
|
|
476 | as_shade.tintColor.green = c.g; |
|
|
477 | as_shade.tintColor.blue = c.b; |
|
|
478 | |
|
|
479 | background_tint = shading2tint32 (&as_shade); |
|
|
480 | } |
|
|
481 | |
|
|
482 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
483 | { |
|
|
484 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
485 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
486 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
487 | if (tmp) |
|
|
488 | { |
|
|
489 | destroy_asimage (&background); |
|
|
490 | background = tmp; |
|
|
491 | } |
|
|
492 | } |
|
|
493 | # endif |
455 | |
494 | |
456 | ASImage *result = 0; |
495 | ASImage *result = 0; |
457 | |
496 | |
458 | int target_width = target->szHint.width; |
497 | int target_width = target->szHint.width; |
459 | int target_height = target->szHint.height; |
498 | int target_height = target->szHint.height; |
… | |
… | |
495 | new_pmap_height = background->height; |
534 | new_pmap_height = background->height; |
496 | result = background; |
535 | result = background; |
497 | |
536 | |
498 | if (background_tint != TINT_LEAVE_SAME) |
537 | if (background_tint != TINT_LEAVE_SAME) |
499 | { |
538 | { |
500 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
539 | ASImage *tmp = tile_asimage (target->asv, background, 0, 0, |
501 | target_width, target_height, background_tint, |
540 | target_width, target_height, background_tint, |
502 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
541 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
503 | if (tmp) |
542 | if (tmp) |
504 | result = tmp; |
543 | result = tmp; |
505 | } |
544 | } |
… | |
… | |
533 | if (h_scale == 0 || v_scale == 0) |
572 | if (h_scale == 0 || v_scale == 0) |
534 | { |
573 | { |
535 | ASImage *tmp = tile_asimage (target->asv, result, |
574 | ASImage *tmp = tile_asimage (target->asv, result, |
536 | (h_scale > 0) ? 0 : (int)result->width - x, |
575 | (h_scale > 0) ? 0 : (int)result->width - x, |
537 | (v_scale > 0) ? 0 : (int)result->height - y, |
576 | (v_scale > 0) ? 0 : (int)result->height - y, |
538 | new_pmap_width, |
577 | new_pmap_width, |
539 | new_pmap_height, |
578 | new_pmap_height, |
540 | TINT_LEAVE_SAME, ASA_XImage, |
579 | TINT_LEAVE_SAME, ASA_XImage, |
541 | 100, ASIMAGE_QUALITY_DEFAULT); |
580 | 100, ASIMAGE_QUALITY_DEFAULT); |
542 | if (tmp) |
581 | if (tmp) |
543 | { |
582 | { |
… | |
… | |
550 | } |
589 | } |
551 | else |
590 | else |
552 | { |
591 | { |
553 | /* if blending background and image - pixmap has to be sized same as target window */ |
592 | /* if blending background and image - pixmap has to be sized same as target window */ |
554 | ASImageLayer *layers = create_image_layers (2); |
593 | ASImageLayer *layers = create_image_layers (2); |
555 | ASImage *merged_im = NULL; |
|
|
556 | |
594 | |
557 | layers[0].im = background; |
595 | layers[0].im = background; |
558 | layers[0].clip_width = target_width; |
596 | layers[0].clip_width = target_width; |
559 | layers[0].clip_height = target_height; |
597 | layers[0].clip_height = target_height; |
560 | layers[0].tint = background_tint; |
598 | layers[0].tint = background_tint; |
… | |
… | |
660 | |
698 | |
661 | XFreeGC (target->dpy, gc); |
699 | XFreeGC (target->dpy, gc); |
662 | TIMING_TEST_PRINT_RESULT (asim); |
700 | TIMING_TEST_PRINT_RESULT (asim); |
663 | } |
701 | } |
664 | |
702 | |
|
|
703 | if (background) |
|
|
704 | destroy_asimage (&background); |
|
|
705 | |
665 | return true; |
706 | return true; |
666 | } |
707 | } |
667 | # endif /* HAVE_AFTERIMAGE */ |
708 | # endif /* HAVE_AFTERIMAGE */ |
668 | |
709 | |
669 | bool |
710 | bool |
… | |
… | |
671 | { |
712 | { |
672 | assert (file); |
713 | assert (file); |
673 | |
714 | |
674 | if (*file) |
715 | if (*file) |
675 | { |
716 | { |
|
|
717 | if (const char *p = strchr (file, ';')) |
|
|
718 | { |
|
|
719 | size_t len = p - file; |
|
|
720 | char *f = rxvt_temp_buf<char> (len + 1); |
|
|
721 | memcpy (f, file, len); |
|
|
722 | f[len] = '\0'; |
|
|
723 | file = f; |
|
|
724 | } |
|
|
725 | |
676 | # ifdef HAVE_AFTERIMAGE |
726 | # ifdef HAVE_AFTERIMAGE |
677 | if (!target->asimman) |
727 | if (!target->asimman) |
678 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
728 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
679 | |
|
|
680 | if (const char *p = strchr (file, ';')) |
|
|
681 | { |
|
|
682 | size_t len = p - file; |
|
|
683 | char *f = (char *)malloc (len + 1); |
|
|
684 | memcpy (f, file, len); |
|
|
685 | f[len] = '\0'; |
|
|
686 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
|
|
687 | free (f); |
|
|
688 | } |
|
|
689 | else |
|
|
690 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
729 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
691 | |
|
|
692 | return original_asim; |
730 | return original_asim; |
693 | # endif |
731 | # endif |
694 | } |
732 | } |
695 | |
733 | |
696 | return false; |
734 | return false; |
… | |
… | |
848 | unsigned long result = 0; |
886 | unsigned long result = 0; |
849 | |
887 | |
850 | if (target == NULL) |
888 | if (target == NULL) |
851 | return 0; |
889 | return 0; |
852 | |
890 | |
853 | /* root dimentions may change from call to call - but Display structure should |
891 | /* root dimensions may change from call to call - but Display structure should |
854 | * be always up-to-date, so let's use it : |
892 | * be always up-to-date, so let's use it : |
855 | */ |
893 | */ |
856 | Window root = target->display->root; |
894 | Window root = target->display->root; |
857 | int screen = target->display->screen; |
895 | int screen = target->display->screen; |
858 | Display *dpy = target->dpy; |
896 | Display *dpy = target->dpy; |
… | |
… | |
947 | else |
985 | else |
948 | result |= transpPmapTiled; |
986 | result |= transpPmapTiled; |
949 | } |
987 | } |
950 | else |
988 | else |
951 | { |
989 | { |
952 | /* strightforward pixmap copy */ |
990 | /* straightforward pixmap copy */ |
953 | gcv.tile = root_pixmap; |
991 | gcv.tile = root_pixmap; |
954 | gcv.fill_style = FillTiled; |
992 | gcv.fill_style = FillTiled; |
955 | |
993 | |
956 | while (sx < 0) sx += (int)root_width; |
994 | while (sx < 0) sx += (int)root_width; |
957 | while (sy < 0) sy += (int)root_height; |
995 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
1108 | return false; |
1146 | return false; |
1109 | } |
1147 | } |
1110 | # endif /* ENABLE_TRANSPARENCY */ |
1148 | # endif /* ENABLE_TRANSPARENCY */ |
1111 | |
1149 | |
1112 | # ifndef HAVE_AFTERIMAGE |
1150 | # ifndef HAVE_AFTERIMAGE |
1113 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1151 | static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm); |
1114 | # endif |
1152 | # endif |
1115 | |
1153 | |
1116 | bool |
1154 | bool |
1117 | bgPixmap_t::render () |
1155 | bgPixmap_t::render () |
1118 | { |
1156 | { |
… | |
… | |
1135 | && pmap_depth == target->depth) |
1173 | && pmap_depth == target->depth) |
1136 | flags = flags & ~isInvalid; |
1174 | flags = flags & ~isInvalid; |
1137 | } |
1175 | } |
1138 | # endif |
1176 | # endif |
1139 | |
1177 | |
1140 | XImage *result = NULL; |
|
|
1141 | # ifdef HAVE_AFTERIMAGE |
1178 | # ifdef HAVE_AFTERIMAGE |
1142 | if (original_asim |
1179 | if (original_asim |
1143 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1180 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1144 | { |
1181 | { |
1145 | target->init_asv (); |
|
|
1146 | |
|
|
1147 | ASImage *background = NULL; |
|
|
1148 | ARGB32 as_tint = TINT_LEAVE_SAME; |
|
|
1149 | if (background_flags) |
|
|
1150 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
1151 | |
|
|
1152 | # ifdef ENABLE_TRANSPARENCY |
|
|
1153 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
1154 | { |
|
|
1155 | ShadingInfo as_shade; |
|
|
1156 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
1157 | |
|
|
1158 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1159 | if (flags & tintSet) |
|
|
1160 | tint.get (c); |
|
|
1161 | as_shade.tintColor.red = c.r; |
|
|
1162 | as_shade.tintColor.green = c.g; |
|
|
1163 | as_shade.tintColor.blue = c.b; |
|
|
1164 | |
|
|
1165 | as_tint = shading2tint32 (&as_shade); |
|
|
1166 | } |
|
|
1167 | |
|
|
1168 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1169 | { |
|
|
1170 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1171 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1172 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1173 | if (tmp) |
|
|
1174 | { |
|
|
1175 | destroy_asimage (&background); |
|
|
1176 | background = tmp; |
|
|
1177 | } |
|
|
1178 | } |
|
|
1179 | # endif |
|
|
1180 | |
|
|
1181 | if (render_asim (background, as_tint)) |
1182 | if (render_asim (background_flags)) |
1182 | flags = flags & ~isInvalid; |
1183 | flags = flags & ~isInvalid; |
1183 | if (background) |
|
|
1184 | destroy_asimage (&background); |
|
|
1185 | } |
1184 | } |
1186 | else if (background_flags && pmap_depth != target->depth) |
1185 | # endif |
1187 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1188 | |
1186 | |
1189 | # elif !XFT /* our own client-side tinting */ |
1187 | XImage *result = NULL; |
1190 | |
|
|
1191 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
|
|
1192 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1193 | |
1188 | |
1194 | if (background_flags && (flags & isInvalid)) |
1189 | if (background_flags && (flags & isInvalid)) |
1195 | { |
1190 | { |
1196 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1191 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1197 | |
1192 | |
|
|
1193 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
|
|
1194 | /* our own client-side tinting */ |
|
|
1195 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1196 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1198 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1197 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1199 | { |
1198 | { |
1200 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1199 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1201 | if (flags & tintSet) |
1200 | if (flags & tintSet) |
1202 | tint.get (c); |
1201 | tint.get (c); |
1203 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1202 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1204 | } |
1203 | } |
|
|
1204 | # endif |
1205 | } |
1205 | } |
1206 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1207 | |
1206 | |
1208 | if (result) |
1207 | if (result) |
1209 | { |
1208 | { |
1210 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1209 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1211 | |
1210 | |
… | |
… | |
1346 | /* taken from aterm-0.4.2 */ |
1345 | /* taken from aterm-0.4.2 */ |
1347 | |
1346 | |
1348 | typedef uint32_t RUINT32T; |
1347 | typedef uint32_t RUINT32T; |
1349 | |
1348 | |
1350 | static void |
1349 | static void |
1351 | ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
1350 | ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm) |
1352 | { |
1351 | { |
1353 | int sh_r, sh_g, sh_b; |
1352 | int sh_r, sh_g, sh_b; |
1354 | RUINT32T mask_r, mask_g, mask_b; |
1353 | RUINT32T mask_r, mask_g, mask_b; |
1355 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1354 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1356 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
1355 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |