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.23 by ayin, Sat Jan 5 13:52:23 2008 UTC vs.
Revision 1.39 by sf-exg, Mon Jul 26 09:57:53 2010 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
27#define DO_TIMING_TEST 0 27#define DO_TIMING_TEST 0
28 28
29#if DO_TIMING_TEST 29#if DO_TIMING_TEST
30# include <sys/time.h> 30# include <sys/time.h>
31#define TIMING_TEST_START(id) \ 31#define TIMING_TEST_START(id) \
32 struct timeval timing_test_##id##_stv;\ 32 struct timeval timing_test_##id##_stv;\
33 gettimeofday (&timing_test_##id##_stv, NULL); 33 gettimeofday (&timing_test_##id##_stv, NULL);
34 34
35#define TIMING_TEST_PRINT_RESULT(id) \ 35#define TIMING_TEST_PRINT_RESULT(id) \
36 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 36 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\
37 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 37 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\
87 */ 87 */
88 88
89#ifdef HAVE_BG_PIXMAP 89#ifdef HAVE_BG_PIXMAP
90bgPixmap_t::bgPixmap_t () 90bgPixmap_t::bgPixmap_t ()
91{ 91{
92 // this is basically redundant as bgPixmap_t is only used in
93 // zero_initialised-derived structs
92#ifdef HAVE_AFTERIMAGE 94#ifdef HAVE_AFTERIMAGE
93 original_asim = NULL; 95 original_asim = NULL;
94#endif 96#endif
95#ifdef BG_IMAGE_FROM_FILE 97#ifdef BG_IMAGE_FROM_FILE
96 h_scale = v_scale = 0; 98 h_scale = v_scale = 0;
97 h_align = v_align = 0; 99 h_align = v_align = 0;
98#endif 100#endif
99 flags = 0; 101 flags = 0;
100 pixmap = None; 102 pixmap = None;
101 valid_since = invalid_since = 0; 103 valid_since = invalid_since = 0;
104 target = 0;
102} 105}
103 106
104void 107void
105bgPixmap_t::destroy () 108bgPixmap_t::destroy ()
106{ 109{
121 return true; 124 return true;
122# endif 125# endif
123 126
124# ifdef BG_IMAGE_FROM_FILE 127# ifdef BG_IMAGE_FROM_FILE
125# ifdef HAVE_AFTERIMAGE 128# ifdef HAVE_AFTERIMAGE
126 if (original_asim != NULL) 129 if (original_asim)
127# endif 130# endif
128 { 131 {
129 if (h_scale != 0 || v_scale != 0 132 if (h_scale != 0 || v_scale != 0
130 || h_align != 0 || v_align != 0) 133 || h_align != 0 || v_align != 0)
131 return true; 134 return true;
133# endif 136# endif
134 137
135 return false; 138 return false;
136} 139}
137 140
138bool 141bool
139bgPixmap_t::window_position_sensitive () 142bgPixmap_t::window_position_sensitive ()
140{ 143{
141# ifdef ENABLE_TRANSPARENCY 144# ifdef ENABLE_TRANSPARENCY
142 if (flags & isTransparent) 145 if (flags & isTransparent)
143 return true; 146 return true;
144# endif 147# endif
145 148
146# ifdef BG_IMAGE_FROM_FILE 149# ifdef BG_IMAGE_FROM_FILE
147# ifdef HAVE_AFTERIMAGE 150# ifdef HAVE_AFTERIMAGE
148 if (original_asim != NULL) 151 if (original_asim)
149# endif 152# endif
150 { 153 {
151 if (h_align == rootAlign || v_align == rootAlign) 154 if (h_align == rootAlign || v_align == rootAlign)
152 return true; 155 return true;
153 } 156 }
157}; 160};
158 161
159bool bgPixmap_t::need_client_side_rendering () 162bool bgPixmap_t::need_client_side_rendering ()
160{ 163{
161# ifdef HAVE_AFTERIMAGE 164# ifdef HAVE_AFTERIMAGE
162 if (original_asim != NULL) 165 if (original_asim)
163 return true; 166 return true;
164# endif 167# endif
165# ifdef ENABLE_TRANSPARENCY 168# ifdef ENABLE_TRANSPARENCY
166 if (flags & isTransparent) 169 if (flags & isTransparent)
167 { 170 {
256 int geom_flags = 0, changed = 0; 259 int geom_flags = 0, changed = 0;
257 int x = 0, y = 0; 260 int x = 0, y = 0;
258 unsigned int w = 0, h = 0; 261 unsigned int w = 0, h = 0;
259 unsigned int n; 262 unsigned int n;
260 unsigned long new_flags = (flags & (~geometryFlags)); 263 unsigned long new_flags = (flags & (~geometryFlags));
261 char *p; 264 const char *p;
262# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 265# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
263 266
264 if (geom == NULL) 267 if (geom == NULL)
265 return false; 268 return false;
266 269
274 if (n < MAXLEN_GEOM) 277 if (n < MAXLEN_GEOM)
275 { 278 {
276 char *ops; 279 char *ops;
277 new_flags |= geometrySet; 280 new_flags |= geometrySet;
278 281
279 strncpy (str, geom, n); 282 memcpy (str, geom, n);
280 str[n] = '\0'; 283 str[n] = '\0';
281 if (str[0] == ':') 284 if (str[0] == ':')
282 ops = &str[0]; 285 ops = &str[0];
283 else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0])) 286 else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0]))
284 ops = &str[0]; 287 ops = &str[0];
367 if (ops) 370 if (ops)
368 { 371 {
369 while (*ops) 372 while (*ops)
370 { 373 {
371 while (*ops == ':' || isspace(*ops)) ++ops; 374 while (*ops == ':' || isspace(*ops)) ++ops;
375
372# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) 376# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0)
373 if (CHECK_GEOM_OPS("tile")) 377 if (CHECK_GEOM_OPS ("tile"))
374 { 378 {
375 w = h = noScale; 379 w = h = noScale;
376 geom_flags |= WidthValue|HeightValue; 380 geom_flags |= WidthValue|HeightValue;
377 } 381 }
378 else if (CHECK_GEOM_OPS("propscale")) 382 else if (CHECK_GEOM_OPS ("propscale"))
379 { 383 {
380 if (w == 0 && h == 0) 384 if (w == 0 && h == 0)
381 { 385 {
382 w = windowScale; 386 w = windowScale;
383 geom_flags |= WidthValue; 387 geom_flags |= WidthValue;
384 } 388 }
385 new_flags |= propScale; 389 new_flags |= propScale;
386 } 390 }
387 else if (CHECK_GEOM_OPS("hscale")) 391 else if (CHECK_GEOM_OPS ("hscale"))
388 { 392 {
389 if (w == 0)
390 w = windowScale; 393 if (w == 0) w = windowScale;
394
391 h = noScale; 395 h = noScale;
392 geom_flags |= WidthValue|HeightValue; 396 geom_flags |= WidthValue|HeightValue;
393 } 397 }
394 else if (CHECK_GEOM_OPS("vscale")) 398 else if (CHECK_GEOM_OPS ("vscale"))
395 { 399 {
396 if (h == 0)
397 h = windowScale; 400 if (h == 0) h = windowScale;
401
398 w = noScale; 402 w = noScale;
399 geom_flags |= WidthValue|HeightValue; 403 geom_flags |= WidthValue|HeightValue;
400 } 404 }
401 else if (CHECK_GEOM_OPS("scale")) 405 else if (CHECK_GEOM_OPS ("scale"))
402 { 406 {
403 if (h == 0)
404 h = windowScale; 407 if (h == 0) h = windowScale;
405 if (w == 0)
406 w = windowScale; 408 if (w == 0) w = windowScale;
409
407 geom_flags |= WidthValue|HeightValue; 410 geom_flags |= WidthValue|HeightValue;
408 } 411 }
409 else if (CHECK_GEOM_OPS("auto")) 412 else if (CHECK_GEOM_OPS ("auto"))
410 { 413 {
411 w = h = windowScale; 414 w = h = windowScale;
412 x = y = centerAlign; 415 x = y = centerAlign;
413 geom_flags |= WidthValue|HeightValue|XValue|YValue; 416 geom_flags |= WidthValue|HeightValue|XValue|YValue;
414 } 417 }
415 else if (CHECK_GEOM_OPS("root")) 418 else if (CHECK_GEOM_OPS ("root"))
416 { 419 {
417 w = h = noScale; 420 w = h = noScale;
418 x = y = rootAlign; 421 x = y = rootAlign;
419 geom_flags |= WidthValue|HeightValue|XValue|YValue; 422 geom_flags |= WidthValue|HeightValue|XValue|YValue;
420 } 423 }
421# undef CHECK_GEOM_OPS 424# undef CHECK_GEOM_OPS
425
422 while (*ops != ':' && *ops != '\0') ++ops; 426 while (*ops != ':' && *ops != '\0') ++ops;
423 } /* done parsing ops */ 427 } /* done parsing ops */
424 } 428 }
425 429
426 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) 430 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) ++changed;
427 ++changed;
428 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) 431 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) ++changed;
429 ++changed;
430 if (check_set_align_value (geom_flags, XValue, h_align, x)) 432 if (check_set_align_value (geom_flags, XValue, h_align, x)) ++changed;
431 ++changed;
432 if (check_set_align_value (geom_flags, YValue, v_align, y)) 433 if (check_set_align_value (geom_flags, YValue, v_align, y)) ++changed;
433 ++changed;
434 } 434 }
435 435
436 if (new_flags != flags) 436 if (new_flags != flags)
437 { 437 {
438 flags = new_flags; 438 flags = new_flags;
439 changed++; 439 changed++;
440 } 440 }
441
441//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 442//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
442// flags, h_scale, v_scale, h_align, v_align); 443// flags, h_scale, v_scale, h_align, v_align);
443 return (changed > 0); 444 return (changed > 0);
444} 445}
445 446
448bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) 449bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint)
449{ 450{
450 if (target == NULL) 451 if (target == NULL)
451 return false; 452 return false;
452 453
454 target->init_asv ();
455
456 ASImage *result = 0;
457
453 int target_width = (int)target->szHint.width; 458 int target_width = target->szHint.width;
454 int target_height = (int)target->szHint.height; 459 int target_height = target->szHint.height;
455 int new_pmap_width = target_width, new_pmap_height = target_height; 460 int new_pmap_width = target_width;
456 ASImage *result = NULL; 461 int new_pmap_height = target_height;
457 462
458 int x = 0; 463 int x = 0;
459 int y = 0; 464 int y = 0;
460 int w = h_scale * target_width / 100; 465 int w = h_scale * target_width / 100;
461 int h = v_scale * target_height / 100; 466 int h = v_scale * target_height / 100;
468 { 473 {
469 target->get_window_origin(x, y); 474 target->get_window_origin(x, y);
470 x = -x; 475 x = -x;
471 y = -y; 476 y = -y;
472 } 477 }
478
473 if (h_align != rootAlign) 479 if (h_align != rootAlign)
474 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); 480 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
481
475 if (v_align != rootAlign) 482 if (v_align != rootAlign)
476 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); 483 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
477 } 484 }
478 485
479 if (original_asim == NULL 486 if (!original_asim
480 || x >= target_width 487 || x >= target_width
481 || y >= target_height 488 || y >= target_height
482 || (w > 0 && x + w <= 0) 489 || (w > 0 && x + w <= 0)
483 || (h > 0 && y + h <= 0)) 490 || (h > 0 && y + h <= 0))
484 { 491 {
485 if (background) 492 if (background)
486 { 493 {
487 new_pmap_width = background->width; 494 new_pmap_width = background->width;
488 new_pmap_height = background->height; 495 new_pmap_height = background->height;
489 result = background; 496 result = background;
497
490 if (background_tint != TINT_LEAVE_SAME) 498 if (background_tint != TINT_LEAVE_SAME)
491 { 499 {
492 ASImage* tmp = tile_asimage (target->asv, background, 0, 0, 500 ASImage *tmp = tile_asimage (target->asv, background, 0, 0,
493 target_width, target_height, background_tint, 501 target_width, target_height, background_tint,
494 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); 502 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT);
495 if (tmp) 503 if (tmp)
496 result = tmp; 504 result = tmp;
497 } 505 }
500 new_pmap_width = new_pmap_height = 0; 508 new_pmap_width = new_pmap_height = 0;
501 } 509 }
502 else 510 else
503 { 511 {
504 result = original_asim; 512 result = original_asim;
513
505 if ((w > 0 && w != original_asim->width) 514 if ((w > 0 && w != original_asim->width)
506 || (h > 0 && h != original_asim->height)) 515 || (h > 0 && h != original_asim->height))
507 { 516 {
508 result = scale_asimage (target->asv, original_asim, 517 result = scale_asimage (target->asv, original_asim,
509 w > 0 ? w : original_asim->width, 518 w > 0 ? w : original_asim->width,
510 h > 0 ? h : original_asim->height, 519 h > 0 ? h : original_asim->height,
511 background ? ASA_ASImage : ASA_XImage, 520 background ? ASA_ASImage : ASA_XImage,
512 100, ASIMAGE_QUALITY_DEFAULT); 521 100, ASIMAGE_QUALITY_DEFAULT);
513 } 522 }
523
514 if (background == NULL) 524 if (background == NULL)
515 { 525 {
516 /* if tiling - pixmap has to be sized exactly as the image, 526 /* if tiling - pixmap has to be sized exactly as the image,
517 but there is no need to make it bigger than the window! */ 527 but there is no need to make it bigger than the window! */
518 if (h_scale == 0) 528 if (h_scale == 0)
521 new_pmap_height = min (result->height, target_height); 531 new_pmap_height = min (result->height, target_height);
522 /* we also need to tile our image in one or both directions */ 532 /* we also need to tile our image in one or both directions */
523 if (h_scale == 0 || v_scale == 0) 533 if (h_scale == 0 || v_scale == 0)
524 { 534 {
525 ASImage *tmp = tile_asimage (target->asv, result, 535 ASImage *tmp = tile_asimage (target->asv, result,
526 (h_scale > 0) ? 0 : (int)result->width - x, 536 (h_scale > 0) ? 0 : (int)result->width - x,
527 (v_scale > 0) ? 0 : (int)result->height - y, 537 (v_scale > 0) ? 0 : (int)result->height - y,
528 new_pmap_width, 538 new_pmap_width,
529 new_pmap_height, 539 new_pmap_height,
530 TINT_LEAVE_SAME, ASA_XImage, 540 TINT_LEAVE_SAME, ASA_XImage,
531 100, ASIMAGE_QUALITY_DEFAULT); 541 100, ASIMAGE_QUALITY_DEFAULT);
532 if (tmp) 542 if (tmp)
533 { 543 {
534 if (result != original_asim) 544 if (result != original_asim)
535 destroy_asimage (&result); 545 destroy_asimage (&result);
546
536 result = tmp; 547 result = tmp;
537 } 548 }
538 } 549 }
539 } 550 }
540 else 551 else
546 layers[0].im = background; 557 layers[0].im = background;
547 layers[0].clip_width = target_width; 558 layers[0].clip_width = target_width;
548 layers[0].clip_height = target_height; 559 layers[0].clip_height = target_height;
549 layers[0].tint = background_tint; 560 layers[0].tint = background_tint;
550 layers[1].im = result; 561 layers[1].im = result;
562
551 if (w <= 0) 563 if (w <= 0)
552 { 564 {
553 /* tile horizontally */ 565 /* tile horizontally */
554 while (x > 0) x -= (int)result->width; 566 while (x > 0) x -= (int)result->width;
555 layers[1].dst_x = x; 567 layers[1].dst_x = x;
559 { 571 {
560 /* clip horizontally */ 572 /* clip horizontally */
561 layers[1].dst_x = x; 573 layers[1].dst_x = x;
562 layers[1].clip_width = result->width; 574 layers[1].clip_width = result->width;
563 } 575 }
576
564 if (h <= 0) 577 if (h <= 0)
565 { 578 {
566 while (y > 0) y -= (int)result->height; 579 while (y > 0) y -= (int)result->height;
567 layers[1].dst_y = y; 580 layers[1].dst_y = y;
568 layers[1].clip_height = result->height + target_height; 581 layers[1].clip_height = result->height + target_height;
570 else 583 else
571 { 584 {
572 layers[1].dst_y = y; 585 layers[1].dst_y = y;
573 layers[1].clip_height = result->height; 586 layers[1].clip_height = result->height;
574 } 587 }
588
575 if (target->rs[Rs_blendtype]) 589 if (target->rs[Rs_blendtype])
576 { 590 {
577 layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); 591 layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]);
578 if (layers[1].merge_scanlines == NULL) 592 if (layers[1].merge_scanlines == NULL)
579 layers[1].merge_scanlines = alphablend_scanlines; 593 layers[1].merge_scanlines = alphablend_scanlines;
580 } 594 }
595
581 ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, 596 ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height,
582 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); 597 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT);
598
583 if (tmp) 599 if (tmp)
584 { 600 {
585 if (result != original_asim) 601 if (result != original_asim)
586 destroy_asimage (&result); 602 destroy_asimage (&result);
603
587 result = tmp; 604 result = tmp;
588 } 605 }
606
589 free (layers); 607 free (layers);
590 } 608 }
591 } 609 }
592 TIMING_TEST_PRINT_RESULT (asim); 610 TIMING_TEST_PRINT_RESULT (asim);
593 611
622 640
623 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 641 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
624 int dst_width = result->width, dst_height = result->height; 642 int dst_width = result->width, dst_height = result->height;
625 if (background == NULL) 643 if (background == NULL)
626 { 644 {
627 if (h_scale > 0)
628 src_x = make_clip_rectangle (x, result->width, new_pmap_width, dst_x, dst_width); 645 if (h_scale > 0) src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width );
629 if (v_scale > 0)
630 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); 646 if (v_scale > 0) src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
631 647
632 if (dst_x > 0 || dst_y > 0 648 if (dst_x > 0 || dst_y > 0
633 || dst_x + dst_width < new_pmap_width 649 || dst_x + dst_width < new_pmap_width
634 || dst_y + dst_height < new_pmap_height) 650 || dst_y + dst_height < new_pmap_height)
635 {
636 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 651 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
637 }
638 } 652 }
639 653
640 /* put result on pixmap */ 654 /* put result on pixmap */
641 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 655 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
642 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); 656 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True);
653# endif /* HAVE_AFTERIMAGE */ 667# endif /* HAVE_AFTERIMAGE */
654 668
655bool 669bool
656bgPixmap_t::set_file (const char *file) 670bgPixmap_t::set_file (const char *file)
657{ 671{
658 char *f;
659
660 assert (file != NULL); 672 assert (file);
661 673
662 if (*file != '\0') 674 if (*file)
663 { 675 {
664# ifdef HAVE_AFTERIMAGE 676# ifdef HAVE_AFTERIMAGE
665 if (target->asimman == NULL) 677 if (!target->asimman)
666 target->asimman = create_generic_imageman (target->rs[Rs_path]); 678 target->asimman = create_generic_imageman (target->rs[Rs_path]);
667 if ((f = strchr (file, ';')) == NULL) 679
668 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); 680 if (const char *p = strchr (file, ';'))
669 else
670 { 681 {
671 size_t len = f - file; 682 size_t len = p - file;
672 f = (char *)malloc (len + 1); 683 char *f = (char *)malloc (len + 1);
673 strncpy (f, file, len); 684 memcpy (f, file, len);
674 f[len] = '\0'; 685 f[len] = '\0';
675 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 686 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
676 free (f); 687 free (f);
677 } 688 }
689 else
690 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
691
678 return (original_asim != NULL); 692 return original_asim;
679# endif 693# endif
680 } 694 }
695
681 return false; 696 return false;
682} 697}
683 698
684# endif /* BG_IMAGE_FROM_FILE */ 699# endif /* BG_IMAGE_FROM_FILE */
685 700
690 if (!(flags & isTransparent)) 705 if (!(flags & isTransparent))
691 { 706 {
692 flags |= isTransparent; 707 flags |= isTransparent;
693 return true; 708 return true;
694 } 709 }
710
695 return false; 711 return false;
696} 712}
697 713
698bool 714bool
699bgPixmap_t::set_blur_radius (const char *geom) 715bgPixmap_t::set_blur_radius (const char *geom)
832 unsigned long result = 0; 848 unsigned long result = 0;
833 849
834 if (target == NULL) 850 if (target == NULL)
835 return 0; 851 return 0;
836 852
837 /* root dimentions may change from call to call - but Display structure should 853 /* root dimensions may change from call to call - but Display structure should
838 * be always up-to-date, so let's use it : 854 * be always up-to-date, so let's use it :
839 */ 855 */
840 Window root = target->display->root; 856 Window root = target->display->root;
841 int screen = target->display->screen; 857 int screen = target->display->screen;
842 Display *dpy = target->dpy; 858 Display *dpy = target->dpy;
931 else 947 else
932 result |= transpPmapTiled; 948 result |= transpPmapTiled;
933 } 949 }
934 else 950 else
935 { 951 {
936 /* strightforward pixmap copy */ 952 /* straightforward pixmap copy */
937 gcv.tile = root_pixmap; 953 gcv.tile = root_pixmap;
938 gcv.fill_style = FillTiled; 954 gcv.fill_style = FillTiled;
939 955
940 while (sx < 0) sx += (int)root_width; 956 while (sx < 0) sx += (int)root_width;
941 while (sy < 0) sy += (int)root_height; 957 while (sy < 0) sy += (int)root_height;
1092 return false; 1108 return false;
1093} 1109}
1094# endif /* ENABLE_TRANSPARENCY */ 1110# endif /* ENABLE_TRANSPARENCY */
1095 1111
1096# ifndef HAVE_AFTERIMAGE 1112# ifndef HAVE_AFTERIMAGE
1097static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 1113static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm);
1098# endif 1114# endif
1099 1115
1100bool 1116bool
1101bgPixmap_t::render () 1117bgPixmap_t::render ()
1102{ 1118{
1105 if (target == NULL) 1121 if (target == NULL)
1106 return false; 1122 return false;
1107 1123
1108 TIMING_TEST_START (tp); 1124 TIMING_TEST_START (tp);
1109 1125
1110 invalidate(); 1126 invalidate ();
1111# ifdef ENABLE_TRANSPARENCY 1127# ifdef ENABLE_TRANSPARENCY
1112 if (flags & isTransparent) 1128 if (flags & isTransparent)
1113 { 1129 {
1114 /* we need to re-generate transparency pixmap in that case ! */ 1130 /* we need to re-generate transparency pixmap in that case ! */
1115 background_flags = make_transparency_pixmap (); 1131 background_flags = make_transparency_pixmap ();
1124 XImage *result = NULL; 1140 XImage *result = NULL;
1125# ifdef HAVE_AFTERIMAGE 1141# ifdef HAVE_AFTERIMAGE
1126 if (original_asim 1142 if (original_asim
1127 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1143 || (background_flags & transpTransformations) != (flags & transpTransformations))
1128 { 1144 {
1145 target->init_asv ();
1146
1129 ASImage *background = NULL; 1147 ASImage *background = NULL;
1130 ARGB32 as_tint = TINT_LEAVE_SAME; 1148 ARGB32 as_tint = TINT_LEAVE_SAME;
1131 if (background_flags) 1149 if (background_flags)
1132 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 1150 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
1133 1151
1134# ifdef ENABLE_TRANSPARENCY 1152# ifdef ENABLE_TRANSPARENCY
1135 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1153 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1136 { 1154 {
1137 ShadingInfo as_shade; 1155 ShadingInfo as_shade;
1144 as_shade.tintColor.green = c.g; 1162 as_shade.tintColor.green = c.g;
1145 as_shade.tintColor.blue = c.b; 1163 as_shade.tintColor.blue = c.b;
1146 1164
1147 as_tint = shading2tint32 (&as_shade); 1165 as_tint = shading2tint32 (&as_shade);
1148 } 1166 }
1167
1149 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 1168 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
1150 { 1169 {
1151 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 1170 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
1152 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, 1171 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
1153 100, ASIMAGE_QUALITY_DEFAULT); 1172 100, ASIMAGE_QUALITY_DEFAULT);
1154 if (tmp) 1173 if (tmp)
1155 { 1174 {
1156 destroy_asimage (&background); 1175 destroy_asimage (&background);
1160# endif 1179# endif
1161 1180
1162 if (render_asim (background, as_tint)) 1181 if (render_asim (background, as_tint))
1163 flags = flags & ~isInvalid; 1182 flags = flags & ~isInvalid;
1164 if (background) 1183 if (background)
1165 destroy_asimage (&background); 1184 destroy_asimage (&background);
1166 } 1185 }
1167 else if (background_flags && pmap_depth != target->depth) 1186 else if (background_flags && pmap_depth != target->depth)
1187 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1188
1189# elif !XFT /* our own client-side tinting */
1190
1191 /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side.
1192 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1193
1194 if (background_flags && (flags & isInvalid))
1168 { 1195 {
1169 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1196 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1170 }
1171 1197
1172# elif !XFT /* our own client-side tinting */
1173
1174 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side.
1175 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1176
1177 if (background_flags && (flags & isInvalid))
1178 {
1179 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1180 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1198 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1181 { 1199 {
1182 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1200 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1183 if (flags & tintSet) 1201 if (flags & tintSet)
1184 tint.get (c); 1202 tint.get (c);
1259# ifdef ENABLE_TRANSPARENCY 1277# ifdef ENABLE_TRANSPARENCY
1260 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); 1278 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen));
1261# endif 1279# endif
1262 return true; 1280 return true;
1263 } 1281 }
1282
1264 return false; 1283 return false;
1265} 1284}
1266 1285
1267void 1286void
1268bgPixmap_t::apply () 1287bgPixmap_t::apply ()
1269{ 1288{
1270 if (target) 1289 if (target)
1271 { 1290 {
1272 flags &= ~isVtOrigin; 1291 flags &= ~isVtOrigin;
1292
1273 if (pixmap != None) 1293 if (pixmap != None)
1274 { 1294 {
1275 /* set target's background to pixmap */ 1295 /* set target's background to pixmap */
1276# ifdef ENABLE_TRANSPARENCY 1296# ifdef ENABLE_TRANSPARENCY
1277 if (flags & isTransparent) 1297 if (flags & isTransparent)
1278 { 1298 {
1279 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); 1299 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap);
1280 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); 1300 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative);
1281# if HAVE_SCROLLBARS 1301
1282 if (target->scrollBar.win) 1302 if (target->scrollBar.win)
1283 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); 1303 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative);
1284# endif
1285 } 1304 }
1286 else 1305 else
1287# endif 1306# endif
1288 { 1307 {
1289 flags |= isVtOrigin; 1308 flags |= isVtOrigin;
1290 /* force old pixmap dereference in case it was transparent before :*/ 1309 /* force old pixmap dereference in case it was transparent before :*/
1291 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1310 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1292 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); 1311 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap);
1293 /* do we also need to set scrollbar's background here ? */ 1312 /* do we also need to set scrollbar's background here ? */
1294# if HAVE_SCROLLBARS 1313
1295 if (target->scrollBar.win) 1314 if (target->scrollBar.win)
1296 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1315 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1297# endif
1298 } 1316 }
1299 } 1317 }
1300 else 1318 else
1301 { 1319 {
1302 /* set target background to a pixel */ 1320 /* set target background to a pixel */
1303 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1321 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1304 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); 1322 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]);
1305 /* do we also need to set scrollbar's background here ? */ 1323 /* do we also need to set scrollbar's background here ? */
1306# if HAVE_SCROLLBARS
1307 if (target->scrollBar.win) 1324 if (target->scrollBar.win)
1308 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1325 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1309# endif
1310 } 1326 }
1327
1311 /* don't want Expose on the parent or vt. It is better to use 1328 /* don't want Expose on the parent or vt. It is better to use
1312 scr_touch or we get a great deal of flicker otherwise: */ 1329 scr_touch or we get a great deal of flicker otherwise: */
1313 XClearWindow (target->dpy, target->parent[0]); 1330 XClearWindow (target->dpy, target->parent[0]);
1314 1331
1315# if HAVE_SCROLLBARS 1332 if (target->scrollBar.state && target->scrollBar.win)
1316 if (target->scrollBar.win)
1317 { 1333 {
1318 target->scrollBar.setIdle (); 1334 target->scrollBar.state = STATE_IDLE;
1319 target->scrollbar_show (0); 1335 target->scrollBar.show (0);
1320 } 1336 }
1321# endif
1322 1337
1323 target->want_refresh = 1; 1338 target->want_refresh = 1;
1324 flags |= hasChanged; 1339 flags |= hasChanged;
1325 } 1340 }
1326} 1341}
1331/* taken from aterm-0.4.2 */ 1346/* taken from aterm-0.4.2 */
1332 1347
1333typedef uint32_t RUINT32T; 1348typedef uint32_t RUINT32T;
1334 1349
1335static void 1350static void
1336ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) 1351ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm)
1337{ 1352{
1338 int sh_r, sh_g, sh_b; 1353 int sh_r, sh_g, sh_b;
1339 RUINT32T mask_r, mask_g, mask_b; 1354 RUINT32T mask_r, mask_g, mask_b;
1340 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 1355 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1341 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1356 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines