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.153 by sf-exg, Sun May 8 21:07:43 2011 UTC vs.
Revision 1.162 by sf-exg, Thu Aug 11 12:27:26 2011 UTC

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;
742 root_pmap = bg_pixmap; 772 root_pmap = bg_pixmap;
743 bg_pixmap = None; 773 bg_pixmap = None;
744 } 774 }
745 else 775 else
746 { 776 {
747 if (h_scale == 0 || v_scale == 0) 777 if (bg_flags & BG_TILE)
748 { 778 {
749 new_pmap_width = min (image_width, target_width); 779 new_pmap_width = min (image_width, target_width);
750 new_pmap_height = min (image_height, target_height); 780 new_pmap_height = min (image_height, target_height);
751 } 781 }
752 } 782 }
760 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);
761 bg_pmap_width = new_pmap_width; 791 bg_pmap_width = new_pmap_width;
762 bg_pmap_height = new_pmap_height; 792 bg_pmap_height = new_pmap_height;
763 } 793 }
764 794
765 if (bg_pixmap != None)
766 {
767 gcv.foreground = pix_colors[Color_bg]; 795 gcv.foreground = pix_colors[Color_bg];
768 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 796 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
769 797
770 if (gc) 798 if (gc)
771 { 799 {
772 if (h_scale == 0 || v_scale == 0) 800 if (bg_flags & BG_TILE)
773 { 801 {
774 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 802 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
775
776 if (tile != None)
777 {
778 pixbuf_to_pixmap (result, tile, gc, 803 pixbuf_to_pixmap (result, tile, gc,
779 0, 0, 804 0, 0,
780 0, 0, 805 0, 0,
781 image_width, image_height); 806 image_width, image_height);
782 807
783 gcv.tile = tile; 808 gcv.tile = tile;
784 gcv.fill_style = FillTiled; 809 gcv.fill_style = FillTiled;
785 gcv.ts_x_origin = x; 810 gcv.ts_x_origin = x;
786 gcv.ts_y_origin = y; 811 gcv.ts_y_origin = y;
787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 812 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
788 813
789 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 814 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
790 XFreePixmap (dpy, tile); 815 XFreePixmap (dpy, tile);
791 }
792 } 816 }
793 else 817 else
794 { 818 {
795 int src_x, src_y, dst_x, dst_y; 819 int src_x, src_y, dst_x, dst_y;
796 int dst_width, dst_height; 820 int dst_width, dst_height;
797 821
798 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width ); 822 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width );
799 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 823 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
800 824
801 if (dst_x > 0 || dst_y > 0 825 if (dst_x > 0 || dst_y > 0
802 || dst_x + dst_width < new_pmap_width 826 || dst_x + dst_width < new_pmap_width
803 || dst_y + dst_height < new_pmap_height) 827 || dst_y + dst_height < new_pmap_height)
804 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 828 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
805 829
806 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 830 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
807 pixbuf_to_pixmap (result, bg_pixmap, gc, 831 pixbuf_to_pixmap (result, bg_pixmap, gc,
808 src_x, src_y, 832 src_x, src_y,
809 dst_x, dst_y, 833 dst_x, dst_y,
810 dst_width, dst_height); 834 dst_width, dst_height);
811 } 835 }
812 836
813#if XRENDER 837#if XRENDER
814 if (tr_flags) 838 if (tr_flags)
815 { 839 {
816 XRenderPictureAttributes pa; 840 XRenderPictureAttributes pa;
817 841
818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 842 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 843 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
820 844
821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 845 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 846 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
823 847
824 pa.repeat = True; 848 pa.repeat = True;
825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 849 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 850 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 851 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
828 XFreePixmap (dpy, mask_pmap); 852 XFreePixmap (dpy, mask_pmap);
829 853
830 if (src && dst && mask)
831 {
832 XRenderColor mask_c; 854 XRenderColor mask_c;
833 855
834 mask_c.alpha = 0x8000; 856 mask_c.alpha = 0x8000;
835 mask_c.red = 0; 857 mask_c.red = 0;
836 mask_c.green = 0; 858 mask_c.green = 0;
837 mask_c.blue = 0; 859 mask_c.blue = 0;
838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 860 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
839 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);
840 }
841 862
842 XRenderFreePicture (dpy, src); 863 XRenderFreePicture (dpy, src);
843 XRenderFreePicture (dpy, dst); 864 XRenderFreePicture (dpy, dst);
844 XRenderFreePicture (dpy, mask); 865 XRenderFreePicture (dpy, mask);
845 } 866 }
846#endif 867#endif
847 868
848 XFreeGC (dpy, gc); 869 XFreeGC (dpy, gc);
849 870
850 ret = true; 871 ret = true;
851 }
852 } 872 }
853 873
854 if (result != pixbuf) 874 if (result != pixbuf)
855 g_object_unref (result); 875 g_object_unref (result);
856 876
1047 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1067 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1048 1068
1049 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1069 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1050 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1070 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1051 1071
1052 if (kernel && params && src && dst) 1072 if (kernel && params)
1053 { 1073 {
1054 if (h_blurRadius) 1074 if (h_blurRadius)
1055 { 1075 {
1056 size = h_blurRadius * 2 + 1; 1076 size = h_blurRadius * 2 + 1;
1057 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1077 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1157 pa.component_alpha = True; 1177 pa.component_alpha = True;
1158 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1178 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1159 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);
1160 XFreePixmap (dpy, mask_pmap); 1180 XFreePixmap (dpy, mask_pmap);
1161 1181
1162 if (mask_pic && overlay_pic && back_pic)
1163 {
1164 XRenderColor mask_c; 1182 XRenderColor mask_c;
1165 1183
1166 mask_c.alpha = 0xffff; 1184 mask_c.alpha = 0xffff;
1167 mask_c.red = 1185 mask_c.red =
1168 mask_c.green = 1186 mask_c.green =
1169 mask_c.blue = 0; 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;
1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1201 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1171 1202
1172 mask_c.alpha = 0;
1173 mask_c.red = 0xffff - c.r;
1174 mask_c.green = 0xffff - c.g;
1175 mask_c.blue = 0xffff - c.b;
1176 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1177 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1178
1179 if (shade > 100)
1180 {
1181 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1182 mask_c.alpha = 0;
1183 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1184
1185 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);
1186 } 1204 }
1187 1205
1188 ret = true; 1206 ret = true;
1189 }
1190 1207
1191 XRenderFreePicture (dpy, mask_pic); 1208 XRenderFreePicture (dpy, mask_pic);
1192 XRenderFreePicture (dpy, overlay_pic); 1209 XRenderFreePicture (dpy, overlay_pic);
1193 XRenderFreePicture (dpy, back_pic); 1210 XRenderFreePicture (dpy, back_pic);
1194# endif 1211# endif
1251#if XRENDER 1268#if XRENDER
1252 if (bg_flags & BG_HAS_RENDER) 1269 if (bg_flags & BG_HAS_RENDER)
1253 { 1270 {
1254 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1271 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1255 1272
1256 if (recoded_root_pmap != None)
1257 {
1258 XRenderPictureAttributes pa; 1273 XRenderPictureAttributes pa;
1259 1274
1260 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1275 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1261 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1276 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1262 1277
1263 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1278 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1264 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1279 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1265 1280
1266 if (src && dst)
1267 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);
1268 else
1269 {
1270 XFreePixmap (dpy, recoded_root_pmap);
1271 recoded_root_pmap = None;
1272 }
1273 1282
1274 XRenderFreePicture (dpy, src); 1283 XRenderFreePicture (dpy, src);
1275 XRenderFreePicture (dpy, dst); 1284 XRenderFreePicture (dpy, dst);
1276 }
1277 } 1285 }
1278 else 1286 else
1279#endif 1287#endif
1280 recoded_root_pmap = None; 1288 recoded_root_pmap = None;
1281 } 1289 }
1292 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1300 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1293 bg_pmap_width = window_width; 1301 bg_pmap_width = window_width;
1294 bg_pmap_height = window_height; 1302 bg_pmap_height = window_height;
1295 } 1303 }
1296 1304
1297 if (bg_pixmap != None)
1298 {
1299 /* straightforward pixmap copy */ 1305 /* straightforward pixmap copy */
1300 while (sx < 0) sx += root_width; 1306 while (sx < 0) sx += root_width;
1301 while (sy < 0) sy += root_height; 1307 while (sy < 0) sy += root_height;
1302 1308
1303 gcv.tile = recoded_root_pmap; 1309 gcv.tile = recoded_root_pmap;
1304 gcv.fill_style = FillTiled; 1310 gcv.fill_style = FillTiled;
1305 gcv.ts_x_origin = -sx; 1311 gcv.ts_x_origin = -sx;
1306 gcv.ts_y_origin = -sy; 1312 gcv.ts_y_origin = -sy;
1307 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1313 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1308 1314
1309 if (gc) 1315 if (gc)
1310 { 1316 {
1311 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1317 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1312 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1318 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1313 XFreeGC (dpy, gc); 1319 XFreeGC (dpy, gc);
1314 1320
1315 if (!(bg_flags & BG_CLIENT_RENDER)) 1321 if (!(bg_flags & BG_CLIENT_RENDER))
1316 { 1322 {
1317 if ((bg_flags & BG_NEEDS_BLUR) 1323 if ((bg_flags & BG_NEEDS_BLUR)
1318 && (bg_flags & BG_HAS_RENDER_CONV)) 1324 && (bg_flags & BG_HAS_RENDER_CONV))
1319 { 1325 {
1320 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1326 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1321 result &= ~BG_NEEDS_BLUR; 1327 result &= ~BG_NEEDS_BLUR;
1322 } 1328 }
1323 if ((bg_flags & BG_NEEDS_TINT) 1329 if ((bg_flags & BG_NEEDS_TINT)
1324 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) 1330 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1325 { 1331 {
1326 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1332 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1327 result &= ~BG_NEEDS_TINT; 1333 result &= ~BG_NEEDS_TINT;
1328 } 1334 }
1329 } /* server side rendering completed */ 1335 } /* server side rendering completed */
1330 }
1331 } 1336 }
1332 1337
1333 if (recoded_root_pmap != root_pixmap) 1338 if (recoded_root_pmap != root_pixmap)
1334 XFreePixmap (dpy, recoded_root_pmap); 1339 XFreePixmap (dpy, recoded_root_pmap);
1335 1340
1464 uint32_t mask_r, mask_g, mask_b; 1469 uint32_t mask_r, mask_g, mask_b;
1465 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1470 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1466 rgba low; 1471 rgba low;
1467 rgba high; 1472 rgba high;
1468 int i; 1473 int i;
1469 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 1474 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1470 1475
1471 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1476 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1472 1477
1473 /* for convenience */ 1478 /* for convenience */
1474 mask_r = visual->red_mask; 1479 mask_r = visual->red_mask;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines