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.71 by sasha, Fri Aug 17 22:01:33 2007 UTC

93bool bgPixmap_t::need_client_side_rendering () 93bool bgPixmap_t::need_client_side_rendering ()
94{ 94{
95# ifdef HAVE_AFTERIMAGE 95# ifdef HAVE_AFTERIMAGE
96 if (original_asim != NULL) 96 if (original_asim != NULL)
97 return true; 97 return true;
98#endif 98# endif
99# ifdef ENABLE_TRANSPARENCY 99# ifdef ENABLE_TRANSPARENCY
100 if (flags & isTransparent) 100 if (flags & isTransparent)
101 { 101 {
102 if ((flags & blurNeeded) 102 if ((flags & blurNeeded)
103 || ((flags & tintNeeded) && !(flags & tintServerSide))) 103 || ((flags & tintNeeded) && !(flags & tintServerSide)))
633 else if (tint) 633 else if (tint)
634 { 634 {
635 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 635 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
636 tint->get (c); 636 tint->get (c);
637 637
638 flags |= bgPixmap_t::tintNeeded;
639 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) 638 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
640 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 639 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
641 { 640 {
642 flags |= bgPixmap_t::tintNeeded; 641 flags |= bgPixmap_t::tintNeeded;
643#define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) 642# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
644 if (IS_COMPONENT_WHOLESOME (c.r) 643 if (IS_COMPONENT_WHOLESOME (c.r)
645 && IS_COMPONENT_WHOLESOME (c.g) 644 && IS_COMPONENT_WHOLESOME (c.g)
646 && IS_COMPONENT_WHOLESOME (c.b)) 645 && IS_COMPONENT_WHOLESOME (c.b))
647 flags |= bgPixmap_t::tintServerSide; 646 flags |= bgPixmap_t::tintServerSide;
648#undef IS_COMPONENT_WHOLESOME 647# undef IS_COMPONENT_WHOLESOME
649 } 648 }
650 } 649 }
651 return flags; 650 return flags;
652} 651}
653 652
812 } 811 }
813 } 812 }
814 813
815 if (tiled_root_pmap != None) 814 if (tiled_root_pmap != None)
816 { 815 {
817 if (flags & tintNeeded) 816 if (flags & tintNeeded && !need_client_side_rendering ())
818 { 817 {
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 818 /* In this case we can tint image server-side getting significant
826 * performance improvements, as we eliminate XImage transfer 819 * performance improvements, as we eliminate XImage transfer
827 */ 820 */
828 gcv.foreground = Pixel (tint); 821 gcv.foreground = Pixel (tint);
829 gcv.function = GXand; 822 gcv.function = GXand;
830 gcv.fill_style = FillSolid; 823 gcv.fill_style = FillSolid;
831 if (gc) 824 if (gc)
832 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); 825 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv);
833 else 826 else
834 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); 827 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
835 if (gc) 828 if (gc)
836 { 829 {
837 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 830 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
838 result |= transpPmapTinted; 831 result |= transpPmapTinted;
839 }
840 } 832 }
841 } 833 }
842 if (pixmap) 834 if (pixmap)
843 XFreePixmap (dpy, pixmap); 835 XFreePixmap (dpy, pixmap);
844 pixmap = tiled_root_pmap; 836 pixmap = tiled_root_pmap;
871} 863}
872# endif /* ENABLE_TRANSPARENCY */ 864# endif /* ENABLE_TRANSPARENCY */
873 865
874# ifndef HAVE_AFTERIMAGE 866# ifndef HAVE_AFTERIMAGE
875static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 867static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm);
876#endif 868# endif
877 869
878 870
879bool 871bool
880bgPixmap_t::render () 872bgPixmap_t::render ()
881{ 873{
906 ASImage *background = NULL; 898 ASImage *background = NULL;
907 ARGB32 as_tint = TINT_LEAVE_SAME; 899 ARGB32 as_tint = TINT_LEAVE_SAME;
908 if (background_flags) 900 if (background_flags)
909 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 901 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
910 902
903# ifdef ENABLE_TRANSPARENCY
911 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 904 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
912 { 905 {
913 ShadingInfo as_shade; 906 ShadingInfo as_shade;
914 as_shade.shading = (shade == 0) ? 100 : shade; 907 as_shade.shading = (shade == 0) ? 100 : shade;
915 908
920 as_shade.tintColor.green = c.g; 913 as_shade.tintColor.green = c.g;
921 as_shade.tintColor.blue = c.b; 914 as_shade.tintColor.blue = c.b;
922 915
923 as_tint = shading2tint32 (&as_shade); 916 as_tint = shading2tint32 (&as_shade);
924 } 917 }
925
926 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 918 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
927 { 919 {
928 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 920 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, 921 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
930 100, ASIMAGE_QUALITY_DEFAULT); 922 100, ASIMAGE_QUALITY_DEFAULT);
932 { 924 {
933 destroy_asimage (&background); 925 destroy_asimage (&background);
934 background = tmp; 926 background = tmp;
935 } 927 }
936 } 928 }
929# endif
937 930
938 if (render_asim (background, as_tint)) 931 if (render_asim (background, as_tint))
939 flags = flags & ~isInvalid; 932 flags = flags & ~isInvalid;
940 if (background) 933 if (background)
941 destroy_asimage (&background); 934 destroy_asimage (&background);
954 if (flags & tintSet) 947 if (flags & tintSet)
955 tint.get (c); 948 tint.get (c);
956 ShadeXImage (target, result, shade, c.r, c.g, c.b); 949 ShadeXImage (target, result, shade, c.r, c.g, c.b);
957 } 950 }
958 } 951 }
959# endif 952# endif /* HAVE_AFTERIMAGE */
960 if (result != NULL) 953 if (result != NULL)
961 { 954 {
962 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 955 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
963 if (gc) 956 if (gc)
964 { 957 {
965 if (pmap_depth != target->depth && pixmap != None) 958 if (/*pmap_depth != target->depth &&*/ pixmap != None)
966 { 959 {
967 XFreePixmap (target->dpy, pixmap); 960 XFreePixmap (target->dpy, pixmap);
968 pixmap = None; 961 pixmap = None;
969 } 962 }
970 if (pixmap == None) 963 if (pixmap == None)
972 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); 965 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth);
973 pmap_width = result->width; 966 pmap_width = result->width;
974 pmap_height = result->height; 967 pmap_height = result->height;
975 pmap_depth = target->depth; 968 pmap_depth = target->depth;
976 } 969 }
970 if (pmap_depth != result->depth)
971 { /* Bad Match error will ensue ! stupid X !!!! */
972 if( result->depth == 24 && pmap_depth == 32)
973 result->depth = 32;
974 else if( result->depth == 32 && pmap_depth == 24)
975 result->depth = 24;
976 else
977 {
978 /* TODO: implement image recoding */
979 }
980 }
981 if (pmap_depth == result->depth)
977 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 982 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
978 XFreeGC (target->dpy, gc); 983 XFreeGC (target->dpy, gc);
979 flags = flags & ~isInvalid; 984 flags = flags & ~isInvalid;
980 } 985 }
981 XDestroyImage (result); 986 XDestroyImage (result);
982 } 987 }
986 if (pixmap != None) 991 if (pixmap != None)
987 { 992 {
988 XFreePixmap (target->dpy, pixmap); 993 XFreePixmap (target->dpy, pixmap);
989 pixmap = None; 994 pixmap = None;
990 } 995 }
991// TODO : we need to get rid of that garbadge :
992 target->am_transparent = target->am_pixmap_trans = 0;
993 } 996 }
994 else
995 target->am_transparent = target->am_pixmap_trans = 1;
996 997
997 apply (); 998 apply ();
998 999
999 return true; 1000 return true;
1000} 1001}
1056 } 1057 }
1057 /* don't want Expose on the parent */ 1058 /* don't want Expose on the parent */
1058 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); 1059 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False);
1059 /* do want Expose on the vt */ 1060 /* do want Expose on the vt */
1060 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); 1061 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True);
1061#if HAVE_SCROLLBARS 1062# if HAVE_SCROLLBARS
1062 if (target->scrollBar.win) 1063 if (target->scrollBar.win)
1063 { 1064 {
1064 target->scrollBar.setIdle (); 1065 target->scrollBar.setIdle ();
1065 target->scrollbar_show (0); 1066 target->scrollbar_show (0);
1066 } 1067 }
1067#endif 1068# endif
1068 /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ 1069 /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */
1070 target->want_refresh = 1;
1071# ifdef ENABLE_TRANSPARENCY
1069 target->want_refresh = target->want_full_refresh = 1; 1072 target->want_full_refresh = 1;
1073# endif
1070 /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ 1074 /* TODO: why do we need a flush here ??? It causes segfault on resize ! */
1071// target->flush (); 1075// target->flush ();
1072 } 1076 }
1073} 1077}
1074#endif /* HAVE_BG_PIXMAP */
1075
1076 1078
1077void 1079void
1078rxvt_term::get_window_origin (int &x, int &y) 1080rxvt_term::get_window_origin (int &x, int &y)
1079{ 1081{
1080 Window cr; 1082 Window cr;
1101 } 1103 }
1102 } 1104 }
1103 return None; 1105 return None;
1104} 1106}
1105 1107
1108/*
1109 * Check our parents are still who we think they are.
1110 * Do transparency updates if required
1111 */
1112int
1113rxvt_term::update_background ()
1114{
1115 bgPixmap.invalidate();
1116 /* no chance of real time refresh if we are blurring ! */
1117 if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded))
1118 bgPixmap.render();
1119 else
1120 {
1121 update_background_ev.stop ();
1122 if (!bgPixmap.need_client_side_rendering())
1123 update_background_ev.start (NOW + .05);
1124 else if (bgPixmap.flags & bgPixmap_t::blurNeeded)
1125 update_background_ev.start (NOW + .2); /* very slow !!! */
1126 else
1127 update_background_ev.start (NOW + .07);
1128 }
1129 return 0;
1130}
1106 1131
1107#ifdef ENABLE_TRANSPARENCY 1132void
1108#ifndef HAVE_AFTERIMAGE 1133rxvt_term::update_background_cb (time_watcher &w)
1134{
1135 bgPixmap.render ();
1136}
1137#endif /* HAVE_BG_PIXMAP */
1138
1139#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1109/* taken from aterm-0.4.2 */ 1140/* taken from aterm-0.4.2 */
1110 1141
1111typedef uint32_t RUINT32T; 1142typedef uint32_t RUINT32T;
1112 1143
1113static void 1144static void
1336 } 1367 }
1337 } 1368 }
1338 1369
1339 free (lookup); 1370 free (lookup);
1340} 1371}
1341#endif 1372#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 1373
1375#if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ 1374#if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */
1376void 1375void
1377rxvt_term::check_our_parents_cb (time_watcher &w) 1376rxvt_term::check_our_parents_cb (time_watcher &w)
1378{ 1377{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines