ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.14 by root, Mon Jun 4 15:53:12 2012 UTC vs.
Revision 1.32 by root, Thu Jun 7 07:53:12 2012 UTC

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
9rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) 7rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
10: s(screen), w(width), h(height), format(format), shared(false) 8: s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal),
9 pm(0), refcnt(0)
11{ 10{
12 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
13} 11}
14 12
13rxvt_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), refcnt(img.refcnt)
15{
16 if (refcnt)
17 ++*refcnt;
18}
19
20#if 0
15rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap) 21rxvt_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) 22: s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false), pm(pixmap)
17{ 23{
24}
25#endif
26
27rxvt_img *
28rxvt_img::new_from_root (rxvt_screen *s)
29{
30 Display *dpy = s->display->dpy;
31 unsigned int root_pm_w, root_pm_h;
32 Pixmap root_pixmap = s->display->get_pixmap_property (s->display->xa[XA_XROOTPMAP_ID]);
33 if (root_pixmap == None)
34 root_pixmap = s->display->get_pixmap_property (s->display->xa[XA_ESETROOT_PMAP_ID]);
35
36 if (root_pixmap == None)
37 return 0;
38
39 Window wdummy;
40 int idummy;
41 unsigned int udummy;
42
43 if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pm_w, &root_pm_h, &udummy, &udummy))
44 return 0;
45
46 rxvt_img *img = new rxvt_img (
47 s,
48 XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)),
49 root_pm_w,
50 root_pm_h
51 );
52
53 img->pm = root_pixmap;
54
55 return img;
18} 56}
19 57
20rxvt_img * 58rxvt_img *
21rxvt_img::new_from_file (rxvt_screen *s, const char *filename) 59rxvt_img::new_from_file (rxvt_screen *s, const char *filename)
22{ 60{
30 s, 68 s,
31 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24), 69 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24),
32 gdk_pixbuf_get_width (pb), 70 gdk_pixbuf_get_width (pb),
33 gdk_pixbuf_get_height (pb) 71 gdk_pixbuf_get_height (pb)
34 ); 72 );
35 73 img->alloc ();
36 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0); 74 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0);
37 75
76 g_object_unref (pb);
77
38 return img; 78 return img;
39} 79}
40 80
81void
82rxvt_img::destroy ()
83{
84 if (!refcnt || --*refcnt)
85 return;
86
87 if (pm)
88 XFreePixmap (s->display->dpy, pm);
89
90 delete refcnt;
91}
92
41rxvt_img::~rxvt_img () 93rxvt_img::~rxvt_img ()
42{ 94{
43 if (!shared) 95 destroy ();
44 XFreePixmap (s->display->dpy, pm); 96}
97
98void
99rxvt_img::alloc ()
100{
101 pm = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
102 refcnt = new int (1);
45} 103}
46 104
47void 105void
48rxvt_img::unshare () 106rxvt_img::unshare ()
49{ 107{
50 if (!shared) 108 if (refcnt && *refcnt == 1)
51 return; 109 return;
52 110
53 rxvt_img *img = clone (); 111 Pixmap pm2 = XCreatePixmap (s->display->dpy, s->display->root, w, h, format->depth);
112 GC gc = XCreateGC (s->display->dpy, pm, 0, 0);
113 XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0);
114 XFreeGC (s->display->dpy, gc);
54 115
55 ::swap (pm , img->pm); 116 destroy ();
56 ::swap (shared, img->shared);
57 117
58 delete img; 118 pm = pm2;
119 refcnt = new int (1);
59} 120}
60 121
61void 122void
62rxvt_img::fill (const rxvt_color &c) 123rxvt_img::fill (const rxvt_color &c)
63{ 124{
87 148
88 for (int i = 0; i < width; i++) 149 for (int i = 0; i < width; i++)
89 params[i+2] = XDoubleToFixed (kernel[i] / sum); 150 params[i+2] = XDoubleToFixed (kernel[i] / sum);
90} 151}
91 152
92void 153rxvt_img *
93rxvt_img::blur (int rh, int rv) 154rxvt_img::blur (int rh, int rv)
94{ 155{
95 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV)) 156 if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV))
96 return; 157 return clone ();
97 158
98 Display *dpy = s->display->dpy; 159 Display *dpy = s->display->dpy;
99 int size = max (rh, rv) * 2 + 1; 160 int size = max (rh, rv) * 2 + 1;
100 double *kernel = (double *)malloc (size * sizeof (double)); 161 double *kernel = (double *)malloc (size * sizeof (double));
101 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 162 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
163 rxvt_img *img = new rxvt_img (s, format, w, h);
164 img->alloc ();
102 165
103 XRenderPictureAttributes pa; 166 XRenderPictureAttributes pa;
104 167
105 pa.repeat = RepeatPad; 168 pa.repeat = RepeatPad;
106 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); 169 Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa);
170 Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa);
171
107 Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth); 172 Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth);
108 Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); 173 Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa);
109 XFreePixmap (dpy, tmp); 174 XFreePixmap (dpy, tmp_pm);
110 175
111 if (kernel && params) 176 if (kernel && params)
112 { 177 {
113 size = rh * 2 + 1; 178 size = rh * 2 + 1;
114 get_gaussian_kernel (rh, size, kernel, params); 179 get_gaussian_kernel (rh, size, kernel, params);
116 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 181 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
117 XRenderComposite (dpy, 182 XRenderComposite (dpy,
118 PictOpSrc, 183 PictOpSrc,
119 src, 184 src,
120 None, 185 None,
121 dst, 186 tmp,
122 0, 0, 187 0, 0,
123 0, 0, 188 0, 0,
124 0, 0, 189 0, 0,
125 w, h); 190 w, h);
126 191
127 ::swap (src, dst);
128
129 size = rv * 2 + 1; 192 size = rv * 2 + 1;
130 get_gaussian_kernel (rv, size, kernel, params); 193 get_gaussian_kernel (rv, size, kernel, params);
131 ::swap (params[0], params[1]); 194 ::swap (params[0], params[1]);
132 195
133 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 196 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
134 XRenderComposite (dpy, 197 XRenderComposite (dpy,
135 PictOpSrc, 198 PictOpSrc,
136 src, 199 tmp,
137 None, 200 None,
138 dst, 201 dst,
139 0, 0, 202 0, 0,
140 0, 0, 203 0, 0,
141 0, 0, 204 0, 0,
144 207
145 free (kernel); 208 free (kernel);
146 free (params); 209 free (params);
147 XRenderFreePicture (dpy, src); 210 XRenderFreePicture (dpy, src);
148 XRenderFreePicture (dpy, dst); 211 XRenderFreePicture (dpy, dst);
212 XRenderFreePicture (dpy, tmp);
213
214 return img;
149} 215}
150 216
151static Picture 217static Picture
152create_xrender_mask (Display *dpy, Drawable drawable, Bool argb) 218create_xrender_mask (Display *dpy, Drawable drawable, Bool argb)
153{ 219{
162 228
163 return mask; 229 return mask;
164} 230}
165 231
166void 232void
167rxvt_img::brightness (double r, double g, double b, double a) 233rxvt_img::brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a)
168{ 234{
169 Display *dpy = s->display->dpy; 235 Display *dpy = s->display->dpy;
170 Picture src = create_xrender_mask (dpy, pm, True); 236 Picture src = create_xrender_mask (dpy, pm, True);
171 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 237 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
172 238
173 XRenderColor mask_c; 239 XRenderColor mask_c;
174 mask_c.red = float_to_component (r); 240 mask_c.red = r;
175 mask_c.green = float_to_component (g); 241 mask_c.green = g;
176 mask_c.blue = float_to_component (b); 242 mask_c.blue = b;
177 mask_c.alpha = float_to_component (a); 243 mask_c.alpha = a;
178 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 244 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
179 245
180 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 246 XRenderComposite (dpy, PictOpAdd, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
247
248 XRenderFreePicture (dpy, src);
249 XRenderFreePicture (dpy, dst);
181} 250}
182 251
183void 252void
184rxvt_img::contrast (double r, double g, double b, double a) 253rxvt_img::contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a)
185{ 254{
186 if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL)) 255 if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL))
187 return; 256 return;
188 257
189 Display *dpy = s->display->dpy; 258 Display *dpy = s->display->dpy;
190 Picture src = create_xrender_mask (dpy, pm, True); 259 Picture src = create_xrender_mask (dpy, pm, True);
191 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 260 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
192 261
193 XRenderColor mask_c; 262 XRenderColor mask_c;
194 mask_c.red = float_to_component (r); 263 mask_c.red = r;
195 mask_c.green = float_to_component (g); 264 mask_c.green = g;
196 mask_c.blue = float_to_component (b); 265 mask_c.blue = b;
197 mask_c.alpha = float_to_component (a); 266 mask_c.alpha = a;
198 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 267 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1);
199 268
200 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 269 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
270
271 XRenderFreePicture (dpy, src);
272 XRenderFreePicture (dpy, dst);
201} 273}
202 274
203bool 275bool
204rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y) 276rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y)
205{ 277{
206 bool argb = format->id == PictStandardARGB32;
207
208 Display *dpy = s->display->dpy; 278 Display *dpy = s->display->dpy;
209 279
210 if (s->visual->c_class != TrueColor) 280 if (s->visual->c_class != TrueColor)
211 return false; 281 return false;
212 282
213 uint32_t red_mask, green_mask, blue_mask, alpha_mask; 283 uint32_t red_mask, green_mask, blue_mask, alpha_mask;
214 284
215 if (argb) 285 red_mask = (uint32_t)format->direct.redMask << format->direct.red;
216 { 286 green_mask = (uint32_t)format->direct.greenMask << format->direct.green;
217 red_mask = 0xff << 16; 287 blue_mask = (uint32_t)format->direct.blueMask << format->direct.blue;
218 green_mask = 0xff << 8;
219 blue_mask = 0xff;
220 alpha_mask = 0xff << 24;
221 }
222 else
223 {
224 red_mask = s->visual->red_mask;
225 green_mask = s->visual->green_mask;
226 blue_mask = s->visual->blue_mask;
227 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; 288 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha;
228 }
229 289
230 int width_r = ecb_popcount32 (red_mask); 290 int width_r = ecb_popcount32 (red_mask);
231 int width_g = ecb_popcount32 (green_mask); 291 int width_g = ecb_popcount32 (green_mask);
232 int width_b = ecb_popcount32 (blue_mask); 292 int width_b = ecb_popcount32 (blue_mask);
233 int width_a = ecb_popcount32 (alpha_mask); 293 int width_a = ecb_popcount32 (alpha_mask);
241 int sh_a = ecb_ctz32 (alpha_mask); 301 int sh_a = ecb_ctz32 (alpha_mask);
242 302
243 if (width > 32767 || height > 32767) 303 if (width > 32767 || height > 32767)
244 return false; 304 return false;
245 305
246 XImage *ximage = XCreateImage (dpy, s->visual, argb ? 32 : format->depth, ZPixmap, 0, 0, 306 XImage *ximage = XCreateImage (dpy, s->visual, format->depth, ZPixmap, 0, 0,
247 width, height, 32, 0); 307 width, height, 32, 0);
248 if (!ximage) 308 if (!ximage)
249 return false; 309 return false;
250 310
251 if (height > INT_MAX / ximage->bytes_per_line 311 if (height > INT_MAX / ximage->bytes_per_line
261 321
262 int rowstride = gdk_pixbuf_get_rowstride (pixbuf); 322 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
263 int channels = gdk_pixbuf_get_n_channels (pixbuf); 323 int channels = gdk_pixbuf_get_n_channels (pixbuf);
264 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 324 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
265 char *line = ximage->data; 325 char *line = ximage->data;
266
267 rgba c (0, 0, 0);
268
269 if (channels == 4 && alpha_mask == 0)
270 {
271 //pix_colors[Color_bg].get (c);
272 //TODO
273 c.r >>= 8;
274 c.g >>= 8;
275 c.b >>= 8;
276 }
277 326
278 for (int y = 0; y < height; y++) 327 for (int y = 0; y < height; y++)
279 { 328 {
280 for (int x = 0; x < width; x++) 329 for (int x = 0; x < width; x++)
281 { 330 {
284 unsigned char r, g, b, a; 333 unsigned char r, g, b, a;
285 334
286 if (channels == 4) 335 if (channels == 4)
287 { 336 {
288 a = pixel[3]; 337 a = pixel[3];
289 r = (pixel[0] * a + c.r * (0xff - a)) / 0xff; 338 r = pixel[0] * a / 0xff;
290 g = (pixel[1] * a + c.g * (0xff - a)) / 0xff; 339 g = pixel[1] * a / 0xff;
291 b = (pixel[2] * a + c.b * (0xff - a)) / 0xff; 340 b = pixel[2] * a / 0xff;
292 } 341 }
293 else 342 else
294 { 343 {
295 a = 0xff; 344 a = 0xff;
296 r = pixel[0]; 345 r = pixel[0];
321} 370}
322 371
323rxvt_img * 372rxvt_img *
324rxvt_img::clone () 373rxvt_img::clone ()
325{ 374{
326 GC gc = XCreateGC (s->display->dpy, pm, 0, 0); 375 return new rxvt_img (*this);
327 Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth);
328 XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0);
329 XFreeGC (s->display->dpy, gc);
330 return new rxvt_img (s, format, w, h, pm2);
331} 376}
332 377
333rxvt_img * 378rxvt_img *
334rxvt_img::transform (int new_width, int new_height, int repeat, double matrix[9]) 379rxvt_img::sub_rect (int x, int y, int width, int height)
335{ 380{
336 rxvt_img *img = new rxvt_img (s, format, new_width, new_height); 381 rxvt_img *img = new rxvt_img (s, format, width, height);
382 img->alloc ();
337 383
338 Display *dpy = s->display->dpy; 384 Display *dpy = s->display->dpy;
339 XRenderPictureAttributes pa; 385 XRenderPictureAttributes pa;
340 pa.repeat = repeat; 386 pa.repeat = repeat;
341 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); 387 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa);
342 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 388 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
343 389
390 XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height);
391
392 XRenderFreePicture (dpy, src);
393 XRenderFreePicture (dpy, dst);
394
395 return img;
396}
397
398rxvt_img *
399rxvt_img::transform (int new_width, int new_height, double matrix[9])
400{
401 rxvt_img *img = new rxvt_img (s, format, new_width, new_height);
402 img->alloc ();
403
404 Display *dpy = s->display->dpy;
405 XRenderPictureAttributes pa;
406 pa.repeat = repeat;
407 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa);
408 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
409
344 XTransform xfrm; 410 XTransform xfrm;
345 411
346 for (int i = 0; i < 3; ++i) 412 for (int i = 0; i < 3; ++i)
347 for (int j = 0; j < 3; ++j) 413 for (int j = 0; j < 3; ++j)
348 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); 414 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]);
349 415
416 XRenderSetPictureFilter (dpy, src, "good", 0, 0);
350 XRenderSetPictureTransform (dpy, src, &xfrm); 417 XRenderSetPictureTransform (dpy, src, &xfrm);
351 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); 418 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height);
352 419
353 XRenderFreePicture (dpy, src); 420 XRenderFreePicture (dpy, src);
354 XRenderFreePicture (dpy, dst); 421 XRenderFreePicture (dpy, dst);
358 425
359rxvt_img * 426rxvt_img *
360rxvt_img::scale (int new_width, int new_height) 427rxvt_img::scale (int new_width, int new_height)
361{ 428{
362 double matrix[9] = { 429 double matrix[9] = {
363 new_width / (double)w, 0, 0, 430 w / (double)new_width, 0, 0,
364 0, new_height / (double)h, 0, 431 0, h / (double)new_height, 0,
365 0, 0, 1 432 0, 0, 1
366 }; 433 };
367 434
368 return transform (new_width, new_height, RepeatNormal, matrix); 435 return transform (new_width, new_height, matrix);
369} 436}
370 437
371rxvt_img * 438rxvt_img *
439rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi)
440{
441 double s = sin (phi);
442 double c = cos (phi);
443
444 double matrix[9] = {
445 c, -s, -c * x + s * y + x,
446 s, c, -s * x - c * y + y,
447 0, 0, 1
448 };
449
450 return transform (new_width, new_height, matrix);
451}
452
453rxvt_img *
372rxvt_img::convert_to (XRenderPictFormat *new_format) 454rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg)
373{ 455{
456 if (new_format == format)
457 return clone ();
458
374 rxvt_img *img = new rxvt_img (s, new_format, w, h); 459 rxvt_img *img = new rxvt_img (s, new_format, w, h);
460 img->alloc ();
375 461
376 Display *dpy = s->display->dpy; 462 Display *dpy = s->display->dpy;
377 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0); 463 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0);
378 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); 464 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0);
465 int op = PictOpSrc;
379 466
467 if (format->direct.alphaMask && !new_format->direct.alphaMask)
468 {
469 // does it have to be that complicated
470 rgba c;
471 bg.get (c);
472
473 XRenderColor rc = { c.r, c.g, c.b, 0xffff };
474 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);
475
476 op = PictOpOver;
477 }
478
380 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, w, h); 479 XRenderComposite (dpy, op, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
381 480
382 XRenderFreePicture (dpy, src); 481 XRenderFreePicture (dpy, src);
383 XRenderFreePicture (dpy, dst); 482 XRenderFreePicture (dpy, dst);
384 483
385 return img; 484 return img;
386} 485}
387 486
487rxvt_img *
488rxvt_img::blend (rxvt_img *img, double factor)
489{
490 rxvt_img *img2 = clone ();
491 Display *dpy = s->display->dpy;
492 Picture src = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
493 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0);
494 Picture mask = create_xrender_mask (dpy, img->pm, False);
495
496 XRenderColor mask_c;
497
498 mask_c.alpha = float_to_component (factor);
499 mask_c.red =
500 mask_c.green =
501 mask_c.blue = 0;
502 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
503
504 XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, w, h);
505
506 XRenderFreePicture (dpy, src);
507 XRenderFreePicture (dpy, dst);
508 XRenderFreePicture (dpy, mask);
509
510 return img2;
511}
512
388#endif 513#endif
389 514

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines