--- rxvt-unicode/src/rxvtimg.C 2012/06/07 20:26:21 1.55 +++ rxvt-unicode/src/rxvtimg.C 2012/06/08 21:48:07 1.66 @@ -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) { @@ -123,10 +116,7 @@ uint32_t v = (r << 16) | (g << 8) | b; - if (ecb_big_endian ()) - v = ecb_bswap32 (v); - - if (byte_order_mismatch) + if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch) v = ecb_bswap32 (v); *dst++ = v; @@ -136,12 +126,12 @@ { uint32_t v = *(uint32_t *)src; src += 4; - if (ecb_little_endian ()) + if (ecb_big_endian ()) v = ecb_bswap32 (v); - v = ecb_rotr32 (v, 8); + v = ecb_rotl32 (v, 8); // abgr to bgra - if (byte_order_mismatch) + if (!byte_order_mismatch) v = ecb_bswap32 (v); *dst++ = v; @@ -221,7 +211,6 @@ if (ref->cnt == 1 && ref->ours) return; - //TODO: maybe should reify instead Pixmap pm2 = XCreatePixmap (s->display->dpy, s->display->root, ref->w, ref->h, format->depth); GC gc = XCreateGC (s->display->dpy, pm, 0, 0); XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, ref->w, ref->h, 0, 0); @@ -277,11 +266,10 @@ rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); img->alloc (); - Picture src = src_picture (); - XRenderPictureAttributes pa; pa.repeat = RepeatPad; - Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa); + Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); + Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0); Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth); Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa); @@ -307,7 +295,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, @@ -344,7 +332,7 @@ } void -rxvt_img::brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a) +rxvt_img::brightness (uint16_t r, uint16_t g, uint16_t b, uint16_t a) { Display *dpy = s->display->dpy; Picture src = create_xrender_mask (dpy, pm, True); @@ -364,10 +352,13 @@ } void -rxvt_img::contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a) +rxvt_img::contrast (uint16_t r, uint16_t g, uint16_t b, uint16_t a) { if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL)) - return; + { + rxvt_warn ("rxvt_img::contrast operation not supported on this display, RENDER extension too old.\n"); + return; + } Display *dpy = s->display->dpy; Picture src = create_xrender_mask (dpy, pm, True); @@ -420,9 +411,10 @@ Display *dpy = s->display->dpy; - bool alpha = !format->direct.alphaMask - && (x || y) - && repeat == RepeatNone; + // add an alpha channel if... + bool alpha = !format->direct.alphaMask // pixmap has none yet + && (x || y) // we need one because of non-zero offset + && repeat == RepeatNone; // and we have no good pixels to fill with rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); img->alloc (); @@ -482,10 +474,8 @@ for (int j = 0; j < 3; ++j) xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); -#if 0 xfrm.matrix [0][2] -= XDoubleToFixed (x);//TODO xfrm.matrix [1][2] -= XDoubleToFixed (y); -#endif XRenderSetPictureFilter (dpy, src, "good", 0, 0); XRenderSetPictureTransform (dpy, src, &xfrm);