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

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.4 by ayin, Fri Sep 14 09:38:33 2007 UTC vs.
Revision 1.10 by ayin, Wed Oct 31 09:55:23 2007 UTC

31 31
32#if DO_TIMING_TEST 32#if DO_TIMING_TEST
33#define TIMING_TEST_START(id) \ 33#define TIMING_TEST_START(id) \
34 struct timeval timing_test_##id##_stv;\ 34 struct timeval timing_test_##id##_stv;\
35 gettimeofday (&timing_test_##id##_stv, NULL); 35 gettimeofday (&timing_test_##id##_stv, NULL);
36 36
37#define TIMING_TEST_PRINT_RESULT(id) \ 37#define TIMING_TEST_PRINT_RESULT(id) \
38 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 38 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\
39 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 39 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\
40 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) 40 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0)
41 41
130 return true; 130 return true;
131# endif 131# endif
132# ifdef ENABLE_TRANSPARENCY 132# ifdef ENABLE_TRANSPARENCY
133 if (flags & isTransparent) 133 if (flags & isTransparent)
134 { 134 {
135# ifdef HAVE_AFTERIMAGE // can't blur without libAI anyways
135 if (((flags & blurNeeded) && !(flags & blurServerSide)) 136 if ((flags & blurNeeded) && !(flags & blurServerSide))
137 return true;
138# endif
136 || ((flags & tintNeeded) && !(flags & tintServerSide))) 139 if ((flags & tintNeeded) && !(flags & tintServerSide))
137 return true; 140 return true;
138 } 141 }
139# endif 142# endif
140 return false; 143 return false;
141} 144}
142 145
315 else if (!(flags & geometrySet)) 318 else if (!(flags & geometrySet))
316 { /* default geometry - scaled and centered */ 319 { /* default geometry - scaled and centered */
317 x = y = defaultAlign; 320 x = y = defaultAlign;
318 w = h = defaultScale; 321 w = h = defaultScale;
319 } 322 }
320 323
321 if (!(flags & geometrySet)) 324 if (!(flags & geometrySet))
322 geom_flags |= WidthValue|HeightValue|XValue|YValue; 325 geom_flags |= WidthValue|HeightValue|XValue|YValue;
323 326
324 if (ops) 327 if (ops)
325 { 328 {
446 { 449 {
447 result = original_asim; 450 result = original_asim;
448 if ((w > 0 && w != original_asim->width) 451 if ((w > 0 && w != original_asim->width)
449 || (h > 0 && h != original_asim->height)) 452 || (h > 0 && h != original_asim->height))
450 { 453 {
451 result = scale_asimage (target->asv, original_asim, 454 result = scale_asimage (target->asv, original_asim,
452 w > 0 ? w : original_asim->width, 455 w > 0 ? w : original_asim->width,
453 h > 0 ? h : original_asim->height, 456 h > 0 ? h : original_asim->height,
454 background ? ASA_ASImage : ASA_XImage, 457 background ? ASA_ASImage : ASA_XImage,
455 100, ASIMAGE_QUALITY_DEFAULT); 458 100, ASIMAGE_QUALITY_DEFAULT);
456 } 459 }
457 if (background == NULL) 460 if (background == NULL)
462 new_pmap_height = result->height; 465 new_pmap_height = result->height;
463 /* we also need to tile our image in one or both directions */ 466 /* we also need to tile our image in one or both directions */
464 if (h_scale == 0 || v_scale == 0) 467 if (h_scale == 0 || v_scale == 0)
465 { 468 {
466 ASImage *tmp = tile_asimage (target->asv, result, 469 ASImage *tmp = tile_asimage (target->asv, result,
467 (h_scale > 0) ? 0 : (int)result->width - x, 470 (h_scale > 0) ? 0 : (int)result->width - x,
468 (v_scale > 0) ? 0 : (int)result->height - y, 471 (v_scale > 0) ? 0 : (int)result->height - y,
469 result->width, result->height, 472 result->width, result->height,
470 TINT_LEAVE_SAME, ASA_XImage, 473 TINT_LEAVE_SAME, ASA_XImage,
471 100, ASIMAGE_QUALITY_DEFAULT); 474 100, ASIMAGE_QUALITY_DEFAULT);
472 if (tmp) 475 if (tmp)
473 { 476 {
575 } 578 }
576 579
577 /* put result on pixmap */ 580 /* put result on pixmap */
578 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 581 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
579 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); 582 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True);
580 583
581 if (result != background && result != original_asim) 584 if (result != background && result != original_asim)
582 destroy_asimage (&result); 585 destroy_asimage (&result);
583 586
584 XFreeGC (target->dpy, gc); 587 XFreeGC (target->dpy, gc);
585 TIMING_TEST_PRINT_RESULT (asim); 588 TIMING_TEST_PRINT_RESULT (asim);
611 f[len] = '\0'; 614 f[len] = '\0';
612 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 615 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
613 free (f); 616 free (f);
614 } 617 }
615 return (original_asim != NULL); 618 return (original_asim != NULL);
616# endif 619# endif
617 } 620 }
618 return false; 621 return false;
619} 622}
620 623
621# endif /* BG_IMAGE_FROM_FILE */ 624# endif /* BG_IMAGE_FROM_FILE */
622 625
623# ifdef ENABLE_TRANSPARENCY 626# ifdef ENABLE_TRANSPARENCY
624bool 627bool
625bgPixmap_t::set_transparent () 628bgPixmap_t::set_transparent ()
626{ 629{
627 if (!(flags & isTransparent)) 630 if (!(flags & isTransparent))
628 { 631 {
629 flags |= isTransparent; 632 flags |= isTransparent;
654 if (v_blurRadius != vr) 657 if (v_blurRadius != vr)
655 { 658 {
656 ++changed; 659 ++changed;
657 v_blurRadius = vr; 660 v_blurRadius = vr;
658 } 661 }
659 662
660 if (v_blurRadius == 0 && h_blurRadius == 0) 663 if (v_blurRadius == 0 && h_blurRadius == 0)
661 flags &= ~blurNeeded; 664 flags &= ~blurNeeded;
662 else 665 else
663 flags |= blurNeeded; 666 flags |= blurNeeded;
664 667
691 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 694 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
692 { 695 {
693 flags |= bgPixmap_t::tintNeeded; 696 flags |= bgPixmap_t::tintNeeded;
694 } 697 }
695 } 698 }
696 699
697 if (flags & bgPixmap_t::tintNeeded) 700 if (flags & bgPixmap_t::tintNeeded)
698 { 701 {
699 if (flags & bgPixmap_t::tintWholesome) 702 if (flags & bgPixmap_t::tintWholesome)
700 flags |= bgPixmap_t::tintServerSide; 703 flags |= bgPixmap_t::tintServerSide;
701 else 704 else
738bool 741bool
739bgPixmap_t::set_shade (const char *shade_str) 742bgPixmap_t::set_shade (const char *shade_str)
740{ 743{
741 int new_shade = (shade_str) ? atoi (shade_str) : 0; 744 int new_shade = (shade_str) ? atoi (shade_str) : 0;
742 745
746 if (new_shade < 0 && new_shade > -100)
747 new_shade = 200 - (100 + new_shade);
743 if (new_shade == 100) 748 else if (new_shade == 100)
744 new_shade = 0; 749 new_shade = 0;
745 750
746 if (new_shade != shade) 751 if (new_shade != shade)
747 { 752 {
748 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); 753 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade);
751 return true; 756 return true;
752 } 757 }
753 return false; 758 return false;
754} 759}
755 760
756/* make_transparency_pixmap() 761/* make_transparency_pixmap()
757 * Builds a pixmap sized the same as terminal window, with depth same as the root window 762 * Builds a pixmap sized the same as terminal window, with depth same as the root window
758 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by 763 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by
759 * our window. 764 * our window.
760 */ 765 */
761unsigned long 766unsigned long
762bgPixmap_t::make_transparency_pixmap () 767bgPixmap_t::make_transparency_pixmap ()
763{ 768{
862 else 867 else
863 {/* strightforward pixmap copy */ 868 {/* strightforward pixmap copy */
864 gcv.tile = root_pixmap; 869 gcv.tile = root_pixmap;
865 gcv.fill_style = FillTiled; 870 gcv.fill_style = FillTiled;
866 871
867 while (sx < 0) sx += (int)window_width; 872 while (sx < 0) sx += (int)root_width;
868 while (sy < 0) sy += (int)window_height; 873 while (sy < 0) sy += (int)root_height;
869 874
870 gcv.ts_x_origin = -sx; 875 gcv.ts_x_origin = -sx;
871 gcv.ts_y_origin = -sy; 876 gcv.ts_y_origin = -sy;
872 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 877 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
873 878
879 } 884 }
880 TIMING_TEST_PRINT_RESULT (tp); 885 TIMING_TEST_PRINT_RESULT (tp);
881 886
882 if (tiled_root_pmap != None) 887 if (tiled_root_pmap != None)
883 { 888 {
884 if (!need_client_side_rendering ()) 889 if (!need_client_side_rendering ())
885 { 890 {
886 if ((flags & tintNeeded)) 891 if ((flags & tintNeeded))
887 { 892 {
888 if (flags & tintWholesome) 893 if (flags & tintWholesome)
889 { 894 {
890 /* In this case we can tint image server-side getting significant 895 /* In this case we can tint image server-side getting significant
891 * performance improvements, as we eliminate XImage transfer 896 * performance improvements, as we eliminate XImage transfer
932 pf.direct.greenMask = 0xff; 937 pf.direct.greenMask = 0xff;
933 pf.direct.blueMask = 0xff; 938 pf.direct.blueMask = 0xff;
934 pf.direct.alphaMask = 0xff; 939 pf.direct.alphaMask = 0xff;
935 940
936 XRenderPictFormat *solid_format = XRenderFindFormat (dpy, 941 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
937 (PictFormatType| 942 (PictFormatType|
938 PictFormatDepth| 943 PictFormatDepth|
939 PictFormatRedMask| 944 PictFormatRedMask|
940 PictFormatGreenMask| 945 PictFormatGreenMask|
941 PictFormatBlueMask| 946 PictFormatBlueMask|
942 PictFormatAlphaMask), 947 PictFormatAlphaMask),
943 &pf, 948 &pf,
944 0); 949 0);
945 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); 950 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
946 XRenderPictureAttributes pa ; 951 XRenderPictureAttributes pa ;
947 952
948 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); 953 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa);
949 954
951 956
952 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 957 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
953 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 958 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
954 XFreePixmap (dpy, overlay_pmap); 959 XFreePixmap (dpy, overlay_pmap);
955 960
956 pa.component_alpha = True; 961 pa.component_alpha = True;
957 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 962 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
958 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 963 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
959 XFreePixmap (dpy, mask_pmap); 964 XFreePixmap (dpy, mask_pmap);
960 965
961 if (mask_pic && overlay_pic && back_pic) 966 if (mask_pic && overlay_pic && back_pic)
977 XRenderFreePicture (dpy, mask_pic); 982 XRenderFreePicture (dpy, mask_pic);
978 XRenderFreePicture (dpy, overlay_pic); 983 XRenderFreePicture (dpy, overlay_pic);
979 XRenderFreePicture (dpy, back_pic); 984 XRenderFreePicture (dpy, back_pic);
980# if DO_TIMING_TEST 985# if DO_TIMING_TEST
981 XSync (dpy, False); 986 XSync (dpy, False);
982# endif 987# endif
983# endif 988# endif
984 } 989 }
985 } 990 }
986 } /* server side rendering completed */ 991 } /* server side rendering completed */
987 992
991 pixmap = tiled_root_pmap; 996 pixmap = tiled_root_pmap;
992 pmap_width = window_width; 997 pmap_width = window_width;
993 pmap_height = window_height; 998 pmap_height = window_height;
994 pmap_depth = root_depth; 999 pmap_depth = root_depth;
995 } 1000 }
996 1001
997 if (gc) 1002 if (gc)
998 XFreeGC (dpy, gc); 1003 XFreeGC (dpy, gc);
999 1004
1000 TIMING_TEST_PRINT_RESULT (tp); 1005 TIMING_TEST_PRINT_RESULT (tp);
1001 1006
1002 return result; 1007 return result;
1003} 1008}
1004 1009
1005bool 1010bool
1006bgPixmap_t::set_root_pixmap () 1011bgPixmap_t::set_root_pixmap ()
1007{ 1012{
1008 Pixmap new_root_pixmap = None; 1013 Pixmap new_root_pixmap = None;
1009 1014
1010 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1015 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1011 if (new_root_pixmap == None) 1016 if (new_root_pixmap == None)
1012 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1017 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1013 1018
1014 if (new_root_pixmap != root_pixmap) 1019 if (new_root_pixmap != root_pixmap)
1094 } 1099 }
1095 else if (background_flags && pmap_depth != target->depth) 1100 else if (background_flags && pmap_depth != target->depth)
1096 { 1101 {
1097 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1102 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1098 } 1103 }
1104
1099# else /* our own client-side tinting */ 1105# elif !XFT /* our own client-side tinting */
1106
1107 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side.
1108 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1109
1100 if (background_flags && (flags & isInvalid)) 1110 if (background_flags && (flags & isInvalid))
1101 { 1111 {
1102 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1112 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1103 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1113 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1104 { 1114 {
1157 1167
1158 apply (); 1168 apply ();
1159 1169
1160 TIMING_TEST_PRINT_RESULT (tp); 1170 TIMING_TEST_PRINT_RESULT (tp);
1161 1171
1162 return true; 1172 return true;
1163} 1173}
1164 1174
1165bool 1175bool
1166bgPixmap_t::set_target (rxvt_term *new_target) 1176bgPixmap_t::set_target (rxvt_term *new_target)
1167{ 1177{
1168 if (new_target) 1178 if (new_target)
1169 if (target != new_target) 1179 if (target != new_target)
1170 { 1180 {
1217# if HAVE_SCROLLBARS 1227# if HAVE_SCROLLBARS
1218 if (target->scrollBar.win) 1228 if (target->scrollBar.win)
1219 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1229 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1220# endif 1230# endif
1221 } 1231 }
1222 1232 /* don't want Expose on the parent or vt. It is better to use
1223 /* don't want Expose on the parent */ 1233 scr_touch or we get a great deal of flicker otherwise: */
1224 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); 1234 XClearWindow (target->dpy, target->parent[0]);
1225 /* do want Expose on the vt, so we get refreshed properly */
1226 XClearArea (target->dpy, target->vt, 0, 0, 0, 0, True);
1227 1235
1228# if HAVE_SCROLLBARS 1236# if HAVE_SCROLLBARS
1229 if (target->scrollBar.win) 1237 if (target->scrollBar.win)
1230 { 1238 {
1231 target->scrollBar.setIdle (); 1239 target->scrollBar.setIdle ();
1232 target->scrollbar_show (0); 1240 target->scrollbar_show (0);
1233 } 1241 }
1234# endif 1242# endif
1243
1244 target->want_refresh = 1;
1245 flags |= hasChanged;
1235 } 1246 }
1236} 1247}
1237 1248
1238#endif /* HAVE_BG_PIXMAP */ 1249#endif /* HAVE_BG_PIXMAP */
1239 1250
1240#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1251#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT
1241/* taken from aterm-0.4.2 */ 1252/* taken from aterm-0.4.2 */
1242 1253
1243typedef uint32_t RUINT32T; 1254typedef uint32_t RUINT32T;
1244 1255
1245static void 1256static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines