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.70 by sf-exg, Tue Oct 5 20:22:25 2010 UTC vs.
Revision 1.78 by sf-exg, Wed Oct 13 10:27:22 2010 UTC

104#ifdef BG_IMAGE_FROM_FILE 104#ifdef BG_IMAGE_FROM_FILE
105 have_image = false; 105 have_image = false;
106 h_scale = v_scale = 0; 106 h_scale = v_scale = 0;
107 h_align = v_align = 0; 107 h_align = v_align = 0;
108#endif 108#endif
109#ifdef ENABLE_TRANSPARENCY
110 shade = 100;
111#endif
109 flags = 0; 112 flags = 0;
110 pixmap = None; 113 pixmap = None;
111 valid_since = invalid_since = 0; 114 valid_since = invalid_since = 0;
112 target = 0; 115 target = 0;
113} 116}
499 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 502 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
500 503
501 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 504 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
502 { 505 {
503 ShadingInfo as_shade; 506 ShadingInfo as_shade;
504 as_shade.shading = (shade == 0) ? 100 : shade; 507 as_shade.shading = shade;
505 508
506 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 509 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
507 if (flags & tintSet) 510 if (flags & tintSet)
508 tint.get (c); 511 tint.get (c);
509 as_shade.tintColor.red = c.r; 512 as_shade.tintColor.red = c.r;
511 as_shade.tintColor.blue = c.b; 514 as_shade.tintColor.blue = c.b;
512 515
513 background_tint = shading2tint32 (&as_shade); 516 background_tint = shading2tint32 (&as_shade);
514 } 517 }
515 518
516 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 519 if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL)
517 { 520 {
518 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 521 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
519 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, 522 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage,
520 100, ASIMAGE_QUALITY_DEFAULT); 523 100, ASIMAGE_QUALITY_DEFAULT);
521 if (tmp) 524 if (tmp)
616 layers[0].clip_width = target_width; 619 layers[0].clip_width = target_width;
617 layers[0].clip_height = target_height; 620 layers[0].clip_height = target_height;
618 layers[0].tint = background_tint; 621 layers[0].tint = background_tint;
619 layers[1].im = result; 622 layers[1].im = result;
620 623
621 if (w <= 0) 624 if (h_scale == 0 || v_scale == 0)
622 { 625 {
623 /* tile horizontally */ 626 /* tile horizontally */
624 while (x > 0) x -= (int)result->width; 627 while (x > 0) x -= (int)result->width;
625 layers[1].dst_x = x; 628 layers[1].dst_x = x;
626 layers[1].clip_width = result->width+target_width; 629 layers[1].clip_width = result->width+target_width;
630 /* clip horizontally */ 633 /* clip horizontally */
631 layers[1].dst_x = x; 634 layers[1].dst_x = x;
632 layers[1].clip_width = result->width; 635 layers[1].clip_width = result->width;
633 } 636 }
634 637
635 if (h <= 0) 638 if (h_scale == 0 || v_scale == 0)
636 { 639 {
637 while (y > 0) y -= (int)result->height; 640 while (y > 0) y -= (int)result->height;
638 layers[1].dst_y = y; 641 layers[1].dst_y = y;
639 layers[1].clip_height = result->height + target_height; 642 layers[1].clip_height = result->height + target_height;
640 } 643 }
959static inline unsigned long 962static inline unsigned long
960compute_tint_shade_flags (rxvt_color *tint, int shade) 963compute_tint_shade_flags (rxvt_color *tint, int shade)
961{ 964{
962 unsigned long flags = 0; 965 unsigned long flags = 0;
963 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 966 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
964 bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); 967 bool has_shade = shade != 100;
965 968
966 if (tint) 969 if (tint)
967 { 970 {
968 tint->get (c); 971 tint->get (c);
969# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) 972# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
1001} 1004}
1002 1005
1003bool 1006bool
1004bgPixmap_t::set_tint (rxvt_color &new_tint) 1007bgPixmap_t::set_tint (rxvt_color &new_tint)
1005{ 1008{
1006 if (tint != new_tint) 1009 if (!(flags & tintSet) || tint != new_tint)
1007 { 1010 {
1008 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 1011 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
1009 tint = new_tint; 1012 tint = new_tint;
1010 flags = (flags & ~tintFlags) | new_flags | tintSet; 1013 flags = (flags & ~tintFlags) | new_flags | tintSet;
1011 return true; 1014 return true;
1029} 1032}
1030 1033
1031bool 1034bool
1032bgPixmap_t::set_shade (const char *shade_str) 1035bgPixmap_t::set_shade (const char *shade_str)
1033{ 1036{
1034 int new_shade = (shade_str) ? atoi (shade_str) : 0; 1037 int new_shade = (shade_str) ? atoi (shade_str) : 100;
1035 1038
1036 if (new_shade < 0 && new_shade > -100) 1039 clamp_it (new_shade, -100, 200);
1040 if (new_shade < 0)
1037 new_shade = 200 - (100 + new_shade); 1041 new_shade = 200 - (100 + new_shade);
1038 else if (new_shade == 100)
1039 new_shade = 0;
1040 1042
1041 if (new_shade != shade) 1043 if (new_shade != shade)
1042 { 1044 {
1043 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); 1045 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade);
1044 shade = new_shade; 1046 shade = new_shade;
1048 1050
1049 return false; 1051 return false;
1050} 1052}
1051 1053
1052bool 1054bool
1053bgPixmap_t::tint_pixmap (Pixmap pixmap, Window root, int width, int height) 1055bgPixmap_t::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1054{ 1056{
1055 Display *dpy = target->dpy; 1057 Display *dpy = target->dpy;
1056 bool ret = false; 1058 bool ret = false;
1057 1059
1058 if (flags & tintWholesome) 1060 if (flags & tintWholesome)
1064 * performance improvements, as we eliminate XImage transfer 1066 * performance improvements, as we eliminate XImage transfer
1065 */ 1067 */
1066 gcv.foreground = Pixel (tint); 1068 gcv.foreground = Pixel (tint);
1067 gcv.function = GXand; 1069 gcv.function = GXand;
1068 gcv.fill_style = FillSolid; 1070 gcv.fill_style = FillSolid;
1069 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); 1071 gc = XCreateGC (dpy, pixmap, GCFillStyle | GCForeground | GCFunction, &gcv);
1070 if (gc) 1072 if (gc)
1071 { 1073 {
1072 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); 1074 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
1073 ret = true; 1075 ret = true;
1074 XFreeGC (dpy, gc); 1076 XFreeGC (dpy, gc);
1080 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1082 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1081 1083
1082 if (flags & tintSet) 1084 if (flags & tintSet)
1083 tint.get (c); 1085 tint.get (c);
1084 1086
1085 if (shade > 0 && shade < 100) 1087 if (shade <= 100)
1086 { 1088 {
1087 c.r = (c.r * shade) / 100; 1089 c.r = (c.r * shade) / 100;
1088 c.g = (c.g * shade) / 100; 1090 c.g = (c.g * shade) / 100;
1089 c.b = (c.b * shade) / 100; 1091 c.b = (c.b * shade) / 100;
1090 } 1092 }
1091 else if (shade > 100 && shade < 200) 1093 else
1092 {
1093 c.r = (c.r * (200 - shade)) / 100;
1094 c.g = (c.g * (200 - shade)) / 100;
1095 c.b = (c.b * (200 - shade)) / 100;
1096 } 1094 {
1095 c.r = ((0xffff - c.r) * (200 - shade)) / 100;
1096 c.g = ((0xffff - c.g) * (200 - shade)) / 100;
1097 c.b = ((0xffff - c.b) * (200 - shade)) / 100;
1098 }
1097 1099
1098 XRenderPictFormat pf; 1100 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1099 pf.type = PictTypeDirect;
1100 pf.depth = 32;
1101 pf.direct.redMask = 0xff;
1102 pf.direct.greenMask = 0xff;
1103 pf.direct.blueMask = 0xff;
1104 pf.direct.alphaMask = 0xff;
1105
1106 XRenderPictFormat *solid_format = XRenderFindFormat (dpy, 1101 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1107 (PictFormatType|
1108 PictFormatDepth|
1109 PictFormatRedMask|
1110 PictFormatGreenMask|
1111 PictFormatBlueMask|
1112 PictFormatAlphaMask),
1113 &pf,
1114 0);
1115 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
1116 XRenderPictureAttributes pa; 1102 XRenderPictureAttributes pa;
1117 1103
1118 Picture back_pic = XRenderCreatePicture (dpy, pixmap, root_format, 0, &pa); 1104 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1119 1105
1120 pa.repeat = True; 1106 pa.repeat = True;
1121 1107
1122 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 1108 Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1123 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 1109 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1124 XFreePixmap (dpy, overlay_pmap); 1110 XFreePixmap (dpy, overlay_pmap);
1125 1111
1126 pa.component_alpha = True; 1112 pa.component_alpha = True;
1127 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 1113 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1128 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 1114 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
1129 XFreePixmap (dpy, mask_pmap); 1115 XFreePixmap (dpy, mask_pmap);
1130 1116
1131 if (mask_pic && overlay_pic && back_pic) 1117 if (mask_pic && overlay_pic && back_pic)
1132 { 1118 {
1192 || sx >= root_width || sy >= root_height) 1178 || sx >= root_width || sy >= root_height)
1193 return 0; 1179 return 0;
1194 1180
1195 if (root_pixmap != None) 1181 if (root_pixmap != None)
1196 { 1182 {
1197 /* we want to validate the pixmap and get it's size at the same time : */ 1183 /* we want to validate the pixmap and get its size at the same time : */
1198 int junk; 1184 int junk;
1199 unsigned int ujunk; 1185 unsigned int ujunk;
1200 /* root pixmap may be bad - allow a error */ 1186 /* root pixmap may be bad - allow a error */
1201 target->allowedxerror = -1; 1187 target->allowedxerror = -1;
1202 1188
1292 { 1278 {
1293 if (!need_client_side_rendering ()) 1279 if (!need_client_side_rendering ())
1294 { 1280 {
1295 if ((flags & tintNeeded)) 1281 if ((flags & tintNeeded))
1296 { 1282 {
1297 if (tint_pixmap (tiled_root_pmap, root, window_width, window_height)) 1283 if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height))
1298 result |= transpPmapTinted; 1284 result |= transpPmapTinted;
1299 } 1285 }
1300 } /* server side rendering completed */ 1286 } /* server side rendering completed */
1301 1287
1302 if (pixmap) 1288 if (pixmap)
1543 int i; 1529 int i;
1544 1530
1545 Visual *visual = term->visual; 1531 Visual *visual = term->visual;
1546 1532
1547 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; 1533 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ;
1548
1549 if (shade == 0)
1550 shade = 100;
1551 1534
1552 /* for convenience */ 1535 /* for convenience */
1553 mask_r = visual->red_mask; 1536 mask_r = visual->red_mask;
1554 mask_g = visual->green_mask; 1537 mask_g = visual->green_mask;
1555 mask_b = visual->blue_mask; 1538 mask_b = visual->blue_mask;
1611 default: 1594 default:
1612 return; /* we do not support this color depth */ 1595 return; /* we do not support this color depth */
1613 } 1596 }
1614 1597
1615 /* prepare limits for color transformation (each channel is handled separately) */ 1598 /* prepare limits for color transformation (each channel is handled separately) */
1616 if (shade < 0) { 1599 if (shade > 100) {
1617 shade = -shade; 1600 shade = 200 - shade;
1618 if (shade < 0) shade = 0;
1619 if (shade > 100) shade = 100;
1620 1601
1621 lower_lim_r = 65535-rm; 1602 lower_lim_r = 65535-rm;
1622 lower_lim_g = 65535-gm; 1603 lower_lim_g = 65535-gm;
1623 lower_lim_b = 65535-bm; 1604 lower_lim_b = 65535-bm;
1624 1605
1626 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); 1607 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
1627 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); 1608 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
1628 1609
1629 upper_lim_r = upper_lim_g = upper_lim_b = 65535; 1610 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1630 } else { 1611 } else {
1631 if (shade < 0) shade = 0;
1632 if (shade > 100) shade = 100;
1633 1612
1634 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1613 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1635 1614
1636 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); 1615 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
1637 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); 1616 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines