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.69 by root, Sat Jun 9 11:15:29 2012 UTC vs.
Revision 1.72 by sf-exg, Sat Jun 9 16:21:16 2012 UTC

314 XRenderFreePicture (dpy, tmp); 314 XRenderFreePicture (dpy, tmp);
315 315
316 return img; 316 return img;
317} 317}
318 318
319static Picture
320create_xrender_mask (Display *dpy, Drawable drawable, Bool argb)
321{
322 Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8);
323
324 XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8);
325 XRenderPictureAttributes pa;
326 pa.repeat = True;
327 Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa);
328
329 XFreePixmap (dpy, pixmap);
330
331 return mask;
332}
333
334static void 319static void
335extract (int32_t cl0, int32_t cl1, int32_t &c, unsigned short &xc) 320extract (int32_t cl0, int32_t cl1, int32_t &c, unsigned short &xc)
336{ 321{
337 int32_t x = clamp (c, cl0, cl1); 322 int32_t x = clamp (c, cl0, cl1);
338 c -= x; 323 c -= x;
357 342
358 Display *dpy = s->display->dpy; 343 Display *dpy = s->display->dpy;
359 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 344 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
360 345
361 // loop should not be needed for brightness, as only -1..1 makes sense 346 // loop should not be needed for brightness, as only -1..1 makes sense
362
363 while (r | g | b | a) 347 //while (r | g | b | a)
364 { 348 {
365 unsigned short xr, xg, xb, xa; 349 unsigned short xr, xg, xb, xa;
366 XRenderColor mask_c; 350 XRenderColor mask_c;
367 351
368 if (extract (0, 65535, r, g, b, a, mask_c.red, mask_c.green, mask_c.blue, mask_c.alpha)) 352 if (extract (0, 65535, r, g, b, a, mask_c.red, mask_c.green, mask_c.blue, mask_c.alpha))
370 354
371 if (extract (-65535, 0, r, g, b, a, mask_c.red, mask_c.green, mask_c.blue, mask_c.alpha)) 355 if (extract (-65535, 0, r, g, b, a, mask_c.red, mask_c.green, mask_c.blue, mask_c.alpha))
372 { 356 {
373 XRenderColor mask_w = { 65535, 65535, 65535, 65535 }; 357 XRenderColor mask_w = { 65535, 65535, 65535, 65535 };
374 XRenderFillRectangle (dpy, PictOpDifference, dst, &mask_w, 0, 0, w, h); 358 XRenderFillRectangle (dpy, PictOpDifference, dst, &mask_w, 0, 0, w, h);
375 mask_c.red = -mask_c.red; 359 mask_c.red = -mask_c.red; //TODO: verify that doing clamp, assign, and negation does the right thing
376 mask_c.green = -mask_c.green; 360 mask_c.green = -mask_c.green;
377 mask_c.blue = -mask_c.blue; 361 mask_c.blue = -mask_c.blue;
378 mask_c.alpha = -mask_c.alpha; 362 mask_c.alpha = -mask_c.alpha;
379 XRenderFillRectangle (dpy, PictOpAdd, dst, &mask_c, 0, 0, w, h); 363 XRenderFillRectangle (dpy, PictOpAdd, dst, &mask_c, 0, 0, w, h);
380 XRenderFillRectangle (dpy, PictOpDifference, dst, &mask_w, 0, 0, w, h); 364 XRenderFillRectangle (dpy, PictOpDifference, dst, &mask_w, 0, 0, w, h);
395 } 379 }
396 380
397 unshare (); 381 unshare ();
398 382
399 Display *dpy = s->display->dpy; 383 Display *dpy = s->display->dpy;
400 Picture src = create_xrender_mask (dpy, pm, True);
401 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0); 384 Picture dst = XRenderCreatePicture (dpy, pm, format, 0, 0);
402 385
403 XRenderColor mask_c; 386 XRenderColor mask_c;
404 mask_c.red = r; 387 mask_c.red = r;
405 mask_c.green = g; 388 mask_c.green = g;
406 mask_c.blue = b; 389 mask_c.blue = b;
407 mask_c.alpha = a; 390 mask_c.alpha = a;
408 XRenderFillRectangle (dpy, PictOpSrc, src, &mask_c, 0, 0, 1, 1); 391 XRenderFillRectangle (dpy, PictOpMultiply, dst, &mask_c, 0, 0, w, h);
409 392
410 XRenderComposite (dpy, PictOpMultiply, src, None, dst, 0, 0, 0, 0, 0, 0, w, h);
411
412 XRenderFreePicture (dpy, src);
413 XRenderFreePicture (dpy, dst); 393 XRenderFreePicture (dpy, dst);
414} 394}
415 395
416rxvt_img * 396rxvt_img *
417rxvt_img::clone () 397rxvt_img::clone ()
600{ 580{
601 rxvt_img *img2 = clone (); 581 rxvt_img *img2 = clone ();
602 Display *dpy = s->display->dpy; 582 Display *dpy = s->display->dpy;
603 Picture src = img->src_picture (); 583 Picture src = img->src_picture ();
604 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0); 584 Picture dst = XRenderCreatePicture (dpy, img2->pm, img2->format, 0, 0);
605 Picture mask = create_xrender_mask (dpy, img->pm, False); 585
586 Pixmap pixmap = XCreatePixmap (dpy, img->pm, 1, 1, 8);
587 XRenderPictFormat *format = XRenderFindStandardFormat (dpy, PictStandardA8);
588 XRenderPictureAttributes pa;
589 pa.repeat = True;
590 Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa);
591 XFreePixmap (dpy, pixmap);
606 592
607 XRenderColor mask_c; 593 XRenderColor mask_c;
608 594
609 mask_c.alpha = float_to_component (factor); 595 mask_c.alpha = float_to_component (factor);
610 mask_c.red = 596 mask_c.red =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines