|
|
1 | /*----------------------------------------------------------------------* |
|
|
2 | * File: rxvtimg.C |
|
|
3 | *----------------------------------------------------------------------* |
|
|
4 | * |
|
|
5 | * All portions of code are copyright by their respective author/s. |
|
|
6 | * Copyright (c) 2012 Marc Lehmann <schmorp@schmorp.de> |
|
|
7 | * Copyright (c) 2012 Emanuele Giaquinta <e.giaquinta@glauco.it> |
|
|
8 | * |
|
|
9 | * This program is free software; you can redistribute it and/or modify |
|
|
10 | * it under the terms of the GNU General Public License as published by |
|
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
|
12 | * (at your option) any later version. |
|
|
13 | * |
|
|
14 | * This program is distributed in the hope that it will be useful, |
|
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
17 | * GNU General Public License for more details. |
|
|
18 | * |
|
|
19 | * You should have received a copy of the GNU General Public License |
|
|
20 | * along with this program; if not, write to the Free Software |
|
|
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
22 | *---------------------------------------------------------------------*/ |
|
|
23 | |
1 | #include <string.h> |
24 | #include <string.h> |
2 | #include <math.h> |
25 | #include <math.h> |
3 | #include "../config.h" |
26 | #include "../config.h" |
4 | #include "rxvt.h" |
27 | #include "rxvt.h" |
5 | |
28 | |
… | |
… | |
293 | uint8_t r = *src++; |
316 | uint8_t r = *src++; |
294 | uint8_t g = *src++; |
317 | uint8_t g = *src++; |
295 | uint8_t b = *src++; |
318 | uint8_t b = *src++; |
296 | |
319 | |
297 | uint32_t v = (255 << 24) | (r << 16) | (g << 8) | b; |
320 | uint32_t v = (255 << 24) | (r << 16) | (g << 8) | b; |
298 | |
321 | |
299 | if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch) |
322 | if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch) |
300 | v = ecb_bswap32 (v); |
323 | v = ecb_bswap32 (v); |
301 | |
324 | |
302 | *dst++ = v; |
325 | *dst++ = v; |
303 | } |
326 | } |
… | |
… | |
426 | rxvt_img *img = new rxvt_img (s, find_alpha_format_for (dpy, format), x, y, w, h, repeat); |
449 | rxvt_img *img = new rxvt_img (s, find_alpha_format_for (dpy, format), x, y, w, h, repeat); |
427 | img->alloc (); |
450 | img->alloc (); |
428 | |
451 | |
429 | Picture src = picture (); |
452 | Picture src = picture (); |
430 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
453 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
431 | |
454 | |
432 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
455 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
433 | |
456 | |
434 | XRenderFreePicture (dpy, src); |
457 | XRenderFreePicture (dpy, src); |
435 | XRenderFreePicture (dpy, dst); |
458 | XRenderFreePicture (dpy, dst); |
436 | |
459 | |
… | |
… | |
644 | |
667 | |
645 | Display *dpy = s->display->dpy; |
668 | Display *dpy = s->display->dpy; |
646 | Picture src = img->picture (); |
669 | Picture src = img->picture (); |
647 | Picture dst = picture (); |
670 | Picture dst = picture (); |
648 | Picture mask_p = 0; |
671 | Picture mask_p = 0; |
649 | |
672 | |
650 | if (mask != 1.) |
673 | if (mask != 1.) |
651 | { |
674 | { |
652 | mask_p = create_xrender_mask (dpy, img->pm, False, False); |
675 | mask_p = create_xrender_mask (dpy, img->pm, False, False); |
653 | XRenderColor mask_c = { 0, 0, 0, float_to_component (mask) }; |
676 | XRenderColor mask_c = { 0, 0, 0, float_to_component (mask) }; |
654 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
677 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
… | |
… | |
685 | rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); |
708 | rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); |
686 | img->alloc (); |
709 | img->alloc (); |
687 | |
710 | |
688 | Picture src = picture (); |
711 | Picture src = picture (); |
689 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
712 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
690 | |
713 | |
691 | if (alpha) |
714 | if (alpha) |
692 | { |
715 | { |
693 | XRenderColor rc = { 0, 0, 0, 0 }; |
716 | XRenderColor rc = { 0, 0, 0, 0 }; |
694 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles |
717 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles |
695 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, x, y, ref->w, ref->h); |
718 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, x, y, ref->w, ref->h); |