--- rxvt-unicode/src/background.C 2011/01/28 00:08:57 1.143 +++ rxvt-unicode/src/background.C 2011/12/25 17:01:21 1.182 @@ -3,7 +3,7 @@ *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2005-2008 Marc Lehmann + * Copyright (c) 2005-2008 Marc Lehmann * Copyright (c) 2007 Sasha Vasko * Copyright (c) 2010 Emanuele Giaquinta * @@ -34,32 +34,6 @@ #define FilterConvolution "convolution" #endif -/* - * Pixmap geometry string interpretation : - * Each geometry string contains zero or one scale/position - * adjustment and may optionally be followed by a colon and one or more - * colon-delimited pixmap operations. - * The following table shows the valid geometry strings and their - * effects on the background image : - * - * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. - * W and H are percentages of the terminal window size. - * X and Y are also percentages; e.g., +50+50 centers - * the image in the window. - * - * Pixmap Operations : (should be prepended by a colon) - * tile Tile image. Scaling/position modifiers above will affect - * the tile size and origin. - * propscale When scaling, scale proportionally. That is, maintain the - * proper aspect ratio for the image. Any portion of the - * background not covered by the image is filled with the - * current background color. - * hscale Scale horizontally, tile vertically ? - * vscale Tile horizontally, scale vertically ? - * scale Scale both up and down - * auto Same as 100x100+50+50 - */ - #ifdef HAVE_BG_PIXMAP void rxvt_term::bg_destroy () @@ -67,6 +41,10 @@ #ifdef HAVE_AFTERIMAGE if (original_asim) safe_asimage_destroy (original_asim); + if (asv) + destroy_asvisual (asv, 0); + if (asimman) + destroy_image_manager (asimman, 0); #endif #ifdef HAVE_PIXBUF @@ -101,7 +79,7 @@ # endif # ifdef BG_IMAGE_FROM_FILE - if (have_image) + if (bg_flags & BG_IS_FROM_FILE) { if (bg_flags & BG_IS_SIZE_SENSITIVE) return true; @@ -120,7 +98,7 @@ # endif # ifdef BG_IMAGE_FROM_FILE - if (have_image) + if (bg_flags & BG_IS_FROM_FILE) { if (bg_flags & BG_ROOT_ALIGN) return true; @@ -174,9 +152,9 @@ if (align >= 0 && align <= 100) return diff * align / 100; else if (align > 100 && align <= 200) - return ((align - 100) * smaller / 100) + window_size - smaller; + return (align - 100) * smaller / 100 + window_size - smaller; else if (align >= -100 && align < 0) - return ((align + 100) * smaller / 100) - image_size; + return (align + 100) * smaller / 100 - image_size; return 0; } @@ -205,85 +183,87 @@ int geom_flags = 0; int x = 0, y = 0; unsigned int w = 0, h = 0; - unsigned int n; - unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); - const char *ops; + unsigned long new_flags = bg_flags & ~BG_GEOMETRY_FLAGS; if (geom == NULL) return false; - char str[256]; - - ops = strchr (geom, ':'); - if (ops == NULL) - n = strlen (geom); - else - n = ops - geom; - - if (n >= sizeof (str)) - return false; - - memcpy (str, geom, n); - str[n] = '\0'; - rxvt_strtrim (str); - - if (str[0]) - { - /* we have geometry string - let's handle it prior to applying ops */ - geom_flags = XParseGeometry (str, &x, &y, &w, &h); - } /* done parsing geometry string */ - - if (!update) - { - if (!(geom_flags & XValue)) - x = y = defaultAlign; - else if (!(geom_flags & YValue)) - y = x; - - if (!(geom_flags & (WidthValue|HeightValue))) - w = h = defaultScale; - else if (!(geom_flags & HeightValue)) - h = w; - else if (!(geom_flags & WidthValue)) - w = h; - - geom_flags |= WidthValue|HeightValue|XValue|YValue; - } - - if (ops) + if (geom[0]) { - char **arr = rxvt_strsplit (':', ops + 1); + char **arr = rxvt_strsplit (':', geom); - for (int i = 0; arr[i]; i++) + for (int i = 0; arr[i]; i++) { - if (!strcasecmp (arr[i], "tile")) + if (!strcasecmp (arr[i], "style=tiled")) + { + new_flags = BG_TILE; + w = h = noScale; + x = y = 0; + geom_flags = WidthValue|HeightValue|XValue|YValue; + } + else if (!strcasecmp (arr[i], "style=aspect-stretched")) + { + new_flags = BG_KEEP_ASPECT; + w = h = windowScale; + x = y = centerAlign; + geom_flags = WidthValue|HeightValue|XValue|YValue; + } + else if (!strcasecmp (arr[i], "style=stretched")) + { + new_flags = 0; + w = h = windowScale; + geom_flags = WidthValue|HeightValue; + } + else if (!strcasecmp (arr[i], "style=centered")) + { + new_flags = 0; + w = h = noScale; + x = y = centerAlign; + geom_flags = WidthValue|HeightValue|XValue|YValue; + } + else if (!strcasecmp (arr[i], "style=root-tiled")) + { + new_flags = BG_TILE|BG_ROOT_ALIGN; + w = h = noScale; + geom_flags = WidthValue|HeightValue; + } + else if (!strcasecmp (arr[i], "op=tile")) + new_flags |= BG_TILE; + else if (!strcasecmp (arr[i], "op=keep-aspect")) + new_flags |= BG_KEEP_ASPECT; + else if (!strcasecmp (arr[i], "op=root-align")) + new_flags |= BG_ROOT_ALIGN; + + // deprecated + else if (!strcasecmp (arr[i], "tile")) { + new_flags |= BG_TILE; w = h = noScale; geom_flags |= WidthValue|HeightValue; } else if (!strcasecmp (arr[i], "propscale")) { - new_flags |= BG_PROP_SCALE; + new_flags |= BG_KEEP_ASPECT; + w = h = windowScale; + geom_flags |= WidthValue|HeightValue; } else if (!strcasecmp (arr[i], "hscale")) { - if (w == 0) w = windowScale; - + new_flags |= BG_TILE; + w = windowScale; h = noScale; geom_flags |= WidthValue|HeightValue; } else if (!strcasecmp (arr[i], "vscale")) { - if (h == 0) h = windowScale; - + new_flags |= BG_TILE; + h = windowScale; w = noScale; geom_flags |= WidthValue|HeightValue; } else if (!strcasecmp (arr[i], "scale")) { - if (h == 0) h = windowScale; - if (w == 0) w = windowScale; - + w = h = windowScale; geom_flags |= WidthValue|HeightValue; } else if (!strcasecmp (arr[i], "auto")) @@ -294,15 +274,35 @@ } else if (!strcasecmp (arr[i], "root")) { - new_flags |= BG_ROOT_ALIGN; + new_flags |= BG_TILE|BG_ROOT_ALIGN; w = h = noScale; geom_flags |= WidthValue|HeightValue; } + + else + geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); } /* done parsing ops */ rxvt_free_strsplit (arr); } + if (!update) + { + if (!(geom_flags & XValue)) + x = y = defaultAlign; + else if (!(geom_flags & YValue)) + y = x; + + if (!(geom_flags & (WidthValue|HeightValue))) + w = h = defaultScale; + else if (!(geom_flags & HeightValue)) + h = w; + else if (!(geom_flags & WidthValue)) + w = h; + + geom_flags |= WidthValue|HeightValue|XValue|YValue; + } + if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; @@ -323,18 +323,16 @@ int target_width = szHint.width; int target_height = szHint.height; - if (bg_flags & BG_PROP_SCALE) + w = h_scale * target_width / 100; + h = v_scale * target_height / 100; + + if (bg_flags & BG_KEEP_ASPECT) { - float scale = (float)target_width / image_width; - min_it (scale, (float)target_height / image_height); + float scale = (float)w / image_width; + min_it (scale, (float)h / image_height); w = image_width * scale + 0.5; h = image_height * scale + 0.5; } - else - { - w = h_scale * target_width / 100; - h = v_scale * target_height / 100; - } if (!w) w = image_width; if (!h) h = image_height; @@ -351,7 +349,8 @@ } bg_flags &= ~BG_IS_SIZE_SENSITIVE; - if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale + if (!(bg_flags & BG_TILE) + || h_scale || v_scale || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) || w > target_width || h > target_height) bg_flags |= BG_IS_SIZE_SENSITIVE; @@ -388,7 +387,7 @@ if ((tr_flags & BG_NEEDS_BLUR) && background != NULL) { ASImage *tmp = blur_asimage_gauss (asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, - (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, + ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); if (tmp) { @@ -417,8 +416,8 @@ || (!(bg_flags & BG_ROOT_ALIGN) && (x >= target_width || y >= target_height - || (x + w <= 0) - || (y + h <= 0)))) + || x + w <= 0 + || y + h <= 0))) { if (background) { @@ -442,18 +441,18 @@ { result = original_asim; - if ((w != original_asim->width) - || (h != original_asim->height)) + if (w != original_asim->width + || h != original_asim->height) { result = scale_asimage (asv, original_asim, w, h, - background ? ASA_ASImage : ASA_XImage, + ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); } if (background == NULL) { - if (h_scale == 0 || v_scale == 0) + if (bg_flags & BG_TILE) { /* if tiling - pixmap has to be sized exactly as the image, but there is no need to make it bigger than the window! */ @@ -488,7 +487,7 @@ layers[0].tint = background_tint; layers[1].im = result; - if (h_scale == 0 || v_scale == 0) + if (bg_flags & BG_TILE) { /* tile horizontally */ while (x > 0) x -= (int)result->width; @@ -502,7 +501,7 @@ layers[1].clip_width = result->width; } - if (h_scale == 0 || v_scale == 0) + if (bg_flags & BG_TILE) { while (y > 0) y -= (int)result->height; layers[1].dst_y = y; @@ -562,7 +561,7 @@ int dst_width = result->width, dst_height = result->height; if (background == NULL) { - if (!(h_scale == 0 || v_scale == 0)) + if (!(bg_flags & BG_TILE)) { src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); @@ -618,16 +617,16 @@ else return false; - width_r = rxvt_popcount (visual->red_mask); - width_g = rxvt_popcount (visual->green_mask); - width_b = rxvt_popcount (visual->blue_mask); + width_r = ecb_popcount32 (visual->red_mask); + width_g = ecb_popcount32 (visual->green_mask); + width_b = ecb_popcount32 (visual->blue_mask); if (width_r > 8 || width_g > 8 || width_b > 8) return false; - sh_r = rxvt_ctz (visual->red_mask); - sh_g = rxvt_ctz (visual->green_mask); - sh_b = rxvt_ctz (visual->blue_mask); + sh_r = ecb_ctz32 (visual->red_mask); + sh_g = ecb_ctz32 (visual->green_mask); + sh_b = ecb_ctz32 (visual->blue_mask); if (width > INT_MAX / height / bytes_per_pixel) return false; @@ -644,7 +643,7 @@ return false; } - ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; + ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; rowstride = gdk_pixbuf_get_rowstride (pixbuf); channels = gdk_pixbuf_get_n_channels (pixbuf); @@ -707,60 +706,63 @@ if (!(bg_flags & BG_ROOT_ALIGN) && (x >= target_width || y >= target_height - || (x + w <= 0) - || (y + h <= 0))) + || x + w <= 0 + || y + h <= 0)) return false; result = pixbuf; - if ((w != image_width) - || (h != image_height)) + if (w != image_width + || h != image_height) { result = gdk_pixbuf_scale_simple (pixbuf, w, h, GDK_INTERP_BILINEAR); } + if (!result) + return false; + bool ret = false; - if (result) - { - XGCValues gcv; - GC gc; - Pixmap root_pmap; + XGCValues gcv; + GC gc; + Pixmap root_pmap; - image_width = gdk_pixbuf_get_width (result); - image_height = gdk_pixbuf_get_height (result); + image_width = gdk_pixbuf_get_width (result); + image_height = gdk_pixbuf_get_height (result); - if (tr_flags) - { - root_pmap = bg_pixmap; - bg_pixmap = None; - } - else + if (tr_flags) + { + root_pmap = bg_pixmap; + bg_pixmap = None; + } + else + { + if (bg_flags & BG_TILE) { - if (h_scale == 0 || v_scale == 0) - { - new_pmap_width = min (image_width, target_width); - new_pmap_height = min (image_height, target_height); - } + new_pmap_width = min (image_width, target_width); + new_pmap_height = min (image_height, target_height); } + } - if (bg_pixmap == None - || bg_pmap_width != new_pmap_width - || bg_pmap_height != new_pmap_height) - { - if (bg_pixmap) - XFreePixmap (dpy, bg_pixmap); - bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); - bg_pmap_width = new_pmap_width; - bg_pmap_height = new_pmap_height; - } + if (bg_pixmap == None + || bg_pmap_width != new_pmap_width + || bg_pmap_height != new_pmap_height) + { + if (bg_pixmap) + XFreePixmap (dpy, bg_pixmap); + bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); + bg_pmap_width = new_pmap_width; + bg_pmap_height = new_pmap_height; + } - gcv.foreground = pix_colors[Color_bg]; - gc = XCreateGC (dpy, vt, GCForeground, &gcv); + gcv.foreground = pix_colors[Color_bg]; + gc = XCreateGC (dpy, vt, GCForeground, &gcv); - if (h_scale == 0 || v_scale == 0) + if (gc) + { + if (bg_flags & BG_TILE) { Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); pixbuf_to_pixmap (result, tile, gc, @@ -814,34 +816,32 @@ Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); XFreePixmap (dpy, mask_pmap); - if (src && dst && mask) - { - XRenderColor mask_c; + XRenderColor mask_c; - mask_c.alpha = 0x8000; - mask_c.red = 0; - mask_c.green = 0; - mask_c.blue = 0; - XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); - XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); - } + mask_c.alpha = 0x8000; + mask_c.red = 0; + mask_c.green = 0; + mask_c.blue = 0; + XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); + XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); XRenderFreePicture (dpy, src); XRenderFreePicture (dpy, dst); XRenderFreePicture (dpy, mask); - - XFreePixmap (dpy, root_pmap); } #endif - if (result != pixbuf) - g_object_unref (result); - XFreeGC (dpy, gc); ret = true; } + if (result != pixbuf) + g_object_unref (result); + + if (tr_flags) + XFreePixmap (dpy, root_pmap); + return ret; } # endif /* HAVE_PIXBUF */ @@ -852,7 +852,10 @@ if (!file || !*file) return false; - if (const char *p = strchr (file, ';')) + bool ret = false; + const char *p = strchr (file, ';'); + + if (p) { size_t len = p - file; char *f = rxvt_temp_buf (len + 1); @@ -870,9 +873,8 @@ if (original_asim) safe_asimage_destroy (original_asim); original_asim = image; - bg_flags |= BG_CLIENT_RENDER; - have_image = true; - return true; + bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER; + ret = true; } # endif @@ -883,12 +885,20 @@ if (pixbuf) g_object_unref (pixbuf); pixbuf = image; - have_image = true; - return true; + bg_flags |= BG_IS_FROM_FILE; + ret = true; } # endif - return false; + if (ret) + { + if (p) + bg_set_geometry (p + 1); + else + bg_set_default_geometry (); + } + + return ret; } # endif /* BG_IMAGE_FROM_FILE */ @@ -942,27 +952,26 @@ return changed; } -static inline unsigned long -compute_tint_shade_flags (rxvt_color *tint, int shade) +void +rxvt_term::set_tint_shade_flags () { - unsigned long flags = 0; - rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); + rgba c; bool has_shade = shade != 100; - if (tint) + bg_flags &= ~BG_TINT_FLAGS; + + if (bg_flags & BG_TINT_SET) { - tint->get (c); + tint.get (c); if (!has_shade && (c.r <= 0x00ff || c.r >= 0xff00) && (c.g <= 0x00ff || c.g >= 0xff00) && (c.b <= 0x00ff || c.b >= 0xff00)) - flags |= rxvt_term::BG_TINT_BITAND; + bg_flags |= BG_TINT_BITAND; } - if (has_shade || tint) - flags |= rxvt_term::BG_NEEDS_TINT; - - return flags; + if (has_shade || (bg_flags & BG_TINT_SET)) + bg_flags |= BG_NEEDS_TINT; } bool @@ -970,9 +979,9 @@ { if (!(bg_flags & BG_TINT_SET) || tint != new_tint) { - unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); tint = new_tint; - bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; + bg_flags |= BG_TINT_SET; + set_tint_shade_flags (); return true; } @@ -990,9 +999,8 @@ if (new_shade != shade) { - unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade); shade = new_shade; - bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; + set_tint_shade_flags (); return true; } @@ -1027,6 +1035,9 @@ { bool ret = false; #if XRENDER + if (!(bg_flags & BG_HAS_RENDER_CONV)) + return false; + int size = max (h_blurRadius, v_blurRadius) * 2 + 1; double *kernel = (double *)malloc (size * sizeof (double)); XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); @@ -1037,7 +1048,7 @@ Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); - if (kernel && params && src && dst) + if (kernel && params) { if (h_blurRadius) { @@ -1109,25 +1120,25 @@ XFreeGC (dpy, gc); } } - else - { # if XRENDER - rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); + else if (bg_flags & BG_HAS_RENDER) + { + rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); if (bg_flags & BG_TINT_SET) tint.get (c); if (shade <= 100) { - c.r = (c.r * shade) / 100; - c.g = (c.g * shade) / 100; - c.b = (c.b * shade) / 100; + c.r = c.r * shade / 100; + c.g = c.g * shade / 100; + c.b = c.b * shade / 100; } else { - c.r = (c.r * (200 - shade)) / 100; - c.g = (c.g * (200 - shade)) / 100; - c.b = (c.b * (200 - shade)) / 100; + c.r = c.r * (200 - shade) / 100; + c.g = c.g * (200 - shade) / 100; + c.b = c.b * (200 - shade) / 100; } XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); @@ -1144,46 +1155,45 @@ pa.component_alpha = True; Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); - Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); + Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); XFreePixmap (dpy, mask_pmap); - if (mask_pic && overlay_pic && back_pic) - { - XRenderColor mask_c; + XRenderColor mask_c; - mask_c.red = mask_c.green = mask_c.blue = 0; - mask_c.alpha = 0xffff; - XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); + mask_c.alpha = 0xffff; + mask_c.red = + mask_c.green = + mask_c.blue = 0; + XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); + + mask_c.alpha = 0; + mask_c.red = 0xffff - c.r; + mask_c.green = 0xffff - c.g; + mask_c.blue = 0xffff - c.b; + XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); + XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); + if (shade > 100) + { + mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; mask_c.alpha = 0; - mask_c.red = 0xffff - c.r; - mask_c.green = 0xffff - c.g; - mask_c.blue = 0xffff - c.b; - XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); - XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); - - if (shade > 100) - { - mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; - mask_c.alpha = 0; - XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); - - XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); - } + XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); - ret = true; + XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); } + ret = true; + XRenderFreePicture (dpy, mask_pic); XRenderFreePicture (dpy, overlay_pic); XRenderFreePicture (dpy, back_pic); -# endif } +# endif return ret; } -/* make_transparency_pixmap() +/* * Builds a pixmap of the same size as the terminal window that contains * the tiled portion of the root pixmap that is supposed to be covered by * our window. @@ -1237,32 +1247,27 @@ #if XRENDER if (bg_flags & BG_HAS_RENDER) { + recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); + XRenderPictureAttributes pa; XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); - recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); - if (src && dst) - XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); - else - { - XFreePixmap (dpy, recoded_root_pmap); - root_pixmap = None; - } + XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); XRenderFreePicture (dpy, src); XRenderFreePicture (dpy, dst); } else #endif - root_pixmap = None; + recoded_root_pmap = None; } - if (root_pixmap == None) + if (recoded_root_pmap == None) return 0; if (bg_pixmap == None @@ -1276,12 +1281,9 @@ bg_pmap_height = window_height; } - if (bg_pixmap == None) - return 0; - /* straightforward pixmap copy */ - while (sx < 0) sx += (int)root_width; - while (sy < 0) sy += (int)root_height; + while (sx < 0) sx += root_pmap_width; + while (sy < 0) sy += root_pmap_height; gcv.tile = recoded_root_pmap; gcv.fill_style = FillTiled; @@ -1297,14 +1299,12 @@ if (!(bg_flags & BG_CLIENT_RENDER)) { - if ((bg_flags & BG_NEEDS_BLUR) - && (bg_flags & BG_HAS_RENDER_CONV)) + if (bg_flags & BG_NEEDS_BLUR) { if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) result &= ~BG_NEEDS_BLUR; } - if ((bg_flags & BG_NEEDS_TINT) - && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) + if (bg_flags & BG_NEEDS_TINT) { if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) result &= ~BG_NEEDS_TINT; @@ -1346,13 +1346,12 @@ tr_flags = make_transparency_pixmap (); if (tr_flags == 0) return false; - else if (!(tr_flags & BG_EFFECTS_FLAGS)) - bg_flags |= BG_IS_VALID; + bg_flags |= BG_IS_VALID; } # endif # ifdef BG_IMAGE_FROM_FILE - if (have_image + if ((bg_flags & BG_IS_FROM_FILE) || (tr_flags & BG_EFFECTS_FLAGS)) { if (render_image (tr_flags)) @@ -1363,7 +1362,7 @@ # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) XImage *result = NULL; - if (tr_flags && !(bg_flags & BG_IS_VALID)) + if (tr_flags & BG_NEEDS_TINT) { result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); } @@ -1371,7 +1370,8 @@ if (result) { /* our own client-side tinting */ - if (tr_flags & BG_NEEDS_TINT) + //if (tr_flags & BG_NEEDS_TINT) + if (1) { rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); if (bg_flags & BG_TINT_SET) @@ -1386,7 +1386,6 @@ XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); XFreeGC (dpy, gc); - bg_flags |= BG_IS_VALID; } XDestroyImage (result); @@ -1437,7 +1436,19 @@ #endif /* HAVE_BG_PIXMAP */ #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) -/* taken from aterm-0.4.2 */ +/* based on code from aterm-0.4.2 */ + +static inline void +fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) +{ + for (int i = 0; i <= mask >> sh; i++) + { + uint32_t tmp; + tmp = i * high; + tmp += (mask >> sh) * low; + lookup[i] = (tmp / 0xffff) << sh; + } +} static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) @@ -1445,10 +1456,9 @@ int sh_r, sh_g, sh_b; uint32_t mask_r, mask_g, mask_b; uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; - rgba low; + unsigned short low; rgba high; - int i; - int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; + int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; @@ -1525,9 +1535,7 @@ high.g = c.g * shade / 100; high.b = c.b * shade / 100; - low.r = 65535 * (100 - shade) / 100; - low.g = 65535 * (100 - shade) / 100; - low.b = 65535 * (100 - shade) / 100; + low = 0xffff * (100 - shade) / 100; } else { @@ -1535,31 +1543,13 @@ high.g = c.g * shade / 100; high.b = c.b * shade / 100; - low.r = low.g = low.b = 0; + low = 0; } /* fill our lookup tables */ - for (i = 0; i <= mask_r>>sh_r; i++) - { - uint32_t tmp; - tmp = i * high.r; - tmp += (mask_r>>sh_r) * low.r; - lookup_r[i] = (tmp/65535)<>sh_g; i++) - { - uint32_t tmp; - tmp = i * high.g; - tmp += (mask_g>>sh_g) * low.g; - lookup_g[i] = (tmp/65535)<>sh_b; i++) - { - uint32_t tmp; - tmp = i * high.b; - tmp += (mask_b>>sh_b) * low.b; - lookup_b[i] = (tmp/65535)<bits_per_pixel == 32