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.9 by sasha, Mon Oct 29 13:39:43 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
318 else if (!(flags & geometrySet)) 318 else if (!(flags & geometrySet))
319 { /* default geometry - scaled and centered */ 319 { /* default geometry - scaled and centered */
320 x = y = defaultAlign; 320 x = y = defaultAlign;
321 w = h = defaultScale; 321 w = h = defaultScale;
322 } 322 }
323 323
324 if (!(flags & geometrySet)) 324 if (!(flags & geometrySet))
325 geom_flags |= WidthValue|HeightValue|XValue|YValue; 325 geom_flags |= WidthValue|HeightValue|XValue|YValue;
326 326
327 if (ops) 327 if (ops)
328 { 328 {
449 { 449 {
450 result = original_asim; 450 result = original_asim;
451 if ((w > 0 && w != original_asim->width) 451 if ((w > 0 && w != original_asim->width)
452 || (h > 0 && h != original_asim->height)) 452 || (h > 0 && h != original_asim->height))
453 { 453 {
454 result = scale_asimage (target->asv, original_asim, 454 result = scale_asimage (target->asv, original_asim,
455 w > 0 ? w : original_asim->width, 455 w > 0 ? w : original_asim->width,
456 h > 0 ? h : original_asim->height, 456 h > 0 ? h : original_asim->height,
457 background ? ASA_ASImage : ASA_XImage, 457 background ? ASA_ASImage : ASA_XImage,
458 100, ASIMAGE_QUALITY_DEFAULT); 458 100, ASIMAGE_QUALITY_DEFAULT);
459 } 459 }
460 if (background == NULL) 460 if (background == NULL)
465 new_pmap_height = result->height; 465 new_pmap_height = result->height;
466 /* 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 */
467 if (h_scale == 0 || v_scale == 0) 467 if (h_scale == 0 || v_scale == 0)
468 { 468 {
469 ASImage *tmp = tile_asimage (target->asv, result, 469 ASImage *tmp = tile_asimage (target->asv, result,
470 (h_scale > 0) ? 0 : (int)result->width - x, 470 (h_scale > 0) ? 0 : (int)result->width - x,
471 (v_scale > 0) ? 0 : (int)result->height - y, 471 (v_scale > 0) ? 0 : (int)result->height - y,
472 result->width, result->height, 472 result->width, result->height,
473 TINT_LEAVE_SAME, ASA_XImage, 473 TINT_LEAVE_SAME, ASA_XImage,
474 100, ASIMAGE_QUALITY_DEFAULT); 474 100, ASIMAGE_QUALITY_DEFAULT);
475 if (tmp) 475 if (tmp)
476 { 476 {
578 } 578 }
579 579
580 /* put result on pixmap */ 580 /* put result on pixmap */
581 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 581 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
582 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);
583 583
584 if (result != background && result != original_asim) 584 if (result != background && result != original_asim)
585 destroy_asimage (&result); 585 destroy_asimage (&result);
586 586
587 XFreeGC (target->dpy, gc); 587 XFreeGC (target->dpy, gc);
588 TIMING_TEST_PRINT_RESULT (asim); 588 TIMING_TEST_PRINT_RESULT (asim);
614 f[len] = '\0'; 614 f[len] = '\0';
615 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 615 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
616 free (f); 616 free (f);
617 } 617 }
618 return (original_asim != NULL); 618 return (original_asim != NULL);
619# endif 619# endif
620 } 620 }
621 return false; 621 return false;
622} 622}
623 623
624# endif /* BG_IMAGE_FROM_FILE */ 624# endif /* BG_IMAGE_FROM_FILE */
625 625
626# ifdef ENABLE_TRANSPARENCY 626# ifdef ENABLE_TRANSPARENCY
627bool 627bool
628bgPixmap_t::set_transparent () 628bgPixmap_t::set_transparent ()
629{ 629{
630 if (!(flags & isTransparent)) 630 if (!(flags & isTransparent))
631 { 631 {
632 flags |= isTransparent; 632 flags |= isTransparent;
657 if (v_blurRadius != vr) 657 if (v_blurRadius != vr)
658 { 658 {
659 ++changed; 659 ++changed;
660 v_blurRadius = vr; 660 v_blurRadius = vr;
661 } 661 }
662 662
663 if (v_blurRadius == 0 && h_blurRadius == 0) 663 if (v_blurRadius == 0 && h_blurRadius == 0)
664 flags &= ~blurNeeded; 664 flags &= ~blurNeeded;
665 else 665 else
666 flags |= blurNeeded; 666 flags |= blurNeeded;
667 667
694 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 694 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
695 { 695 {
696 flags |= bgPixmap_t::tintNeeded; 696 flags |= bgPixmap_t::tintNeeded;
697 } 697 }
698 } 698 }
699 699
700 if (flags & bgPixmap_t::tintNeeded) 700 if (flags & bgPixmap_t::tintNeeded)
701 { 701 {
702 if (flags & bgPixmap_t::tintWholesome) 702 if (flags & bgPixmap_t::tintWholesome)
703 flags |= bgPixmap_t::tintServerSide; 703 flags |= bgPixmap_t::tintServerSide;
704 else 704 else
756 return true; 756 return true;
757 } 757 }
758 return false; 758 return false;
759} 759}
760 760
761/* make_transparency_pixmap() 761/* make_transparency_pixmap()
762 * 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
763 * 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
764 * our window. 764 * our window.
765 */ 765 */
766unsigned long 766unsigned long
767bgPixmap_t::make_transparency_pixmap () 767bgPixmap_t::make_transparency_pixmap ()
768{ 768{
884 } 884 }
885 TIMING_TEST_PRINT_RESULT (tp); 885 TIMING_TEST_PRINT_RESULT (tp);
886 886
887 if (tiled_root_pmap != None) 887 if (tiled_root_pmap != None)
888 { 888 {
889 if (!need_client_side_rendering ()) 889 if (!need_client_side_rendering ())
890 { 890 {
891 if ((flags & tintNeeded)) 891 if ((flags & tintNeeded))
892 { 892 {
893 if (flags & tintWholesome) 893 if (flags & tintWholesome)
894 { 894 {
895 /* In this case we can tint image server-side getting significant 895 /* In this case we can tint image server-side getting significant
896 * performance improvements, as we eliminate XImage transfer 896 * performance improvements, as we eliminate XImage transfer
956 956
957 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 957 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
958 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 958 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
959 XFreePixmap (dpy, overlay_pmap); 959 XFreePixmap (dpy, overlay_pmap);
960 960
961 pa.component_alpha = True; 961 pa.component_alpha = True;
962 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 962 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
963 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);
964 XFreePixmap (dpy, mask_pmap); 964 XFreePixmap (dpy, mask_pmap);
965 965
966 if (mask_pic && overlay_pic && back_pic) 966 if (mask_pic && overlay_pic && back_pic)
982 XRenderFreePicture (dpy, mask_pic); 982 XRenderFreePicture (dpy, mask_pic);
983 XRenderFreePicture (dpy, overlay_pic); 983 XRenderFreePicture (dpy, overlay_pic);
984 XRenderFreePicture (dpy, back_pic); 984 XRenderFreePicture (dpy, back_pic);
985# if DO_TIMING_TEST 985# if DO_TIMING_TEST
986 XSync (dpy, False); 986 XSync (dpy, False);
987# endif 987# endif
988# endif 988# endif
989 } 989 }
990 } 990 }
991 } /* server side rendering completed */ 991 } /* server side rendering completed */
992 992
996 pixmap = tiled_root_pmap; 996 pixmap = tiled_root_pmap;
997 pmap_width = window_width; 997 pmap_width = window_width;
998 pmap_height = window_height; 998 pmap_height = window_height;
999 pmap_depth = root_depth; 999 pmap_depth = root_depth;
1000 } 1000 }
1001 1001
1002 if (gc) 1002 if (gc)
1003 XFreeGC (dpy, gc); 1003 XFreeGC (dpy, gc);
1004 1004
1005 TIMING_TEST_PRINT_RESULT (tp); 1005 TIMING_TEST_PRINT_RESULT (tp);
1006 1006
1007 return result; 1007 return result;
1008} 1008}
1009 1009
1010bool 1010bool
1011bgPixmap_t::set_root_pixmap () 1011bgPixmap_t::set_root_pixmap ()
1012{ 1012{
1013 Pixmap new_root_pixmap = None; 1013 Pixmap new_root_pixmap = None;
1014 1014
1015 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1015 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1016 if (new_root_pixmap == None) 1016 if (new_root_pixmap == None)
1017 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1017 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1018 1018
1019 if (new_root_pixmap != root_pixmap) 1019 if (new_root_pixmap != root_pixmap)
1167 1167
1168 apply (); 1168 apply ();
1169 1169
1170 TIMING_TEST_PRINT_RESULT (tp); 1170 TIMING_TEST_PRINT_RESULT (tp);
1171 1171
1172 return true; 1172 return true;
1173} 1173}
1174 1174
1175bool 1175bool
1176bgPixmap_t::set_target (rxvt_term *new_target) 1176bgPixmap_t::set_target (rxvt_term *new_target)
1177{ 1177{
1178 if (new_target) 1178 if (new_target)
1179 if (target != new_target) 1179 if (target != new_target)
1180 { 1180 {
1227# if HAVE_SCROLLBARS 1227# if HAVE_SCROLLBARS
1228 if (target->scrollBar.win) 1228 if (target->scrollBar.win)
1229 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1229 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1230# endif 1230# endif
1231 } 1231 }
1232 /* don't want Expose on the parent or vt. It is better to use 1232 /* don't want Expose on the parent or vt. It is better to use
1233 scr_touch or we get a great deal of flicker otherwise: */ 1233 scr_touch or we get a great deal of flicker otherwise: */
1234 XClearWindow (target->dpy, target->parent[0]); 1234 XClearWindow (target->dpy, target->parent[0]);
1235 1235
1236# if HAVE_SCROLLBARS 1236# if HAVE_SCROLLBARS
1237 if (target->scrollBar.win) 1237 if (target->scrollBar.win)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines