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.160 by sf-exg, Thu Aug 11 08:37:17 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"))
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")) 303 else if (!strcasecmp (arr[i], "scale"))
287 { 304 {
288 if (h == 0) h = windowScale; 305 if (h == 0) h = windowScale;
289 if (w == 0) w = windowScale; 306 if (w == 0) w = windowScale;
290 307
291 geom_flags |= WidthValue|HeightValue; 308 geom_flags |= WidthValue|HeightValue;
292 } 309 }
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")) 310 else if (!strcasecmp (arr[i], "root"))
300 { 311 {
301 new_flags |= BG_ROOT_ALIGN; 312 new_flags |= BG_TILE|BG_ROOT_ALIGN;
302 w = h = noScale; 313 w = h = noScale;
303 geom_flags |= WidthValue|HeightValue; 314 geom_flags |= WidthValue|HeightValue;
304 } 315 }
305 } /* done parsing ops */ 316 } /* done parsing ops */
306 317
353 x = make_align_position (h_align, target_width, w); 364 x = make_align_position (h_align, target_width, w);
354 y = make_align_position (v_align, target_height, h); 365 y = make_align_position (v_align, target_height, h);
355 } 366 }
356 367
357 bg_flags &= ~BG_IS_SIZE_SENSITIVE; 368 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
369 if (!(bg_flags & BG_TILE)
358 if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale 370 || (bg_flags & BG_PROP_SCALE) || h_scale || v_scale
359 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) 371 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
360 || w > target_width || h > target_height) 372 || w > target_width || h > target_height)
361 bg_flags |= BG_IS_SIZE_SENSITIVE; 373 bg_flags |= BG_IS_SIZE_SENSITIVE;
362} 374}
363 375
455 100, ASIMAGE_QUALITY_DEFAULT); 467 100, ASIMAGE_QUALITY_DEFAULT);
456 } 468 }
457 469
458 if (background == NULL) 470 if (background == NULL)
459 { 471 {
460 if (h_scale == 0 || v_scale == 0) 472 if (bg_flags & BG_TILE)
461 { 473 {
462 /* if tiling - pixmap has to be sized exactly as the image, 474 /* if tiling - pixmap has to be sized exactly as the image,
463 but there is no need to make it bigger than the window! */ 475 but there is no need to make it bigger than the window! */
464 new_pmap_width = min (result->width, target_width); 476 new_pmap_width = min (result->width, target_width);
465 new_pmap_height = min (result->height, target_height); 477 new_pmap_height = min (result->height, target_height);
490 layers[0].clip_width = target_width; 502 layers[0].clip_width = target_width;
491 layers[0].clip_height = target_height; 503 layers[0].clip_height = target_height;
492 layers[0].tint = background_tint; 504 layers[0].tint = background_tint;
493 layers[1].im = result; 505 layers[1].im = result;
494 506
495 if (h_scale == 0 || v_scale == 0) 507 if (bg_flags & BG_TILE)
496 { 508 {
497 /* tile horizontally */ 509 /* tile horizontally */
498 while (x > 0) x -= (int)result->width; 510 while (x > 0) x -= (int)result->width;
499 layers[1].dst_x = x; 511 layers[1].dst_x = x;
500 layers[1].clip_width = result->width+target_width; 512 layers[1].clip_width = result->width+target_width;
504 /* clip horizontally */ 516 /* clip horizontally */
505 layers[1].dst_x = x; 517 layers[1].dst_x = x;
506 layers[1].clip_width = result->width; 518 layers[1].clip_width = result->width;
507 } 519 }
508 520
509 if (h_scale == 0 || v_scale == 0) 521 if (bg_flags & BG_TILE)
510 { 522 {
511 while (y > 0) y -= (int)result->height; 523 while (y > 0) y -= (int)result->height;
512 layers[1].dst_y = y; 524 layers[1].dst_y = y;
513 layers[1].clip_height = result->height + target_height; 525 layers[1].clip_height = result->height + target_height;
514 } 526 }
564 576
565 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 577 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
566 int dst_width = result->width, dst_height = result->height; 578 int dst_width = result->width, dst_height = result->height;
567 if (background == NULL) 579 if (background == NULL)
568 { 580 {
569 if (!(h_scale == 0 || v_scale == 0)) 581 if (!(bg_flags & BG_TILE))
570 { 582 {
571 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); 583 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); 584 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
573 } 585 }
574 586
620 else if (depth == 15 || depth == 16) 632 else if (depth == 15 || depth == 16)
621 bytes_per_pixel = 2; 633 bytes_per_pixel = 2;
622 else 634 else
623 return false; 635 return false;
624 636
625 width_r = rxvt_popcount (visual->red_mask); 637 width_r = ecb_popcount32 (visual->red_mask);
626 width_g = rxvt_popcount (visual->green_mask); 638 width_g = ecb_popcount32 (visual->green_mask);
627 width_b = rxvt_popcount (visual->blue_mask); 639 width_b = ecb_popcount32 (visual->blue_mask);
628 640
629 if (width_r > 8 || width_g > 8 || width_b > 8) 641 if (width_r > 8 || width_g > 8 || width_b > 8)
630 return false; 642 return false;
631 643
632 sh_r = rxvt_ctz (visual->red_mask); 644 sh_r = ecb_ctz32 (visual->red_mask);
633 sh_g = rxvt_ctz (visual->green_mask); 645 sh_g = ecb_ctz32 (visual->green_mask);
634 sh_b = rxvt_ctz (visual->blue_mask); 646 sh_b = ecb_ctz32 (visual->blue_mask);
635 647
636 if (width > INT_MAX / height / bytes_per_pixel) 648 if (width > INT_MAX / height / bytes_per_pixel)
637 return false; 649 return false;
638 650
639 data = (char *)malloc (width * height * bytes_per_pixel); 651 data = (char *)malloc (width * height * bytes_per_pixel);
646 { 658 {
647 free (data); 659 free (data);
648 return false; 660 return false;
649 } 661 }
650 662
651 ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 663 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
652 664
653 rowstride = gdk_pixbuf_get_rowstride (pixbuf); 665 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
654 channels = gdk_pixbuf_get_n_channels (pixbuf); 666 channels = gdk_pixbuf_get_n_channels (pixbuf);
655 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 667 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
656 line = data; 668 line = data;
742 root_pmap = bg_pixmap; 754 root_pmap = bg_pixmap;
743 bg_pixmap = None; 755 bg_pixmap = None;
744 } 756 }
745 else 757 else
746 { 758 {
747 if (h_scale == 0 || v_scale == 0) 759 if (bg_flags & BG_TILE)
748 { 760 {
749 new_pmap_width = min (image_width, target_width); 761 new_pmap_width = min (image_width, target_width);
750 new_pmap_height = min (image_height, target_height); 762 new_pmap_height = min (image_height, target_height);
751 } 763 }
752 } 764 }
760 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 772 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
761 bg_pmap_width = new_pmap_width; 773 bg_pmap_width = new_pmap_width;
762 bg_pmap_height = new_pmap_height; 774 bg_pmap_height = new_pmap_height;
763 } 775 }
764 776
765 if (bg_pixmap != None)
766 {
767 gcv.foreground = pix_colors[Color_bg]; 777 gcv.foreground = pix_colors[Color_bg];
768 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 778 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
769 779
770 if (gc) 780 if (gc)
771 { 781 {
772 if (h_scale == 0 || v_scale == 0) 782 if (bg_flags & BG_TILE)
773 { 783 {
774 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 784 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
775
776 if (tile != None)
777 {
778 pixbuf_to_pixmap (result, tile, gc, 785 pixbuf_to_pixmap (result, tile, gc,
779 0, 0, 786 0, 0,
780 0, 0, 787 0, 0,
781 image_width, image_height); 788 image_width, image_height);
782 789
783 gcv.tile = tile; 790 gcv.tile = tile;
784 gcv.fill_style = FillTiled; 791 gcv.fill_style = FillTiled;
785 gcv.ts_x_origin = x; 792 gcv.ts_x_origin = x;
786 gcv.ts_y_origin = y; 793 gcv.ts_y_origin = y;
787 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 794 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
788 795
789 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 796 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
790 XFreePixmap (dpy, tile); 797 XFreePixmap (dpy, tile);
791 }
792 } 798 }
793 else 799 else
794 { 800 {
795 int src_x, src_y, dst_x, dst_y; 801 int src_x, src_y, dst_x, dst_y;
796 int dst_width, dst_height; 802 int dst_width, dst_height;
797 803
798 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width ); 804 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); 805 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
800 806
801 if (dst_x > 0 || dst_y > 0 807 if (dst_x > 0 || dst_y > 0
802 || dst_x + dst_width < new_pmap_width 808 || dst_x + dst_width < new_pmap_width
803 || dst_y + dst_height < new_pmap_height) 809 || dst_y + dst_height < new_pmap_height)
804 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 810 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
805 811
806 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 812 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
807 pixbuf_to_pixmap (result, bg_pixmap, gc, 813 pixbuf_to_pixmap (result, bg_pixmap, gc,
808 src_x, src_y, 814 src_x, src_y,
809 dst_x, dst_y, 815 dst_x, dst_y,
810 dst_width, dst_height); 816 dst_width, dst_height);
811 } 817 }
812 818
813#if XRENDER 819#if XRENDER
814 if (tr_flags) 820 if (tr_flags)
815 { 821 {
816 XRenderPictureAttributes pa; 822 XRenderPictureAttributes pa;
817 823
818 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 824 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
819 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 825 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
820 826
821 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 827 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
822 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 828 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
823 829
824 pa.repeat = True; 830 pa.repeat = True;
825 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); 831 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
826 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 832 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
827 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 833 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
828 XFreePixmap (dpy, mask_pmap); 834 XFreePixmap (dpy, mask_pmap);
829 835
830 if (src && dst && mask)
831 {
832 XRenderColor mask_c; 836 XRenderColor mask_c;
833 837
834 mask_c.alpha = 0x8000; 838 mask_c.alpha = 0x8000;
835 mask_c.red = 0; 839 mask_c.red = 0;
836 mask_c.green = 0; 840 mask_c.green = 0;
837 mask_c.blue = 0; 841 mask_c.blue = 0;
838 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 842 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); 843 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height);
840 }
841 844
842 XRenderFreePicture (dpy, src); 845 XRenderFreePicture (dpy, src);
843 XRenderFreePicture (dpy, dst); 846 XRenderFreePicture (dpy, dst);
844 XRenderFreePicture (dpy, mask); 847 XRenderFreePicture (dpy, mask);
845 } 848 }
846#endif 849#endif
847 850
848 XFreeGC (dpy, gc); 851 XFreeGC (dpy, gc);
849 852
850 ret = true; 853 ret = true;
851 }
852 } 854 }
853 855
854 if (result != pixbuf) 856 if (result != pixbuf)
855 g_object_unref (result); 857 g_object_unref (result);
856 858
1047 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1049 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1048 1050
1049 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1051 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1050 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1052 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1051 1053
1052 if (kernel && params && src && dst) 1054 if (kernel && params)
1053 { 1055 {
1054 if (h_blurRadius) 1056 if (h_blurRadius)
1055 { 1057 {
1056 size = h_blurRadius * 2 + 1; 1058 size = h_blurRadius * 2 + 1;
1057 get_gaussian_kernel (h_blurRadius, size, kernel, params); 1059 get_gaussian_kernel (h_blurRadius, size, kernel, params);
1157 pa.component_alpha = True; 1159 pa.component_alpha = True;
1158 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1160 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1159 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); 1161 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1160 XFreePixmap (dpy, mask_pmap); 1162 XFreePixmap (dpy, mask_pmap);
1161 1163
1162 if (mask_pic && overlay_pic && back_pic)
1163 {
1164 XRenderColor mask_c; 1164 XRenderColor mask_c;
1165 1165
1166 mask_c.alpha = 0xffff; 1166 mask_c.alpha = 0xffff;
1167 mask_c.red = 1167 mask_c.red =
1168 mask_c.green = 1168 mask_c.green =
1169 mask_c.blue = 0; 1169 mask_c.blue = 0;
1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1171
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;
1170 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1183 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1171 1184
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); 1185 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1186 } 1186 }
1187 1187
1188 ret = true; 1188 ret = true;
1189 }
1190 1189
1191 XRenderFreePicture (dpy, mask_pic); 1190 XRenderFreePicture (dpy, mask_pic);
1192 XRenderFreePicture (dpy, overlay_pic); 1191 XRenderFreePicture (dpy, overlay_pic);
1193 XRenderFreePicture (dpy, back_pic); 1192 XRenderFreePicture (dpy, back_pic);
1194# endif 1193# endif
1251#if XRENDER 1250#if XRENDER
1252 if (bg_flags & BG_HAS_RENDER) 1251 if (bg_flags & BG_HAS_RENDER)
1253 { 1252 {
1254 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); 1253 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1255 1254
1256 if (recoded_root_pmap != None)
1257 {
1258 XRenderPictureAttributes pa; 1255 XRenderPictureAttributes pa;
1259 1256
1260 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1257 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1261 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1258 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1262 1259
1263 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); 1260 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1264 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1261 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1265 1262
1266 if (src && dst)
1267 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1263 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 1264
1274 XRenderFreePicture (dpy, src); 1265 XRenderFreePicture (dpy, src);
1275 XRenderFreePicture (dpy, dst); 1266 XRenderFreePicture (dpy, dst);
1276 }
1277 } 1267 }
1278 else 1268 else
1279#endif 1269#endif
1280 recoded_root_pmap = None; 1270 recoded_root_pmap = None;
1281 } 1271 }
1292 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); 1282 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1293 bg_pmap_width = window_width; 1283 bg_pmap_width = window_width;
1294 bg_pmap_height = window_height; 1284 bg_pmap_height = window_height;
1295 } 1285 }
1296 1286
1297 if (bg_pixmap != None)
1298 {
1299 /* straightforward pixmap copy */ 1287 /* straightforward pixmap copy */
1300 while (sx < 0) sx += root_width; 1288 while (sx < 0) sx += root_width;
1301 while (sy < 0) sy += root_height; 1289 while (sy < 0) sy += root_height;
1302 1290
1303 gcv.tile = recoded_root_pmap; 1291 gcv.tile = recoded_root_pmap;
1304 gcv.fill_style = FillTiled; 1292 gcv.fill_style = FillTiled;
1305 gcv.ts_x_origin = -sx; 1293 gcv.ts_x_origin = -sx;
1306 gcv.ts_y_origin = -sy; 1294 gcv.ts_y_origin = -sy;
1307 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1295 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1308 1296
1309 if (gc) 1297 if (gc)
1310 { 1298 {
1311 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1299 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1312 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1300 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1313 XFreeGC (dpy, gc); 1301 XFreeGC (dpy, gc);
1314 1302
1315 if (!(bg_flags & BG_CLIENT_RENDER)) 1303 if (!(bg_flags & BG_CLIENT_RENDER))
1316 { 1304 {
1317 if ((bg_flags & BG_NEEDS_BLUR) 1305 if ((bg_flags & BG_NEEDS_BLUR)
1318 && (bg_flags & BG_HAS_RENDER_CONV)) 1306 && (bg_flags & BG_HAS_RENDER_CONV))
1319 { 1307 {
1320 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1308 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1321 result &= ~BG_NEEDS_BLUR; 1309 result &= ~BG_NEEDS_BLUR;
1322 } 1310 }
1323 if ((bg_flags & BG_NEEDS_TINT) 1311 if ((bg_flags & BG_NEEDS_TINT)
1324 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) 1312 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1325 { 1313 {
1326 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1314 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1327 result &= ~BG_NEEDS_TINT; 1315 result &= ~BG_NEEDS_TINT;
1328 } 1316 }
1329 } /* server side rendering completed */ 1317 } /* server side rendering completed */
1330 }
1331 } 1318 }
1332 1319
1333 if (recoded_root_pmap != root_pixmap) 1320 if (recoded_root_pmap != root_pixmap)
1334 XFreePixmap (dpy, recoded_root_pmap); 1321 XFreePixmap (dpy, recoded_root_pmap);
1335 1322
1464 uint32_t mask_r, mask_g, mask_b; 1451 uint32_t mask_r, mask_g, mask_b;
1465 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1452 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1466 rgba low; 1453 rgba low;
1467 rgba high; 1454 rgba high;
1468 int i; 1455 int i;
1469 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 1456 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1470 1457
1471 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1458 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1472 1459
1473 /* for convenience */ 1460 /* for convenience */
1474 mask_r = visual->red_mask; 1461 mask_r = visual->red_mask;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines