… | |
… | |
314 | XRenderFreePicture (dpy, tmp); |
314 | XRenderFreePicture (dpy, tmp); |
315 | |
315 | |
316 | return img; |
316 | return img; |
317 | } |
317 | } |
318 | |
318 | |
319 | static Picture |
|
|
320 | create_xrender_mask (Display *dpy, Drawable drawable, Bool argb) |
|
|
321 | { |
|
|
322 | Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8); |
|
|
323 | |
|
|
324 | XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8); |
|
|
325 | XRenderPictureAttributes pa; |
|
|
326 | pa.repeat = True; |
|
|
327 | Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); |
|
|
328 | |
|
|
329 | XFreePixmap (dpy, pixmap); |
|
|
330 | |
|
|
331 | return mask; |
|
|
332 | } |
|
|
333 | |
|
|
334 | static void |
319 | static void |
335 | extract (int32_t cl0, int32_t cl1, int32_t &c, unsigned short &xc) |
320 | extract (int32_t cl0, int32_t cl1, int32_t &c, unsigned short &xc) |
336 | { |
321 | { |
337 | int32_t x = clamp (c, cl0, cl1); |
322 | int32_t x = clamp (c, cl0, cl1); |
338 | c -= x; |
323 | c -= x; |
… | |
… | |
394 | } |
379 | } |
395 | |
380 | |
396 | unshare (); |
381 | unshare (); |
397 | |
382 | |
398 | Display *dpy = s->display->dpy; |
383 | Display *dpy = s->display->dpy; |
399 | Picture src = create_xrender_mask (dpy, pm, True); |
|
|
400 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
384 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
401 | |
385 | |
402 | XRenderColor mask_c; |
386 | XRenderColor mask_c; |
403 | mask_c.red = r; |
387 | mask_c.red = r; |
404 | mask_c.green = g; |
388 | mask_c.green = g; |
405 | mask_c.blue = b; |
389 | mask_c.blue = b; |
406 | mask_c.alpha = a; |
390 | mask_c.alpha = a; |
407 | XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); |
391 | XRenderFillRectangle (dpy, PictOpMultiply, dst, &mask_c, 0, 0, w, h); |
408 | |
392 | |
409 | XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
|
|
410 | |
|
|
411 | XRenderFreePicture (dpy, src); |
|
|
412 | XRenderFreePicture (dpy, dst); |
393 | XRenderFreePicture (dpy, dst); |
413 | } |
394 | } |
414 | |
395 | |
415 | rxvt_img * |
396 | rxvt_img * |
416 | rxvt_img::clone () |
397 | rxvt_img::clone () |
… | |
… | |
599 | { |
580 | { |
600 | rxvt_img *img2 = clone (); |
581 | rxvt_img *img2 = clone (); |
601 | Display *dpy = s->display->dpy; |
582 | Display *dpy = s->display->dpy; |
602 | Picture src = img->src_picture (); |
583 | Picture src = img->src_picture (); |
603 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
584 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
604 | Picture mask = create_xrender_mask (dpy, img->pm, False); |
585 | |
|
|
586 | Pixmap pixmap = XCreatePixmap (dpy, img->pm, 1, 1, 8); |
|
|
587 | XRenderPictFormat *format = XRenderFindStandardFormat (dpy, PictStandardA8); |
|
|
588 | XRenderPictureAttributes pa; |
|
|
589 | pa.repeat = True; |
|
|
590 | Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); |
|
|
591 | XFreePixmap (dpy, pixmap); |
605 | |
592 | |
606 | XRenderColor mask_c; |
593 | XRenderColor mask_c; |
607 | |
594 | |
608 | mask_c.alpha = float_to_component (factor); |
595 | mask_c.alpha = float_to_component (factor); |
609 | mask_c.red = |
596 | mask_c.red = |