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 |
|
|
8 | struct 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 | |
|
|
39 | static XRenderPictFormat * |
|
|
40 | find_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 | |
7 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat) |
59 | rxvt_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 | { |
… | |
… | |
195 | 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); |
196 | ref = new pixref (w, h); |
248 | ref = new pixref (w, h); |
197 | } |
249 | } |
198 | |
250 | |
199 | Picture |
251 | Picture |
200 | rxvt_img::src_picture () |
252 | rxvt_img::picture () |
201 | { |
253 | { |
202 | Display *dpy = s->display->dpy; |
254 | Display *dpy = s->display->dpy; |
203 | |
255 | |
204 | XRenderPictureAttributes pa; |
256 | XRenderPictureAttributes pa; |
205 | pa.repeat = repeat; |
257 | pa.repeat = repeat; |
… | |
… | |
229 | rxvt_img::fill (const rgba &c) |
281 | rxvt_img::fill (const rgba &c) |
230 | { |
282 | { |
231 | XRenderColor rc = { c.r, c.g, c.b, c.a }; |
283 | XRenderColor rc = { c.r, c.g, c.b, c.a }; |
232 | |
284 | |
233 | Display *dpy = s->display->dpy; |
285 | Display *dpy = s->display->dpy; |
234 | Picture src = src_picture (); |
286 | Picture src = picture (); |
235 | XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); |
287 | XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); |
236 | XRenderFreePicture (dpy, src); |
288 | XRenderFreePicture (dpy, src); |
237 | } |
289 | } |
238 | |
290 | |
|
|
291 | void |
|
|
292 | rxvt_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; |
|
|
314 | } |
|
|
315 | |
239 | static void |
316 | static void |
240 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
317 | get_gaussian_kernel (int radius, int width, rxvt_img::nv *kernel, XFixed *params) |
241 | { |
318 | { |
242 | double sigma = radius / 2.0; |
319 | rxvt_img::nv sigma = radius / 2.0; |
243 | double scale = sqrt (2.0 * M_PI) * sigma; |
320 | rxvt_img::nv scale = sqrt (2.0 * M_PI) * sigma; |
244 | double sum = 0.0; |
321 | rxvt_img::nv sum = 0.0; |
245 | |
322 | |
246 | for (int i = 0; i < width; i++) |
323 | for (int i = 0; i < width; i++) |
247 | { |
324 | { |
248 | double x = i - width / 2; |
325 | rxvt_img::nv x = i - width / 2; |
249 | kernel[i] = exp (-(x * x) / (2.0 * sigma * sigma)) / scale; |
326 | kernel[i] = exp (-(x * x) / (2.0 * sigma * sigma)) / scale; |
250 | sum += kernel[i]; |
327 | sum += kernel[i]; |
251 | } |
328 | } |
252 | |
329 | |
253 | params[0] = XDoubleToFixed (width); |
330 | params[0] = XDoubleToFixed (width); |
… | |
… | |
263 | if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV)) |
340 | if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV)) |
264 | return clone (); |
341 | return clone (); |
265 | |
342 | |
266 | Display *dpy = s->display->dpy; |
343 | Display *dpy = s->display->dpy; |
267 | int size = max (rh, rv) * 2 + 1; |
344 | int size = max (rh, rv) * 2 + 1; |
268 | double *kernel = (double *)malloc (size * sizeof (double)); |
345 | nv *kernel = (nv *)malloc (size * sizeof (nv)); |
269 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
346 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
270 | 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); |
271 | img->alloc (); |
348 | img->alloc (); |
272 | |
349 | |
273 | XRenderPictureAttributes pa; |
350 | XRenderPictureAttributes pa; |
… | |
… | |
404 | g = (g * (a >> 8)) >> 8; |
481 | g = (g * (a >> 8)) >> 8; |
405 | b = (b * (a >> 8)) >> 8; |
482 | b = (b * (a >> 8)) >> 8; |
406 | |
483 | |
407 | Display *dpy = s->display->dpy; |
484 | Display *dpy = s->display->dpy; |
408 | |
485 | |
409 | Picture src = src_picture (); |
486 | Picture src = picture (); |
410 | Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0); |
487 | Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0); |
411 | Picture mul = create_xrender_mask (dpy, pm, True, True); |
488 | Picture mul = create_xrender_mask (dpy, pm, True, True); |
412 | |
489 | |
413 | //TODO: this operator does not yet implement some useful contrast |
490 | //TODO: this operator does not yet implement some useful contrast |
414 | while (r | g | b | a) |
491 | while (r | g | b | a) |
… | |
… | |
431 | ::swap (img->pm , pm ); |
508 | ::swap (img->pm , pm ); |
432 | |
509 | |
433 | delete img; |
510 | delete img; |
434 | } |
511 | } |
435 | |
512 | |
|
|
513 | void |
|
|
514 | rxvt_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 | |
436 | rxvt_img * |
539 | rxvt_img * |
437 | rxvt_img::clone () |
540 | rxvt_img::clone () |
438 | { |
541 | { |
439 | return new rxvt_img (*this); |
542 | return new rxvt_img (*this); |
440 | } |
|
|
441 | |
|
|
442 | static XRenderPictFormat * |
|
|
443 | find_alpha_format_for (Display *dpy, XRenderPictFormat *format) |
|
|
444 | { |
|
|
445 | if (format->direct.alphaMask) |
|
|
446 | return format; // already has alpha |
|
|
447 | |
|
|
448 | // try to find a suitable alpha format, one bit alpha is enough for our purposes |
|
|
449 | if (format->type == PictTypeDirect) |
|
|
450 | for (int n = 0; XRenderPictFormat *f = XRenderFindFormat (dpy, 0, 0, n); ++n) |
|
|
451 | if (f->direct.alphaMask |
|
|
452 | && f->type == PictTypeDirect |
|
|
453 | && ecb_popcount32 (f->direct.redMask ) >= ecb_popcount32 (format->direct.redMask ) |
|
|
454 | && ecb_popcount32 (f->direct.greenMask) >= ecb_popcount32 (format->direct.greenMask) |
|
|
455 | && ecb_popcount32 (f->direct.blueMask ) >= ecb_popcount32 (format->direct.blueMask )) |
|
|
456 | return f; |
|
|
457 | |
|
|
458 | // should be a very good fallback |
|
|
459 | return XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
460 | } |
543 | } |
461 | |
544 | |
462 | rxvt_img * |
545 | rxvt_img * |
463 | rxvt_img::reify () |
546 | rxvt_img::reify () |
464 | { |
547 | { |
… | |
… | |
473 | && repeat == RepeatNone; // and we have no good pixels to fill with |
556 | && repeat == RepeatNone; // and we have no good pixels to fill with |
474 | |
557 | |
475 | 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); |
476 | img->alloc (); |
559 | img->alloc (); |
477 | |
560 | |
478 | Picture src = src_picture (); |
561 | Picture src = picture (); |
479 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
562 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
480 | |
563 | |
481 | if (alpha) |
564 | if (alpha) |
482 | { |
565 | { |
483 | XRenderColor rc = { 0, 0, 0, 0 }; |
566 | XRenderColor rc = { 0, 0, 0, 0 }; |
484 | 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 |
485 | 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); |
486 | } |
569 | } |
487 | else |
570 | else |
488 | 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); |
489 | |
572 | |
490 | XRenderFreePicture (dpy, src); |
573 | XRenderFreePicture (dpy, src); |
491 | XRenderFreePicture (dpy, dst); |
574 | XRenderFreePicture (dpy, dst); |
492 | |
575 | |
493 | return img; |
576 | return img; |
… | |
… | |
496 | rxvt_img * |
579 | rxvt_img * |
497 | rxvt_img::sub_rect (int x, int y, int width, int height) |
580 | rxvt_img::sub_rect (int x, int y, int width, int height) |
498 | { |
581 | { |
499 | rxvt_img *img = clone (); |
582 | rxvt_img *img = clone (); |
500 | |
583 | |
501 | img->x += x; |
584 | img->x -= x; |
502 | img->y += y; |
585 | img->y -= y; |
503 | |
586 | |
504 | if (w != width || h != height) |
587 | if (w != width || h != height) |
505 | { |
588 | { |
506 | img->w = width; |
589 | img->w = width; |
507 | img->h = height; |
590 | img->h = height; |
… | |
… | |
513 | |
596 | |
514 | return img; |
597 | return img; |
515 | } |
598 | } |
516 | |
599 | |
517 | static void |
600 | static void |
518 | mat_invert (double mat[3][3], double (&inv)[3][3]) |
601 | mat_invert (rxvt_img::nv mat[3][3], rxvt_img::nv (&inv)[3][3]) |
519 | { |
602 | { |
520 | double s0 = mat [2][2] * mat [1][1] - mat [2][1] * mat [1][2]; |
603 | rxvt_img::nv s0 = mat [2][2] * mat [1][1] - mat [2][1] * mat [1][2]; |
521 | double s1 = mat [2][1] * mat [0][2] - mat [2][2] * mat [0][1]; |
604 | rxvt_img::nv s1 = mat [2][1] * mat [0][2] - mat [2][2] * mat [0][1]; |
522 | double s2 = mat [1][2] * mat [0][1] - mat [1][1] * mat [0][2]; |
605 | rxvt_img::nv s2 = mat [1][2] * mat [0][1] - mat [1][1] * mat [0][2]; |
523 | |
606 | |
524 | double invdet = 1. / (mat [0][0] * s0 + mat [1][0] * s1 + mat [2][0] * s2); |
607 | rxvt_img::nv invdet = 1. / (mat [0][0] * s0 + mat [1][0] * s1 + mat [2][0] * s2); |
525 | |
608 | |
526 | inv [0][0] = invdet * s0; |
609 | inv [0][0] = invdet * s0; |
527 | inv [0][1] = invdet * s1; |
610 | inv [0][1] = invdet * s1; |
528 | inv [0][2] = invdet * s2; |
611 | inv [0][2] = invdet * s2; |
529 | |
612 | |
… | |
… | |
534 | inv [2][0] = invdet * (mat [2][1] * mat [1][0] - mat [2][0] * mat [1][1]); |
617 | inv [2][0] = invdet * (mat [2][1] * mat [1][0] - mat [2][0] * mat [1][1]); |
535 | inv [2][1] = invdet * (mat [2][0] * mat [0][1] - mat [2][1] * mat [0][0]); |
618 | inv [2][1] = invdet * (mat [2][0] * mat [0][1] - mat [2][1] * mat [0][0]); |
536 | inv [2][2] = invdet * (mat [1][1] * mat [0][0] - mat [1][0] * mat [0][1]); |
619 | inv [2][2] = invdet * (mat [1][1] * mat [0][0] - mat [1][0] * mat [0][1]); |
537 | } |
620 | } |
538 | |
621 | |
539 | static double |
622 | static rxvt_img::nv |
540 | mat_apply (double mat[3][3], int i, double x, double y) |
623 | mat_apply (rxvt_img::nv mat[3][3], int i, rxvt_img::nv x, rxvt_img::nv y) |
541 | { |
624 | { |
542 | double v = mat [i][0] * x + mat [i][1] * y + mat [i][2]; |
625 | rxvt_img::nv v = mat [i][0] * x + mat [i][1] * y + mat [i][2]; |
543 | double w = mat [2][0] * x + mat [2][1] * y + mat [2][2]; |
626 | rxvt_img::nv w = mat [2][0] * x + mat [2][1] * y + mat [2][2]; |
544 | |
627 | |
545 | return v * (1. / w); |
628 | return v * (1. / w); |
546 | } |
629 | } |
547 | |
630 | |
548 | rxvt_img * |
631 | rxvt_img * |
549 | rxvt_img::transform (double matrix[3][3]) |
632 | rxvt_img::transform (nv matrix[3][3]) |
550 | { |
633 | { |
551 | // find new offset |
|
|
552 | int ox = mat_apply (matrix, 0, x, y); |
|
|
553 | int oy = mat_apply (matrix, 1, x, y); |
|
|
554 | |
|
|
555 | // calculate new pixel bounding box coordinates |
634 | // calculate new pixel bounding box coordinates |
556 | double d [2], rmin[2], rmax[2]; |
635 | nv rmin[2], rmax[2]; |
557 | |
636 | |
558 | for (int i = 0; i < 2; ++i) |
637 | for (int i = 0; i < 2; ++i) |
559 | { |
638 | { |
560 | double v; |
639 | nv v; |
|
|
640 | |
561 | v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; d [i] = v; |
641 | v = mat_apply (matrix, i, 0+x, 0+y); rmin [i] = rmax [i] = v; |
562 | v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v); |
642 | v = mat_apply (matrix, i, w+x, 0+y); min_it (rmin [i], v); max_it (rmax [i], v); |
563 | v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v); |
643 | v = mat_apply (matrix, i, 0+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v); |
564 | v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v); |
644 | v = mat_apply (matrix, i, w+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v); |
565 | } |
645 | } |
566 | |
646 | |
|
|
647 | // TODO: adjust matrix for subpixel accuracy |
567 | int dx = floor (rmin [0]); |
648 | int dx = floor (rmin [0]); |
568 | int dy = floor (rmin [1]); |
649 | int dy = floor (rmin [1]); |
569 | |
650 | |
570 | int new_width = ceil (rmax [0] - dx); |
651 | int new_width = ceil (rmax [0] - dx); |
571 | int new_height = ceil (rmax [1] - dy); |
652 | int new_height = ceil (rmax [1] - dy); |
572 | |
653 | |
573 | double inv[3][3]; |
654 | nv inv[3][3]; |
574 | mat_invert (matrix, inv); |
655 | mat_invert (matrix, inv); |
575 | |
656 | |
576 | rxvt_img *img = new rxvt_img (s, format, ox - dx - d [0], oy - dy - d [1], new_width, new_height, repeat); |
657 | rxvt_img *img = new rxvt_img (s, format, dx, dy, new_width, new_height, repeat); |
577 | img->alloc (); |
658 | img->alloc (); |
578 | |
659 | |
579 | Display *dpy = s->display->dpy; |
660 | Display *dpy = s->display->dpy; |
580 | Picture src = src_picture (); |
661 | Picture src = picture (); |
581 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
662 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
582 | |
663 | |
583 | XTransform xfrm; |
664 | XTransform xfrm; |
584 | |
665 | |
585 | for (int i = 0; i < 3; ++i) |
666 | for (int i = 0; i < 3; ++i) |
… | |
… | |
600 | rxvt_img::scale (int new_width, int new_height) |
681 | rxvt_img::scale (int new_width, int new_height) |
601 | { |
682 | { |
602 | if (w == new_width && h == new_height) |
683 | if (w == new_width && h == new_height) |
603 | return clone (); |
684 | return clone (); |
604 | |
685 | |
605 | double matrix[3][3] = { |
686 | nv matrix[3][3] = { |
606 | { new_width / (double)w, 0, 0 }, |
687 | { new_width / (nv)w, 0, 0 }, |
607 | { 0, new_height / (double)h, 0 }, |
688 | { 0, new_height / (nv)h, 0 }, |
608 | { 0, 0, 1 } |
689 | { 0, 0, 1 } |
609 | }; |
690 | }; |
610 | |
691 | |
611 | int old_repeat_mode = repeat; |
692 | int old_repeat_mode = repeat; |
612 | repeat = RepeatPad; // not right, but xrender can't properly scale it seems |
693 | repeat = RepeatPad; // not right, but xrender can't properly scale it seems |
613 | |
694 | |
… | |
… | |
618 | |
699 | |
619 | return img; |
700 | return img; |
620 | } |
701 | } |
621 | |
702 | |
622 | rxvt_img * |
703 | rxvt_img * |
623 | rxvt_img::rotate (int cx, int cy, double phi) |
704 | rxvt_img::rotate (int cx, int cy, nv phi) |
624 | { |
705 | { |
625 | double s = sin (phi); |
706 | nv s = sin (phi); |
626 | double c = cos (phi); |
707 | nv c = cos (phi); |
627 | |
708 | |
628 | double matrix[3][3] = { |
709 | nv matrix[3][3] = { |
629 | { c, -s, cx - c * cx + s * cy }, |
710 | { c, -s, cx - c * cx + s * cy + 200 }, |
630 | { s, c, cy - s * cx - c * cy }, |
711 | { s, c, cy - s * cx - c * cy }, |
631 | { 0, 0, 1 } |
712 | { 0, 0, 1 } |
632 | //{ c, -s, 0 }, |
713 | //{ c, -s, 0 }, |
633 | //{ s, c, 0 }, |
714 | //{ s, c, 0 }, |
634 | //{ 0, 0, 1 } |
715 | //{ 0, 0, 1 } |
… | |
… | |
650 | |
731 | |
651 | rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); |
732 | rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); |
652 | img->alloc (); |
733 | img->alloc (); |
653 | |
734 | |
654 | Display *dpy = s->display->dpy; |
735 | Display *dpy = s->display->dpy; |
655 | Picture src = src_picture (); |
736 | Picture src = picture (); |
656 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |
737 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |
657 | int op = PictOpSrc; |
738 | int op = PictOpSrc; |
658 | |
739 | |
659 | if (format->direct.alphaMask && !new_format->direct.alphaMask) |
740 | if (format->direct.alphaMask && !new_format->direct.alphaMask) |
660 | { |
741 | { |
… | |
… | |
672 | |
753 | |
673 | return img; |
754 | return img; |
674 | } |
755 | } |
675 | |
756 | |
676 | rxvt_img * |
757 | rxvt_img * |
677 | rxvt_img::blend (rxvt_img *img, double factor) |
758 | rxvt_img::blend (rxvt_img *img, nv factor) |
678 | { |
759 | { |
679 | rxvt_img *img2 = clone (); |
760 | rxvt_img *img2 = clone (); |
680 | Display *dpy = s->display->dpy; |
761 | Display *dpy = s->display->dpy; |
681 | Picture src = img->src_picture (); |
762 | Picture src = img->picture (); |
682 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
763 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
683 | Picture mask = create_xrender_mask (dpy, img->pm, False, False); |
764 | Picture mask = create_xrender_mask (dpy, img->pm, False, False); |
684 | |
765 | |
685 | XRenderColor mask_c; |
766 | XRenderColor mask_c; |
686 | |
767 | |