… | |
… | |
87 | */ |
87 | */ |
88 | |
88 | |
89 | #ifdef HAVE_BG_PIXMAP |
89 | #ifdef HAVE_BG_PIXMAP |
90 | bgPixmap_t::bgPixmap_t () |
90 | bgPixmap_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 | |
104 | void |
107 | void |
105 | bgPixmap_t::destroy () |
108 | bgPixmap_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; |
… | |
… | |
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 | |
159 | bool bgPixmap_t::need_client_side_rendering () |
162 | bool 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 | { |
… | |
… | |
468 | { |
471 | { |
469 | target->get_window_origin(x, y); |
472 | target->get_window_origin(x, y); |
470 | x = -x; |
473 | x = -x; |
471 | y = -y; |
474 | y = -y; |
472 | } |
475 | } |
|
|
476 | |
473 | if (h_align != rootAlign) |
477 | if (h_align != rootAlign) |
474 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
478 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
|
|
479 | |
475 | if (v_align != rootAlign) |
480 | if (v_align != rootAlign) |
476 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
481 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
477 | } |
482 | } |
478 | |
483 | |
479 | if (original_asim == NULL |
484 | if (!original_asim |
480 | || x >= target_width |
485 | || x >= target_width |
481 | || y >= target_height |
486 | || y >= target_height |
482 | || (w > 0 && x + w <= 0) |
487 | || (w > 0 && x + w <= 0) |
483 | || (h > 0 && y + h <= 0)) |
488 | || (h > 0 && y + h <= 0)) |
484 | { |
489 | { |
485 | if (background) |
490 | if (background) |
486 | { |
491 | { |
487 | new_pmap_width = background->width; |
492 | new_pmap_width = background->width; |
488 | new_pmap_height = background->height; |
493 | new_pmap_height = background->height; |
489 | result = background; |
494 | result = background; |
|
|
495 | |
490 | if (background_tint != TINT_LEAVE_SAME) |
496 | if (background_tint != TINT_LEAVE_SAME) |
491 | { |
497 | { |
492 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
498 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
493 | target_width, target_height, background_tint, |
499 | target_width, target_height, background_tint, |
494 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
500 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
… | |
… | |
500 | new_pmap_width = new_pmap_height = 0; |
506 | new_pmap_width = new_pmap_height = 0; |
501 | } |
507 | } |
502 | else |
508 | else |
503 | { |
509 | { |
504 | result = original_asim; |
510 | result = original_asim; |
|
|
511 | |
505 | if ((w > 0 && w != original_asim->width) |
512 | if ((w > 0 && w != original_asim->width) |
506 | || (h > 0 && h != original_asim->height)) |
513 | || (h > 0 && h != original_asim->height)) |
507 | { |
514 | { |
508 | result = scale_asimage (target->asv, original_asim, |
515 | result = scale_asimage (target->asv, original_asim, |
509 | w > 0 ? w : original_asim->width, |
516 | w > 0 ? w : original_asim->width, |
510 | h > 0 ? h : original_asim->height, |
517 | h > 0 ? h : original_asim->height, |
511 | background ? ASA_ASImage : ASA_XImage, |
518 | background ? ASA_ASImage : ASA_XImage, |
512 | 100, ASIMAGE_QUALITY_DEFAULT); |
519 | 100, ASIMAGE_QUALITY_DEFAULT); |
513 | } |
520 | } |
|
|
521 | |
514 | if (background == NULL) |
522 | if (background == NULL) |
515 | { |
523 | { |
516 | /* if tiling - pixmap has to be sized exactly as the image, |
524 | /* if tiling - pixmap has to be sized exactly as the image, |
517 | but there is no need to make it bigger than the window! */ |
525 | but there is no need to make it bigger than the window! */ |
518 | if (h_scale == 0) |
526 | if (h_scale == 0) |
… | |
… | |
521 | new_pmap_height = min (result->height, target_height); |
529 | new_pmap_height = min (result->height, target_height); |
522 | /* we also need to tile our image in one or both directions */ |
530 | /* we also need to tile our image in one or both directions */ |
523 | if (h_scale == 0 || v_scale == 0) |
531 | if (h_scale == 0 || v_scale == 0) |
524 | { |
532 | { |
525 | ASImage *tmp = tile_asimage (target->asv, result, |
533 | ASImage *tmp = tile_asimage (target->asv, result, |
526 | (h_scale > 0) ? 0 : (int)result->width - x, |
534 | (h_scale > 0) ? 0 : (int)result->width - x, |
527 | (v_scale > 0) ? 0 : (int)result->height - y, |
535 | (v_scale > 0) ? 0 : (int)result->height - y, |
528 | new_pmap_width, |
536 | new_pmap_width, |
529 | new_pmap_height, |
537 | new_pmap_height, |
530 | TINT_LEAVE_SAME, ASA_XImage, |
538 | TINT_LEAVE_SAME, ASA_XImage, |
531 | 100, ASIMAGE_QUALITY_DEFAULT); |
539 | 100, ASIMAGE_QUALITY_DEFAULT); |
532 | if (tmp) |
540 | if (tmp) |
533 | { |
541 | { |
534 | if (result != original_asim) |
542 | if (result != original_asim) |
535 | destroy_asimage (&result); |
543 | destroy_asimage (&result); |
|
|
544 | |
536 | result = tmp; |
545 | result = tmp; |
537 | } |
546 | } |
538 | } |
547 | } |
539 | } |
548 | } |
540 | else |
549 | else |
… | |
… | |
546 | layers[0].im = background; |
555 | layers[0].im = background; |
547 | layers[0].clip_width = target_width; |
556 | layers[0].clip_width = target_width; |
548 | layers[0].clip_height = target_height; |
557 | layers[0].clip_height = target_height; |
549 | layers[0].tint = background_tint; |
558 | layers[0].tint = background_tint; |
550 | layers[1].im = result; |
559 | layers[1].im = result; |
|
|
560 | |
551 | if (w <= 0) |
561 | if (w <= 0) |
552 | { |
562 | { |
553 | /* tile horizontally */ |
563 | /* tile horizontally */ |
554 | while (x > 0) x -= (int)result->width; |
564 | while (x > 0) x -= (int)result->width; |
555 | layers[1].dst_x = x; |
565 | layers[1].dst_x = x; |
… | |
… | |
559 | { |
569 | { |
560 | /* clip horizontally */ |
570 | /* clip horizontally */ |
561 | layers[1].dst_x = x; |
571 | layers[1].dst_x = x; |
562 | layers[1].clip_width = result->width; |
572 | layers[1].clip_width = result->width; |
563 | } |
573 | } |
|
|
574 | |
564 | if (h <= 0) |
575 | if (h <= 0) |
565 | { |
576 | { |
566 | while (y > 0) y -= (int)result->height; |
577 | while (y > 0) y -= (int)result->height; |
567 | layers[1].dst_y = y; |
578 | layers[1].dst_y = y; |
568 | layers[1].clip_height = result->height + target_height; |
579 | layers[1].clip_height = result->height + target_height; |
… | |
… | |
570 | else |
581 | else |
571 | { |
582 | { |
572 | layers[1].dst_y = y; |
583 | layers[1].dst_y = y; |
573 | layers[1].clip_height = result->height; |
584 | layers[1].clip_height = result->height; |
574 | } |
585 | } |
|
|
586 | |
575 | if (target->rs[Rs_blendtype]) |
587 | if (target->rs[Rs_blendtype]) |
576 | { |
588 | { |
577 | layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); |
589 | layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); |
578 | if (layers[1].merge_scanlines == NULL) |
590 | if (layers[1].merge_scanlines == NULL) |
579 | layers[1].merge_scanlines = alphablend_scanlines; |
591 | layers[1].merge_scanlines = alphablend_scanlines; |
580 | } |
592 | } |
|
|
593 | |
581 | ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, |
594 | ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, |
582 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
595 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
|
|
596 | |
583 | if (tmp) |
597 | if (tmp) |
584 | { |
598 | { |
585 | if (result != original_asim) |
599 | if (result != original_asim) |
586 | destroy_asimage (&result); |
600 | destroy_asimage (&result); |
|
|
601 | |
587 | result = tmp; |
602 | result = tmp; |
588 | } |
603 | } |
|
|
604 | |
589 | free (layers); |
605 | free (layers); |
590 | } |
606 | } |
591 | } |
607 | } |
592 | TIMING_TEST_PRINT_RESULT (asim); |
608 | TIMING_TEST_PRINT_RESULT (asim); |
593 | |
609 | |
… | |
… | |
655 | bool |
671 | bool |
656 | bgPixmap_t::set_file (const char *file) |
672 | bgPixmap_t::set_file (const char *file) |
657 | { |
673 | { |
658 | char *f; |
674 | char *f; |
659 | |
675 | |
660 | assert (file != NULL); |
676 | assert (file); |
661 | |
677 | |
662 | if (*file != '\0') |
678 | if (*file) |
663 | { |
679 | { |
664 | # ifdef HAVE_AFTERIMAGE |
680 | # ifdef HAVE_AFTERIMAGE |
665 | if (target->asimman == NULL) |
681 | if (target->asimman == NULL) |
666 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
682 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
|
|
683 | |
667 | if ((f = strchr (file, ';')) == NULL) |
684 | if ((f = strchr (file, ';')) == NULL) |
668 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
685 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
669 | else |
686 | else |
670 | { |
687 | { |
671 | size_t len = f - file; |
688 | size_t len = f - file; |
… | |
… | |
673 | memcpy (f, file, len); |
690 | memcpy (f, file, len); |
674 | f[len] = '\0'; |
691 | f[len] = '\0'; |
675 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
692 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
676 | free (f); |
693 | free (f); |
677 | } |
694 | } |
|
|
695 | |
678 | return (original_asim != NULL); |
696 | return original_asim; |
679 | # endif |
697 | # endif |
680 | } |
698 | } |
|
|
699 | |
681 | return false; |
700 | return false; |
682 | } |
701 | } |
683 | |
702 | |
684 | # endif /* BG_IMAGE_FROM_FILE */ |
703 | # endif /* BG_IMAGE_FROM_FILE */ |
685 | |
704 | |
… | |
… | |
690 | if (!(flags & isTransparent)) |
709 | if (!(flags & isTransparent)) |
691 | { |
710 | { |
692 | flags |= isTransparent; |
711 | flags |= isTransparent; |
693 | return true; |
712 | return true; |
694 | } |
713 | } |
|
|
714 | |
695 | return false; |
715 | return false; |
696 | } |
716 | } |
697 | |
717 | |
698 | bool |
718 | bool |
699 | bgPixmap_t::set_blur_radius (const char *geom) |
719 | bgPixmap_t::set_blur_radius (const char *geom) |