--- rxvt-unicode/src/rxvtimg.C 2012/06/07 20:04:54 1.51 +++ rxvt-unicode/src/rxvtimg.C 2012/06/08 10:12:45 1.60 @@ -16,13 +16,6 @@ ++ref->cnt; } -#if 0 -rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) -: s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false), pm(pixmap) -{ -} -#endif - rxvt_img * rxvt_img::new_from_root (rxvt_screen *s) { @@ -73,23 +66,27 @@ // that both 24 and 32 bpp MUST be supported by any screen that supports xrender int depth = gdk_pixbuf_get_has_alpha (pb) ? 32 : 24; + int byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; + XImage xi; xi.width = width; xi.height = height; xi.xoffset = 0; xi.format = ZPixmap; - xi.byte_order = LSBFirst; // maybe go for host byte order, because servers are usually local? - xi.bitmap_unit = 32; //XY only, unused - xi.bitmap_bit_order = LSBFirst; //XY only, unused + xi.byte_order = ImageByteOrder (dpy); + xi.bitmap_unit = 0; //XY only, unused + xi.bitmap_bit_order = 0; //XY only, unused xi.bitmap_pad = BitmapPad (dpy); xi.depth = depth; xi.bytes_per_line = 0; xi.bits_per_pixel = 32; //Z only - xi.red_mask = 0x000000ff; //Z only - xi.green_mask = 0x0000ff00; //Z only - xi.blue_mask = 0x00ff0000; //Z only - xi.obdata = 0; // probbaly unused + xi.red_mask = 0x00000000; //Z only, unused + xi.green_mask = 0x00000000; //Z only, unused + xi.blue_mask = 0x00000000; //Z only, unused + xi.obdata = 0; // probably unused + + bool byte_order_mismatch = byte_order != xi.byte_order; if (!XInitImage (&xi)) rxvt_fatal ("unable to initialise ximage, please report.\n"); @@ -117,9 +114,9 @@ uint8_t g = *src++; uint8_t b = *src++; - uint32_t v = r | (g << 8) | (b << 16); + uint32_t v = (r << 16) | (g << 8) | b; - if (ecb_big_endian ()) + if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch) v = ecb_bswap32 (v); *dst++ = v; @@ -132,6 +129,11 @@ if (ecb_big_endian ()) v = ecb_bswap32 (v); + v = ecb_rotl32 (v, 8); // abgr to bgra + + if (!byte_order_mismatch) + v = ecb_bswap32 (v); + *dst++ = v; } @@ -295,7 +297,7 @@ get_gaussian_kernel (rv, size, kernel, params); ::swap (params[0], params[1]); - XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); + XRenderSetPictureFilter (dpy, tmp, FilterConvolution, params, size+2); XRenderComposite (dpy, PictOpSrc, tmp,