… | |
… | |
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 | #define float_to_component(d) ((d) * 65535.99) |
|
|
8 | |
|
|
9 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
7 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat) |
10 | : s(screen), w(width), h(height), format(format), shared(false) |
8 | : s(screen), x(x), y(y), w(width), h(height), format(format), repeat(repeat), |
|
|
9 | pm(0), ref(0) |
11 | { |
10 | { |
12 | pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); |
|
|
13 | } |
11 | } |
14 | |
12 | |
|
|
13 | rxvt_img::rxvt_img (const rxvt_img &img) |
|
|
14 | : s(img.s), x(img.x), y(img.y), w(img.w), h(img.h), format(img.format), repeat(img.repeat), pm(img.pm), ref(img.ref) |
|
|
15 | { |
|
|
16 | ++ref->cnt; |
|
|
17 | } |
|
|
18 | |
|
|
19 | #if 0 |
15 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) |
20 | rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) |
16 | : s(screen), pm(pixmap), w(width), h(height), format(format), shared(false) |
21 | : s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false), pm(pixmap) |
17 | { |
22 | { |
18 | } |
23 | } |
|
|
24 | #endif |
19 | |
25 | |
20 | rxvt_img * |
26 | rxvt_img * |
21 | rxvt_img::new_from_root (rxvt_screen *s) |
27 | rxvt_img::new_from_root (rxvt_screen *s) |
22 | { |
28 | { |
23 | Display *dpy = s->display->dpy; |
29 | Display *dpy = s->display->dpy; |
… | |
… | |
37 | return 0; |
43 | return 0; |
38 | |
44 | |
39 | rxvt_img *img = new rxvt_img ( |
45 | rxvt_img *img = new rxvt_img ( |
40 | s, |
46 | s, |
41 | XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)), |
47 | XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)), |
|
|
48 | 0, |
|
|
49 | 0, |
42 | root_pm_w, |
50 | root_pm_w, |
43 | root_pm_h, |
51 | root_pm_h |
44 | root_pixmap |
|
|
45 | ); |
52 | ); |
46 | |
53 | |
47 | img->shared = true; |
54 | img->pm = root_pixmap; |
|
|
55 | img->ref = new pixref (root_pm_w, root_pm_h); |
|
|
56 | img->ref->ours = false; |
48 | |
57 | |
49 | return img; |
58 | return img; |
50 | } |
59 | } |
51 | |
60 | |
52 | rxvt_img * |
61 | rxvt_img * |
… | |
… | |
59 | rxvt_fatal ("rxvt_img::new_from_file: %s\n", err->message); |
68 | rxvt_fatal ("rxvt_img::new_from_file: %s\n", err->message); |
60 | |
69 | |
61 | rxvt_img *img = new rxvt_img ( |
70 | rxvt_img *img = new rxvt_img ( |
62 | s, |
71 | s, |
63 | XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24), |
72 | XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24), |
|
|
73 | 0, |
|
|
74 | 0, |
64 | gdk_pixbuf_get_width (pb), |
75 | gdk_pixbuf_get_width (pb), |
65 | gdk_pixbuf_get_height (pb) |
76 | gdk_pixbuf_get_height (pb) |
66 | ); |
77 | ); |
67 | |
78 | img->alloc (); |
68 | img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0); |
79 | img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0); |
69 | |
80 | |
70 | g_object_unref (pb); |
81 | g_object_unref (pb); |
71 | |
82 | |
72 | return img; |
83 | return img; |
73 | } |
84 | } |
74 | |
85 | |
|
|
86 | void |
|
|
87 | rxvt_img::destroy () |
|
|
88 | { |
|
|
89 | if (--ref->cnt) |
|
|
90 | return; |
|
|
91 | |
|
|
92 | if (pm && ref->ours) |
|
|
93 | XFreePixmap (s->display->dpy, pm); |
|
|
94 | |
|
|
95 | delete ref; |
|
|
96 | } |
|
|
97 | |
75 | rxvt_img::~rxvt_img () |
98 | rxvt_img::~rxvt_img () |
76 | { |
99 | { |
77 | if (!shared) |
100 | destroy (); |
78 | XFreePixmap (s->display->dpy, pm); |
101 | } |
|
|
102 | |
|
|
103 | void |
|
|
104 | rxvt_img::alloc () |
|
|
105 | { |
|
|
106 | pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth); |
|
|
107 | ref = new pixref (w, h); |
|
|
108 | } |
|
|
109 | |
|
|
110 | Picture |
|
|
111 | rxvt_img::src_picture () |
|
|
112 | { |
|
|
113 | Display *dpy = s->display->dpy; |
|
|
114 | |
|
|
115 | XRenderPictureAttributes pa; |
|
|
116 | pa.repeat = repeat; |
|
|
117 | Picture pic = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); |
|
|
118 | |
|
|
119 | return pic; |
79 | } |
120 | } |
80 | |
121 | |
81 | void |
122 | void |
82 | rxvt_img::unshare () |
123 | rxvt_img::unshare () |
83 | { |
124 | { |
84 | if (!shared) |
125 | if (ref->cnt == 1 && ref->ours) |
85 | return; |
126 | return; |
86 | |
127 | |
87 | rxvt_img *img = clone (); |
128 | //TODO: maybe should reify instead |
|
|
129 | Pixmap pm2 = XCreatePixmap (s->display->dpy, s->display->root, ref->w, ref->h, format->depth); |
|
|
130 | GC gc = XCreateGC (s->display->dpy, pm, 0, 0); |
|
|
131 | XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, ref->w, ref->h, 0, 0); |
|
|
132 | XFreeGC (s->display->dpy, gc); |
88 | |
133 | |
89 | ::swap (pm , img->pm); |
134 | destroy (); |
90 | ::swap (shared, img->shared); |
|
|
91 | |
135 | |
92 | delete img; |
136 | pm = pm2; |
|
|
137 | ref = new pixref (ref->w, ref->h); |
93 | } |
138 | } |
94 | |
139 | |
95 | void |
140 | void |
96 | rxvt_img::fill (const rxvt_color &c) |
141 | rxvt_img::fill (const rxvt_color &c) |
97 | { |
142 | { |
… | |
… | |
131 | |
176 | |
132 | Display *dpy = s->display->dpy; |
177 | Display *dpy = s->display->dpy; |
133 | int size = max (rh, rv) * 2 + 1; |
178 | int size = max (rh, rv) * 2 + 1; |
134 | double *kernel = (double *)malloc (size * sizeof (double)); |
179 | double *kernel = (double *)malloc (size * sizeof (double)); |
135 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
180 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
136 | rxvt_img *img = new rxvt_img (s, format, w, h); |
181 | rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); |
|
|
182 | img->alloc (); |
|
|
183 | |
|
|
184 | Picture src = src_picture (); |
137 | |
185 | |
138 | XRenderPictureAttributes pa; |
186 | XRenderPictureAttributes pa; |
139 | |
|
|
140 | pa.repeat = RepeatPad; |
187 | pa.repeat = RepeatPad; |
141 | Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa); |
|
|
142 | Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa); |
188 | Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa); |
143 | |
189 | |
144 | Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth); |
190 | Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth); |
145 | Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa); |
191 | Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa); |
146 | XFreePixmap (dpy, tmp_pm); |
192 | XFreePixmap (dpy, tmp_pm); |
… | |
… | |
200 | |
246 | |
201 | return mask; |
247 | return mask; |
202 | } |
248 | } |
203 | |
249 | |
204 | void |
250 | void |
205 | rxvt_img::brightness (double r, double g, double b, double a) |
251 | rxvt_img::brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a) |
206 | { |
252 | { |
207 | Display *dpy = s->display->dpy; |
253 | Display *dpy = s->display->dpy; |
208 | Picture src = create_xrender_mask (dpy, pm, True); |
254 | Picture src = create_xrender_mask (dpy, pm, True); |
209 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
255 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
210 | |
256 | |
211 | XRenderColor mask_c; |
257 | XRenderColor mask_c; |
212 | mask_c.red = float_to_component (r); |
258 | mask_c.red = r; |
213 | mask_c.green = float_to_component (g); |
259 | mask_c.green = g; |
214 | mask_c.blue = float_to_component (b); |
260 | mask_c.blue = b; |
215 | mask_c.alpha = float_to_component (a); |
261 | mask_c.alpha = a; |
216 | XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); |
262 | XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); |
217 | |
263 | |
218 | XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
264 | XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
219 | |
265 | |
220 | XRenderFreePicture (dpy, src); |
266 | XRenderFreePicture (dpy, src); |
221 | XRenderFreePicture (dpy, dst); |
267 | XRenderFreePicture (dpy, dst); |
222 | } |
268 | } |
223 | |
269 | |
224 | void |
270 | void |
225 | rxvt_img::contrast (double r, double g, double b, double a) |
271 | rxvt_img::contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a) |
226 | { |
272 | { |
227 | if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL)) |
273 | if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL)) |
228 | return; |
274 | return; |
229 | |
275 | |
230 | Display *dpy = s->display->dpy; |
276 | Display *dpy = s->display->dpy; |
231 | Picture src = create_xrender_mask (dpy, pm, True); |
277 | Picture src = create_xrender_mask (dpy, pm, True); |
232 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
278 | Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); |
233 | |
279 | |
234 | XRenderColor mask_c; |
280 | XRenderColor mask_c; |
235 | mask_c.red = float_to_component (r); |
281 | mask_c.red = r; |
236 | mask_c.green = float_to_component (g); |
282 | mask_c.green = g; |
237 | mask_c.blue = float_to_component (b); |
283 | mask_c.blue = b; |
238 | mask_c.alpha = float_to_component (a); |
284 | mask_c.alpha = a; |
239 | XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); |
285 | XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); |
240 | |
286 | |
241 | XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
287 | XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
242 | |
288 | |
243 | XRenderFreePicture (dpy, src); |
289 | XRenderFreePicture (dpy, src); |
… | |
… | |
342 | } |
388 | } |
343 | |
389 | |
344 | rxvt_img * |
390 | rxvt_img * |
345 | rxvt_img::clone () |
391 | rxvt_img::clone () |
346 | { |
392 | { |
347 | rxvt_img *img = new rxvt_img (s, format, w, h); |
393 | return new rxvt_img (*this); |
348 | |
|
|
349 | GC gc = XCreateGC (s->display->dpy, pm, 0, 0); |
|
|
350 | XCopyArea (s->display->dpy, pm, img->pm, gc, 0, 0, w, h, 0, 0); |
|
|
351 | XFreeGC (s->display->dpy, gc); |
|
|
352 | |
|
|
353 | return img; |
|
|
354 | } |
394 | } |
355 | |
395 | |
356 | rxvt_img * |
|
|
357 | rxvt_img::sub_rect (int x, int y, int width, int height, int repeat) |
|
|
358 | { |
|
|
359 | rxvt_img *img = new rxvt_img (s, format, width, height); |
|
|
360 | |
396 | |
|
|
397 | static XRenderPictFormat * |
|
|
398 | find_alpha_format_for (Display *dpy, XRenderPictFormat *format) |
|
|
399 | { |
|
|
400 | if (format->direct.alphaMask) |
|
|
401 | return format; // already has alpha |
|
|
402 | |
|
|
403 | // try to find a suitable alpha format, one bit alpha is enough for our purposes |
|
|
404 | if (format->type == PictTypeDirect) |
|
|
405 | for (int n = 0; XRenderPictFormat *f = XRenderFindFormat (dpy, 0, 0, n); ++n) |
|
|
406 | if (f->direct.alphaMask |
|
|
407 | && f->type == PictTypeDirect |
|
|
408 | && ecb_popcount32 (f->direct.redMask ) >= ecb_popcount32 (format->direct.redMask ) |
|
|
409 | && ecb_popcount32 (f->direct.greenMask) >= ecb_popcount32 (format->direct.greenMask) |
|
|
410 | && ecb_popcount32 (f->direct.blueMask ) >= ecb_popcount32 (format->direct.blueMask )) |
|
|
411 | return f; |
|
|
412 | |
|
|
413 | // should be a very good fallback |
|
|
414 | return XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
415 | } |
|
|
416 | |
|
|
417 | rxvt_img * |
|
|
418 | rxvt_img::reify () |
|
|
419 | { |
|
|
420 | if (x == 0 && y == 0 && w == ref->w && h == ref->h) |
|
|
421 | return clone (); |
|
|
422 | |
361 | Display *dpy = s->display->dpy; |
423 | Display *dpy = s->display->dpy; |
362 | XRenderPictureAttributes pa; |
424 | |
363 | pa.repeat = repeat; |
425 | bool alpha = !format->direct.alphaMask |
364 | Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); |
426 | && (x || y) |
|
|
427 | && repeat == RepeatNone; |
|
|
428 | |
|
|
429 | rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); |
|
|
430 | img->alloc (); |
|
|
431 | |
|
|
432 | Picture src = src_picture (); |
365 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
433 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
366 | |
434 | |
|
|
435 | if (alpha) |
|
|
436 | { |
|
|
437 | XRenderColor rc = { 0, 0, 0, 0 }; |
|
|
438 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles |
|
|
439 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, -x, -y, ref->w, ref->h); |
|
|
440 | } |
|
|
441 | else |
367 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height); |
442 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); |
368 | |
443 | |
369 | XRenderFreePicture (dpy, src); |
444 | XRenderFreePicture (dpy, src); |
370 | XRenderFreePicture (dpy, dst); |
445 | XRenderFreePicture (dpy, dst); |
371 | |
446 | |
372 | return img; |
447 | return img; |
373 | } |
448 | } |
374 | |
449 | |
375 | rxvt_img * |
450 | rxvt_img * |
|
|
451 | rxvt_img::sub_rect (int x, int y, int width, int height) |
|
|
452 | { |
|
|
453 | rxvt_img *img = clone (); |
|
|
454 | |
|
|
455 | img->x += x; |
|
|
456 | img->y += y; |
|
|
457 | |
|
|
458 | if (w != width || h != height) |
|
|
459 | { |
|
|
460 | img->w = width; |
|
|
461 | img->h = height; |
|
|
462 | |
|
|
463 | rxvt_img *img2 = img->reify (); |
|
|
464 | delete img; |
|
|
465 | img = img2; |
|
|
466 | } |
|
|
467 | |
|
|
468 | return img; |
|
|
469 | } |
|
|
470 | |
|
|
471 | rxvt_img * |
376 | rxvt_img::transform (int new_width, int new_height, double matrix[9], int repeat) |
472 | rxvt_img::transform (int new_width, int new_height, double matrix[9]) |
377 | { |
473 | { |
378 | rxvt_img *img = new rxvt_img (s, format, new_width, new_height); |
474 | rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat); |
|
|
475 | img->alloc (); |
379 | |
476 | |
380 | Display *dpy = s->display->dpy; |
477 | Display *dpy = s->display->dpy; |
381 | XRenderPictureAttributes pa; |
478 | Picture src = src_picture (); |
382 | pa.repeat = repeat; |
|
|
383 | Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); |
|
|
384 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
479 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
385 | |
480 | |
386 | XTransform xfrm; |
481 | XTransform xfrm; |
387 | |
482 | |
388 | for (int i = 0; i < 3; ++i) |
483 | for (int i = 0; i < 3; ++i) |
389 | for (int j = 0; j < 3; ++j) |
484 | for (int j = 0; j < 3; ++j) |
390 | xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); |
485 | xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); |
391 | |
486 | |
|
|
487 | #if 0 |
|
|
488 | xfrm.matrix [0][2] -= XDoubleToFixed (x);//TODO |
|
|
489 | xfrm.matrix [1][2] -= XDoubleToFixed (y); |
|
|
490 | #endif |
|
|
491 | |
392 | XRenderSetPictureFilter (dpy, src, "good", 0, 0); |
492 | XRenderSetPictureFilter (dpy, src, "good", 0, 0); |
393 | XRenderSetPictureTransform (dpy, src, &xfrm); |
493 | XRenderSetPictureTransform (dpy, src, &xfrm); |
394 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); |
494 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); |
395 | |
495 | |
396 | XRenderFreePicture (dpy, src); |
496 | XRenderFreePicture (dpy, src); |
… | |
… | |
400 | } |
500 | } |
401 | |
501 | |
402 | rxvt_img * |
502 | rxvt_img * |
403 | rxvt_img::scale (int new_width, int new_height) |
503 | rxvt_img::scale (int new_width, int new_height) |
404 | { |
504 | { |
|
|
505 | if (w == new_width && h == new_height) |
|
|
506 | return clone (); |
|
|
507 | |
405 | double matrix[9] = { |
508 | double matrix[9] = { |
406 | w / (double)new_width, 0, 0, |
509 | w / (double)new_width, 0, 0, |
407 | 0, h / (double)new_height, 0, |
510 | 0, h / (double)new_height, 0, |
408 | 0, 0, 1 |
511 | 0, 0, 1 |
409 | }; |
512 | }; |
410 | |
513 | |
|
|
514 | int old_repeat_mode = repeat; |
|
|
515 | repeat = RepeatPad; // not right, but xrender can't proeprly scale it seems |
|
|
516 | |
411 | return transform (new_width, new_height, matrix); |
517 | rxvt_img *img = transform (new_width, new_height, matrix); |
412 | } |
|
|
413 | |
518 | |
|
|
519 | repeat = old_repeat_mode; |
|
|
520 | img->repeat = repeat; |
|
|
521 | |
|
|
522 | return img; |
|
|
523 | } |
|
|
524 | |
414 | rxvt_img * |
525 | rxvt_img * |
415 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi, int repeat) |
526 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) |
416 | { |
527 | { |
417 | double s = sin (phi); |
528 | double s = sin (phi); |
418 | double c = cos (phi); |
529 | double c = cos (phi); |
419 | |
530 | |
420 | double matrix[9] = { |
531 | double matrix[9] = { |
421 | c, -s, -c * x + s * y + x, |
532 | c, -s, -c * x + s * y + x, |
422 | s, c, -s * x - c * y + y, |
533 | s, c, -s * x - c * y + y, |
423 | 0, 0, 1 |
534 | 0, 0, 1 |
424 | }; |
535 | }; |
425 | |
536 | |
426 | return transform (new_width, new_height, matrix, repeat); |
537 | return transform (new_width, new_height, matrix); |
427 | } |
538 | } |
428 | |
539 | |
429 | rxvt_img * |
540 | rxvt_img * |
430 | rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) |
541 | rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) |
431 | { |
542 | { |
|
|
543 | if (new_format == format) |
|
|
544 | return clone (); |
|
|
545 | |
432 | rxvt_img *img = new rxvt_img (s, new_format, w, h); |
546 | rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); |
|
|
547 | img->alloc (); |
433 | |
548 | |
434 | Display *dpy = s->display->dpy; |
549 | Display *dpy = s->display->dpy; |
435 | Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0); |
550 | Picture src = src_picture (); |
436 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |
551 | Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); |
437 | int op = PictOpSrc; |
552 | int op = PictOpSrc; |
438 | |
553 | |
439 | printf ("fa %x,%x fb %x,%x\n", f->direct.alpha, f->direct.alpha_mask, new_format->direct.alpha, new_format->direct.alpha_mask);//D |
|
|
440 | |
|
|
441 | if (f->direct.alpha && !new_format->direct.alpha) |
554 | if (format->direct.alphaMask && !new_format->direct.alphaMask) |
442 | { |
555 | { |
443 | // does it have to be that complicated |
556 | // does it have to be that complicated |
444 | rgba c; |
557 | rgba c; |
445 | bg.get (c); |
558 | bg.get (c); |
446 | |
559 | |
447 | XRenderColor rc = { c.r, c.g, c.b, 0xffff }; |
560 | XRenderColor rc = { c.r, c.g, c.b, 0xffff }; |
448 | |
|
|
449 | XRenderFillRectangle (dpy, PictOpSrc, dst, &mask_c, 0, 0, w, h); |
561 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); |
450 | |
562 | |
451 | op = PictOpOver; |
563 | op = PictOpOver; |
452 | } |
564 | } |
453 | |
565 | |
454 | XRenderComposite (dpy, op, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
566 | XRenderComposite (dpy, op, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
… | |
… | |
462 | rxvt_img * |
574 | rxvt_img * |
463 | rxvt_img::blend (rxvt_img *img, double factor) |
575 | rxvt_img::blend (rxvt_img *img, double factor) |
464 | { |
576 | { |
465 | rxvt_img *img2 = clone (); |
577 | rxvt_img *img2 = clone (); |
466 | Display *dpy = s->display->dpy; |
578 | Display *dpy = s->display->dpy; |
467 | Picture src = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
579 | Picture src = img->src_picture (); |
468 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
580 | Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); |
469 | Picture mask = create_xrender_mask (dpy, img->pm, False); |
581 | Picture mask = create_xrender_mask (dpy, img->pm, False); |
470 | |
582 | |
471 | XRenderColor mask_c; |
583 | XRenderColor mask_c; |
472 | |
584 | |