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.65 by sf-exg, Mon Oct 4 20:45:45 2010 UTC vs.
Revision 1.72 by sf-exg, Sat Oct 9 14:57:50 2010 UTC

226make_align_position (int align, int window_size, int image_size) 226make_align_position (int align, int window_size, int image_size)
227{ 227{
228 int diff = window_size - image_size; 228 int diff = window_size - image_size;
229 int smaller = min (image_size, window_size); 229 int smaller = min (image_size, window_size);
230 230
231 if (align >= 0 && align <= 50) 231 if (align >= 0 && align <= 100)
232 return diff * align / 100; 232 return diff * align / 100;
233 else if (align > 50 && align <= 100)
234 return window_size - image_size - diff * (100 - align) / 100;
235 else if (align > 100 && align <= 200 ) 233 else if (align > 100 && align <= 200 )
236 return ((align - 100) * smaller / 100) + window_size - smaller; 234 return ((align - 100) * smaller / 100) + window_size - smaller;
237 else if (align >= -100 && align < 0) 235 else if (align >= -100 && align < 0)
238 return ((align + 100) * smaller / 100) - image_size; 236 return ((align + 100) * smaller / 100) - image_size;
239 return 0; 237 return 0;
241 239
242static inline int 240static inline int
243make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) 241make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size)
244{ 242{
245 int src_pos = 0; 243 int src_pos = 0;
246 dst_pos = 0; 244 dst_pos = pos;
247 dst_size = size; 245 dst_size = size;
248 if (pos < 0) 246 if (pos < 0)
249 { 247 {
250 src_pos = -pos; 248 src_pos = -pos;
249 dst_pos = 0;
251 dst_size += pos; 250 dst_size += pos;
252 } 251 }
253 else if (pos > 0)
254 dst_pos = pos;
255 252
256 if (dst_pos + dst_size > target_size) 253 if (dst_pos + dst_size > target_size)
257 dst_size = target_size - dst_pos; 254 dst_size = target_size - dst_pos;
258 return src_pos; 255 return src_pos;
259} 256}
461 { 458 {
462 w = h_scale * target_width / 100; 459 w = h_scale * target_width / 100;
463 h = v_scale * target_height / 100; 460 h = v_scale * target_height / 100;
464 } 461 }
465 462
463 if (!w) w = image_width;
464 if (!h) h = image_height;
465
466 if (flags & rootAlign) 466 if (flags & rootAlign)
467 { 467 {
468 target->get_window_origin (x, y); 468 target->get_window_origin (x, y);
469 x = -x; 469 x = -x;
470 y = -y; 470 y = -y;
471 } 471 }
472 else 472 else
473 { 473 {
474 x = make_align_position (h_align, target_width, w > 0 ? w : image_width); 474 x = make_align_position (h_align, target_width, w);
475 y = make_align_position (v_align, target_height, h > 0 ? h : image_height); 475 y = make_align_position (v_align, target_height, h);
476 } 476 }
477 477
478 flags &= ~sizeSensitive; 478 flags &= ~sizeSensitive;
479 if (h_scale != 0 || v_scale != 0 479 if (h_scale != 0 || v_scale != 0
480 || h_align != 0 || v_align != 0 480 || h_align != 0 || v_align != 0
481 || image_width > target_width || image_height > target_height) 481 || w > target_width || h > target_height)
482 flags |= sizeSensitive; 482 flags |= sizeSensitive;
483} 483}
484 484
485# ifdef HAVE_AFTERIMAGE 485# ifdef HAVE_AFTERIMAGE
486bool 486bool
542 542
543 if (original_asim) 543 if (original_asim)
544 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); 544 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
545 545
546 if (!original_asim 546 if (!original_asim
547 || (!(flags & rootAlign)
547 || x >= target_width 548 && (x >= target_width
548 || y >= target_height 549 || y >= target_height
549 || (w > 0 && x + w <= 0) 550 || (x + w <= 0)
550 || (h > 0 && y + h <= 0)) 551 || (y + h <= 0))))
551 { 552 {
552 if (background) 553 if (background)
553 { 554 {
554 new_pmap_width = background->width; 555 new_pmap_width = background->width;
555 new_pmap_height = background->height; 556 new_pmap_height = background->height;
569 } 570 }
570 else 571 else
571 { 572 {
572 result = original_asim; 573 result = original_asim;
573 574
574 if ((w > 0 && w != original_asim->width) 575 if ((w != original_asim->width)
575 || (h > 0 && h != original_asim->height)) 576 || (h != original_asim->height))
576 { 577 {
577 result = scale_asimage (target->asv, original_asim, 578 result = scale_asimage (target->asv, original_asim,
578 w > 0 ? w : original_asim->width, 579 w, h,
579 h > 0 ? h : original_asim->height,
580 background ? ASA_ASImage : ASA_XImage, 580 background ? ASA_ASImage : ASA_XImage,
581 100, ASIMAGE_QUALITY_DEFAULT); 581 100, ASIMAGE_QUALITY_DEFAULT);
582 } 582 }
583 583
584 if (background == NULL) 584 if (background == NULL)
616 layers[0].clip_width = target_width; 616 layers[0].clip_width = target_width;
617 layers[0].clip_height = target_height; 617 layers[0].clip_height = target_height;
618 layers[0].tint = background_tint; 618 layers[0].tint = background_tint;
619 layers[1].im = result; 619 layers[1].im = result;
620 620
621 if (w <= 0) 621 if (h_scale == 0 || v_scale == 0)
622 { 622 {
623 /* tile horizontally */ 623 /* tile horizontally */
624 while (x > 0) x -= (int)result->width; 624 while (x > 0) x -= (int)result->width;
625 layers[1].dst_x = x; 625 layers[1].dst_x = x;
626 layers[1].clip_width = result->width+target_width; 626 layers[1].clip_width = result->width+target_width;
630 /* clip horizontally */ 630 /* clip horizontally */
631 layers[1].dst_x = x; 631 layers[1].dst_x = x;
632 layers[1].clip_width = result->width; 632 layers[1].clip_width = result->width;
633 } 633 }
634 634
635 if (h <= 0) 635 if (h_scale == 0 || v_scale == 0)
636 { 636 {
637 while (y > 0) y -= (int)result->height; 637 while (y > 0) y -= (int)result->height;
638 layers[1].dst_y = y; 638 layers[1].dst_y = y;
639 layers[1].clip_height = result->height + target_height; 639 layers[1].clip_height = result->height + target_height;
640 } 640 }
762 int w = 0; 762 int w = 0;
763 int h = 0; 763 int h = 0;
764 764
765 get_image_geometry (image_width, image_height, w, h, x, y); 765 get_image_geometry (image_width, image_height, w, h, x, y);
766 766
767 if (!(flags & rootAlign)
767 if (x >= target_width 768 && (x >= target_width
768 || y >= target_height 769 || y >= target_height
769 || (w > 0 && x + w <= 0) 770 || (x + w <= 0)
770 || (h > 0 && y + h <= 0)) 771 || (y + h <= 0)))
771 return false; 772 return false;
772 773
773 result = pixbuf; 774 result = pixbuf;
774 775
775 if ((w > 0 && w != image_width) 776 if ((w != image_width)
776 || (h > 0 && h != image_height)) 777 || (h != image_height))
777 { 778 {
778 result = gdk_pixbuf_scale_simple (pixbuf, 779 result = gdk_pixbuf_scale_simple (pixbuf,
779 w > 0 ? w : image_width, 780 w, h,
780 h > 0 ? h : image_height,
781 GDK_INTERP_BILINEAR); 781 GDK_INTERP_BILINEAR);
782 } 782 }
783 783
784 bool ret = false; 784 bool ret = false;
785 785
1048 1048
1049 return false; 1049 return false;
1050} 1050}
1051 1051
1052bool 1052bool
1053bgPixmap_t::tint_pixmap (Pixmap pixmap) 1053bgPixmap_t::tint_pixmap (Pixmap pixmap, Window root, int width, int height)
1054{ 1054{
1055 Window root = target->display->root;
1056 Display *dpy = target->dpy; 1055 Display *dpy = target->dpy;
1057 int window_width = target->szHint.width;
1058 int window_height = target->szHint.height;
1059 bool ret = false; 1056 bool ret = false;
1060 1057
1061 if (flags & tintWholesome) 1058 if (flags & tintWholesome)
1062 { 1059 {
1063 XGCValues gcv; 1060 XGCValues gcv;
1070 gcv.function = GXand; 1067 gcv.function = GXand;
1071 gcv.fill_style = FillSolid; 1068 gcv.fill_style = FillSolid;
1072 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); 1069 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
1073 if (gc) 1070 if (gc)
1074 { 1071 {
1075 XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); 1072 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
1076 ret = true; 1073 ret = true;
1077 XFreeGC (dpy, gc); 1074 XFreeGC (dpy, gc);
1078 } 1075 }
1079 } 1076 }
1080 else 1077 else
1091 c.g = (c.g * shade) / 100; 1088 c.g = (c.g * shade) / 100;
1092 c.b = (c.b * shade) / 100; 1089 c.b = (c.b * shade) / 100;
1093 } 1090 }
1094 else if (shade > 100 && shade < 200) 1091 else if (shade > 100 && shade < 200)
1095 { 1092 {
1096 c.r = (c.r * (200 - shade)) / 100; 1093 c.r = ((0xffff - c.r) * (200 - shade)) / 100;
1097 c.g = (c.g * (200 - shade)) / 100; 1094 c.g = ((0xffff - c.g) * (200 - shade)) / 100;
1098 c.b = (c.b * (200 - shade)) / 100; 1095 c.b = ((0xffff - c.b) * (200 - shade)) / 100;
1099 } 1096 }
1100 1097
1101 XRenderPictFormat pf; 1098 XRenderPictFormat pf;
1102 pf.type = PictTypeDirect; 1099 pf.type = PictTypeDirect;
1103 pf.depth = 32; 1100 pf.depth = 32;
1142 mask_c.alpha = 0; 1139 mask_c.alpha = 0;
1143 mask_c.red = 0xffff - c.r; 1140 mask_c.red = 0xffff - c.r;
1144 mask_c.green = 0xffff - c.g; 1141 mask_c.green = 0xffff - c.g;
1145 mask_c.blue = 0xffff - c.b; 1142 mask_c.blue = 0xffff - c.b;
1146 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1143 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1147 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); 1144 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1148 ret = true; 1145 ret = true;
1149 } 1146 }
1150 1147
1151 XRenderFreePicture (dpy, mask_pic); 1148 XRenderFreePicture (dpy, mask_pic);
1152 XRenderFreePicture (dpy, overlay_pic); 1149 XRenderFreePicture (dpy, overlay_pic);
1295 { 1292 {
1296 if (!need_client_side_rendering ()) 1293 if (!need_client_side_rendering ())
1297 { 1294 {
1298 if ((flags & tintNeeded)) 1295 if ((flags & tintNeeded))
1299 { 1296 {
1300 if (tint_pixmap (tiled_root_pmap)) 1297 if (tint_pixmap (tiled_root_pmap, root, window_width, window_height))
1301 result |= transpPmapTinted; 1298 result |= transpPmapTinted;
1302 } 1299 }
1303 } /* server side rendering completed */ 1300 } /* server side rendering completed */
1304 1301
1305 if (pixmap) 1302 if (pixmap)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines