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.146 by sf-exg, Sat Jan 29 17:50:31 2011 UTC vs.
Revision 1.162 by sf-exg, Thu Aug 11 12:27:26 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
46 * W and H are percentages of the terminal window size. 46 * W and H are percentages of the terminal window size.
47 * X and Y are also percentages; e.g., +50+50 centers 47 * X and Y are also percentages; e.g., +50+50 centers
48 * the image in the window. 48 * the image in the window.
49 * 49 *
50 * Pixmap Operations : (should be prepended by a colon) 50 * Pixmap Operations : (should be prepended by a colon)
51 * tile Tile image. Scaling/position modifiers above will affect
52 * the tile size and origin.
53 * propscale When scaling, scale proportionally. That is, maintain the
54 * proper aspect ratio for the image. Any portion of the
55 * background not covered by the image is filled with the
56 * current background color.
57 * hscale Scale horizontally, tile vertically ?
58 * vscale Tile horizontally, scale vertically ?
59 * scale Scale both up and down
60 * auto Same as 100x100+50+50
61 */ 51 */
62 52
63#ifdef HAVE_BG_PIXMAP 53#ifdef HAVE_BG_PIXMAP
64void 54void
65rxvt_term::bg_destroy () 55rxvt_term::bg_destroy ()
258 { 248 {
259 char **arr = rxvt_strsplit (':', ops + 1); 249 char **arr = rxvt_strsplit (':', ops + 1);
260 250
261 for (int i = 0; arr[i]; i++) 251 for (int i = 0; arr[i]; i++)
262 { 252 {
253 if (!strcasecmp (arr[i], "style=tiled"))
254 {
255 new_flags = BG_TILE;
256 w = h = noScale;
257 x = y = 0;
258 geom_flags = WidthValue|HeightValue|XValue|YValue;
259 }
260 else if (!strcasecmp (arr[i], "style=aspect-stretched"))
261 {
262 new_flags = BG_PROP_SCALE;
263 x = y = centerAlign;
264 geom_flags = XValue|YValue;
265 }
266 else if (!strcasecmp (arr[i], "style=stretched"))
267 {
268 new_flags = 0;
269 w = h = windowScale;
270 geom_flags = WidthValue|HeightValue;
271 }
272 else if (!strcasecmp (arr[i], "style=centered"))
273 {
274 new_flags = 0;
275 w = h = noScale;
276 x = y = centerAlign;
277 geom_flags = WidthValue|HeightValue|XValue|YValue;
278 }
279 else if (!strcasecmp (arr[i], "style=root-tiled"))
280 {
281 new_flags = BG_TILE|BG_ROOT_ALIGN;
282 w = h = noScale;
283 geom_flags = WidthValue|HeightValue;
284 }
285 else if (!strcasecmp (arr[i], "op=tile"))
286 new_flags |= BG_TILE;
287 else if (!strcasecmp (arr[i], "op=pscale"))
288 new_flags |= BG_PROP_SCALE;
289 else if (!strcasecmp (arr[i], "op=root"))
290 new_flags |= BG_ROOT_ALIGN;
291
292 // deprecated
263 if (!strcasecmp (arr[i], "tile")) 293 else if (!strcasecmp (arr[i], "tile"))
264 { 294 {
295 new_flags |= BG_TILE;
265 w = h = noScale; 296 w = h = noScale;
266 geom_flags |= WidthValue|HeightValue; 297 geom_flags |= WidthValue|HeightValue;
267 } 298 }
268 else if (!strcasecmp (arr[i], "propscale")) 299 else if (!strcasecmp (arr[i], "propscale"))
269 { 300 {
270 new_flags |= BG_PROP_SCALE; 301 new_flags |= BG_PROP_SCALE;
271 } 302 }
272 else if (!strcasecmp (arr[i], "hscale")) 303 else if (!strcasecmp (arr[i], "hscale"))
273 { 304 {
305 new_flags |= BG_TILE;
274 if (w == 0) w = windowScale; 306 w = windowScale;
275
276 h = noScale; 307 h = noScale;
277 geom_flags |= WidthValue|HeightValue; 308 geom_flags |= WidthValue|HeightValue;
278 } 309 }
279 else if (!strcasecmp (arr[i], "vscale")) 310 else if (!strcasecmp (arr[i], "vscale"))
280 { 311 {
312 new_flags |= BG_TILE;
281 if (h == 0) h = windowScale; 313 h = windowScale;
282
283 w = noScale; 314 w = noScale;
284 geom_flags |= WidthValue|HeightValue; 315 geom_flags |= WidthValue|HeightValue;
285 } 316 }
286 else if (!strcasecmp (arr[i], "scale")) 317 else if (!strcasecmp (arr[i], "scale"))
287 { 318 {
288 if (h == 0) h = windowScale;
289 if (w == 0) w = windowScale; 319 w = h = windowScale;
290
291 geom_flags |= WidthValue|HeightValue; 320 geom_flags |= WidthValue|HeightValue;
292 } 321 }
293 else if (!strcasecmp (arr[i], "auto")) 322 else if (!strcasecmp (arr[i], "auto"))
294 { 323 {
295 w = h = windowScale; 324 w = h = windowScale;
296 x = y = centerAlign; 325 x = y = centerAlign;
297 geom_flags |= WidthValue|HeightValue|XValue|YValue; 326 geom_flags |= WidthValue|HeightValue|XValue|YValue;
298 } 327 }
299 else if (!strcasecmp (arr[i], "root")) 328 else if (!strcasecmp (arr[i], "root"))
300 { 329 {
301 new_flags |= BG_ROOT_ALIGN; 330 new_flags |= BG_TILE|BG_ROOT_ALIGN;
302 w = h = noScale; 331 w = h = noScale;
303 geom_flags |= WidthValue|HeightValue; 332 geom_flags |= WidthValue|HeightValue;
304 } 333 }
305 } /* done parsing ops */ 334 } /* done parsing ops */
306 335
353 x = make_align_position (h_align, target_width, w); 382 x = make_align_position (h_align, target_width, w);
354 y = make_align_position (v_align, target_height, h); 383 y = make_align_position (v_align, target_height, h);
355 } 384 }
356 385
357 bg_flags &= ~BG_IS_SIZE_SENSITIVE; 386 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
387 if (!(bg_flags & BG_TILE)
358 if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale 388 || (bg_flags & BG_PROP_SCALE) || h_scale || v_scale
359 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) 389 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
360 || w > target_width || h > target_height) 390 || w > target_width || h > target_height)
361 bg_flags |= BG_IS_SIZE_SENSITIVE; 391 bg_flags |= BG_IS_SIZE_SENSITIVE;
362} 392}
363 393
455 100, ASIMAGE_QUALITY_DEFAULT); 485 100, ASIMAGE_QUALITY_DEFAULT);
456 } 486 }
457 487
458 if (background == NULL) 488 if (background == NULL)
459 { 489 {
460 if (h_scale == 0 || v_scale == 0) 490 if (bg_flags & BG_TILE)
461 { 491 {
462 /* if tiling - pixmap has to be sized exactly as the image, 492 /* if tiling - pixmap has to be sized exactly as the image,
463 but there is no need to make it bigger than the window! */ 493 but there is no need to make it bigger than the window! */
464 new_pmap_width = min (result->width, target_width); 494 new_pmap_width = min (result->width, target_width);
465 new_pmap_height = min (result->height, target_height); 495 new_pmap_height = min (result->height, target_height);
490 layers[0].clip_width = target_width; 520 layers[0].clip_width = target_width;
491 layers[0].clip_height = target_height; 521 layers[0].clip_height = target_height;
492 layers[0].tint = background_tint; 522 layers[0].tint = background_tint;
493 layers[1].im = result; 523 layers[1].im = result;
494 524
495 if (h_scale == 0 || v_scale == 0) 525 if (bg_flags & BG_TILE)
496 { 526 {
497 /* tile horizontally */ 527 /* tile horizontally */
498 while (x > 0) x -= (int)result->width; 528 while (x > 0) x -= (int)result->width;
499 layers[1].dst_x = x; 529 layers[1].dst_x = x;
500 layers[1].clip_width = result->width+target_width; 530 layers[1].clip_width = result->width+target_width;
504 /* clip horizontally */ 534 /* clip horizontally */
505 layers[1].dst_x = x; 535 layers[1].dst_x = x;
506 layers[1].clip_width = result->width; 536 layers[1].clip_width = result->width;
507 } 537 }
508 538
509 if (h_scale == 0 || v_scale == 0) 539 if (bg_flags & BG_TILE)
510 { 540 {
511 while (y > 0) y -= (int)result->height; 541 while (y > 0) y -= (int)result->height;
512 layers[1].dst_y = y; 542 layers[1].dst_y = y;
513 layers[1].clip_height = result->height + target_height; 543 layers[1].clip_height = result->height + target_height;
514 } 544 }
564 594
565 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 595 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
566 int dst_width = result->width, dst_height = result->height; 596 int dst_width = result->width, dst_height = result->height;
567 if (background == NULL) 597 if (background == NULL)
568 { 598 {
569 if (!(h_scale == 0 || v_scale == 0)) 599 if (!(bg_flags & BG_TILE))
570 { 600 {
571 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); 601 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); 602 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
573 } 603 }
574 604
620 else if (depth == 15 || depth == 16) 650 else if (depth == 15 || depth == 16)
621 bytes_per_pixel = 2; 651 bytes_per_pixel = 2;
622 else 652 else
623 return false; 653 return false;
624 654
625 width_r = rxvt_popcount (visual->red_mask); 655 width_r = ecb_popcount32 (visual->red_mask);
626 width_g = rxvt_popcount (visual->green_mask); 656 width_g = ecb_popcount32 (visual->green_mask);
627 width_b = rxvt_popcount (visual->blue_mask); 657 width_b = ecb_popcount32 (visual->blue_mask);
628 658
629 if (width_r > 8 || width_g > 8 || width_b > 8) 659 if (width_r > 8 || width_g > 8 || width_b > 8)
630 return false; 660 return false;
631 661
632 sh_r = rxvt_ctz (visual->red_mask); 662 sh_r = ecb_ctz32 (visual->red_mask);
633 sh_g = rxvt_ctz (visual->green_mask); 663 sh_g = ecb_ctz32 (visual->green_mask);
634 sh_b = rxvt_ctz (visual->blue_mask); 664 sh_b = ecb_ctz32 (visual->blue_mask);
635 665
636 if (width > INT_MAX / height / bytes_per_pixel) 666 if (width > INT_MAX / height / bytes_per_pixel)
637 return false; 667 return false;
638 668
639 data = (char *)malloc (width * height * bytes_per_pixel); 669 data = (char *)malloc (width * height * bytes_per_pixel);
646 { 676 {
647 free (data); 677 free (data);
648 return false; 678 return false;
649 } 679 }
650 680
651 ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 681 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
652 682
653 rowstride = gdk_pixbuf_get_rowstride (pixbuf); 683 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
654 channels = gdk_pixbuf_get_n_channels (pixbuf); 684 channels = gdk_pixbuf_get_n_channels (pixbuf);
655 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 685 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
656 line = data; 686 line = data;
723 result = gdk_pixbuf_scale_simple (pixbuf, 753 result = gdk_pixbuf_scale_simple (pixbuf,
724 w, h, 754 w, h,
725 GDK_INTERP_BILINEAR); 755 GDK_INTERP_BILINEAR);
726 } 756 }
727 757
758 if (!result)
759 return false;
760
728 bool ret = false; 761 bool ret = false;
729 762
730 if (result)
731 {
732 XGCValues gcv; 763 XGCValues gcv;
733 GC gc; 764 GC gc;
734 Pixmap root_pmap; 765 Pixmap root_pmap;
735 766
736 image_width = gdk_pixbuf_get_width (result); 767 image_width = gdk_pixbuf_get_width (result);
737 image_height = gdk_pixbuf_get_height (result); 768 image_height = gdk_pixbuf_get_height (result);
738 769
739 if (tr_flags) 770 if (tr_flags)
740 { 771 {
741 root_pmap = bg_pixmap; 772 root_pmap = bg_pixmap;
742 bg_pixmap = None; 773 bg_pixmap = None;
774 }
775 else
776 {
777 if (bg_flags & BG_TILE)
743 } 778 {
744 else
745 {
746 if (h_scale == 0 || v_scale == 0)
747 {
748 new_pmap_width = min (image_width, target_width); 779 new_pmap_width = min (image_width, target_width);
749 new_pmap_height = min (image_height, target_height); 780 new_pmap_height = min (image_height, target_height);
750 } 781 }
751 } 782 }
752 783
753 if (bg_pixmap == None 784 if (bg_pixmap == None
754 || bg_pmap_width != new_pmap_width 785 || bg_pmap_width != new_pmap_width
755 || bg_pmap_height != new_pmap_height) 786 || bg_pmap_height != new_pmap_height)
756 { 787 {
757 if (bg_pixmap) 788 if (bg_pixmap)
758 XFreePixmap (dpy, bg_pixmap); 789 XFreePixmap (dpy, bg_pixmap);
759 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 790 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
760 bg_pmap_width = new_pmap_width; 791 bg_pmap_width = new_pmap_width;
761 bg_pmap_height = new_pmap_height; 792 bg_pmap_height = new_pmap_height;
762 } 793 }
763 794
764 gcv.foreground = pix_colors[Color_bg]; 795 gcv.foreground = pix_colors[Color_bg];
765 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 796 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
766 797
767 if (h_scale == 0 || v_scale == 0) 798 if (gc)
799 {
800 if (bg_flags & BG_TILE)
768 { 801 {
769 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 802 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
770 pixbuf_to_pixmap (result, tile, gc, 803 pixbuf_to_pixmap (result, tile, gc,
771 0, 0, 804 0, 0,
772 0, 0, 805 0, 0,
816 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 849 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
817 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 850 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
818 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 851 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
819 XFreePixmap (dpy, mask_pmap); 852 XFreePixmap (dpy, mask_pmap);
820 853
821 if (src && dst && mask)
822 {
823 XRenderColor mask_c; 854 XRenderColor mask_c;
824 855
825 mask_c.alpha = 0x8000; 856 mask_c.alpha = 0x8000;
826 mask_c.red = 0; 857 mask_c.red = 0;
827 mask_c.green = 0; 858 mask_c.green = 0;
828 mask_c.blue = 0; 859 mask_c.blue = 0;
829 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 860 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); 861 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
831 }
832 862
833 XRenderFreePicture (dpy, src); 863 XRenderFreePicture (dpy, src);
834 XRenderFreePicture (dpy, dst); 864 XRenderFreePicture (dpy, dst);
835 XRenderFreePicture (dpy, mask); 865 XRenderFreePicture (dpy, mask);
836
837 XFreePixmap (dpy, root_pmap);
838 } 866 }
839#endif 867#endif
840 868
841 if (result != pixbuf)
842 g_object_unref (result);
843
844 XFreeGC (dpy, gc); 869 XFreeGC (dpy, gc);
845 870
846 ret = true; 871 ret = true;
847 } 872 }
873
874 if (result != pixbuf)
875 g_object_unref (result);
876
877 if (tr_flags)
878 XFreePixmap (dpy, root_pmap);
848 879
849 return ret; 880 return ret;
850} 881}
851# endif /* HAVE_PIXBUF */ 882# endif /* HAVE_PIXBUF */
852 883
1036 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1067 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1037 1068
1038 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1069 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1039 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1070 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1040 1071
1041 if (kernel && params && src && dst) 1072 if (kernel && params)
1042 { 1073 {
1043 if (h_blurRadius) 1074 if (h_blurRadius)
1044 { 1075 {
1045 size = h_blurRadius * 2 + 1; 1076 size = h_blurRadius * 2 + 1;
1046 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1077 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1111 } 1142 }
1112 } 1143 }
1113 else 1144 else
1114 { 1145 {
1115# if XRENDER 1146# if XRENDER
1116 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1147 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1117 1148
1118 if (bg_flags & BG_TINT_SET) 1149 if (bg_flags & BG_TINT_SET)
1119 tint.get (c); 1150 tint.get (c);
1120 1151
1121 if (shade <= 100) 1152 if (shade <= 100)
1122 { 1153 {
1123 c.r = (c.r * shade) / 100; 1154 c.r = c.r * shade / 100;
1124 c.g = (c.g * shade) / 100; 1155 c.g = c.g * shade / 100;
1125 c.b = (c.b * shade) / 100; 1156 c.b = c.b * shade / 100;
1126 } 1157 }
1127 else 1158 else
1128 { 1159 {
1129 c.r = (c.r * (200 - shade)) / 100; 1160 c.r = c.r * (200 - shade) / 100;
1130 c.g = (c.g * (200 - shade)) / 100; 1161 c.g = c.g * (200 - shade) / 100;
1131 c.b = (c.b * (200 - shade)) / 100; 1162 c.b = c.b * (200 - shade) / 100;
1132 } 1163 }
1133 1164
1134 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); 1165 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1135 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1166 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1136 XRenderPictureAttributes pa; 1167 XRenderPictureAttributes pa;
1143 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 1174 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1144 XFreePixmap (dpy, overlay_pmap); 1175 XFreePixmap (dpy, overlay_pmap);
1145 1176
1146 pa.component_alpha = True; 1177 pa.component_alpha = True;
1147 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1178 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1148 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 1179 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1149 XFreePixmap (dpy, mask_pmap); 1180 XFreePixmap (dpy, mask_pmap);
1150 1181
1151 if (mask_pic && overlay_pic && back_pic)
1152 {
1153 XRenderColor mask_c; 1182 XRenderColor mask_c;
1154 1183
1155 mask_c.red = mask_c.green = mask_c.blue = 0;
1156 mask_c.alpha = 0xffff; 1184 mask_c.alpha = 0xffff;
1185 mask_c.red =
1186 mask_c.green =
1187 mask_c.blue = 0;
1188 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1189
1190 mask_c.alpha = 0;
1191 mask_c.red = 0xffff - c.r;
1192 mask_c.green = 0xffff - c.g;
1193 mask_c.blue = 0xffff - c.b;
1194 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1195 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1196
1197 if (shade > 100)
1198 {
1199 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1200 mask_c.alpha = 0;
1157 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1201 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1158 1202
1159 mask_c.alpha = 0;
1160 mask_c.red = 0xffff - c.r;
1161 mask_c.green = 0xffff - c.g;
1162 mask_c.blue = 0xffff - c.b;
1163 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1164 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1165
1166 if (shade > 100)
1167 {
1168 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1169 mask_c.alpha = 0;
1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1171
1172 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1203 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1173 } 1204 }
1174 1205
1175 ret = true; 1206 ret = true;
1176 }
1177 1207
1178 XRenderFreePicture (dpy, mask_pic); 1208 XRenderFreePicture (dpy, mask_pic);
1179 XRenderFreePicture (dpy, overlay_pic); 1209 XRenderFreePicture (dpy, overlay_pic);
1180 XRenderFreePicture (dpy, back_pic); 1210 XRenderFreePicture (dpy, back_pic);
1181# endif 1211# endif
1182 } 1212 }
1183 1213
1184 return ret; 1214 return ret;
1185} 1215}
1186 1216
1187/* make_transparency_pixmap() 1217/*
1188 * Builds a pixmap of the same size as the terminal window that contains 1218 * Builds a pixmap of the same size as the terminal window that contains
1189 * the tiled portion of the root pixmap that is supposed to be covered by 1219 * the tiled portion of the root pixmap that is supposed to be covered by
1190 * our window. 1220 * our window.
1191 */ 1221 */
1192unsigned long 1222unsigned long
1236 if (root_pixmap != None && root_depth != depth) 1266 if (root_pixmap != None && root_depth != depth)
1237 { 1267 {
1238#if XRENDER 1268#if XRENDER
1239 if (bg_flags & BG_HAS_RENDER) 1269 if (bg_flags & BG_HAS_RENDER)
1240 { 1270 {
1271 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1272
1241 XRenderPictureAttributes pa; 1273 XRenderPictureAttributes pa;
1242 1274
1243 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1275 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1244 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1276 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1245 1277
1246 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1247 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1278 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1248 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1279 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1249 1280
1250 if (src && dst)
1251 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1281 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1252 else
1253 {
1254 XFreePixmap (dpy, recoded_root_pmap);
1255 root_pixmap = None;
1256 }
1257 1282
1258 XRenderFreePicture (dpy, src); 1283 XRenderFreePicture (dpy, src);
1259 XRenderFreePicture (dpy, dst); 1284 XRenderFreePicture (dpy, dst);
1260 } 1285 }
1261 else 1286 else
1262#endif 1287#endif
1263 root_pixmap = None; 1288 recoded_root_pmap = None;
1264 } 1289 }
1265 1290
1266 if (root_pixmap == None) 1291 if (recoded_root_pmap == None)
1267 return 0; 1292 return 0;
1268 1293
1269 if (bg_pixmap == None 1294 if (bg_pixmap == None
1270 || bg_pmap_width != window_width 1295 || bg_pmap_width != window_width
1271 || bg_pmap_height != window_height) 1296 || bg_pmap_height != window_height)
1275 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1300 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1276 bg_pmap_width = window_width; 1301 bg_pmap_width = window_width;
1277 bg_pmap_height = window_height; 1302 bg_pmap_height = window_height;
1278 } 1303 }
1279 1304
1280 if (bg_pixmap == None)
1281 return 0;
1282
1283 /* straightforward pixmap copy */ 1305 /* straightforward pixmap copy */
1284 while (sx < 0) sx += (int)root_width; 1306 while (sx < 0) sx += root_width;
1285 while (sy < 0) sy += (int)root_height; 1307 while (sy < 0) sy += root_height;
1286 1308
1287 gcv.tile = recoded_root_pmap; 1309 gcv.tile = recoded_root_pmap;
1288 gcv.fill_style = FillTiled; 1310 gcv.fill_style = FillTiled;
1289 gcv.ts_x_origin = -sx; 1311 gcv.ts_x_origin = -sx;
1290 gcv.ts_y_origin = -sy; 1312 gcv.ts_y_origin = -sy;
1447 uint32_t mask_r, mask_g, mask_b; 1469 uint32_t mask_r, mask_g, mask_b;
1448 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1470 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1449 rgba low; 1471 rgba low;
1450 rgba high; 1472 rgba high;
1451 int i; 1473 int i;
1452 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 1474 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1453 1475
1454 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1476 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1455 1477
1456 /* for convenience */ 1478 /* for convenience */
1457 mask_r = visual->red_mask; 1479 mask_r = visual->red_mask;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines