ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.76 by root, Sun Jun 10 10:29:26 2012 UTC vs.
Revision 1.91 by root, Fri Jun 15 13:21:59 2012 UTC

1#include <math.h> 1#include <math.h>
2#include "../config.h" 2#include "../config.h"
3#include "rxvt.h" 3#include "rxvt.h"
4 4
5#if HAVE_IMG 5#if HAVE_IMG
6
7#if 0
8struct pict
9{
10 Display *dpy;
11 Picture pic;
12
13 operator Picture () const
14 {
15 return pic;
16 }
17
18 pict ()
19 : pic (0)
20 {
21 }
22
23 pict (rxvt_img *img, XRenderPictFormat *format = 0)
24 : dpy (img->s->display->dpy)
25 {
26 XRenderPictureAttributes pa;
27 pa.repeat = img->repeat;
28 pic = XRenderCreatePicture (dpy, img->pm, format ? format : img->format, CPRepeat, &pa);
29 }
30
31 ~pict ()
32 {
33 if (pic)
34 XRenderFreePicture (dpy, pic);
35 }
36};
37#endif
38
39static XRenderPictFormat *
40find_alpha_format_for (Display *dpy, XRenderPictFormat *format)
41{
42 if (format->direct.alphaMask)
43 return format; // already has alpha
44
45 // try to find a suitable alpha format, one bit alpha is enough for our purposes
46 if (format->type == PictTypeDirect)
47 for (int n = 0; XRenderPictFormat *f = XRenderFindFormat (dpy, 0, 0, n); ++n)
48 if (f->direct.alphaMask
49 && f->type == PictTypeDirect
50 && ecb_popcount32 (f->direct.redMask ) >= ecb_popcount32 (format->direct.redMask )
51 && ecb_popcount32 (f->direct.greenMask) >= ecb_popcount32 (format->direct.greenMask)
52 && ecb_popcount32 (f->direct.blueMask ) >= ecb_popcount32 (format->direct.blueMask ))
53 return f;
54
55 // should be a very good fallback
56 return XRenderFindStandardFormat (dpy, PictStandardARGB32);
57}
6 58
7rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat) 59rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat)
8: s(screen), x(x), y(y), w(width), h(height), format(format), repeat(repeat), 60: s(screen), x(x), y(y), w(width), h(height), format(format), repeat(repeat),
9 pm(0), ref(0) 61 pm(0), ref(0)
10{ 62{
50 102
51 return img; 103 return img;
52} 104}
53 105
54# if HAVE_PIXBUF 106# if HAVE_PIXBUF
107
55rxvt_img * 108rxvt_img *
56rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) 109rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb)
57{ 110{
58 Display *dpy = s->display->dpy; 111 Display *dpy = s->display->dpy;
59 112
166 219
167 g_object_unref (pb); 220 g_object_unref (pb);
168 221
169 return img; 222 return img;
170} 223}
224
171# endif 225# endif
172 226
173void 227void
174rxvt_img::destroy () 228rxvt_img::destroy ()
175{ 229{
193 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); 247 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
194 ref = new pixref (w, h); 248 ref = new pixref (w, h);
195} 249}
196 250
197Picture 251Picture
198rxvt_img::src_picture () 252rxvt_img::picture ()
199{ 253{
200 Display *dpy = s->display->dpy; 254 Display *dpy = s->display->dpy;
201 255
202 XRenderPictureAttributes pa; 256 XRenderPictureAttributes pa;
203 pa.repeat = repeat; 257 pa.repeat = repeat;
222 pm = pm2; 276 pm = pm2;
223 ref = new pixref (ref->w, ref->h); 277 ref = new pixref (ref->w, ref->h);
224} 278}
225 279
226void 280void
227rxvt_img::fill (const rxvt_color &c) 281rxvt_img::fill (const rgba &c)
228{ 282{
229 XGCValues gcv; 283 XRenderColor rc = { c.r, c.g, c.b, c.a };
230 gcv.foreground = c; 284
231 GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv); 285 Display *dpy = s->display->dpy;
232 XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h); 286 Picture src = picture ();
233 XFreeGC (s->display->dpy, gc); 287 XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h);
288 XRenderFreePicture (dpy, src);
289}
290
291void
292rxvt_img::add_alpha ()
293{
294 if (format->direct.alphaMask)
295 return;
296
297 Display *dpy = s->display->dpy;
298
299 rxvt_img *img = new rxvt_img (s, find_alpha_format_for (dpy, format), x, y, w, h, repeat);
300 img->alloc ();
301
302 Picture src = picture ();
303 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
304
305 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
306
307 XRenderFreePicture (dpy, src);
308 XRenderFreePicture (dpy, dst);
309
310 ::swap (img->ref, ref);
311 ::swap (img->pm , pm );
312
313 delete img;
234} 314}
235 315
236static void 316static void
237get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) 317get_gaussian_kernel (int radius, int width, rxvt_img::nv *kernel, XFixed *params)
238{ 318{
239 double sigma = radius / 2.0; 319 rxvt_img::nv sigma = radius / 2.0;
240 double scale = sqrt (2.0 * M_PI) * sigma; 320 rxvt_img::nv scale = sqrt (2.0 * M_PI) * sigma;
241 double sum = 0.0; 321 rxvt_img::nv sum = 0.0;
242 322
243 for (int i = 0; i < width; i++) 323 for (int i = 0; i < width; i++)
244 { 324 {
245 double x = i - width / 2; 325 rxvt_img::nv x = i - width / 2;
246 kernel[i] = exp (-(x * x) / (2.0 * sigma * sigma)) / scale; 326 kernel[i] = exp (-(x * x) / (2.0 * sigma * sigma)) / scale;
247 sum += kernel[i]; 327 sum += kernel[i];
248 } 328 }
249 329
250 params[0] = XDoubleToFixed (width); 330 params[0] = XDoubleToFixed (width);
260 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV)) 340 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV))
261 return clone (); 341 return clone ();
262 342
263 Display *dpy = s->display->dpy; 343 Display *dpy = s->display->dpy;
264 int size = max (rh, rv) * 2 + 1; 344 int size = max (rh, rv) * 2 + 1;
265 double *kernel = (double *)malloc (size * sizeof (double)); 345 nv *kernel = (nv *)malloc (size * sizeof (nv));
266 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 346 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
267 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); 347 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat);
268 img->alloc (); 348 img->alloc ();
269 349
270 XRenderPictureAttributes pa; 350 XRenderPictureAttributes pa;
308 w, h); 388 w, h);
309 } 389 }
310 390
311 free (kernel); 391 free (kernel);
312 free (params); 392 free (params);
393
313 XRenderFreePicture (dpy, src); 394 XRenderFreePicture (dpy, src);
314 XRenderFreePicture (dpy, dst); 395 XRenderFreePicture (dpy, dst);
315 XRenderFreePicture (dpy, tmp); 396 XRenderFreePicture (dpy, tmp);
316 397
317 return img; 398 return img;
391 if (r < 0 || g < 0 || b < 0 || a < 0) 472 if (r < 0 || g < 0 || b < 0 || a < 0)
392 rxvt_fatal ("rxvt_img::contrast does not support negative values.\n"); 473 rxvt_fatal ("rxvt_img::contrast does not support negative values.\n");
393 474
394 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); 475 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat);
395 img->alloc (); 476 img->alloc ();
396 477 img->fill (rgba (0, 0, 0, 0));
397 {
398 rxvt_color empty;
399 empty.set (s, rgba (0, 0, 0, 0));
400 img->fill (empty);
401 }
402 478
403 // premultiply (yeah, these are not exact, sue me or fix it) 479 // premultiply (yeah, these are not exact, sue me or fix it)
404 r = (r * (a >> 8)) >> 8; 480 r = (r * (a >> 8)) >> 8;
405 g = (g * (a >> 8)) >> 8; 481 g = (g * (a >> 8)) >> 8;
406 b = (b * (a >> 8)) >> 8; 482 b = (b * (a >> 8)) >> 8;
407 483
408 Display *dpy = s->display->dpy; 484 Display *dpy = s->display->dpy;
409 485
410 Picture src = src_picture (); 486 Picture src = picture ();
411 Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0); 487 Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0);
412 Picture mul = create_xrender_mask (dpy, pm, True, True); 488 Picture mul = create_xrender_mask (dpy, pm, True, True);
413 489
414 //TODO: this operator does not yet implement some useful contrast 490 //TODO: this operator does not yet implement some useful contrast
415 while (r | g | b | a) 491 while (r | g | b | a)
432 ::swap (img->pm , pm ); 508 ::swap (img->pm , pm );
433 509
434 delete img; 510 delete img;
435} 511}
436 512
513void
514rxvt_img::draw (rxvt_img *img, int op, nv mask)
515{
516 unshare ();
517
518 Display *dpy = s->display->dpy;
519 Picture src = img->picture ();
520 Picture dst = picture ();
521 Picture mask_p = 0;
522
523 if (mask != 1.)
524 {
525 mask_p = create_xrender_mask (dpy, img->pm, False, False);
526 XRenderColor mask_c = { 0, 0, 0, float_to_component (mask) };
527 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
528 }
529
530 XRenderComposite (dpy, op, src, mask_p, dst, x - img->x, y - img->y, 0, 0, 0, 0, w, h);
531
532 XRenderFreePicture (dpy, src);
533 XRenderFreePicture (dpy, dst);
534
535 if (mask_p)
536 XRenderFreePicture (dpy, mask_p);
537}
538
437rxvt_img * 539rxvt_img *
438rxvt_img::clone () 540rxvt_img::clone ()
439{ 541{
440 return new rxvt_img (*this); 542 return new rxvt_img (*this);
441}
442
443static XRenderPictFormat *
444find_alpha_format_for (Display *dpy, XRenderPictFormat *format)
445{
446 if (format->direct.alphaMask)
447 return format; // already has alpha
448
449 // try to find a suitable alpha format, one bit alpha is enough for our purposes
450 if (format->type == PictTypeDirect)
451 for (int n = 0; XRenderPictFormat *f = XRenderFindFormat (dpy, 0, 0, n); ++n)
452 if (f->direct.alphaMask
453 && f->type == PictTypeDirect
454 && ecb_popcount32 (f->direct.redMask ) >= ecb_popcount32 (format->direct.redMask )
455 && ecb_popcount32 (f->direct.greenMask) >= ecb_popcount32 (format->direct.greenMask)
456 && ecb_popcount32 (f->direct.blueMask ) >= ecb_popcount32 (format->direct.blueMask ))
457 return f;
458
459 // should be a very good fallback
460 return XRenderFindStandardFormat (dpy, PictStandardARGB32);
461} 543}
462 544
463rxvt_img * 545rxvt_img *
464rxvt_img::reify () 546rxvt_img::reify ()
465{ 547{
474 && repeat == RepeatNone; // and we have no good pixels to fill with 556 && repeat == RepeatNone; // and we have no good pixels to fill with
475 557
476 rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); 558 rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat);
477 img->alloc (); 559 img->alloc ();
478 560
479 Picture src = src_picture (); 561 Picture src = picture ();
480 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 562 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
481 563
482 if (alpha) 564 if (alpha)
483 { 565 {
484 XRenderColor rc = { 0, 0, 0, 0 }; 566 XRenderColor rc = { 0, 0, 0, 0 };
485 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles 567 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles
486 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, -x, -y, ref->w, ref->h); 568 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, x, y, ref->w, ref->h);
487 } 569 }
488 else 570 else
489 XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); 571 XRenderComposite (dpy, PictOpSrc, src, None, dst, -x, -y, 0, 0, 0, 0, w, h);
490 572
491 XRenderFreePicture (dpy, src); 573 XRenderFreePicture (dpy, src);
492 XRenderFreePicture (dpy, dst); 574 XRenderFreePicture (dpy, dst);
493 575
494 return img; 576 return img;
497rxvt_img * 579rxvt_img *
498rxvt_img::sub_rect (int x, int y, int width, int height) 580rxvt_img::sub_rect (int x, int y, int width, int height)
499{ 581{
500 rxvt_img *img = clone (); 582 rxvt_img *img = clone ();
501 583
502 img->x += x; 584 img->x -= x;
503 img->y += y; 585 img->y -= y;
504 586
505 if (w != width || h != height) 587 if (w != width || h != height)
506 { 588 {
507 img->w = width; 589 img->w = width;
508 img->h = height; 590 img->h = height;
513 } 595 }
514 596
515 return img; 597 return img;
516} 598}
517 599
518rxvt_img * 600typedef rxvt_img::nv matrix[3][3];
519rxvt_img::transform (int new_width, int new_height, double matrix[9])
520{
521 rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat);
522 img->alloc ();
523 601
524 Display *dpy = s->display->dpy; 602static void
525 Picture src = src_picture (); 603mat_invert (matrix mat, rxvt_img::nv (&inv)[3][3])
526 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 604{
605 rxvt_img::nv s0 = mat [2][2] * mat [1][1] - mat [2][1] * mat [1][2];
606 rxvt_img::nv s1 = mat [2][1] * mat [0][2] - mat [2][2] * mat [0][1];
607 rxvt_img::nv s2 = mat [1][2] * mat [0][1] - mat [1][1] * mat [0][2];
527 608
528 XTransform xfrm; 609 rxvt_img::nv invdet = 1. / (mat [0][0] * s0 + mat [1][0] * s1 + mat [2][0] * s2);
529 610
611 inv [0][0] = invdet * s0;
612 inv [0][1] = invdet * s1;
613 inv [0][2] = invdet * s2;
614
615 inv [1][0] = invdet * (mat [2][0] * mat [1][2] - mat [2][2] * mat [1][0]);
616 inv [1][1] = invdet * (mat [2][2] * mat [0][0] - mat [2][0] * mat [0][2]);
617 inv [1][2] = invdet * (mat [1][0] * mat [0][2] - mat [1][2] * mat [0][0]);
618
619 inv [2][0] = invdet * (mat [2][1] * mat [1][0] - mat [2][0] * mat [1][1]);
620 inv [2][1] = invdet * (mat [2][0] * mat [0][1] - mat [2][1] * mat [0][0]);
621 inv [2][2] = invdet * (mat [1][1] * mat [0][0] - mat [1][0] * mat [0][1]);
622}
623
624static rxvt_img::nv
625mat_apply (matrix mat, int i, rxvt_img::nv x, rxvt_img::nv y)
626{
627 rxvt_img::nv v = mat [i][0] * x + mat [i][1] * y + mat [i][2];
628 rxvt_img::nv w = mat [2][0] * x + mat [2][1] * y + mat [2][2];
629
630 return v * (1. / w);
631}
632
633static void
634mat_mult (matrix a, matrix b, matrix r)
635{
530 for (int i = 0; i < 3; ++i) 636 for (int i = 0; i < 3; ++i)
531 for (int j = 0; j < 3; ++j) 637 for (int j = 0; j < 3; ++j)
638 r [i][j] = a [i][0] * b [0][j]
639 + a [i][1] * b [1][j]
640 + a [i][2] * b [2][j];
641}
642
643static void
644mat_trans (rxvt_img::nv x, rxvt_img::nv y, matrix mat)
645{
646 mat [0][0] = 1; mat [0][1] = 0; mat [0][2] = x;
647 mat [1][0] = 0; mat [1][1] = 1; mat [1][2] = y;
648 mat [2][0] = 0; mat [2][1] = 0; mat [2][2] = 1;
649}
650
651rxvt_img *
652rxvt_img::transform (nv matrix[3][3])
653{
654 // calculate new pixel bounding box coordinates
655 nv r[2], rmin[2], rmax[2];
656
657 for (int i = 0; i < 2; ++i)
658 {
659 nv v;
660
661 v = mat_apply (matrix, i, 0+x, 0+y); rmin [i] = rmax [i] = v; r [i] = v;
662 v = mat_apply (matrix, i, w+x, 0+y); min_it (rmin [i], v); max_it (rmax [i], v);
663 v = mat_apply (matrix, i, 0+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v);
664 v = mat_apply (matrix, i, w+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v);
665 }
666
667 float sx = rmin [0] - x;
668 float sy = rmin [1] - y;
669
670 // TODO: adjust matrix for subpixel accuracy
671 int nx = floor (rmin [0]);
672 int ny = floor (rmin [1]);
673
674 int new_width = ceil (rmax [0] - rmin [0]);
675 int new_height = ceil (rmax [1] - rmin [1]);
676
677 ::matrix tr, tmp;
678 mat_trans (x, y, tr);
679 mat_mult (matrix, tr, tmp);
680 mat_trans (-x, -y, tr);
681 mat_mult (tr, tmp, matrix);
682
683 ::matrix inv;
684 mat_invert (matrix, inv);
685
686 rxvt_img *img = new rxvt_img (s, format, nx, ny, new_width, new_height, repeat);
687 img->alloc ();
688
689 Display *dpy = s->display->dpy;
690 Picture src = picture ();
691 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
692
693 XTransform xfrm;
694
695 for (int i = 0; i < 3; ++i)
696 for (int j = 0; j < 3; ++j)
532 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); 697 xfrm.matrix [i][j] = XDoubleToFixed (inv [i][j]);
533
534 xfrm.matrix [0][2] -= XDoubleToFixed (x);//TODO
535 xfrm.matrix [1][2] -= XDoubleToFixed (y);
536 698
537 XRenderSetPictureFilter (dpy, src, "good", 0, 0); 699 XRenderSetPictureFilter (dpy, src, "good", 0, 0);
538 XRenderSetPictureTransform (dpy, src, &xfrm); 700 XRenderSetPictureTransform (dpy, src, &xfrm);
539 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); 701 XRenderComposite (dpy, PictOpSrc, src, None, dst, sx, sy, 0, 0, 0, 0, new_width, new_height);
702#if 1
703 {
704 XRenderColor rc = { 65535,0,0,65535 };
705 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, new_width, new_height);
706 }{
707 XRenderColor rc = { 0,0,0,65535 };
708 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 1, 1, new_width - 2, new_height - 2);
709 }
710 XRenderComposite (dpy, PictOpOver, src, None, dst, sx, sy, 0, 0, 0, 0, new_width, new_height);
711#endif
540 712
541 XRenderFreePicture (dpy, src); 713 XRenderFreePicture (dpy, src);
542 XRenderFreePicture (dpy, dst); 714 XRenderFreePicture (dpy, dst);
543 715
544 return img; 716 return img;
548rxvt_img::scale (int new_width, int new_height) 720rxvt_img::scale (int new_width, int new_height)
549{ 721{
550 if (w == new_width && h == new_height) 722 if (w == new_width && h == new_height)
551 return clone (); 723 return clone ();
552 724
553 double matrix[9] = { 725 nv matrix[3][3] = {
554 w / (double)new_width, 0, 0, 726 { new_width / (nv)w, 0, 0 },
555 0, h / (double)new_height, 0, 727 { 0, new_height / (nv)h, 0 },
556 0, 0, 1 728 { 0, 0, 1 }
557 }; 729 };
558 730
559 int old_repeat_mode = repeat; 731 int old_repeat_mode = repeat;
560 repeat = RepeatPad; // not right, but xrender can't proeprly scale it seems 732 repeat = RepeatPad; // not right, but xrender can't properly scale it seems
561 733
562 rxvt_img *img = transform (new_width, new_height, matrix); 734 rxvt_img *img = transform (matrix);
563 735
564 repeat = old_repeat_mode; 736 repeat = old_repeat_mode;
565 img->repeat = repeat; 737 img->repeat = repeat;
566 738
567 return img; 739 return img;
568} 740}
569 741
570rxvt_img * 742rxvt_img *
571rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) 743rxvt_img::rotate (int cx, int cy, nv phi)
572{ 744{
573 double s = sin (phi); 745 nv s = sin (phi);
574 double c = cos (phi); 746 nv c = cos (phi);
575 747
576 double matrix[9] = { 748 nv matrix[3][3] = {
749#if 0
577 c, -s, -c * x + s * y + x, 750 { c, -s, cx - c * cx + s * cy },
578 s, c, -s * x - c * y + y, 751 { s, c, cy - s * cx - c * cy },
579 0, 0, 1 752 { 0, 0, 1 }
753#else
754 { c, -s, 0 },
755 { s, c, 0 },
756 { 0, 0, 1 }
757#endif
580 }; 758 };
581 759
582 return transform (new_width, new_height, matrix); 760 move (-cx, -cy);
583} 761 rxvt_img *img = transform (matrix);
762 move ( cx, cy);
763 img->move (cx, cy);
584 764
765 return img;
766}
767
585rxvt_img * 768rxvt_img *
586rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) 769rxvt_img::convert_format (XRenderPictFormat *new_format, const rgba &bg)
587{ 770{
588 if (new_format == format) 771 if (new_format == format)
589 return clone (); 772 return clone ();
590 773
591 rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); 774 rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat);
592 img->alloc (); 775 img->alloc ();
593 776
594 Display *dpy = s->display->dpy; 777 Display *dpy = s->display->dpy;
595 Picture src = src_picture (); 778 Picture src = picture ();
596 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); 779 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0);
597 int op = PictOpSrc; 780 int op = PictOpSrc;
598 781
599 if (format->direct.alphaMask && !new_format->direct.alphaMask) 782 if (format->direct.alphaMask && !new_format->direct.alphaMask)
600 { 783 {
601 // does it have to be that complicated 784 // does it have to be that complicated
602 rgba c;
603 bg.get (c);
604
605 XRenderColor rc = { c.r, c.g, c.b, 0xffff }; 785 XRenderColor rc = { bg.r, bg.g, bg.b, bg.a };
606 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); 786 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);
607 787
608 op = PictOpOver; 788 op = PictOpOver;
609 } 789 }
610 790
615 795
616 return img; 796 return img;
617} 797}
618 798
619rxvt_img * 799rxvt_img *
620rxvt_img::blend (rxvt_img *img, double factor) 800rxvt_img::blend (rxvt_img *img, nv factor)
621{ 801{
622 rxvt_img *img2 = clone (); 802 rxvt_img *img2 = clone ();
623 Display *dpy = s->display->dpy; 803 Display *dpy = s->display->dpy;
624 Picture src = img->src_picture (); 804 Picture src = img->picture ();
625 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); 805 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0);
626 Picture mask = create_xrender_mask (dpy, img->pm, False, False); 806 Picture mask = create_xrender_mask (dpy, img->pm, False, False);
627 807
628 XRenderColor mask_c; 808 XRenderColor mask_c;
629 809

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines