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.154 by sf-exg, Mon May 9 16:35:37 2011 UTC vs.
Revision 1.157 by sf-exg, Tue Aug 9 21:48:00 2011 UTC

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 ? 57 * hscale Scale horizontally, tile vertically ?
58 * vscale Tile horizontally, scale vertically ? 58 * vscale Tile horizontally, scale vertically ?
59 * scale Scale both up and down 59 * scale Scale both up and down
60 * auto Same as 100x100+50+50
61 */ 60 */
62 61
63#ifdef HAVE_BG_PIXMAP 62#ifdef HAVE_BG_PIXMAP
64void 63void
65rxvt_term::bg_destroy () 64rxvt_term::bg_destroy ()
260 259
261 for (int i = 0; arr[i]; i++) 260 for (int i = 0; arr[i]; i++)
262 { 261 {
263 if (!strcasecmp (arr[i], "tile")) 262 if (!strcasecmp (arr[i], "tile"))
264 { 263 {
264 new_flags |= BG_TILE;
265 w = h = noScale; 265 w = h = noScale;
266 geom_flags |= WidthValue|HeightValue; 266 geom_flags |= WidthValue|HeightValue;
267 } 267 }
268 else if (!strcasecmp (arr[i], "propscale")) 268 else if (!strcasecmp (arr[i], "propscale"))
269 { 269 {
288 if (h == 0) h = windowScale; 288 if (h == 0) h = windowScale;
289 if (w == 0) w = windowScale; 289 if (w == 0) w = windowScale;
290 290
291 geom_flags |= WidthValue|HeightValue; 291 geom_flags |= WidthValue|HeightValue;
292 } 292 }
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")) 293 else if (!strcasecmp (arr[i], "root"))
300 { 294 {
301 new_flags |= BG_ROOT_ALIGN; 295 new_flags |= BG_TILE|BG_ROOT_ALIGN;
302 w = h = noScale; 296 w = h = noScale;
303 geom_flags |= WidthValue|HeightValue; 297 geom_flags |= WidthValue|HeightValue;
304 } 298 }
305 } /* done parsing ops */ 299 } /* done parsing ops */
306 300
353 x = make_align_position (h_align, target_width, w); 347 x = make_align_position (h_align, target_width, w);
354 y = make_align_position (v_align, target_height, h); 348 y = make_align_position (v_align, target_height, h);
355 } 349 }
356 350
357 bg_flags &= ~BG_IS_SIZE_SENSITIVE; 351 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
352 if (!(bg_flags & BG_TILE)
358 if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale 353 || (bg_flags & BG_PROP_SCALE) || h_scale || v_scale
359 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) 354 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
360 || w > target_width || h > target_height) 355 || w > target_width || h > target_height)
361 bg_flags |= BG_IS_SIZE_SENSITIVE; 356 bg_flags |= BG_IS_SIZE_SENSITIVE;
362} 357}
363 358
455 100, ASIMAGE_QUALITY_DEFAULT); 450 100, ASIMAGE_QUALITY_DEFAULT);
456 } 451 }
457 452
458 if (background == NULL) 453 if (background == NULL)
459 { 454 {
460 if (h_scale == 0 || v_scale == 0) 455 if (bg_flags & BG_TILE)
461 { 456 {
462 /* if tiling - pixmap has to be sized exactly as the image, 457 /* if tiling - pixmap has to be sized exactly as the image,
463 but there is no need to make it bigger than the window! */ 458 but there is no need to make it bigger than the window! */
464 new_pmap_width = min (result->width, target_width); 459 new_pmap_width = min (result->width, target_width);
465 new_pmap_height = min (result->height, target_height); 460 new_pmap_height = min (result->height, target_height);
490 layers[0].clip_width = target_width; 485 layers[0].clip_width = target_width;
491 layers[0].clip_height = target_height; 486 layers[0].clip_height = target_height;
492 layers[0].tint = background_tint; 487 layers[0].tint = background_tint;
493 layers[1].im = result; 488 layers[1].im = result;
494 489
495 if (h_scale == 0 || v_scale == 0) 490 if (bg_flags & BG_TILE)
496 { 491 {
497 /* tile horizontally */ 492 /* tile horizontally */
498 while (x > 0) x -= (int)result->width; 493 while (x > 0) x -= (int)result->width;
499 layers[1].dst_x = x; 494 layers[1].dst_x = x;
500 layers[1].clip_width = result->width+target_width; 495 layers[1].clip_width = result->width+target_width;
504 /* clip horizontally */ 499 /* clip horizontally */
505 layers[1].dst_x = x; 500 layers[1].dst_x = x;
506 layers[1].clip_width = result->width; 501 layers[1].clip_width = result->width;
507 } 502 }
508 503
509 if (h_scale == 0 || v_scale == 0) 504 if (bg_flags & BG_TILE)
510 { 505 {
511 while (y > 0) y -= (int)result->height; 506 while (y > 0) y -= (int)result->height;
512 layers[1].dst_y = y; 507 layers[1].dst_y = y;
513 layers[1].clip_height = result->height + target_height; 508 layers[1].clip_height = result->height + target_height;
514 } 509 }
564 559
565 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 560 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
566 int dst_width = result->width, dst_height = result->height; 561 int dst_width = result->width, dst_height = result->height;
567 if (background == NULL) 562 if (background == NULL)
568 { 563 {
569 if (!(h_scale == 0 || v_scale == 0)) 564 if (!(bg_flags & BG_TILE))
570 { 565 {
571 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); 566 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); 567 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
573 } 568 }
574 569
620 else if (depth == 15 || depth == 16) 615 else if (depth == 15 || depth == 16)
621 bytes_per_pixel = 2; 616 bytes_per_pixel = 2;
622 else 617 else
623 return false; 618 return false;
624 619
625 width_r = rxvt_popcount (visual->red_mask); 620 width_r = ecb_popcount32 (visual->red_mask);
626 width_g = rxvt_popcount (visual->green_mask); 621 width_g = ecb_popcount32 (visual->green_mask);
627 width_b = rxvt_popcount (visual->blue_mask); 622 width_b = ecb_popcount32 (visual->blue_mask);
628 623
629 if (width_r > 8 || width_g > 8 || width_b > 8) 624 if (width_r > 8 || width_g > 8 || width_b > 8)
630 return false; 625 return false;
631 626
632 sh_r = rxvt_ctz (visual->red_mask); 627 sh_r = ecb_ctz32 (visual->red_mask);
633 sh_g = rxvt_ctz (visual->green_mask); 628 sh_g = ecb_ctz32 (visual->green_mask);
634 sh_b = rxvt_ctz (visual->blue_mask); 629 sh_b = ecb_ctz32 (visual->blue_mask);
635 630
636 if (width > INT_MAX / height / bytes_per_pixel) 631 if (width > INT_MAX / height / bytes_per_pixel)
637 return false; 632 return false;
638 633
639 data = (char *)malloc (width * height * bytes_per_pixel); 634 data = (char *)malloc (width * height * bytes_per_pixel);
646 { 641 {
647 free (data); 642 free (data);
648 return false; 643 return false;
649 } 644 }
650 645
651 ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 646 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
652 647
653 rowstride = gdk_pixbuf_get_rowstride (pixbuf); 648 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
654 channels = gdk_pixbuf_get_n_channels (pixbuf); 649 channels = gdk_pixbuf_get_n_channels (pixbuf);
655 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 650 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
656 line = data; 651 line = data;
742 root_pmap = bg_pixmap; 737 root_pmap = bg_pixmap;
743 bg_pixmap = None; 738 bg_pixmap = None;
744 } 739 }
745 else 740 else
746 { 741 {
747 if (h_scale == 0 || v_scale == 0) 742 if (bg_flags & BG_TILE)
748 { 743 {
749 new_pmap_width = min (image_width, target_width); 744 new_pmap_width = min (image_width, target_width);
750 new_pmap_height = min (image_height, target_height); 745 new_pmap_height = min (image_height, target_height);
751 } 746 }
752 } 747 }
765 gcv.foreground = pix_colors[Color_bg]; 760 gcv.foreground = pix_colors[Color_bg];
766 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 761 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
767 762
768 if (gc) 763 if (gc)
769 { 764 {
770 if (h_scale == 0 || v_scale == 0) 765 if (bg_flags & BG_TILE)
771 { 766 {
772 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 767 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
773 pixbuf_to_pixmap (result, tile, gc, 768 pixbuf_to_pixmap (result, tile, gc,
774 0, 0, 769 0, 0,
775 0, 0, 770 0, 0,
1439 uint32_t mask_r, mask_g, mask_b; 1434 uint32_t mask_r, mask_g, mask_b;
1440 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1435 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1441 rgba low; 1436 rgba low;
1442 rgba high; 1437 rgba high;
1443 int i; 1438 int i;
1444 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; 1439 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1445 1440
1446 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1441 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1447 1442
1448 /* for convenience */ 1443 /* for convenience */
1449 mask_r = visual->red_mask; 1444 mask_r = visual->red_mask;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines