… | |
… | |
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. |
… | |
… | |
93 | // zero_initialised-derived structs |
97 | // zero_initialised-derived structs |
94 | #ifdef HAVE_AFTERIMAGE |
98 | #ifdef HAVE_AFTERIMAGE |
95 | original_asim = NULL; |
99 | original_asim = NULL; |
96 | #endif |
100 | #endif |
97 | #ifdef BG_IMAGE_FROM_FILE |
101 | #ifdef BG_IMAGE_FROM_FILE |
|
|
102 | have_image = false; |
98 | h_scale = v_scale = 0; |
103 | h_scale = v_scale = 0; |
99 | h_align = v_align = 0; |
104 | h_align = v_align = 0; |
100 | #endif |
105 | #endif |
101 | flags = 0; |
106 | flags = 0; |
102 | pixmap = None; |
107 | pixmap = None; |
… | |
… | |
123 | if (flags & isTransparent) |
128 | if (flags & isTransparent) |
124 | return true; |
129 | return true; |
125 | # endif |
130 | # endif |
126 | |
131 | |
127 | # ifdef BG_IMAGE_FROM_FILE |
132 | # ifdef BG_IMAGE_FROM_FILE |
128 | # ifdef HAVE_AFTERIMAGE |
133 | if (have_image) |
129 | if (original_asim) |
|
|
130 | # endif |
|
|
131 | { |
134 | { |
132 | if (h_scale != 0 || v_scale != 0 |
135 | if (h_scale != 0 || v_scale != 0 |
133 | || h_align != 0 || v_align != 0) |
136 | || h_align != 0 || v_align != 0) |
134 | return true; |
137 | return true; |
135 | } |
138 | } |
136 | # endif |
139 | # endif |
137 | |
140 | |
138 | return false; |
141 | return false; |
139 | } |
142 | } |
140 | |
143 | |
141 | bool |
144 | bool |
142 | bgPixmap_t::window_position_sensitive () |
145 | bgPixmap_t::window_position_sensitive () |
143 | { |
146 | { |
144 | # ifdef ENABLE_TRANSPARENCY |
147 | # ifdef ENABLE_TRANSPARENCY |
145 | if (flags & isTransparent) |
148 | if (flags & isTransparent) |
146 | return true; |
149 | return true; |
147 | # endif |
150 | # endif |
148 | |
151 | |
149 | # ifdef BG_IMAGE_FROM_FILE |
152 | # ifdef BG_IMAGE_FROM_FILE |
150 | # ifdef HAVE_AFTERIMAGE |
153 | if (have_image) |
151 | if (original_asim) |
|
|
152 | # endif |
|
|
153 | { |
154 | { |
154 | if (h_align == rootAlign || v_align == rootAlign) |
155 | if (h_align == rootAlign || v_align == rootAlign) |
155 | return true; |
156 | return true; |
156 | } |
157 | } |
157 | # endif |
158 | # endif |
… | |
… | |
259 | int geom_flags = 0, changed = 0; |
260 | int geom_flags = 0, changed = 0; |
260 | int x = 0, y = 0; |
261 | int x = 0, y = 0; |
261 | unsigned int w = 0, h = 0; |
262 | unsigned int w = 0, h = 0; |
262 | unsigned int n; |
263 | unsigned int n; |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | char *p; |
265 | const char *p; |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | |
267 | |
267 | if (geom == NULL) |
268 | if (geom == NULL) |
268 | return false; |
269 | return false; |
269 | |
270 | |
… | |
… | |
437 | { |
438 | { |
438 | flags = new_flags; |
439 | flags = new_flags; |
439 | changed++; |
440 | changed++; |
440 | } |
441 | } |
441 | |
442 | |
442 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
443 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
443 | // flags, h_scale, v_scale, h_align, v_align); |
444 | // flags, h_scale, v_scale, h_align, v_align); |
444 | return (changed > 0); |
445 | return (changed > 0); |
445 | } |
446 | } |
446 | |
447 | |
447 | # ifdef HAVE_AFTERIMAGE |
448 | # ifdef HAVE_AFTERIMAGE |
448 | bool |
449 | bool |
449 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
450 | bgPixmap_t::render_asim (unsigned long background_flags) |
450 | { |
451 | { |
451 | if (target == NULL) |
452 | if (target == NULL) |
452 | return false; |
453 | return false; |
453 | |
454 | |
454 | target->init_asv (); |
455 | target->init_asv (); |
|
|
456 | |
|
|
457 | ASImage *background = NULL; |
|
|
458 | ARGB32 background_tint = TINT_LEAVE_SAME; |
|
|
459 | |
|
|
460 | # ifdef ENABLE_TRANSPARENCY |
|
|
461 | if (background_flags) |
|
|
462 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
463 | |
|
|
464 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
465 | { |
|
|
466 | ShadingInfo as_shade; |
|
|
467 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
468 | |
|
|
469 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
470 | if (flags & tintSet) |
|
|
471 | tint.get (c); |
|
|
472 | as_shade.tintColor.red = c.r; |
|
|
473 | as_shade.tintColor.green = c.g; |
|
|
474 | as_shade.tintColor.blue = c.b; |
|
|
475 | |
|
|
476 | background_tint = shading2tint32 (&as_shade); |
|
|
477 | } |
|
|
478 | |
|
|
479 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
480 | { |
|
|
481 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
482 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
|
|
483 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
484 | if (tmp) |
|
|
485 | { |
|
|
486 | destroy_asimage (&background); |
|
|
487 | background = tmp; |
|
|
488 | } |
|
|
489 | } |
|
|
490 | # endif |
455 | |
491 | |
456 | ASImage *result = 0; |
492 | ASImage *result = 0; |
457 | |
493 | |
458 | int target_width = target->szHint.width; |
494 | int target_width = target->szHint.width; |
459 | int target_height = target->szHint.height; |
495 | int target_height = target->szHint.height; |
… | |
… | |
469 | |
505 | |
470 | if (original_asim) |
506 | if (original_asim) |
471 | { |
507 | { |
472 | if (h_align == rootAlign || v_align == rootAlign) |
508 | if (h_align == rootAlign || v_align == rootAlign) |
473 | { |
509 | { |
474 | target->get_window_origin(x, y); |
510 | target->get_window_origin (x, y); |
475 | x = -x; |
511 | x = -x; |
476 | y = -y; |
512 | y = -y; |
477 | } |
513 | } |
478 | |
514 | |
479 | if (h_align != rootAlign) |
515 | if (h_align != rootAlign) |
… | |
… | |
495 | new_pmap_height = background->height; |
531 | new_pmap_height = background->height; |
496 | result = background; |
532 | result = background; |
497 | |
533 | |
498 | if (background_tint != TINT_LEAVE_SAME) |
534 | if (background_tint != TINT_LEAVE_SAME) |
499 | { |
535 | { |
500 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
536 | ASImage *tmp = tile_asimage (target->asv, background, 0, 0, |
501 | target_width, target_height, background_tint, |
537 | target_width, target_height, background_tint, |
502 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
538 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
503 | if (tmp) |
539 | if (tmp) |
504 | result = tmp; |
540 | result = tmp; |
505 | } |
541 | } |
… | |
… | |
533 | if (h_scale == 0 || v_scale == 0) |
569 | if (h_scale == 0 || v_scale == 0) |
534 | { |
570 | { |
535 | ASImage *tmp = tile_asimage (target->asv, result, |
571 | ASImage *tmp = tile_asimage (target->asv, result, |
536 | (h_scale > 0) ? 0 : (int)result->width - x, |
572 | (h_scale > 0) ? 0 : (int)result->width - x, |
537 | (v_scale > 0) ? 0 : (int)result->height - y, |
573 | (v_scale > 0) ? 0 : (int)result->height - y, |
538 | new_pmap_width, |
574 | new_pmap_width, |
539 | new_pmap_height, |
575 | new_pmap_height, |
540 | TINT_LEAVE_SAME, ASA_XImage, |
576 | TINT_LEAVE_SAME, ASA_XImage, |
541 | 100, ASIMAGE_QUALITY_DEFAULT); |
577 | 100, ASIMAGE_QUALITY_DEFAULT); |
542 | if (tmp) |
578 | if (tmp) |
543 | { |
579 | { |
… | |
… | |
550 | } |
586 | } |
551 | else |
587 | else |
552 | { |
588 | { |
553 | /* if blending background and image - pixmap has to be sized same as target window */ |
589 | /* if blending background and image - pixmap has to be sized same as target window */ |
554 | ASImageLayer *layers = create_image_layers (2); |
590 | ASImageLayer *layers = create_image_layers (2); |
555 | ASImage *merged_im = NULL; |
|
|
556 | |
591 | |
557 | layers[0].im = background; |
592 | layers[0].im = background; |
558 | layers[0].clip_width = target_width; |
593 | layers[0].clip_width = target_width; |
559 | layers[0].clip_height = target_height; |
594 | layers[0].clip_height = target_height; |
560 | layers[0].tint = background_tint; |
595 | layers[0].tint = background_tint; |
… | |
… | |
632 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
667 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
633 | pmap_width = new_pmap_width; |
668 | pmap_width = new_pmap_width; |
634 | pmap_height = new_pmap_height; |
669 | pmap_height = new_pmap_height; |
635 | pmap_depth = target->depth; |
670 | pmap_depth = target->depth; |
636 | } |
671 | } |
637 | /* fill with background color ( if result's not completely overlapping it)*/ |
672 | /* fill with background color (if result's not completely overlapping it) */ |
638 | gcv.foreground = target->pix_colors[Color_bg]; |
673 | gcv.foreground = target->pix_colors[Color_bg]; |
639 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
674 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
640 | |
675 | |
641 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
676 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
642 | int dst_width = result->width, dst_height = result->height; |
677 | int dst_width = result->width, dst_height = result->height; |
… | |
… | |
660 | |
695 | |
661 | XFreeGC (target->dpy, gc); |
696 | XFreeGC (target->dpy, gc); |
662 | TIMING_TEST_PRINT_RESULT (asim); |
697 | TIMING_TEST_PRINT_RESULT (asim); |
663 | } |
698 | } |
664 | |
699 | |
|
|
700 | if (background) |
|
|
701 | destroy_asimage (&background); |
|
|
702 | |
665 | return true; |
703 | return true; |
666 | } |
704 | } |
667 | # endif /* HAVE_AFTERIMAGE */ |
705 | # endif /* HAVE_AFTERIMAGE */ |
668 | |
706 | |
669 | bool |
707 | bool |
… | |
… | |
671 | { |
709 | { |
672 | assert (file); |
710 | assert (file); |
673 | |
711 | |
674 | if (*file) |
712 | if (*file) |
675 | { |
713 | { |
|
|
714 | if (const char *p = strchr (file, ';')) |
|
|
715 | { |
|
|
716 | size_t len = p - file; |
|
|
717 | char *f = rxvt_temp_buf<char> (len + 1); |
|
|
718 | memcpy (f, file, len); |
|
|
719 | f[len] = '\0'; |
|
|
720 | file = f; |
|
|
721 | } |
|
|
722 | |
676 | # ifdef HAVE_AFTERIMAGE |
723 | # ifdef HAVE_AFTERIMAGE |
677 | if (!target->asimman) |
724 | if (!target->asimman) |
678 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
725 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
679 | |
|
|
680 | if (char *f = strchr (file, ';')) |
|
|
681 | { |
|
|
682 | size_t len = f - file; |
|
|
683 | 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); |
726 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
691 | |
727 | if (original_asim) |
692 | return original_asim; |
728 | have_image = true; |
|
|
729 | return have_image; |
693 | # endif |
730 | # endif |
694 | } |
731 | } |
695 | |
732 | |
696 | return false; |
733 | return false; |
697 | } |
734 | } |
… | |
… | |
766 | flags |= bgPixmap_t::tintNeeded; |
803 | flags |= bgPixmap_t::tintNeeded; |
767 | else if (tint) |
804 | else if (tint) |
768 | { |
805 | { |
769 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
806 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
770 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
807 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
771 | { |
808 | { |
772 | flags |= bgPixmap_t::tintNeeded; |
809 | flags |= bgPixmap_t::tintNeeded; |
773 | } |
810 | } |
774 | } |
811 | } |
775 | |
812 | |
776 | if (flags & bgPixmap_t::tintNeeded) |
813 | if (flags & bgPixmap_t::tintNeeded) |
777 | { |
814 | { |
778 | if (flags & bgPixmap_t::tintWholesome) |
815 | if (flags & bgPixmap_t::tintWholesome) |
… | |
… | |
807 | { |
844 | { |
808 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
845 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
809 | |
846 | |
810 | if (new_flags != (flags & tintFlags)) |
847 | if (new_flags != (flags & tintFlags)) |
811 | { |
848 | { |
812 | flags = (flags&~tintFlags)|new_flags; |
849 | flags = (flags&~tintFlags)|new_flags; |
813 | return true; |
850 | return true; |
814 | } |
851 | } |
815 | |
852 | |
816 | return false; |
853 | return false; |
817 | } |
854 | } |
818 | |
855 | |
… | |
… | |
848 | unsigned long result = 0; |
885 | unsigned long result = 0; |
849 | |
886 | |
850 | if (target == NULL) |
887 | if (target == NULL) |
851 | return 0; |
888 | return 0; |
852 | |
889 | |
853 | /* root dimentions may change from call to call - but Display structure should |
890 | /* root dimensions may change from call to call - but Display structure should |
854 | * be always up-to-date, so let's use it : |
891 | * be always up-to-date, so let's use it : |
855 | */ |
892 | */ |
856 | Window root = target->display->root; |
893 | Window root = target->display->root; |
857 | int screen = target->display->screen; |
894 | int screen = target->display->screen; |
858 | Display *dpy = target->dpy; |
895 | Display *dpy = target->dpy; |
… | |
… | |
903 | |
940 | |
904 | attr.background_pixmap = ParentRelative; |
941 | attr.background_pixmap = ParentRelative; |
905 | attr.backing_store = Always; |
942 | attr.backing_store = Always; |
906 | attr.event_mask = ExposureMask; |
943 | attr.event_mask = ExposureMask; |
907 | attr.override_redirect = True; |
944 | attr.override_redirect = True; |
908 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
945 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
909 | CopyFromParent, CopyFromParent, CopyFromParent, |
946 | CopyFromParent, CopyFromParent, CopyFromParent, |
910 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
947 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
911 | &attr); |
948 | &attr); |
912 | |
949 | |
913 | if (src != None) |
950 | if (src != None) |
… | |
… | |
937 | XDestroyWindow (dpy, src); |
974 | XDestroyWindow (dpy, src); |
938 | XUngrabServer (dpy); |
975 | XUngrabServer (dpy); |
939 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
976 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
940 | } |
977 | } |
941 | |
978 | |
942 | if (!success) |
979 | if (!success) |
943 | { |
980 | { |
944 | XFreePixmap (dpy, tiled_root_pmap); |
981 | XFreePixmap (dpy, tiled_root_pmap); |
945 | tiled_root_pmap = None; |
982 | tiled_root_pmap = None; |
946 | } |
983 | } |
947 | else |
984 | else |
948 | result |= transpPmapTiled; |
985 | result |= transpPmapTiled; |
949 | } |
986 | } |
950 | else |
987 | else |
951 | { |
988 | { |
952 | /* strightforward pixmap copy */ |
989 | /* straightforward pixmap copy */ |
953 | gcv.tile = root_pixmap; |
990 | gcv.tile = root_pixmap; |
954 | gcv.fill_style = FillTiled; |
991 | gcv.fill_style = FillTiled; |
955 | |
992 | |
956 | while (sx < 0) sx += (int)root_width; |
993 | while (sx < 0) sx += (int)root_width; |
957 | while (sy < 0) sy += (int)root_height; |
994 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
1070 | # if DO_TIMING_TEST |
1107 | # if DO_TIMING_TEST |
1071 | XSync (dpy, False); |
1108 | XSync (dpy, False); |
1072 | # endif |
1109 | # endif |
1073 | # endif |
1110 | # endif |
1074 | } |
1111 | } |
1075 | } |
1112 | } |
1076 | } /* server side rendering completed */ |
1113 | } /* server side rendering completed */ |
1077 | |
1114 | |
1078 | if (pixmap) |
1115 | if (pixmap) |
1079 | XFreePixmap (dpy, pixmap); |
1116 | XFreePixmap (dpy, pixmap); |
1080 | |
1117 | |
… | |
… | |
1108 | return false; |
1145 | return false; |
1109 | } |
1146 | } |
1110 | # endif /* ENABLE_TRANSPARENCY */ |
1147 | # endif /* ENABLE_TRANSPARENCY */ |
1111 | |
1148 | |
1112 | # ifndef HAVE_AFTERIMAGE |
1149 | # ifndef HAVE_AFTERIMAGE |
1113 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1150 | static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm); |
1114 | # endif |
1151 | # endif |
1115 | |
1152 | |
1116 | bool |
1153 | bool |
1117 | bgPixmap_t::render () |
1154 | bgPixmap_t::render () |
1118 | { |
1155 | { |
1119 | unsigned long background_flags = 0; |
1156 | unsigned long background_flags = 0; |
1120 | |
1157 | |
1121 | if (target == NULL) |
1158 | if (target == NULL) |
1122 | return false; |
1159 | return false; |
1123 | |
|
|
1124 | target->init_asv (); |
|
|
1125 | |
1160 | |
1126 | TIMING_TEST_START (tp); |
1161 | TIMING_TEST_START (tp); |
1127 | |
1162 | |
1128 | invalidate (); |
1163 | invalidate (); |
1129 | # ifdef ENABLE_TRANSPARENCY |
1164 | # ifdef ENABLE_TRANSPARENCY |
… | |
… | |
1132 | /* we need to re-generate transparency pixmap in that case ! */ |
1167 | /* we need to re-generate transparency pixmap in that case ! */ |
1133 | background_flags = make_transparency_pixmap (); |
1168 | background_flags = make_transparency_pixmap (); |
1134 | if (background_flags == 0) |
1169 | if (background_flags == 0) |
1135 | return false; |
1170 | return false; |
1136 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1171 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1137 | && pmap_depth == target->depth) |
1172 | && pmap_depth == target->depth) |
1138 | flags = flags & ~isInvalid; |
1173 | flags = flags & ~isInvalid; |
1139 | } |
1174 | } |
1140 | # endif |
1175 | # endif |
1141 | |
1176 | |
1142 | XImage *result = NULL; |
|
|
1143 | # ifdef HAVE_AFTERIMAGE |
1177 | # ifdef HAVE_AFTERIMAGE |
1144 | if (original_asim |
1178 | if (original_asim |
1145 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1179 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1146 | { |
1180 | { |
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)) |
1181 | if (render_asim (background_flags)) |
1182 | flags = flags & ~isInvalid; |
1182 | flags = flags & ~isInvalid; |
1183 | if (background) |
|
|
1184 | destroy_asimage (&background); |
|
|
1185 | } |
1183 | } |
1186 | else if (background_flags && pmap_depth != target->depth) |
1184 | # endif |
1187 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1188 | |
1185 | |
1189 | # elif !XFT /* our own client-side tinting */ |
1186 | 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 | |
1187 | |
1194 | if (background_flags && (flags & isInvalid)) |
1188 | if (background_flags && (flags & isInvalid)) |
1195 | { |
1189 | { |
1196 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1190 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1197 | |
1191 | |
|
|
1192 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
|
|
1193 | /* our own client-side tinting */ |
|
|
1194 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1195 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1198 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1196 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1199 | { |
1197 | { |
1200 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1198 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1201 | if (flags & tintSet) |
1199 | if (flags & tintSet) |
1202 | tint.get (c); |
1200 | tint.get (c); |
1203 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1201 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1204 | } |
1202 | } |
|
|
1203 | # endif |
1205 | } |
1204 | } |
1206 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1207 | |
1205 | |
1208 | if (result) |
1206 | if (result) |
1209 | { |
1207 | { |
1210 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1208 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1211 | |
1209 | |
… | |
… | |
1243 | |
1241 | |
1244 | XFreeGC (target->dpy, gc); |
1242 | XFreeGC (target->dpy, gc); |
1245 | flags = flags & ~isInvalid; |
1243 | flags = flags & ~isInvalid; |
1246 | } |
1244 | } |
1247 | |
1245 | |
1248 | XDestroyImage (result); |
1246 | XDestroyImage (result); |
1249 | } |
1247 | } |
1250 | |
1248 | |
1251 | if (flags & isInvalid) |
1249 | if (flags & isInvalid) |
1252 | { |
1250 | { |
1253 | if (pixmap != None) |
1251 | if (pixmap != None) |
… | |
… | |
1327 | |
1325 | |
1328 | /* don't want Expose on the parent or vt. It is better to use |
1326 | /* don't want Expose on the parent or vt. It is better to use |
1329 | scr_touch or we get a great deal of flicker otherwise: */ |
1327 | scr_touch or we get a great deal of flicker otherwise: */ |
1330 | XClearWindow (target->dpy, target->parent[0]); |
1328 | XClearWindow (target->dpy, target->parent[0]); |
1331 | |
1329 | |
1332 | if (target->scrollBar.win) |
1330 | if (target->scrollBar.state && target->scrollBar.win) |
1333 | { |
1331 | { |
1334 | target->scrollBar.state = STATE_IDLE; |
1332 | target->scrollBar.state = STATE_IDLE; |
1335 | target->scrollBar.show (0); |
1333 | target->scrollBar.show (0); |
1336 | } |
1334 | } |
1337 | |
1335 | |
… | |
… | |
1346 | /* taken from aterm-0.4.2 */ |
1344 | /* taken from aterm-0.4.2 */ |
1347 | |
1345 | |
1348 | typedef uint32_t RUINT32T; |
1346 | typedef uint32_t RUINT32T; |
1349 | |
1347 | |
1350 | static void |
1348 | static void |
1351 | ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
1349 | ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm) |
1352 | { |
1350 | { |
1353 | int sh_r, sh_g, sh_b; |
1351 | int sh_r, sh_g, sh_b; |
1354 | RUINT32T mask_r, mask_g, mask_b; |
1352 | RUINT32T mask_r, mask_g, mask_b; |
1355 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1353 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1356 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
1354 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |