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.145 by sf-exg, Fri Jan 28 00:21:10 2011 UTC vs.
Revision 1.158 by sf-exg, Wed Aug 10 07:28:36 2011 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> 8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
52 * the tile size and origin. 52 * the tile size and origin.
53 * propscale When scaling, scale proportionally. That is, maintain the 53 * propscale When scaling, scale proportionally. That is, maintain the
54 * proper aspect ratio for the image. Any portion of the 54 * proper aspect ratio for the image. Any portion of the
55 * background not covered by the image is filled with the 55 * background not covered by the image is filled with the
56 * current background color. 56 * current background color.
57 * hscale Scale horizontally, tile vertically ?
58 * vscale Tile horizontally, scale vertically ?
59 * scale Scale both up and down 57 * scale Scale both up and down
60 * auto Same as 100x100+50+50
61 */ 58 */
62 59
63#ifdef HAVE_BG_PIXMAP 60#ifdef HAVE_BG_PIXMAP
64void 61void
65rxvt_term::bg_destroy () 62rxvt_term::bg_destroy ()
260 257
261 for (int i = 0; arr[i]; i++) 258 for (int i = 0; arr[i]; i++)
262 { 259 {
263 if (!strcasecmp (arr[i], "tile")) 260 if (!strcasecmp (arr[i], "tile"))
264 { 261 {
262 new_flags |= BG_TILE;
265 w = h = noScale; 263 w = h = noScale;
266 geom_flags |= WidthValue|HeightValue; 264 geom_flags |= WidthValue|HeightValue;
267 } 265 }
268 else if (!strcasecmp (arr[i], "propscale")) 266 else if (!strcasecmp (arr[i], "propscale"))
269 { 267 {
270 new_flags |= BG_PROP_SCALE; 268 new_flags |= BG_PROP_SCALE;
271 } 269 }
272 else if (!strcasecmp (arr[i], "hscale"))
273 {
274 if (w == 0) w = windowScale;
275
276 h = noScale;
277 geom_flags |= WidthValue|HeightValue;
278 }
279 else if (!strcasecmp (arr[i], "vscale"))
280 {
281 if (h == 0) h = windowScale;
282
283 w = noScale;
284 geom_flags |= WidthValue|HeightValue;
285 }
286 else if (!strcasecmp (arr[i], "scale")) 270 else if (!strcasecmp (arr[i], "scale"))
287 { 271 {
288 if (h == 0) h = windowScale; 272 if (h == 0) h = windowScale;
289 if (w == 0) w = windowScale; 273 if (w == 0) w = windowScale;
290 274
291 geom_flags |= WidthValue|HeightValue; 275 geom_flags |= WidthValue|HeightValue;
292 } 276 }
293 else if (!strcasecmp (arr[i], "auto"))
294 {
295 w = h = windowScale;
296 x = y = centerAlign;
297 geom_flags |= WidthValue|HeightValue|XValue|YValue;
298 }
299 else if (!strcasecmp (arr[i], "root")) 277 else if (!strcasecmp (arr[i], "root"))
300 { 278 {
301 new_flags |= BG_ROOT_ALIGN; 279 new_flags |= BG_TILE|BG_ROOT_ALIGN;
302 w = h = noScale; 280 w = h = noScale;
303 geom_flags |= WidthValue|HeightValue; 281 geom_flags |= WidthValue|HeightValue;
304 } 282 }
305 } /* done parsing ops */ 283 } /* done parsing ops */
306 284
353 x = make_align_position (h_align, target_width, w); 331 x = make_align_position (h_align, target_width, w);
354 y = make_align_position (v_align, target_height, h); 332 y = make_align_position (v_align, target_height, h);
355 } 333 }
356 334
357 bg_flags &= ~BG_IS_SIZE_SENSITIVE; 335 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
336 if (!(bg_flags & BG_TILE)
358 if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale 337 || (bg_flags & BG_PROP_SCALE) || h_scale || v_scale
359 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) 338 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
360 || w > target_width || h > target_height) 339 || w > target_width || h > target_height)
361 bg_flags |= BG_IS_SIZE_SENSITIVE; 340 bg_flags |= BG_IS_SIZE_SENSITIVE;
362} 341}
363 342
455 100, ASIMAGE_QUALITY_DEFAULT); 434 100, ASIMAGE_QUALITY_DEFAULT);
456 } 435 }
457 436
458 if (background == NULL) 437 if (background == NULL)
459 { 438 {
460 if (h_scale == 0 || v_scale == 0) 439 if (bg_flags & BG_TILE)
461 { 440 {
462 /* if tiling - pixmap has to be sized exactly as the image, 441 /* if tiling - pixmap has to be sized exactly as the image,
463 but there is no need to make it bigger than the window! */ 442 but there is no need to make it bigger than the window! */
464 new_pmap_width = min (result->width, target_width); 443 new_pmap_width = min (result->width, target_width);
465 new_pmap_height = min (result->height, target_height); 444 new_pmap_height = min (result->height, target_height);
490 layers[0].clip_width = target_width; 469 layers[0].clip_width = target_width;
491 layers[0].clip_height = target_height; 470 layers[0].clip_height = target_height;
492 layers[0].tint = background_tint; 471 layers[0].tint = background_tint;
493 layers[1].im = result; 472 layers[1].im = result;
494 473
495 if (h_scale == 0 || v_scale == 0) 474 if (bg_flags & BG_TILE)
496 { 475 {
497 /* tile horizontally */ 476 /* tile horizontally */
498 while (x > 0) x -= (int)result->width; 477 while (x > 0) x -= (int)result->width;
499 layers[1].dst_x = x; 478 layers[1].dst_x = x;
500 layers[1].clip_width = result->width+target_width; 479 layers[1].clip_width = result->width+target_width;
504 /* clip horizontally */ 483 /* clip horizontally */
505 layers[1].dst_x = x; 484 layers[1].dst_x = x;
506 layers[1].clip_width = result->width; 485 layers[1].clip_width = result->width;
507 } 486 }
508 487
509 if (h_scale == 0 || v_scale == 0) 488 if (bg_flags & BG_TILE)
510 { 489 {
511 while (y > 0) y -= (int)result->height; 490 while (y > 0) y -= (int)result->height;
512 layers[1].dst_y = y; 491 layers[1].dst_y = y;
513 layers[1].clip_height = result->height + target_height; 492 layers[1].clip_height = result->height + target_height;
514 } 493 }
564 543
565 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 544 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
566 int dst_width = result->width, dst_height = result->height; 545 int dst_width = result->width, dst_height = result->height;
567 if (background == NULL) 546 if (background == NULL)
568 { 547 {
569 if (!(h_scale == 0 || v_scale == 0)) 548 if (!(bg_flags & BG_TILE))
570 { 549 {
571 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); 550 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width );
572 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); 551 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
573 } 552 }
574 553
620 else if (depth == 15 || depth == 16) 599 else if (depth == 15 || depth == 16)
621 bytes_per_pixel = 2; 600 bytes_per_pixel = 2;
622 else 601 else
623 return false; 602 return false;
624 603
625 width_r = rxvt_popcount (visual->red_mask); 604 width_r = ecb_popcount32 (visual->red_mask);
626 width_g = rxvt_popcount (visual->green_mask); 605 width_g = ecb_popcount32 (visual->green_mask);
627 width_b = rxvt_popcount (visual->blue_mask); 606 width_b = ecb_popcount32 (visual->blue_mask);
628 607
629 if (width_r > 8 || width_g > 8 || width_b > 8) 608 if (width_r > 8 || width_g > 8 || width_b > 8)
630 return false; 609 return false;
631 610
632 sh_r = rxvt_ctz (visual->red_mask); 611 sh_r = ecb_ctz32 (visual->red_mask);
633 sh_g = rxvt_ctz (visual->green_mask); 612 sh_g = ecb_ctz32 (visual->green_mask);
634 sh_b = rxvt_ctz (visual->blue_mask); 613 sh_b = ecb_ctz32 (visual->blue_mask);
635 614
636 if (width > INT_MAX / height / bytes_per_pixel) 615 if (width > INT_MAX / height / bytes_per_pixel)
637 return false; 616 return false;
638 617
639 data = (char *)malloc (width * height * bytes_per_pixel); 618 data = (char *)malloc (width * height * bytes_per_pixel);
646 { 625 {
647 free (data); 626 free (data);
648 return false; 627 return false;
649 } 628 }
650 629
651 ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 630 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
652 631
653 rowstride = gdk_pixbuf_get_rowstride (pixbuf); 632 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
654 channels = gdk_pixbuf_get_n_channels (pixbuf); 633 channels = gdk_pixbuf_get_n_channels (pixbuf);
655 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 634 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
656 line = data; 635 line = data;
723 result = gdk_pixbuf_scale_simple (pixbuf, 702 result = gdk_pixbuf_scale_simple (pixbuf,
724 w, h, 703 w, h,
725 GDK_INTERP_BILINEAR); 704 GDK_INTERP_BILINEAR);
726 } 705 }
727 706
707 if (!result)
708 return false;
709
728 bool ret = false; 710 bool ret = false;
729 711
730 if (result)
731 {
732 XGCValues gcv; 712 XGCValues gcv;
733 GC gc; 713 GC gc;
734 Pixmap root_pmap; 714 Pixmap root_pmap;
735 715
736 image_width = gdk_pixbuf_get_width (result); 716 image_width = gdk_pixbuf_get_width (result);
737 image_height = gdk_pixbuf_get_height (result); 717 image_height = gdk_pixbuf_get_height (result);
738 718
739 if (tr_flags) 719 if (tr_flags)
740 { 720 {
741 root_pmap = bg_pixmap; 721 root_pmap = bg_pixmap;
742 bg_pixmap = None; 722 bg_pixmap = None;
723 }
724 else
725 {
726 if (bg_flags & BG_TILE)
743 } 727 {
744 else
745 {
746 if (h_scale == 0 || v_scale == 0)
747 {
748 new_pmap_width = min (image_width, target_width); 728 new_pmap_width = min (image_width, target_width);
749 new_pmap_height = min (image_height, target_height); 729 new_pmap_height = min (image_height, target_height);
750 } 730 }
751 } 731 }
752 732
753 if (bg_pixmap == None 733 if (bg_pixmap == None
754 || bg_pmap_width != new_pmap_width 734 || bg_pmap_width != new_pmap_width
755 || bg_pmap_height != new_pmap_height) 735 || bg_pmap_height != new_pmap_height)
756 { 736 {
757 if (bg_pixmap) 737 if (bg_pixmap)
758 XFreePixmap (dpy, bg_pixmap); 738 XFreePixmap (dpy, bg_pixmap);
759 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 739 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
760 bg_pmap_width = new_pmap_width; 740 bg_pmap_width = new_pmap_width;
761 bg_pmap_height = new_pmap_height; 741 bg_pmap_height = new_pmap_height;
762 } 742 }
763 743
764 gcv.foreground = pix_colors[Color_bg]; 744 gcv.foreground = pix_colors[Color_bg];
765 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 745 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
766 746
767 if (h_scale == 0 || v_scale == 0) 747 if (gc)
748 {
749 if (bg_flags & BG_TILE)
768 { 750 {
769 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 751 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
770 pixbuf_to_pixmap (result, tile, gc, 752 pixbuf_to_pixmap (result, tile, gc,
771 0, 0, 753 0, 0,
772 0, 0, 754 0, 0,
816 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 798 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
817 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 799 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
818 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 800 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
819 XFreePixmap (dpy, mask_pmap); 801 XFreePixmap (dpy, mask_pmap);
820 802
821 if (src && dst && mask)
822 {
823 XRenderColor mask_c; 803 XRenderColor mask_c;
824 804
825 mask_c.alpha = 0x8000; 805 mask_c.alpha = 0x8000;
826 mask_c.red = 0; 806 mask_c.red = 0;
827 mask_c.green = 0; 807 mask_c.green = 0;
828 mask_c.blue = 0; 808 mask_c.blue = 0;
829 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 809 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
830 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); 810 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
831 }
832 811
833 XRenderFreePicture (dpy, src); 812 XRenderFreePicture (dpy, src);
834 XRenderFreePicture (dpy, dst); 813 XRenderFreePicture (dpy, dst);
835 XRenderFreePicture (dpy, mask); 814 XRenderFreePicture (dpy, mask);
836
837 XFreePixmap (dpy, root_pmap);
838 } 815 }
839#endif 816#endif
840 817
841 if (result != pixbuf)
842 g_object_unref (result);
843
844 XFreeGC (dpy, gc); 818 XFreeGC (dpy, gc);
845 819
846 ret = true; 820 ret = true;
847 } 821 }
822
823 if (result != pixbuf)
824 g_object_unref (result);
825
826 if (tr_flags)
827 XFreePixmap (dpy, root_pmap);
848 828
849 return ret; 829 return ret;
850} 830}
851# endif /* HAVE_PIXBUF */ 831# endif /* HAVE_PIXBUF */
852 832
943 bg_flags |= BG_NEEDS_BLUR; 923 bg_flags |= BG_NEEDS_BLUR;
944 924
945 return changed; 925 return changed;
946} 926}
947 927
948static inline unsigned long 928void
949compute_tint_shade_flags (rxvt_color *tint, int shade) 929rxvt_term::set_tint_shade_flags ()
950{ 930{
951 unsigned long flags = 0;
952 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 931 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
953 bool has_shade = shade != 100; 932 bool has_shade = shade != 100;
954 933
955 if (tint) 934 bg_flags &= ~BG_TINT_FLAGS;
935
936 if (bg_flags & BG_TINT_SET)
956 { 937 {
957 tint->get (c); 938 tint.get (c);
958 if (!has_shade 939 if (!has_shade
959 && (c.r <= 0x00ff || c.r >= 0xff00) 940 && (c.r <= 0x00ff || c.r >= 0xff00)
960 && (c.g <= 0x00ff || c.g >= 0xff00) 941 && (c.g <= 0x00ff || c.g >= 0xff00)
961 && (c.b <= 0x00ff || c.b >= 0xff00)) 942 && (c.b <= 0x00ff || c.b >= 0xff00))
962 flags |= rxvt_term::BG_TINT_BITAND; 943 bg_flags |= BG_TINT_BITAND;
963 } 944 }
964 945
965 if (has_shade || tint) 946 if (has_shade || (bg_flags & BG_TINT_SET))
966 flags |= rxvt_term::BG_NEEDS_TINT; 947 bg_flags |= BG_NEEDS_TINT;
967
968 return flags;
969} 948}
970 949
971bool 950bool
972rxvt_term::bg_set_tint (rxvt_color &new_tint) 951rxvt_term::bg_set_tint (rxvt_color &new_tint)
973{ 952{
974 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 953 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
975 { 954 {
976 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
977 tint = new_tint; 955 tint = new_tint;
978 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; 956 bg_flags |= BG_TINT_SET;
957 set_tint_shade_flags ();
979 return true; 958 return true;
980 } 959 }
981 960
982 return false; 961 return false;
983} 962}
991 if (new_shade < 0) 970 if (new_shade < 0)
992 new_shade = 200 - (100 + new_shade); 971 new_shade = 200 - (100 + new_shade);
993 972
994 if (new_shade != shade) 973 if (new_shade != shade)
995 { 974 {
996 unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade);
997 shade = new_shade; 975 shade = new_shade;
998 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; 976 set_tint_shade_flags ();
999 return true; 977 return true;
1000 } 978 }
1001 979
1002 return false; 980 return false;
1003} 981}
1038 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1016 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1039 1017
1040 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1018 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1041 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1019 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1042 1020
1043 if (kernel && params && src && dst) 1021 if (kernel && params)
1044 { 1022 {
1045 if (h_blurRadius) 1023 if (h_blurRadius)
1046 { 1024 {
1047 size = h_blurRadius * 2 + 1; 1025 size = h_blurRadius * 2 + 1;
1048 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1026 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1113 } 1091 }
1114 } 1092 }
1115 else 1093 else
1116 { 1094 {
1117# if XRENDER 1095# if XRENDER
1118 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1096 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1119 1097
1120 if (bg_flags & BG_TINT_SET) 1098 if (bg_flags & BG_TINT_SET)
1121 tint.get (c); 1099 tint.get (c);
1122 1100
1123 if (shade <= 100) 1101 if (shade <= 100)
1124 { 1102 {
1125 c.r = (c.r * shade) / 100; 1103 c.r = c.r * shade / 100;
1126 c.g = (c.g * shade) / 100; 1104 c.g = c.g * shade / 100;
1127 c.b = (c.b * shade) / 100; 1105 c.b = c.b * shade / 100;
1128 } 1106 }
1129 else 1107 else
1130 { 1108 {
1131 c.r = (c.r * (200 - shade)) / 100; 1109 c.r = c.r * (200 - shade) / 100;
1132 c.g = (c.g * (200 - shade)) / 100; 1110 c.g = c.g * (200 - shade) / 100;
1133 c.b = (c.b * (200 - shade)) / 100; 1111 c.b = c.b * (200 - shade) / 100;
1134 } 1112 }
1135 1113
1136 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); 1114 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1137 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1115 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1138 XRenderPictureAttributes pa; 1116 XRenderPictureAttributes pa;
1145 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 1123 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1146 XFreePixmap (dpy, overlay_pmap); 1124 XFreePixmap (dpy, overlay_pmap);
1147 1125
1148 pa.component_alpha = True; 1126 pa.component_alpha = True;
1149 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1127 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1150 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 1128 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1151 XFreePixmap (dpy, mask_pmap); 1129 XFreePixmap (dpy, mask_pmap);
1152 1130
1153 if (mask_pic && overlay_pic && back_pic)
1154 {
1155 XRenderColor mask_c; 1131 XRenderColor mask_c;
1156 1132
1157 mask_c.red = mask_c.green = mask_c.blue = 0;
1158 mask_c.alpha = 0xffff; 1133 mask_c.alpha = 0xffff;
1134 mask_c.red =
1135 mask_c.green =
1136 mask_c.blue = 0;
1137 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1138
1139 mask_c.alpha = 0;
1140 mask_c.red = 0xffff - c.r;
1141 mask_c.green = 0xffff - c.g;
1142 mask_c.blue = 0xffff - c.b;
1143 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1144 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1145
1146 if (shade > 100)
1147 {
1148 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1149 mask_c.alpha = 0;
1159 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1150 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1160 1151
1161 mask_c.alpha = 0;
1162 mask_c.red = 0xffff - c.r;
1163 mask_c.green = 0xffff - c.g;
1164 mask_c.blue = 0xffff - c.b;
1165 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1166 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1167
1168 if (shade > 100)
1169 {
1170 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1171 mask_c.alpha = 0;
1172 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1173
1174 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1152 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1175 } 1153 }
1176 1154
1177 ret = true; 1155 ret = true;
1178 }
1179 1156
1180 XRenderFreePicture (dpy, mask_pic); 1157 XRenderFreePicture (dpy, mask_pic);
1181 XRenderFreePicture (dpy, overlay_pic); 1158 XRenderFreePicture (dpy, overlay_pic);
1182 XRenderFreePicture (dpy, back_pic); 1159 XRenderFreePicture (dpy, back_pic);
1183# endif 1160# endif
1184 } 1161 }
1185 1162
1186 return ret; 1163 return ret;
1187} 1164}
1188 1165
1189/* make_transparency_pixmap() 1166/*
1190 * Builds a pixmap of the same size as the terminal window that contains 1167 * Builds a pixmap of the same size as the terminal window that contains
1191 * the tiled portion of the root pixmap that is supposed to be covered by 1168 * the tiled portion of the root pixmap that is supposed to be covered by
1192 * our window. 1169 * our window.
1193 */ 1170 */
1194unsigned long 1171unsigned long
1238 if (root_pixmap != None && root_depth != depth) 1215 if (root_pixmap != None && root_depth != depth)
1239 { 1216 {
1240#if XRENDER 1217#if XRENDER
1241 if (bg_flags & BG_HAS_RENDER) 1218 if (bg_flags & BG_HAS_RENDER)
1242 { 1219 {
1220 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1221
1243 XRenderPictureAttributes pa; 1222 XRenderPictureAttributes pa;
1244 1223
1245 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1224 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1246 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1225 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1247 1226
1248 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1249 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1227 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1250 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1228 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1251 1229
1252 if (src && dst)
1253 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1230 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1254 else
1255 {
1256 XFreePixmap (dpy, recoded_root_pmap);
1257 root_pixmap = None;
1258 }
1259 1231
1260 XRenderFreePicture (dpy, src); 1232 XRenderFreePicture (dpy, src);
1261 XRenderFreePicture (dpy, dst); 1233 XRenderFreePicture (dpy, dst);
1262 } 1234 }
1263 else 1235 else
1264#endif 1236#endif
1265 root_pixmap = None; 1237 recoded_root_pmap = None;
1266 } 1238 }
1267 1239
1268 if (root_pixmap == None) 1240 if (recoded_root_pmap == None)
1269 return 0; 1241 return 0;
1270 1242
1271 if (bg_pixmap == None 1243 if (bg_pixmap == None
1272 || bg_pmap_width != window_width 1244 || bg_pmap_width != window_width
1273 || bg_pmap_height != window_height) 1245 || bg_pmap_height != window_height)
1277 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1249 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1278 bg_pmap_width = window_width; 1250 bg_pmap_width = window_width;
1279 bg_pmap_height = window_height; 1251 bg_pmap_height = window_height;
1280 } 1252 }
1281 1253
1282 if (bg_pixmap == None)
1283 return 0;
1284
1285 /* straightforward pixmap copy */ 1254 /* straightforward pixmap copy */
1286 while (sx < 0) sx += (int)root_width; 1255 while (sx < 0) sx += root_width;
1287 while (sy < 0) sy += (int)root_height; 1256 while (sy < 0) sy += root_height;
1288 1257
1289 gcv.tile = recoded_root_pmap; 1258 gcv.tile = recoded_root_pmap;
1290 gcv.fill_style = FillTiled; 1259 gcv.fill_style = FillTiled;
1291 gcv.ts_x_origin = -sx; 1260 gcv.ts_x_origin = -sx;
1292 gcv.ts_y_origin = -sy; 1261 gcv.ts_y_origin = -sy;
1449 uint32_t mask_r, mask_g, mask_b; 1418 uint32_t mask_r, mask_g, mask_b;
1450 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1419 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1451 rgba low; 1420 rgba low;
1452 rgba high; 1421 rgba high;
1453 int i; 1422 int i;
1454 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 1423 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1455 1424
1456 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1425 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1457 1426
1458 /* for convenience */ 1427 /* for convenience */
1459 mask_r = visual->red_mask; 1428 mask_r = visual->red_mask;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines