… | |
… | |
224 | pm = pm2; |
224 | pm = pm2; |
225 | ref = new pixref (ref->w, ref->h); |
225 | ref = new pixref (ref->w, ref->h); |
226 | } |
226 | } |
227 | |
227 | |
228 | void |
228 | void |
229 | rxvt_img::fill (const rxvt_color &c) |
229 | rxvt_img::fill (const rgba &c) |
230 | { |
230 | { |
231 | rgba cc; |
|
|
232 | c.get (cc); |
|
|
233 | XRenderColor rc = { cc.r, cc.g, cc.b, cc.a }; |
231 | XRenderColor rc = { c.r, c.g, c.b, c.a }; |
234 | |
232 | |
235 | Display *dpy = s->display->dpy; |
233 | Display *dpy = s->display->dpy; |
236 | Picture src = src_picture (); |
234 | Picture src = src_picture (); |
237 | XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); |
235 | XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); |
238 | XRenderFreePicture (dpy, src); |
236 | XRenderFreePicture (dpy, src); |
… | |
… | |
397 | if (r < 0 || g < 0 || b < 0 || a < 0) |
395 | if (r < 0 || g < 0 || b < 0 || a < 0) |
398 | rxvt_fatal ("rxvt_img::contrast does not support negative values.\n"); |
396 | rxvt_fatal ("rxvt_img::contrast does not support negative values.\n"); |
399 | |
397 | |
400 | rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); |
398 | rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); |
401 | img->alloc (); |
399 | img->alloc (); |
402 | |
400 | img->fill (rgba (0, 0, 0, 0)); |
403 | { |
|
|
404 | rxvt_color empty; |
|
|
405 | empty.set (s, rgba (0, 0, 0, 0)); |
|
|
406 | img->fill (empty); |
|
|
407 | } |
|
|
408 | |
401 | |
409 | // premultiply (yeah, these are not exact, sue me or fix it) |
402 | // premultiply (yeah, these are not exact, sue me or fix it) |
410 | r = (r * (a >> 8)) >> 8; |
403 | r = (r * (a >> 8)) >> 8; |
411 | g = (g * (a >> 8)) >> 8; |
404 | g = (g * (a >> 8)) >> 8; |
412 | b = (b * (a >> 8)) >> 8; |
405 | b = (b * (a >> 8)) >> 8; |
… | |
… | |
648 | |
641 | |
649 | return img; |
642 | return img; |
650 | } |
643 | } |
651 | |
644 | |
652 | rxvt_img * |
645 | rxvt_img * |
653 | rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) |
646 | rxvt_img::convert_format (XRenderPictFormat *new_format, const rgba &bg) |
654 | { |
647 | { |
655 | if (new_format == format) |
648 | if (new_format == format) |
656 | return clone (); |
649 | return clone (); |
657 | |
650 | |
658 | rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); |
651 | rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); |
… | |
… | |
664 | int op = PictOpSrc; |
657 | int op = PictOpSrc; |
665 | |
658 | |
666 | if (format->direct.alphaMask && !new_format->direct.alphaMask) |
659 | if (format->direct.alphaMask && !new_format->direct.alphaMask) |
667 | { |
660 | { |
668 | // does it have to be that complicated |
661 | // does it have to be that complicated |
669 | rgba c; |
|
|
670 | bg.get (c); |
|
|
671 | |
|
|
672 | XRenderColor rc = { c.r, c.g, c.b, 0xffff }; |
662 | XRenderColor rc = { bg.r, bg.g, bg.b, bg.a }; |
673 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); |
663 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); |
674 | |
664 | |
675 | op = PictOpOver; |
665 | op = PictOpOver; |
676 | } |
666 | } |
677 | |
667 | |