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

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.255 by sf-exg, Mon Dec 31 12:05:34 2012 UTC vs.
Revision 1.259 by root, Sat Dec 13 12:24:32 2014 UTC

7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * Copyright (c) 2010-2012 Emanuele Giaquinta <e.giaquinta@glauco.it> 8 * Copyright (c) 2010-2012 Emanuele Giaquinta <e.giaquinta@glauco.it>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
251 flags &= ~IM_IS_SIZE_SENSITIVE; 251 flags &= ~IM_IS_SIZE_SENSITIVE;
252 252
253 return changed; 253 return changed;
254} 254}
255 255
256bool 256void
257rxvt_term::render_image (rxvt_image &image) 257rxvt_term::render_image (rxvt_image &image)
258{ 258{
259 int image_width = image.img->w; 259 int image_width = image.img->w;
260 int image_height = image.img->h; 260 int image_height = image.img->h;
261 int parent_width = szHint.width; 261 int parent_width = szHint.width;
296 if (!(image.flags & IM_ROOT_ALIGN) 296 if (!(image.flags & IM_ROOT_ALIGN)
297 && (x >= parent_width 297 && (x >= parent_width
298 || y >= parent_height 298 || y >= parent_height
299 || x + w <= 0 299 || x + w <= 0
300 || y + h <= 0)) 300 || y + h <= 0))
301 return false; 301 return;
302 302
303 rxvt_img *img = image.img->scale (w, h); 303 rxvt_img *img = image.img->scale (w, h);
304 304
305 if (image.flags & IM_TILE) 305 if (image.flags & IM_TILE)
306 img->repeat_mode (RepeatNormal); 306 img->repeat_mode (RepeatNormal);
314 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 314 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
315 img->convert_format (format, pix_colors [Color_bg])->replace (img); 315 img->convert_format (format, pix_colors [Color_bg])->replace (img);
316 316
317 delete bg_img; 317 delete bg_img;
318 bg_img = img; 318 bg_img = img;
319
320 return true;
321} 319}
322 320
323rxvt_image::rxvt_image () 321rxvt_image::rxvt_image ()
324{ 322{
325 alpha = 0xffff; 323 alpha = 0xffff;
431/* 429/*
432 * Builds a pixmap of the same size as the terminal window that contains 430 * Builds a pixmap of the same size as the terminal window that contains
433 * the tiled portion of the root pixmap that is supposed to be covered by 431 * the tiled portion of the root pixmap that is supposed to be covered by
434 * our window. 432 * our window.
435 */ 433 */
436bool 434void
437rxvt_term::render_root_image () 435rxvt_term::render_root_image ()
438{ 436{
439 /* root dimensions may change from call to call - but Display structure should 437 /* root dimensions may change from call to call - but Display structure should
440 * be always up-to-date, so let's use it : 438 * be always up-to-date, so let's use it :
441 */ 439 */
450 sy = parent_y; 448 sy = parent_y;
451 449
452 /* check if we are outside of the visible part of the virtual screen : */ 450 /* check if we are outside of the visible part of the virtual screen : */
453 if (sx + parent_width <= 0 || sy + parent_height <= 0 451 if (sx + parent_width <= 0 || sy + parent_height <= 0
454 || sx >= root_width || sy >= root_height) 452 || sx >= root_width || sy >= root_height)
455 return 0; 453 return;
456 454
457 while (sx < 0) sx += root_img->w; 455 while (sx < 0) sx += root_img->w;
458 while (sy < 0) sy += root_img->h; 456 while (sy < 0) sy += root_img->h;
459 457
460 rxvt_img *img = root_img->sub_rect (sx, sy, parent_width, parent_height); 458 rxvt_img *img = root_img->sub_rect (sx, sy, parent_width, parent_height);
461 459
462 if (root_effects.need_blur ()) 460 if (root_effects.need_blur ())
463 img->blur (root_effects.h_blurRadius, root_effects.v_blurRadius)->replace (img); 461 img->blur (root_effects.h_blurRadius, root_effects.v_blurRadius)->replace (img);
464 462
465 if (root_effects.need_tint ()) 463 if (root_effects.need_tint ())
466 tint_image (img, root_effects.tint, root_effects.tint_set, root_effects.shade); 464 {
465 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
466
467 if (root_effects.tint_set)
468 root_effects.tint.get (c);
469 rxvt_img::nv factor = root_effects.shade / 100. - 1.;
470 img->shade (factor, c)->replace (img);
471 }
467 472
468 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 473 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
469 img->convert_format (format, pix_colors [Color_bg])->replace (img); 474 img->convert_format (format, pix_colors [Color_bg])->replace (img);
470 475
471 delete bg_img; 476 delete bg_img;
472 bg_img = img; 477 bg_img = img;
473
474 return true;
475} 478}
476# endif /* BG_IMAGE_FROM_ROOT */ 479# endif /* BG_IMAGE_FROM_ROOT */
477 480
478void 481void
479rxvt_term::bg_render () 482rxvt_term::bg_render ()
488 if (!mapped) 491 if (!mapped)
489 return; 492 return;
490 493
491# if BG_IMAGE_FROM_ROOT 494# if BG_IMAGE_FROM_ROOT
492 if (root_img) 495 if (root_img)
496 {
493 if (render_root_image ()) 497 render_root_image ();
494 bg_flags |= BG_IS_TRANSPARENT; 498 bg_flags |= BG_IS_TRANSPARENT;
499 }
495# endif 500# endif
496 501
497# if BG_IMAGE_FROM_FILE 502# if BG_IMAGE_FROM_FILE
498 if (fimage.img) 503 if (fimage.img)
499 render_image (fimage); 504 render_image (fimage);
500# endif 505# endif
501 506
502 scr_recolour (false); 507 scr_recolor (false);
503 bg_flags |= BG_NEEDS_REFRESH; 508 bg_flags |= BG_NEEDS_REFRESH;
504 509
505 bg_valid_since = ev::now (); 510 bg_valid_since = ev::now ();
506} 511}
507 512
534 update_background (); 539 update_background ();
535 } 540 }
536#endif 541#endif
537} 542}
538 543
539void
540rxvt_term::tint_image (rxvt_img *img, rxvt_color &tint, bool tint_set, int shade)
541{
542 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
543
544 if (tint_set)
545 tint.get (c);
546
547 if (shade > 100)
548 {
549 c.r = c.r * (200 - shade) / 100;
550 c.g = c.g * (200 - shade) / 100;
551 c.b = c.b * (200 - shade) / 100;
552 }
553 else
554 {
555 c.r = c.r * shade / 100;
556 c.g = c.g * shade / 100;
557 c.b = c.b * shade / 100;
558 }
559
560 img->contrast (c.r, c.g, c.b, c.a);
561
562 if (shade > 100)
563 {
564 c.a = 0xffff;
565 c.r =
566 c.g =
567 c.b = 0xffff * (shade - 100) / 100;
568 img->brightness (c.r, c.g, c.b, c.a);
569 }
570}
571
572#endif /* HAVE_BG_PIXMAP */ 544#endif /* HAVE_BG_PIXMAP */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines