… | |
… | |
104 | #ifdef BG_IMAGE_FROM_FILE |
104 | #ifdef BG_IMAGE_FROM_FILE |
105 | have_image = false; |
105 | have_image = false; |
106 | h_scale = v_scale = 0; |
106 | h_scale = v_scale = 0; |
107 | h_align = v_align = 0; |
107 | h_align = v_align = 0; |
108 | #endif |
108 | #endif |
|
|
109 | #ifdef ENABLE_TRANSPARENCY |
|
|
110 | shade = 100; |
|
|
111 | #endif |
109 | flags = 0; |
112 | flags = 0; |
110 | pixmap = None; |
113 | pixmap = None; |
111 | valid_since = invalid_since = 0; |
114 | valid_since = invalid_since = 0; |
112 | target = 0; |
115 | target = 0; |
113 | } |
116 | } |
… | |
… | |
157 | # endif |
160 | # endif |
158 | |
161 | |
159 | # ifdef BG_IMAGE_FROM_FILE |
162 | # ifdef BG_IMAGE_FROM_FILE |
160 | if (have_image) |
163 | if (have_image) |
161 | { |
164 | { |
162 | if (h_align == rootAlign || v_align == rootAlign) |
165 | if (flags & rootAlign) |
163 | return true; |
166 | return true; |
164 | } |
167 | } |
165 | # endif |
168 | # endif |
166 | |
169 | |
167 | return false; |
170 | return false; |
… | |
… | |
207 | static inline bool |
210 | static inline bool |
208 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
211 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
209 | { |
212 | { |
210 | if (geom_flags & flag) |
213 | if (geom_flags & flag) |
211 | { |
214 | { |
212 | if (new_value != bgPixmap_t::rootAlign) |
|
|
213 | { |
|
|
214 | if (new_value < -100) |
215 | if (new_value < -100) |
215 | new_value = -100; |
216 | new_value = -100; |
216 | else if (new_value > 200) |
217 | else if (new_value > 200) |
217 | new_value = 200; |
218 | new_value = 200; |
218 | } |
|
|
219 | if (new_value != align) |
219 | if (new_value != align) |
220 | { |
220 | { |
221 | align = new_value; |
221 | align = new_value; |
222 | return true; |
222 | return true; |
223 | } |
223 | } |
… | |
… | |
229 | make_align_position (int align, int window_size, int image_size) |
229 | make_align_position (int align, int window_size, int image_size) |
230 | { |
230 | { |
231 | int diff = window_size - image_size; |
231 | int diff = window_size - image_size; |
232 | int smaller = min (image_size, window_size); |
232 | int smaller = min (image_size, window_size); |
233 | |
233 | |
234 | if (align >= 0 && align <= 50) |
234 | if (align >= 0 && align <= 100) |
235 | return diff * align / 100; |
235 | return diff * align / 100; |
236 | else if (align > 50 && align <= 100) |
|
|
237 | return window_size - image_size - diff * (100 - align) / 100; |
|
|
238 | else if (align > 100 && align <= 200 ) |
236 | else if (align > 100 && align <= 200 ) |
239 | return ((align - 100) * smaller / 100) + window_size - smaller; |
237 | return ((align - 100) * smaller / 100) + window_size - smaller; |
240 | else if (align > -100 && align < 0) |
238 | else if (align >= -100 && align < 0) |
241 | return ((align + 100) * smaller / 100) - image_size; |
239 | return ((align + 100) * smaller / 100) - image_size; |
242 | return 0; |
240 | return 0; |
243 | } |
241 | } |
244 | |
242 | |
245 | static inline int |
243 | static inline int |
246 | make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) |
244 | make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) |
247 | { |
245 | { |
248 | int src_pos = 0; |
246 | int src_pos = 0; |
249 | dst_pos = 0; |
247 | dst_pos = pos; |
250 | dst_size = size; |
248 | dst_size = size; |
251 | if (pos < 0) |
249 | if (pos < 0) |
252 | { |
250 | { |
253 | src_pos = -pos; |
251 | src_pos = -pos; |
|
|
252 | dst_pos = 0; |
254 | dst_size += pos; |
253 | dst_size += pos; |
255 | } |
254 | } |
256 | else if (pos > 0) |
|
|
257 | dst_pos = pos; |
|
|
258 | |
255 | |
259 | if (dst_pos + dst_size > target_size) |
256 | if (dst_pos + dst_size > target_size) |
260 | dst_size = target_size - dst_pos; |
257 | dst_size = target_size - dst_pos; |
261 | return src_pos; |
258 | return src_pos; |
262 | } |
259 | } |
… | |
… | |
387 | w = h = noScale; |
384 | w = h = noScale; |
388 | geom_flags |= WidthValue|HeightValue; |
385 | geom_flags |= WidthValue|HeightValue; |
389 | } |
386 | } |
390 | else if (CHECK_GEOM_OPS ("propscale")) |
387 | else if (CHECK_GEOM_OPS ("propscale")) |
391 | { |
388 | { |
392 | if (w == 0 && h == 0) |
|
|
393 | { |
|
|
394 | w = windowScale; |
|
|
395 | geom_flags |= WidthValue; |
|
|
396 | } |
|
|
397 | new_flags |= propScale; |
389 | new_flags |= propScale; |
398 | } |
390 | } |
399 | else if (CHECK_GEOM_OPS ("hscale")) |
391 | else if (CHECK_GEOM_OPS ("hscale")) |
400 | { |
392 | { |
401 | if (w == 0) w = windowScale; |
393 | if (w == 0) w = windowScale; |
… | |
… | |
423 | x = y = centerAlign; |
415 | x = y = centerAlign; |
424 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
416 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
425 | } |
417 | } |
426 | else if (CHECK_GEOM_OPS ("root")) |
418 | else if (CHECK_GEOM_OPS ("root")) |
427 | { |
419 | { |
|
|
420 | new_flags |= rootAlign; |
428 | w = h = noScale; |
421 | w = h = noScale; |
429 | x = y = rootAlign; |
|
|
430 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
422 | geom_flags |= WidthValue|HeightValue; |
431 | } |
423 | } |
432 | # undef CHECK_GEOM_OPS |
424 | # undef CHECK_GEOM_OPS |
433 | |
425 | |
434 | while (*ops != ':' && *ops != '\0') ++ops; |
426 | while (*ops != ':' && *ops != '\0') ++ops; |
435 | } /* done parsing ops */ |
427 | } /* done parsing ops */ |
… | |
… | |
456 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
448 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
457 | { |
449 | { |
458 | int target_width = target->szHint.width; |
450 | int target_width = target->szHint.width; |
459 | int target_height = target->szHint.height; |
451 | int target_height = target->szHint.height; |
460 | |
452 | |
|
|
453 | if (flags & propScale) |
|
|
454 | { |
|
|
455 | float scale = (float)target_width / image_width; |
|
|
456 | min_it (scale, (float)target_height / image_height); |
|
|
457 | w = image_width * scale + 0.5; |
|
|
458 | h = image_height * scale + 0.5; |
|
|
459 | } |
|
|
460 | else |
|
|
461 | { |
461 | w = h_scale * target_width / 100; |
462 | w = h_scale * target_width / 100; |
462 | h = v_scale * target_height / 100; |
463 | h = v_scale * target_height / 100; |
|
|
464 | } |
463 | |
465 | |
464 | if (h_align == rootAlign || v_align == rootAlign) |
466 | if (!w) w = image_width; |
|
|
467 | if (!h) h = image_height; |
|
|
468 | |
|
|
469 | if (flags & rootAlign) |
465 | { |
470 | { |
466 | target->get_window_origin (x, y); |
471 | target->get_window_origin (x, y); |
467 | x = -x; |
472 | x = -x; |
468 | y = -y; |
473 | y = -y; |
469 | } |
474 | } |
470 | |
475 | else |
471 | if (h_align != rootAlign) |
476 | { |
472 | x = make_align_position (h_align, target_width, w > 0 ? w : image_width); |
477 | x = make_align_position (h_align, target_width, w); |
473 | |
|
|
474 | if (v_align != rootAlign) |
|
|
475 | y = make_align_position (v_align, target_height, h > 0 ? h : image_height); |
478 | y = make_align_position (v_align, target_height, h); |
|
|
479 | } |
476 | |
480 | |
477 | flags &= ~sizeSensitive; |
481 | flags &= ~sizeSensitive; |
478 | if (h_scale != 0 || v_scale != 0 |
482 | if (h_scale != 0 || v_scale != 0 |
479 | || h_align != 0 || v_align != 0 |
483 | || h_align != 0 || v_align != 0 |
480 | || image_width > target_width || image_height > target_height) |
484 | || w > target_width || h > target_height) |
481 | flags |= sizeSensitive; |
485 | flags |= sizeSensitive; |
482 | } |
486 | } |
483 | |
487 | |
484 | # ifdef HAVE_AFTERIMAGE |
488 | # ifdef HAVE_AFTERIMAGE |
485 | bool |
489 | bool |
… | |
… | |
498 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
502 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
499 | |
503 | |
500 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
504 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
501 | { |
505 | { |
502 | ShadingInfo as_shade; |
506 | ShadingInfo as_shade; |
503 | as_shade.shading = (shade == 0) ? 100 : shade; |
507 | as_shade.shading = shade; |
504 | |
508 | |
505 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
509 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
506 | if (flags & tintSet) |
510 | if (flags & tintSet) |
507 | tint.get (c); |
511 | tint.get (c); |
508 | as_shade.tintColor.red = c.r; |
512 | as_shade.tintColor.red = c.r; |
… | |
… | |
510 | as_shade.tintColor.blue = c.b; |
514 | as_shade.tintColor.blue = c.b; |
511 | |
515 | |
512 | background_tint = shading2tint32 (&as_shade); |
516 | background_tint = shading2tint32 (&as_shade); |
513 | } |
517 | } |
514 | |
518 | |
515 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
519 | if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL) |
516 | { |
520 | { |
517 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
521 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
518 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
522 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
519 | 100, ASIMAGE_QUALITY_DEFAULT); |
523 | 100, ASIMAGE_QUALITY_DEFAULT); |
520 | if (tmp) |
524 | if (tmp) |
… | |
… | |
541 | |
545 | |
542 | if (original_asim) |
546 | if (original_asim) |
543 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
547 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
544 | |
548 | |
545 | if (!original_asim |
549 | if (!original_asim |
|
|
550 | || (!(flags & rootAlign) |
546 | || x >= target_width |
551 | && (x >= target_width |
547 | || y >= target_height |
552 | || y >= target_height |
548 | || (w > 0 && x + w <= 0) |
553 | || (x + w <= 0) |
549 | || (h > 0 && y + h <= 0)) |
554 | || (y + h <= 0)))) |
550 | { |
555 | { |
551 | if (background) |
556 | if (background) |
552 | { |
557 | { |
553 | new_pmap_width = background->width; |
558 | new_pmap_width = background->width; |
554 | new_pmap_height = background->height; |
559 | new_pmap_height = background->height; |
… | |
… | |
568 | } |
573 | } |
569 | else |
574 | else |
570 | { |
575 | { |
571 | result = original_asim; |
576 | result = original_asim; |
572 | |
577 | |
573 | if ((w > 0 && w != original_asim->width) |
578 | if ((w != original_asim->width) |
574 | || (h > 0 && h != original_asim->height)) |
579 | || (h != original_asim->height)) |
575 | { |
580 | { |
576 | result = scale_asimage (target->asv, original_asim, |
581 | result = scale_asimage (target->asv, original_asim, |
577 | w > 0 ? w : original_asim->width, |
582 | w, h, |
578 | h > 0 ? h : original_asim->height, |
|
|
579 | background ? ASA_ASImage : ASA_XImage, |
583 | background ? ASA_ASImage : ASA_XImage, |
580 | 100, ASIMAGE_QUALITY_DEFAULT); |
584 | 100, ASIMAGE_QUALITY_DEFAULT); |
581 | } |
585 | } |
582 | |
586 | |
583 | if (background == NULL) |
587 | if (background == NULL) |
… | |
… | |
615 | layers[0].clip_width = target_width; |
619 | layers[0].clip_width = target_width; |
616 | layers[0].clip_height = target_height; |
620 | layers[0].clip_height = target_height; |
617 | layers[0].tint = background_tint; |
621 | layers[0].tint = background_tint; |
618 | layers[1].im = result; |
622 | layers[1].im = result; |
619 | |
623 | |
620 | if (w <= 0) |
624 | if (h_scale == 0 || v_scale == 0) |
621 | { |
625 | { |
622 | /* tile horizontally */ |
626 | /* tile horizontally */ |
623 | while (x > 0) x -= (int)result->width; |
627 | while (x > 0) x -= (int)result->width; |
624 | layers[1].dst_x = x; |
628 | layers[1].dst_x = x; |
625 | layers[1].clip_width = result->width+target_width; |
629 | layers[1].clip_width = result->width+target_width; |
… | |
… | |
629 | /* clip horizontally */ |
633 | /* clip horizontally */ |
630 | layers[1].dst_x = x; |
634 | layers[1].dst_x = x; |
631 | layers[1].clip_width = result->width; |
635 | layers[1].clip_width = result->width; |
632 | } |
636 | } |
633 | |
637 | |
634 | if (h <= 0) |
638 | if (h_scale == 0 || v_scale == 0) |
635 | { |
639 | { |
636 | while (y > 0) y -= (int)result->height; |
640 | while (y > 0) y -= (int)result->height; |
637 | layers[1].dst_y = y; |
641 | layers[1].dst_y = y; |
638 | layers[1].clip_height = result->height + target_height; |
642 | layers[1].clip_height = result->height + target_height; |
639 | } |
643 | } |
… | |
… | |
761 | int w = 0; |
765 | int w = 0; |
762 | int h = 0; |
766 | int h = 0; |
763 | |
767 | |
764 | get_image_geometry (image_width, image_height, w, h, x, y); |
768 | get_image_geometry (image_width, image_height, w, h, x, y); |
765 | |
769 | |
|
|
770 | if (!(flags & rootAlign) |
766 | if (x >= target_width |
771 | && (x >= target_width |
767 | || y >= target_height |
772 | || y >= target_height |
768 | || (w > 0 && x + w <= 0) |
773 | || (x + w <= 0) |
769 | || (h > 0 && y + h <= 0)) |
774 | || (y + h <= 0))) |
770 | return false; |
775 | return false; |
771 | |
776 | |
772 | result = pixbuf; |
777 | result = pixbuf; |
773 | |
778 | |
774 | if ((w > 0 && w != image_width) |
779 | if ((w != image_width) |
775 | || (h > 0 && h != image_height)) |
780 | || (h != image_height)) |
776 | { |
781 | { |
777 | result = gdk_pixbuf_scale_simple (pixbuf, |
782 | result = gdk_pixbuf_scale_simple (pixbuf, |
778 | w > 0 ? w : image_width, |
783 | w, h, |
779 | h > 0 ? h : image_height, |
|
|
780 | GDK_INTERP_BILINEAR); |
784 | GDK_INTERP_BILINEAR); |
781 | } |
785 | } |
782 | |
786 | |
783 | bool ret = false; |
787 | bool ret = false; |
784 | |
788 | |
… | |
… | |
958 | static inline unsigned long |
962 | static inline unsigned long |
959 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
963 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
960 | { |
964 | { |
961 | unsigned long flags = 0; |
965 | unsigned long flags = 0; |
962 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
966 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
963 | bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); |
967 | bool has_shade = shade != 100; |
964 | |
968 | |
965 | if (tint) |
969 | if (tint) |
966 | { |
970 | { |
967 | tint->get (c); |
971 | tint->get (c); |
968 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
972 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
… | |
… | |
1000 | } |
1004 | } |
1001 | |
1005 | |
1002 | bool |
1006 | bool |
1003 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
1007 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
1004 | { |
1008 | { |
1005 | if (tint != new_tint) |
1009 | if (!(flags & tintSet) || tint != new_tint) |
1006 | { |
1010 | { |
1007 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
1011 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
1008 | tint = new_tint; |
1012 | tint = new_tint; |
1009 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
1013 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
1010 | return true; |
1014 | return true; |
… | |
… | |
1028 | } |
1032 | } |
1029 | |
1033 | |
1030 | bool |
1034 | bool |
1031 | bgPixmap_t::set_shade (const char *shade_str) |
1035 | bgPixmap_t::set_shade (const char *shade_str) |
1032 | { |
1036 | { |
1033 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
1037 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1034 | |
1038 | |
1035 | if (new_shade < 0 && new_shade > -100) |
1039 | clamp_it (new_shade, -100, 200); |
|
|
1040 | if (new_shade < 0) |
1036 | new_shade = 200 - (100 + new_shade); |
1041 | new_shade = 200 - (100 + new_shade); |
1037 | else if (new_shade == 100) |
|
|
1038 | new_shade = 0; |
|
|
1039 | |
1042 | |
1040 | if (new_shade != shade) |
1043 | if (new_shade != shade) |
1041 | { |
1044 | { |
1042 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
1045 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
1043 | shade = new_shade; |
1046 | shade = new_shade; |
1044 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1047 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1045 | return true; |
1048 | return true; |
1046 | } |
1049 | } |
1047 | |
1050 | |
1048 | return false; |
1051 | return false; |
|
|
1052 | } |
|
|
1053 | |
|
|
1054 | bool |
|
|
1055 | bgPixmap_t::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
|
|
1056 | { |
|
|
1057 | Display *dpy = target->dpy; |
|
|
1058 | bool ret = false; |
|
|
1059 | |
|
|
1060 | if (flags & tintWholesome) |
|
|
1061 | { |
|
|
1062 | XGCValues gcv; |
|
|
1063 | GC gc; |
|
|
1064 | |
|
|
1065 | /* In this case we can tint image server-side getting significant |
|
|
1066 | * performance improvements, as we eliminate XImage transfer |
|
|
1067 | */ |
|
|
1068 | gcv.foreground = Pixel (tint); |
|
|
1069 | gcv.function = GXand; |
|
|
1070 | gcv.fill_style = FillSolid; |
|
|
1071 | gc = XCreateGC (dpy, pixmap, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1072 | if (gc) |
|
|
1073 | { |
|
|
1074 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
|
|
1075 | ret = true; |
|
|
1076 | XFreeGC (dpy, gc); |
|
|
1077 | } |
|
|
1078 | } |
|
|
1079 | else |
|
|
1080 | { |
|
|
1081 | # if XFT |
|
|
1082 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1083 | |
|
|
1084 | if (flags & tintSet) |
|
|
1085 | tint.get (c); |
|
|
1086 | |
|
|
1087 | if (shade <= 100) |
|
|
1088 | { |
|
|
1089 | c.r = (c.r * shade) / 100; |
|
|
1090 | c.g = (c.g * shade) / 100; |
|
|
1091 | c.b = (c.b * shade) / 100; |
|
|
1092 | } |
|
|
1093 | else |
|
|
1094 | { |
|
|
1095 | c.r = ((0xffff - c.r) * (200 - shade)) / 100; |
|
|
1096 | c.g = ((0xffff - c.g) * (200 - shade)) / 100; |
|
|
1097 | c.b = ((0xffff - c.b) * (200 - shade)) / 100; |
|
|
1098 | } |
|
|
1099 | |
|
|
1100 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1101 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
|
|
1102 | XRenderPictureAttributes pa; |
|
|
1103 | |
|
|
1104 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
|
|
1105 | |
|
|
1106 | pa.repeat = True; |
|
|
1107 | |
|
|
1108 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
|
|
1109 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1110 | XFreePixmap (dpy, overlay_pmap); |
|
|
1111 | |
|
|
1112 | pa.component_alpha = True; |
|
|
1113 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
|
|
1114 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1115 | XFreePixmap (dpy, mask_pmap); |
|
|
1116 | |
|
|
1117 | if (mask_pic && overlay_pic && back_pic) |
|
|
1118 | { |
|
|
1119 | XRenderColor mask_c; |
|
|
1120 | |
|
|
1121 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1122 | mask_c.alpha = 0xffff; |
|
|
1123 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1124 | |
|
|
1125 | mask_c.alpha = 0; |
|
|
1126 | mask_c.red = 0xffff - c.r; |
|
|
1127 | mask_c.green = 0xffff - c.g; |
|
|
1128 | mask_c.blue = 0xffff - c.b; |
|
|
1129 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1130 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1131 | ret = true; |
|
|
1132 | } |
|
|
1133 | |
|
|
1134 | XRenderFreePicture (dpy, mask_pic); |
|
|
1135 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1136 | XRenderFreePicture (dpy, back_pic); |
|
|
1137 | # if DO_TIMING_TEST |
|
|
1138 | XSync (dpy, False); |
|
|
1139 | # endif |
|
|
1140 | # endif |
|
|
1141 | } |
|
|
1142 | |
|
|
1143 | return ret; |
1049 | } |
1144 | } |
1050 | |
1145 | |
1051 | /* make_transparency_pixmap() |
1146 | /* make_transparency_pixmap() |
1052 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1147 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1053 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
1148 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
… | |
… | |
1183 | { |
1278 | { |
1184 | if (!need_client_side_rendering ()) |
1279 | if (!need_client_side_rendering ()) |
1185 | { |
1280 | { |
1186 | if ((flags & tintNeeded)) |
1281 | if ((flags & tintNeeded)) |
1187 | { |
1282 | { |
1188 | if (flags & tintWholesome) |
1283 | if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) |
1189 | { |
|
|
1190 | /* In this case we can tint image server-side getting significant |
|
|
1191 | * performance improvements, as we eliminate XImage transfer |
|
|
1192 | */ |
|
|
1193 | gcv.foreground = Pixel (tint); |
|
|
1194 | gcv.function = GXand; |
|
|
1195 | gcv.fill_style = FillSolid; |
|
|
1196 | if (gc) |
|
|
1197 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1198 | else |
|
|
1199 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1200 | if (gc) |
|
|
1201 | { |
|
|
1202 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
1203 | result |= transpPmapTinted; |
1284 | result |= transpPmapTinted; |
1204 | } |
|
|
1205 | } |
|
|
1206 | else |
|
|
1207 | { |
|
|
1208 | # if XFT |
|
|
1209 | Picture back_pic = 0; |
|
|
1210 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1211 | |
|
|
1212 | if (flags & tintSet) |
|
|
1213 | tint.get (c); |
|
|
1214 | |
|
|
1215 | if (shade > 0 && shade < 100) |
|
|
1216 | { |
|
|
1217 | c.r = (c.r * shade) / 100; |
|
|
1218 | c.g = (c.g * shade) / 100; |
|
|
1219 | c.b = (c.b * shade) / 100; |
|
|
1220 | } |
|
|
1221 | else if (shade > 100 && shade < 200) |
|
|
1222 | { |
|
|
1223 | c.r = (c.r * (200 - shade)) / 100; |
|
|
1224 | c.g = (c.g * (200 - shade)) / 100; |
|
|
1225 | c.b = (c.b * (200 - shade)) / 100; |
|
|
1226 | } |
|
|
1227 | |
|
|
1228 | XRenderPictFormat pf; |
|
|
1229 | pf.type = PictTypeDirect; |
|
|
1230 | pf.depth = 32; |
|
|
1231 | pf.direct.redMask = 0xff; |
|
|
1232 | pf.direct.greenMask = 0xff; |
|
|
1233 | pf.direct.blueMask = 0xff; |
|
|
1234 | pf.direct.alphaMask = 0xff; |
|
|
1235 | |
|
|
1236 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
1237 | (PictFormatType| |
|
|
1238 | PictFormatDepth| |
|
|
1239 | PictFormatRedMask| |
|
|
1240 | PictFormatGreenMask| |
|
|
1241 | PictFormatBlueMask| |
|
|
1242 | PictFormatAlphaMask), |
|
|
1243 | &pf, |
|
|
1244 | 0); |
|
|
1245 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
1246 | XRenderPictureAttributes pa ; |
|
|
1247 | |
|
|
1248 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
1249 | |
|
|
1250 | pa.repeat = True; |
|
|
1251 | |
|
|
1252 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1253 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1254 | XFreePixmap (dpy, overlay_pmap); |
|
|
1255 | |
|
|
1256 | pa.component_alpha = True; |
|
|
1257 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1258 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1259 | XFreePixmap (dpy, mask_pmap); |
|
|
1260 | |
|
|
1261 | if (mask_pic && overlay_pic && back_pic) |
|
|
1262 | { |
|
|
1263 | XRenderColor mask_c; |
|
|
1264 | |
|
|
1265 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1266 | mask_c.alpha = 0xffff; |
|
|
1267 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1268 | |
|
|
1269 | mask_c.alpha = 0; |
|
|
1270 | mask_c.red = 0xffff - c.r; |
|
|
1271 | mask_c.green = 0xffff - c.g; |
|
|
1272 | mask_c.blue = 0xffff - c.b; |
|
|
1273 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1274 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
1275 | result |= transpPmapTinted; |
|
|
1276 | } |
|
|
1277 | |
|
|
1278 | XRenderFreePicture (dpy, mask_pic); |
|
|
1279 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1280 | XRenderFreePicture (dpy, back_pic); |
|
|
1281 | # if DO_TIMING_TEST |
|
|
1282 | XSync (dpy, False); |
|
|
1283 | # endif |
|
|
1284 | # endif |
|
|
1285 | } |
|
|
1286 | } |
1285 | } |
1287 | } /* server side rendering completed */ |
1286 | } /* server side rendering completed */ |
1288 | |
1287 | |
1289 | if (pixmap) |
1288 | if (pixmap) |
1290 | XFreePixmap (dpy, pixmap); |
1289 | XFreePixmap (dpy, pixmap); |
… | |
… | |
1530 | int i; |
1529 | int i; |
1531 | |
1530 | |
1532 | Visual *visual = term->visual; |
1531 | Visual *visual = term->visual; |
1533 | |
1532 | |
1534 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1533 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1535 | |
|
|
1536 | if (shade == 0) |
|
|
1537 | shade = 100; |
|
|
1538 | |
1534 | |
1539 | /* for convenience */ |
1535 | /* for convenience */ |
1540 | mask_r = visual->red_mask; |
1536 | mask_r = visual->red_mask; |
1541 | mask_g = visual->green_mask; |
1537 | mask_g = visual->green_mask; |
1542 | mask_b = visual->blue_mask; |
1538 | mask_b = visual->blue_mask; |
… | |
… | |
1598 | default: |
1594 | default: |
1599 | return; /* we do not support this color depth */ |
1595 | return; /* we do not support this color depth */ |
1600 | } |
1596 | } |
1601 | |
1597 | |
1602 | /* prepare limits for color transformation (each channel is handled separately) */ |
1598 | /* prepare limits for color transformation (each channel is handled separately) */ |
1603 | if (shade < 0) { |
1599 | if (shade > 100) { |
1604 | shade = -shade; |
1600 | shade = 200 - shade; |
1605 | if (shade < 0) shade = 0; |
|
|
1606 | if (shade > 100) shade = 100; |
|
|
1607 | |
1601 | |
1608 | lower_lim_r = 65535-rm; |
1602 | lower_lim_r = 65535-rm; |
1609 | lower_lim_g = 65535-gm; |
1603 | lower_lim_g = 65535-gm; |
1610 | lower_lim_b = 65535-bm; |
1604 | lower_lim_b = 65535-bm; |
1611 | |
1605 | |
… | |
… | |
1613 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
1607 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
1614 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
1608 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
1615 | |
1609 | |
1616 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
1610 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
1617 | } else { |
1611 | } else { |
1618 | if (shade < 0) shade = 0; |
|
|
1619 | if (shade > 100) shade = 100; |
|
|
1620 | |
1612 | |
1621 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
1613 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
1622 | |
1614 | |
1623 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
1615 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
1624 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
1616 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |