--- rxvt-unicode/src/background.C 2010/11/05 17:27:58 1.111 +++ rxvt-unicode/src/background.C 2010/11/11 11:58:10 1.116 @@ -668,20 +668,14 @@ XGCValues gcv; GC gc; - if (pixmap) - { - if (pmap_width != new_pmap_width - || pmap_height != new_pmap_height - || pmap_depth != target->depth) - { - XFreePixmap (target->dpy, pixmap); - pixmap = None; - } - } - /* create Pixmap */ - if (pixmap == None) + if (pixmap == None + || pmap_width != new_pmap_width + || pmap_height != new_pmap_height + || pmap_depth != target->depth) { + if (pixmap) + XFreePixmap (target->dpy, pixmap); pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); pmap_width = new_pmap_width; pmap_height = new_pmap_height; @@ -799,19 +793,13 @@ } } - if (pixmap) - { - if (pmap_width != new_pmap_width - || pmap_height != new_pmap_height - || pmap_depth != target->depth) - { - XFreePixmap (target->dpy, pixmap); - pixmap = None; - } - } - - if (pixmap == None) + if (pixmap == None + || pmap_width != new_pmap_width + || pmap_height != new_pmap_height + || pmap_depth != target->depth) { + if (pixmap) + XFreePixmap (target->dpy, pixmap); pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); pmap_width = new_pmap_width; pmap_height = new_pmap_height; @@ -1241,7 +1229,7 @@ { XRenderColor mask_c; - memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); + mask_c.red = mask_c.green = mask_c.blue = shade > 100 ? 0xffff : 0; mask_c.alpha = 0xffff; XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); @@ -1369,10 +1357,7 @@ XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); result |= transpPmapTiled; XFreeGC (dpy, gc); - } - if (tiled_root_pmap != None) - { if (!need_client_side_rendering ()) { if ((flags & blurNeeded) @@ -1397,6 +1382,8 @@ pmap_height = window_height; pmap_depth = target->depth; } + else + XFreePixmap (dpy, tiled_root_pmap); if (recoded_root_pmap != root_pixmap) XFreePixmap (dpy, recoded_root_pmap); @@ -1415,8 +1402,8 @@ } # endif /* ENABLE_TRANSPARENCY */ -# ifndef HAVE_AFTERIMAGE -static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); +#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) +static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c); # endif bool @@ -1449,7 +1436,7 @@ } # endif -# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER +# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) XImage *result = NULL; if (background_flags && (flags & isInvalid)) @@ -1465,7 +1452,7 @@ rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); if (flags & tintSet) tint.get (c); - ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); + ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); } GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); @@ -1576,17 +1563,17 @@ #endif /* HAVE_BG_PIXMAP */ -#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER +#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) /* taken from aterm-0.4.2 */ static void -ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) +ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c) { int sh_r, sh_g, sh_b; uint32_t mask_r, mask_g, mask_b; uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; - unsigned int lower_lim_r, lower_lim_g, lower_lim_b; - unsigned int upper_lim_r, upper_lim_g, upper_lim_b; + rgba low; + rgba high; int i; int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; @@ -1661,46 +1648,43 @@ { shade = 200 - shade; - lower_lim_r = 65535-rm; - lower_lim_g = 65535-gm; - lower_lim_b = 65535-bm; - - lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); - lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); - lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); - - upper_lim_r = upper_lim_g = upper_lim_b = 65535; + high.r = (65535 - c.r) * shade / 100; + high.g = (65535 - c.g) * shade / 100; + high.b = (65535 - c.b) * shade / 100; + + low.r = 65535 - high.r; + low.g = 65535 - high.g; + low.b = 65535 - high.b; } else { + high.r = c.r * shade / 100; + high.g = c.g * shade / 100; + high.b = c.b * shade / 100; - lower_lim_r = lower_lim_g = lower_lim_b = 0; - - upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100); - upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100); - upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100); + low.r = low.g = low.b = 0; } /* fill our lookup tables */ for (i = 0; i <= mask_r>>sh_r; i++) { uint32_t tmp; - tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); - tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); + tmp = i * high.r; + tmp += (mask_r>>sh_r) * low.r; lookup_r[i] = (tmp/65535)<>sh_g; i++) { uint32_t tmp; - tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); - tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); + tmp = i * high.g; + tmp += (mask_g>>sh_g) * low.g; lookup_g[i] = (tmp/65535)<>sh_b; i++) { uint32_t tmp; - tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); - tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); + tmp = i * high.b; + tmp += (mask_b>>sh_b) * low.b; lookup_b[i] = (tmp/65535)<