ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xpm.C
(Generate patch)

Comparing rxvt-unicode/src/xpm.C (file contents):
Revision 1.70 by sasha, Thu Aug 16 21:26:20 2007 UTC vs.
Revision 1.72 by sasha, Thu Aug 23 20:53:36 2007 UTC

23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *---------------------------------------------------------------------*/ 24 *---------------------------------------------------------------------*/
25 25
26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28
29#define DO_TIMING_TEST 0
30
31#if DO_TIMING_TEST
32#define TIMING_TEST_START(id) \
33 struct timeval timing_test_##id##_stv;\
34 gettimeofday (&timing_test_##id##_stv, NULL);
35
36#define TIMING_TEST_PRINT_RESULT(id) \
37 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\
38 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\
39 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0)
40
41#else
42#define TIMING_TEST_START(id) do{}while (0)
43#define TIMING_TEST_PRINT_RESULT(id) do{}while (0)
44#endif
28 45
29/* 46/*
30 * Pixmap geometry string interpretation : 47 * Pixmap geometry string interpretation :
31 * Each geometry string contains zero or one scale/position 48 * Each geometry string contains zero or one scale/position
32 * adjustment and may optionally be followed by a colon and one or more 49 * adjustment and may optionally be followed by a colon and one or more
93bool bgPixmap_t::need_client_side_rendering () 110bool bgPixmap_t::need_client_side_rendering ()
94{ 111{
95# ifdef HAVE_AFTERIMAGE 112# ifdef HAVE_AFTERIMAGE
96 if (original_asim != NULL) 113 if (original_asim != NULL)
97 return true; 114 return true;
98#endif 115# endif
99# ifdef ENABLE_TRANSPARENCY 116# ifdef ENABLE_TRANSPARENCY
100 if (flags & isTransparent) 117 if (flags & isTransparent)
101 { 118 {
102 if ((flags & blurNeeded) 119 if ((flags & blurNeeded)
103 || ((flags & tintNeeded) && !(flags & tintServerSide))) 120 || ((flags & tintNeeded) && !(flags & tintServerSide)))
376 int x = 0; 393 int x = 0;
377 int y = 0; 394 int y = 0;
378 int w = h_scale * target_width / 100; 395 int w = h_scale * target_width / 100;
379 int h = v_scale * target_height / 100; 396 int h = v_scale * target_height / 100;
380 397
398 TIMING_TEST_START (asim);
399
381 if (original_asim) 400 if (original_asim)
382 { 401 {
383 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); 402 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
384 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); 403 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
385 } 404 }
489 result = tmp; 508 result = tmp;
490 } 509 }
491 free (layers); 510 free (layers);
492 } 511 }
493 } 512 }
513 TIMING_TEST_PRINT_RESULT (asim);
494 514
495 if (pixmap) 515 if (pixmap)
496 { 516 {
497 if (result == NULL 517 if (result == NULL
498 || pmap_width != new_pmap_width 518 || pmap_width != new_pmap_width
544 564
545 if (result != background && result != original_asim) 565 if (result != background && result != original_asim)
546 destroy_asimage (&result); 566 destroy_asimage (&result);
547 567
548 XFreeGC (target->dpy, gc); 568 XFreeGC (target->dpy, gc);
569 TIMING_TEST_PRINT_RESULT (asim);
549 } 570 }
550 571
551 return true; 572 return true;
552} 573}
553# endif /* HAVE_AFTERIMAGE */ 574# endif /* HAVE_AFTERIMAGE */
625 646
626static inline unsigned long 647static inline unsigned long
627compute_tint_shade_flags (rxvt_color *tint, int shade) 648compute_tint_shade_flags (rxvt_color *tint, int shade)
628{ 649{
629 unsigned long flags = 0; 650 unsigned long flags = 0;
651 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
630 652
631 if (shade > 0 && shade <100) 653 if (tint)
654 {
655 tint->get (c);
656# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
657 if (IS_COMPONENT_WHOLESOME (c.r)
658 && IS_COMPONENT_WHOLESOME (c.g)
659 && IS_COMPONENT_WHOLESOME (c.b))
660 flags |= bgPixmap_t::tintWholesome;
661# undef IS_COMPONENT_WHOLESOME
662 }
663
664 if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200))
632 flags |= bgPixmap_t::tintNeeded; 665 flags |= bgPixmap_t::tintNeeded;
633 else if (tint) 666 else if (tint)
634 { 667 {
635 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
636 tint->get (c);
637
638 flags |= bgPixmap_t::tintNeeded;
639 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) 668 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
640 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 669 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
641 { 670 {
642 flags |= bgPixmap_t::tintNeeded; 671 flags |= bgPixmap_t::tintNeeded;
643#define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
644 if (IS_COMPONENT_WHOLESOME (c.r)
645 && IS_COMPONENT_WHOLESOME (c.g)
646 && IS_COMPONENT_WHOLESOME (c.b))
647 flags |= bgPixmap_t::tintServerSide;
648#undef IS_COMPONENT_WHOLESOME
649 } 672 }
650 } 673 }
674
675 if (flags & bgPixmap_t::tintNeeded)
676 {
677 if (flags & bgPixmap_t::tintWholesome)
678 flags |= bgPixmap_t::tintServerSide;
679#if XFT
680 /* TODO: add logic for XRENDER tinting */
681 flags |= bgPixmap_t::tintServerSide;
682#endif
683 }
684
651 return flags; 685 return flags;
652} 686}
653 687
654bool 688bool
655bgPixmap_t::set_tint (rxvt_color &new_tint) 689bgPixmap_t::set_tint (rxvt_color &new_tint)
685 if (new_shade == 100) 719 if (new_shade == 100)
686 new_shade = 0; 720 new_shade = 0;
687 721
688 if (new_shade != shade) 722 if (new_shade != shade)
689 { 723 {
690 unsigned long new_flags = compute_tint_shade_flags (&tint, new_shade); 724 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade);
691 shade = new_shade; 725 shade = new_shade;
692 flags = (flags & ~tintFlags) | new_flags; 726 flags = (flags & ~tintFlags) | new_flags;
693 return true; 727 return true;
694 } 728 }
695 return false; 729 return false;
721 int window_width = target->szHint.width; 755 int window_width = target->szHint.width;
722 int window_height = target->szHint.height; 756 int window_height = target->szHint.height;
723 int sx, sy; 757 int sx, sy;
724 XGCValues gcv; 758 XGCValues gcv;
725 759
760 TIMING_TEST_START (tp);
726 target->get_window_origin (sx, sy); 761 target->get_window_origin (sx, sy);
727 762
728 /* check if we are outside of the visible part of the virtual screen : */ 763 /* check if we are outside of the visible part of the virtual screen : */
729 if (sx + window_width <= 0 || sy + window_height <= 0 764 if (sx + window_width <= 0 || sy + window_height <= 0
730 || sx >= root_width || sy >= root_height) 765 || sx >= root_width || sy >= root_height)
809 { 844 {
810 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 845 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
811 result |= transpPmapTiled; 846 result |= transpPmapTiled;
812 } 847 }
813 } 848 }
849 TIMING_TEST_PRINT_RESULT (tp);
814 850
815 if (tiled_root_pmap != None) 851 if (tiled_root_pmap != None)
852 {
853 if ((flags & tintNeeded) && !need_client_side_rendering ())
816 { 854 {
817 if (flags & tintNeeded) 855 if (flags & tintWholesome)
818 { 856 {
819 if ((flags & tintServerSide)
820 && h_blurRadius <= 1 && v_blurRadius <= 1
821# ifdef HAVE_AFTERIMAGE
822 && original_asim == NULL
823# endif
824 )
825 { /* In this case we can tint image server-side getting significant 857 /* In this case we can tint image server-side getting significant
826 * performance improvements, as we eliminate XImage transfer 858 * performance improvements, as we eliminate XImage transfer
827 */ 859 */
828 gcv.foreground = Pixel (tint); 860 gcv.foreground = Pixel (tint);
829 gcv.function = GXand; 861 gcv.function = GXand;
830 gcv.fill_style = FillSolid; 862 gcv.fill_style = FillSolid;
831 if (gc) 863 if (gc)
832 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); 864 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv);
833 else 865 else
834 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); 866 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
835 if (gc) 867 if (gc)
836 { 868 {
837 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 869 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
870 result |= transpPmapTinted;
871 }
872 }
873 else
874 {
875#if XFT /* TODO : implement proper detection of XRENDER, as XFT may be present without XRENDER ! */
876 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
877 if (flags & tintSet)
878 tint.get (c);
879 if (shade > 0 && shade < 100)
880 {
881 c.r = (c.r * shade) / 100;
882 c.g = (c.g * shade) / 100;
883 c.b = (c.b * shade) / 100;
884 }
885 else if( shade > 100 && shade < 200)
886 {
887 c.r = (c.r * (200 - shade)) / 100;
888 c.g = (c.g * (200 - shade)) / 100;
889 c.b = (c.b * (200 - shade)) / 100;
890 }
891
892 XRenderPictFormat pf;
893 pf.type = PictTypeDirect;
894 pf.depth = 32;
895 pf.direct.redMask = 0xff;
896 pf.direct.greenMask = 0xff;
897 pf.direct.blueMask = 0xff;
898 pf.direct.alphaMask = 0xff;
899
900 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
901 (PictFormatType|
902 PictFormatDepth|
903 PictFormatRedMask|
904 PictFormatGreenMask|
905 PictFormatBlueMask|
906 PictFormatAlphaMask),
907 &pf,
908 0);
909 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
910 XRenderPictureAttributes pa ;
911
912 Picture back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa);
913
914 pa.repeat = True;
915
916 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
917 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
918 XFreePixmap (dpy, overlay_pmap);
919
920 pa.component_alpha = True;
921 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
922 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
923 XFreePixmap (dpy, mask_pmap);
924
925 if (mask_pic && overlay_pic && back_pic)
926 {
927 XRenderColor mask_c;
928
929 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof(mask_c));
930 mask_c.alpha = 0xffff;
931 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
932 memset (&mask_c, 0x0, sizeof(mask_c));
933 mask_c.alpha = 0;
934 if (c.r == c.b && c.b == c.g) /* pure shading */
935 {
936 mask_c.red = mask_c.green = mask_c.blue = 0xffff-c.r;
937 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
938 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
939 }
940 else
941 {
942 mask_c.red = 0xffff-c.r;
943 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
944 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
945 mask_c.red = 0;
946 mask_c.green = 0xffff-c.g;
947 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
948 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
949 mask_c.green = 0;
950 mask_c.blue = 0xffff-c.b;
951 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
952 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
953 }
838 result |= transpPmapTinted; 954 result |= transpPmapTinted;
839 } 955 }
840 } 956 XRenderFreePicture (dpy, mask_pic);
957 XRenderFreePicture (dpy, overlay_pic);
958 XRenderFreePicture (dpy, back_pic);
959#endif
841 } 960 }
961 }
842 if (pixmap) 962 if (pixmap)
843 XFreePixmap (dpy, pixmap); 963 XFreePixmap (dpy, pixmap);
844 pixmap = tiled_root_pmap; 964 pixmap = tiled_root_pmap;
845 pmap_width = window_width; 965 pmap_width = window_width;
846 pmap_height = window_height; 966 pmap_height = window_height;
847 pmap_depth = root_depth; 967 pmap_depth = root_depth;
848 } 968 }
849 969
850 if (gc) 970 if (gc)
851 XFreeGC (dpy, gc); 971 XFreeGC (dpy, gc);
972
973 TIMING_TEST_PRINT_RESULT (tp);
852 974
853 return result; 975 return result;
854} 976}
855 977
856bool 978bool
857bgPixmap_t::set_root_pixmap () 979bgPixmap_t::set_root_pixmap ()
858{ 980{
871} 993}
872# endif /* ENABLE_TRANSPARENCY */ 994# endif /* ENABLE_TRANSPARENCY */
873 995
874# ifndef HAVE_AFTERIMAGE 996# ifndef HAVE_AFTERIMAGE
875static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 997static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm);
876#endif 998# endif
877 999
878 1000
879bool 1001bool
880bgPixmap_t::render () 1002bgPixmap_t::render ()
881{ 1003{
906 ASImage *background = NULL; 1028 ASImage *background = NULL;
907 ARGB32 as_tint = TINT_LEAVE_SAME; 1029 ARGB32 as_tint = TINT_LEAVE_SAME;
908 if (background_flags) 1030 if (background_flags)
909 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 1031 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
910 1032
1033# ifdef ENABLE_TRANSPARENCY
911 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1034 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
912 { 1035 {
913 ShadingInfo as_shade; 1036 ShadingInfo as_shade;
914 as_shade.shading = (shade == 0) ? 100 : shade; 1037 as_shade.shading = (shade == 0) ? 100 : shade;
915 1038
920 as_shade.tintColor.green = c.g; 1043 as_shade.tintColor.green = c.g;
921 as_shade.tintColor.blue = c.b; 1044 as_shade.tintColor.blue = c.b;
922 1045
923 as_tint = shading2tint32 (&as_shade); 1046 as_tint = shading2tint32 (&as_shade);
924 } 1047 }
925
926 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 1048 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
927 { 1049 {
928 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 1050 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
929 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, 1051 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
930 100, ASIMAGE_QUALITY_DEFAULT); 1052 100, ASIMAGE_QUALITY_DEFAULT);
932 { 1054 {
933 destroy_asimage (&background); 1055 destroy_asimage (&background);
934 background = tmp; 1056 background = tmp;
935 } 1057 }
936 } 1058 }
1059# endif
937 1060
938 if (render_asim (background, as_tint)) 1061 if (render_asim (background, as_tint))
939 flags = flags & ~isInvalid; 1062 flags = flags & ~isInvalid;
940 if (background) 1063 if (background)
941 destroy_asimage (&background); 1064 destroy_asimage (&background);
954 if (flags & tintSet) 1077 if (flags & tintSet)
955 tint.get (c); 1078 tint.get (c);
956 ShadeXImage (target, result, shade, c.r, c.g, c.b); 1079 ShadeXImage (target, result, shade, c.r, c.g, c.b);
957 } 1080 }
958 } 1081 }
959# endif 1082# endif /* HAVE_AFTERIMAGE */
960 if (result != NULL) 1083 if (result != NULL)
961 { 1084 {
962 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1085 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
963 if (gc) 1086 if (gc)
964 { 1087 {
965 if (pmap_depth != target->depth && pixmap != None) 1088 if (/*pmap_depth != target->depth &&*/ pixmap != None)
966 { 1089 {
967 XFreePixmap (target->dpy, pixmap); 1090 XFreePixmap (target->dpy, pixmap);
968 pixmap = None; 1091 pixmap = None;
969 } 1092 }
970 if (pixmap == None) 1093 if (pixmap == None)
972 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); 1095 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth);
973 pmap_width = result->width; 1096 pmap_width = result->width;
974 pmap_height = result->height; 1097 pmap_height = result->height;
975 pmap_depth = target->depth; 1098 pmap_depth = target->depth;
976 } 1099 }
1100 if (pmap_depth != result->depth)
1101 { /* Bad Match error will ensue ! stupid X !!!! */
1102 if( result->depth == 24 && pmap_depth == 32)
1103 result->depth = 32;
1104 else if( result->depth == 32 && pmap_depth == 24)
1105 result->depth = 24;
1106 else
1107 {
1108 /* TODO: implement image recoding */
1109 }
1110 }
1111 if (pmap_depth == result->depth)
977 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1112 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
978 XFreeGC (target->dpy, gc); 1113 XFreeGC (target->dpy, gc);
979 flags = flags & ~isInvalid; 1114 flags = flags & ~isInvalid;
980 } 1115 }
981 XDestroyImage (result); 1116 XDestroyImage (result);
982 } 1117 }
986 if (pixmap != None) 1121 if (pixmap != None)
987 { 1122 {
988 XFreePixmap (target->dpy, pixmap); 1123 XFreePixmap (target->dpy, pixmap);
989 pixmap = None; 1124 pixmap = None;
990 } 1125 }
991// TODO : we need to get rid of that garbadge :
992 target->am_transparent = target->am_pixmap_trans = 0;
993 } 1126 }
994 else
995 target->am_transparent = target->am_pixmap_trans = 1;
996 1127
997 apply (); 1128 apply ();
998 1129
999 return true; 1130 return true;
1000} 1131}
1056 } 1187 }
1057 /* don't want Expose on the parent */ 1188 /* don't want Expose on the parent */
1058 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); 1189 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False);
1059 /* do want Expose on the vt */ 1190 /* do want Expose on the vt */
1060 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); 1191 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True);
1061#if HAVE_SCROLLBARS 1192# if HAVE_SCROLLBARS
1062 if (target->scrollBar.win) 1193 if (target->scrollBar.win)
1063 { 1194 {
1064 target->scrollBar.setIdle (); 1195 target->scrollBar.setIdle ();
1065 target->scrollbar_show (0); 1196 target->scrollbar_show (0);
1066 } 1197 }
1067#endif 1198# endif
1068 /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ 1199 /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */
1200 target->want_refresh = 1;
1201# ifdef ENABLE_TRANSPARENCY
1069 target->want_refresh = target->want_full_refresh = 1; 1202 target->want_full_refresh = 1;
1203# endif
1070 /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ 1204 /* TODO: why do we need a flush here ??? It causes segfault on resize ! */
1071// target->flush (); 1205// target->flush ();
1072 } 1206 }
1073} 1207}
1074#endif /* HAVE_BG_PIXMAP */
1075
1076 1208
1077void 1209void
1078rxvt_term::get_window_origin (int &x, int &y) 1210rxvt_term::get_window_origin (int &x, int &y)
1079{ 1211{
1080 Window cr; 1212 Window cr;
1101 } 1233 }
1102 } 1234 }
1103 return None; 1235 return None;
1104} 1236}
1105 1237
1238/*
1239 * Check our parents are still who we think they are.
1240 * Do transparency updates if required
1241 */
1242int
1243rxvt_term::update_background ()
1244{
1245 bgPixmap.invalidate();
1246 /* no chance of real time refresh if we are blurring ! */
1247 if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded))
1248 bgPixmap.render();
1249 else
1250 {
1251 update_background_ev.stop ();
1252 if (!bgPixmap.need_client_side_rendering())
1253 update_background_ev.start (NOW + .05);
1254 else if (bgPixmap.flags & bgPixmap_t::blurNeeded)
1255 update_background_ev.start (NOW + .2); /* very slow !!! */
1256 else
1257 update_background_ev.start (NOW + .07);
1258 }
1259 return 0;
1260}
1106 1261
1107#ifdef ENABLE_TRANSPARENCY 1262void
1108#ifndef HAVE_AFTERIMAGE 1263rxvt_term::update_background_cb (time_watcher &w)
1264{
1265 bgPixmap.render ();
1266}
1267#endif /* HAVE_BG_PIXMAP */
1268
1269#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1109/* taken from aterm-0.4.2 */ 1270/* taken from aterm-0.4.2 */
1110 1271
1111typedef uint32_t RUINT32T; 1272typedef uint32_t RUINT32T;
1112 1273
1113static void 1274static void
1124 1285
1125 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; 1286 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ;
1126 1287
1127 if (shade == 0) 1288 if (shade == 0)
1128 shade = 100; 1289 shade = 100;
1129 1290
1130 /* for convenience */ 1291 /* for convenience */
1131 mask_r = visual->red_mask; 1292 mask_r = visual->red_mask;
1132 mask_g = visual->green_mask; 1293 mask_g = visual->green_mask;
1133 mask_b = visual->blue_mask; 1294 mask_b = visual->blue_mask;
1134 1295
1336 } 1497 }
1337 } 1498 }
1338 1499
1339 free (lookup); 1500 free (lookup);
1340} 1501}
1341#endif 1502#endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */
1342
1343/*
1344 * Check our parents are still who we think they are.
1345 * Do transparency updates if required
1346 */
1347int
1348rxvt_term::update_background ()
1349{
1350 bgPixmap.invalidate();
1351 /* no chance of real time refresh if we are blurring ! */
1352 if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded))
1353 bgPixmap.render();
1354 else
1355 {
1356 update_background_ev.stop ();
1357 if (!bgPixmap.need_client_side_rendering())
1358 update_background_ev.start (NOW + .05);
1359 else if (bgPixmap.flags & bgPixmap_t::blurNeeded)
1360 update_background_ev.start (NOW + .2); /* very slow !!! */
1361 else
1362 update_background_ev.start (NOW + .07);
1363 }
1364 return 0;
1365}
1366
1367void
1368rxvt_term::update_background_cb (time_watcher &w)
1369{
1370 bgPixmap.render ();
1371}
1372#endif /* HAVE_BG_PIXMAP */
1373
1374 1503
1375#if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ 1504#if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */
1376void 1505void
1377rxvt_term::check_our_parents_cb (time_watcher &w) 1506rxvt_term::check_our_parents_cb (time_watcher &w)
1378{ 1507{
1388 Window cr; 1517 Window cr;
1389 unsigned int rootpixmap_w = 0, rootpixmap_h = 0; 1518 unsigned int rootpixmap_w = 0, rootpixmap_h = 0;
1390 1519
1391 if (!option (Opt_transparent)) 1520 if (!option (Opt_transparent))
1392 return; /* Don't try any more */ 1521 return; /* Don't try any more */
1393#if 0
1394 struct timeval stv;
1395 gettimeofday (&stv,NULL);
1396#define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\
1397 fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\
1398 tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0)
1399#else
1400#define PRINT_BACKGROUND_OP_TIME do{}while(0)
1401#endif
1402
1403 1522
1404 XGetWindowAttributes (dpy, display->root, &wrootattr); 1523 XGetWindowAttributes (dpy, display->root, &wrootattr);
1405 rootdepth = wrootattr.depth; 1524 rootdepth = wrootattr.depth;
1406 1525
1407 XGetWindowAttributes (dpy, parent[0], &wattr); 1526 XGetWindowAttributes (dpy, parent[0], &wattr);
1541 { 1660 {
1542 XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); 1661 XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap);
1543 success = False; 1662 success = False;
1544 if (image != NULL) 1663 if (image != NULL)
1545 { 1664 {
1546 PRINT_BACKGROUND_OP_TIME;
1547 if (gc == NULL) 1665 if (gc == NULL)
1548 gc = XCreateGC (dpy, vt, 0UL, &gcvalue); 1666 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
1549 if (ISSET_PIXCOLOR (Color_tint) || shade != 100) 1667 if (ISSET_PIXCOLOR (Color_tint) || shade != 100)
1550 ShadeXImage (this, image, shade, c.r, c.g, c.b); 1668 ShadeXImage (this, image, shade, c.r, c.g, c.b);
1551 XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); 1669 XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
1552 XDestroyImage (image); 1670 XDestroyImage (image);
1553 success = True; 1671 success = True;
1554 } 1672 }
1555 } 1673 }
1556#endif /* HAVE_AFTERIMAGE */ 1674#endif /* HAVE_AFTERIMAGE */
1557 PRINT_BACKGROUND_OP_TIME;
1558 1675
1559 if (gc != NULL) 1676 if (gc != NULL)
1560 XFreeGC (dpy, gc); 1677 XFreeGC (dpy, gc);
1561 1678
1562 bgPixmap.apply(); 1679 bgPixmap.apply();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines