… | |
… | |
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 | |
6 | |
7 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height) |
7 | 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(RepeatNormal), |
8 | : s(screen), x(x), y(y), w(width), h(height), format(format), repeat(repeat), |
9 | pm(0), ref(0) |
9 | pm(0), ref(0) |
10 | { |
10 | { |
11 | } |
11 | } |
12 | |
12 | |
13 | rxvt_img::rxvt_img (const rxvt_img &img) |
13 | rxvt_img::rxvt_img (const rxvt_img &img) |
… | |
… | |
176 | |
176 | |
177 | Display *dpy = s->display->dpy; |
177 | Display *dpy = s->display->dpy; |
178 | int size = max (rh, rv) * 2 + 1; |
178 | int size = max (rh, rv) * 2 + 1; |
179 | double *kernel = (double *)malloc (size * sizeof (double)); |
179 | double *kernel = (double *)malloc (size * sizeof (double)); |
180 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
180 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
181 | rxvt_img *img = new rxvt_img (s, format, x, y, w, h); |
181 | rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); |
182 | img->alloc (); |
182 | img->alloc (); |
183 | |
183 | |
184 | Picture src = src_picture (); |
184 | Picture src = src_picture (); |
185 | |
185 | |
186 | XRenderPictureAttributes pa; |
186 | XRenderPictureAttributes pa; |
… | |
… | |
397 | rxvt_img::reify () |
397 | rxvt_img::reify () |
398 | { |
398 | { |
399 | if (x == 0 && y == 0 && w == ref->w && h == ref->h) |
399 | if (x == 0 && y == 0 && w == ref->w && h == ref->h) |
400 | return clone (); |
400 | return clone (); |
401 | |
401 | |
402 | rxvt_img *img = new rxvt_img (s, format, 0, 0, w, h); |
402 | Display *dpy = s->display->dpy; |
|
|
403 | |
|
|
404 | bool alpha = !format->direct.alphaMask |
|
|
405 | && (x || y) |
|
|
406 | && repeat == RepeatNone; |
|
|
407 | |
|
|
408 | rxvt_img *img = new rxvt_img (s, alpha ? XRenderFindStandardFormat (dpy, PictStandardARGB32) : format, 0, 0, w, h, repeat); |
403 | img->alloc (); |
409 | img->alloc (); |
404 | |
|
|
405 | Display *dpy = s->display->dpy; |
|
|
406 | |
410 | |
407 | Picture src = src_picture (); |
411 | Picture src = src_picture (); |
408 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
412 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
409 | |
413 | |
410 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); |
414 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); |
… | |
… | |
426 | if (w != width || h != height) |
430 | if (w != width || h != height) |
427 | { |
431 | { |
428 | img->w = width; |
432 | img->w = width; |
429 | img->h = height; |
433 | img->h = height; |
430 | |
434 | |
431 | img->reify (); |
435 | rxvt_img *img2 = img->reify (); |
|
|
436 | delete img; |
|
|
437 | img = img2; |
432 | } |
438 | } |
433 | |
439 | |
434 | return img; |
440 | return img; |
435 | } |
441 | } |
436 | |
442 | |
437 | rxvt_img * |
443 | rxvt_img * |
438 | rxvt_img::transform (int new_width, int new_height, double matrix[9]) |
444 | rxvt_img::transform (int new_width, int new_height, double matrix[9]) |
439 | { |
445 | { |
440 | rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height); |
446 | rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat); |
441 | img->alloc (); |
447 | img->alloc (); |
442 | |
448 | |
443 | Display *dpy = s->display->dpy; |
449 | Display *dpy = s->display->dpy; |
444 | Picture src = src_picture (); |
450 | Picture src = src_picture (); |
445 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
451 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
… | |
… | |
494 | rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) |
500 | rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) |
495 | { |
501 | { |
496 | if (new_format == format) |
502 | if (new_format == format) |
497 | return clone (); |
503 | return clone (); |
498 | |
504 | |
499 | rxvt_img *img = new rxvt_img (s, new_format, 0, 0, w, h); |
505 | rxvt_img *img = new rxvt_img (s, new_format, 0, 0, w, h, repeat); |
500 | img->alloc (); |
506 | img->alloc (); |
501 | |
507 | |
502 | Display *dpy = s->display->dpy; |
508 | Display *dpy = s->display->dpy; |
503 | Picture src = src_picture (); |
509 | Picture src = src_picture (); |
504 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |
510 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |