… | |
… | |
9 | |
9 | |
10 | #define float_to_component(d) ((d) * 65535.99) |
10 | #define float_to_component(d) ((d) * 65535.99) |
11 | |
11 | |
12 | #include <X11/extensions/Xrender.h> |
12 | #include <X11/extensions/Xrender.h> |
13 | |
13 | |
14 | struct rxvt_img |
14 | class rxvt_img |
15 | { |
15 | { |
|
|
16 | void alloc (); |
|
|
17 | void destroy (); |
|
|
18 | |
|
|
19 | public: |
16 | rxvt_screen *s; |
20 | rxvt_screen *s; |
17 | Pixmap pm; |
21 | Pixmap pm; |
|
|
22 | int *refcnt; // shared refcnt |
18 | int x, y, w, h, repeat; |
23 | int x, y, w, h, repeat; |
19 | XRenderPictFormat *format; |
24 | XRenderPictFormat *format; |
20 | bool shared; // true if we don't own it |
|
|
21 | |
25 | |
22 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
26 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
|
|
27 | rxvt_img (const rxvt_img &img); |
|
|
28 | |
23 | rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
29 | //rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
24 | static rxvt_img *new_from_root (rxvt_screen *s); // get root pixmap |
30 | static rxvt_img *new_from_root (rxvt_screen *s); // get root pixmap |
25 | static rxvt_img *new_from_file (rxvt_screen *s, const char *filename); // from pixbuf |
31 | static rxvt_img *new_from_file (rxvt_screen *s, const char *filename); // from pixbuf |
26 | |
32 | |
27 | ~rxvt_img (); |
33 | ~rxvt_img (); |
28 | |
34 | |
|
|
35 | // TODO: steal should not do what it does, and this todo should be more specific |
29 | Pixmap steal () |
36 | Pixmap steal () |
30 | { |
37 | { |
31 | shared = true; |
38 | Pixmap retval = pm; |
|
|
39 | pm = None; |
32 | return pm; |
40 | return retval; |
33 | } |
41 | } |
34 | |
42 | |
35 | // inplace |
43 | // inplace |
36 | void move (int dx, int dy) |
44 | void move (int dx, int dy) |
37 | { |
45 | { |
… | |
… | |
42 | void repeat_mode (int repeat) |
50 | void repeat_mode (int repeat) |
43 | { |
51 | { |
44 | this->repeat = repeat; |
52 | this->repeat = repeat; |
45 | } |
53 | } |
46 | |
54 | |
47 | void unshare (); // create a copy of the pixmap if !shared |
55 | void unshare (); // prepare for write |
48 | void fill (const rxvt_color &c); |
56 | void fill (const rxvt_color &c); |
49 | void brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
57 | void brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
50 | void contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
58 | void contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a); |
51 | |
59 | |
52 | void brightness (double r, double g, double b, double a = 1.) |
60 | void brightness (double r, double g, double b, double a = 1.) |