--- rxvt-unicode/src/rxvtimg.C 2012/06/04 16:12:55 1.16 +++ rxvt-unicode/src/rxvtimg.C 2012/06/05 12:30:37 1.18 @@ -103,7 +103,7 @@ XRenderPictureAttributes pa; pa.repeat = RepeatPad; - Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); + Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa); Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth); Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); XFreePixmap (dpy, tmp); @@ -203,8 +203,6 @@ bool rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y) { - bool argb = format->id == PictStandardARGB32; - Display *dpy = s->display->dpy; if (s->visual->c_class != TrueColor) @@ -212,20 +210,10 @@ uint32_t red_mask, green_mask, blue_mask, alpha_mask; - if (argb) - { - red_mask = 0xff << 16; - green_mask = 0xff << 8; - blue_mask = 0xff; - alpha_mask = 0xff << 24; - } - else - { - red_mask = s->visual->red_mask; - green_mask = s->visual->green_mask; - blue_mask = s->visual->blue_mask; - alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; - } + red_mask = (uint32_t)format->direct.redMask << format->direct.red; + green_mask = (uint32_t)format->direct.greenMask << format->direct.green; + blue_mask = (uint32_t)format->direct.blueMask << format->direct.blue; + alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; int width_r = ecb_popcount32 (red_mask); int width_g = ecb_popcount32 (green_mask); @@ -243,7 +231,7 @@ if (width > 32767 || height > 32767) return false; - XImage *ximage = XCreateImage (dpy, s->visual, argb ? 32 : format->depth, ZPixmap, 0, 0, + XImage *ximage = XCreateImage (dpy, s->visual, format->depth, ZPixmap, 0, 0, width, height, 32, 0); if (!ximage) return false; @@ -348,6 +336,7 @@ for (int j = 0; j < 3; ++j) xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); + XRenderSetPictureFilter (dpy, src, "good", 0, 0); XRenderSetPictureTransform (dpy, src, &xfrm); XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); @@ -370,6 +359,21 @@ } rxvt_img * +rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, double phi) +{ + double s = sin (phi); + double c = cos (phi); + + double matrix[9] = { + c, -s, -c * x + s * y + x, + s, c, -s * x - c * y + y, + 0, 0, 1 + }; + + return transform (new_width, new_height, repeat, matrix); +} + +rxvt_img * rxvt_img::convert_to (XRenderPictFormat *new_format) { rxvt_img *img = new rxvt_img (s, new_format, w, h);