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.58 by root, Thu Jun 7 20:35:35 2012 UTC vs.
Revision 1.64 by root, Fri Jun 8 21:33:32 2012 UTC

13rxvt_img::rxvt_img (const rxvt_img &img) 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), ref(img.ref) 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{ 15{
16 ++ref->cnt; 16 ++ref->cnt;
17} 17}
18
19#if 0
20rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap)
21: s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), shared(false), pm(pixmap)
22{
23}
24#endif
25 18
26rxvt_img * 19rxvt_img *
27rxvt_img::new_from_root (rxvt_screen *s) 20rxvt_img::new_from_root (rxvt_screen *s)
28{ 21{
29 Display *dpy = s->display->dpy; 22 Display *dpy = s->display->dpy;
272 double *kernel = (double *)malloc (size * sizeof (double)); 265 double *kernel = (double *)malloc (size * sizeof (double));
273 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 266 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
274 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); 267 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat);
275 img->alloc (); 268 img->alloc ();
276 269
277 Picture src = src_picture ();
278
279 XRenderPictureAttributes pa; 270 XRenderPictureAttributes pa;
280 pa.repeat = RepeatPad; 271 pa.repeat = RepeatPad;
281 Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa); 272 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa);
273 Picture dst = XRenderCreatePicture (dpy, img->pm, format, 0, 0);
282 274
283 Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth); 275 Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth);
284 Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa); 276 Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa);
285 XFreePixmap (dpy, tmp_pm); 277 XFreePixmap (dpy, tmp_pm);
286 278
302 294
303 size = rv * 2 + 1; 295 size = rv * 2 + 1;
304 get_gaussian_kernel (rv, size, kernel, params); 296 get_gaussian_kernel (rv, size, kernel, params);
305 ::swap (params[0], params[1]); 297 ::swap (params[0], params[1]);
306 298
307 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 299 XRenderSetPictureFilter (dpy, tmp, FilterConvolution, params, size+2);
308 XRenderComposite (dpy, 300 XRenderComposite (dpy,
309 PictOpSrc, 301 PictOpSrc,
310 tmp, 302 tmp,
311 None, 303 None,
312 dst, 304 dst,
339 331
340 return mask; 332 return mask;
341} 333}
342 334
343void 335void
344rxvt_img::brightness (unsigned short r, unsigned short g, unsigned short b, unsigned short a) 336rxvt_img::brightness (uint16_t r, uint16_t g, uint16_t b, uint16_t a)
345{ 337{
346 Display *dpy = s->display->dpy; 338 Display *dpy = s->display->dpy;
347 Picture src = create_xrender_mask (dpy, pm, True); 339 Picture src = create_xrender_mask (dpy, pm, True);
348 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 340 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
349 341
359 XRenderFreePicture (dpy, src); 351 XRenderFreePicture (dpy, src);
360 XRenderFreePicture (dpy, dst); 352 XRenderFreePicture (dpy, dst);
361} 353}
362 354
363void 355void
364rxvt_img::contrast (unsigned short r, unsigned short g, unsigned short b, unsigned short a) 356rxvt_img::contrast (uint16_t r, uint16_t g, uint16_t b, uint16_t a)
365{ 357{
366 if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL)) 358 if (!(s->display->flags & DISPLAY_HAS_RENDER_MUL))
359 {
360 rxvt_warn ("rxvt_img::contrast operation not supported on this display, RENDER extension too old.\n");
367 return; 361 return;
362 }
368 363
369 Display *dpy = s->display->dpy; 364 Display *dpy = s->display->dpy;
370 Picture src = create_xrender_mask (dpy, pm, True); 365 Picture src = create_xrender_mask (dpy, pm, True);
371 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 366 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
372 367
415 if (x == 0 && y == 0 && w == ref->w && h == ref->h) 410 if (x == 0 && y == 0 && w == ref->w && h == ref->h)
416 return clone (); 411 return clone ();
417 412
418 Display *dpy = s->display->dpy; 413 Display *dpy = s->display->dpy;
419 414
415 // add an alpha channel if...
420 bool alpha = !format->direct.alphaMask 416 bool alpha = !format->direct.alphaMask // pixmap has none yet
421 && (x || y) 417 && (x || y) // we need one because of non-zero offset
422 && repeat == RepeatNone; 418 && repeat == RepeatNone; // and we have no good pixels to fill with
423 419
424 rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat); 420 rxvt_img *img = new rxvt_img (s, alpha ? find_alpha_format_for (dpy, format) : format, 0, 0, w, h, repeat);
425 img->alloc (); 421 img->alloc ();
426 422
427 Picture src = src_picture (); 423 Picture src = src_picture ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines