… | |
… | |
138 | # endif |
138 | # endif |
139 | |
139 | |
140 | # ifdef BG_IMAGE_FROM_FILE |
140 | # ifdef BG_IMAGE_FROM_FILE |
141 | if (have_image) |
141 | if (have_image) |
142 | { |
142 | { |
143 | if (h_scale != 0 || v_scale != 0 |
143 | if (flags & sizeSensitive) |
144 | || h_align != 0 || v_align != 0) |
|
|
145 | return true; |
144 | return true; |
146 | } |
145 | } |
147 | # endif |
146 | # endif |
148 | |
147 | |
149 | return false; |
148 | return false; |
… | |
… | |
158 | # endif |
157 | # endif |
159 | |
158 | |
160 | # ifdef BG_IMAGE_FROM_FILE |
159 | # ifdef BG_IMAGE_FROM_FILE |
161 | if (have_image) |
160 | if (have_image) |
162 | { |
161 | { |
163 | if (h_align == rootAlign || v_align == rootAlign) |
162 | if (flags & rootAlign) |
164 | return true; |
163 | return true; |
165 | } |
164 | } |
166 | # endif |
165 | # endif |
167 | |
166 | |
168 | return false; |
167 | return false; |
… | |
… | |
208 | static inline bool |
207 | static inline bool |
209 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
208 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
210 | { |
209 | { |
211 | if (geom_flags & flag) |
210 | if (geom_flags & flag) |
212 | { |
211 | { |
213 | if (new_value != bgPixmap_t::rootAlign) |
|
|
214 | { |
|
|
215 | if (new_value < -100) |
212 | if (new_value < -100) |
216 | new_value = -100; |
213 | new_value = -100; |
217 | else if (new_value > 200) |
214 | else if (new_value > 200) |
218 | new_value = 200; |
215 | new_value = 200; |
219 | } |
|
|
220 | if (new_value != align) |
216 | if (new_value != align) |
221 | { |
217 | { |
222 | align = new_value; |
218 | align = new_value; |
223 | return true; |
219 | return true; |
224 | } |
220 | } |
… | |
… | |
236 | return diff * align / 100; |
232 | return diff * align / 100; |
237 | else if (align > 50 && align <= 100) |
233 | else if (align > 50 && align <= 100) |
238 | return window_size - image_size - diff * (100 - align) / 100; |
234 | return window_size - image_size - diff * (100 - align) / 100; |
239 | else if (align > 100 && align <= 200 ) |
235 | else if (align > 100 && align <= 200 ) |
240 | return ((align - 100) * smaller / 100) + window_size - smaller; |
236 | return ((align - 100) * smaller / 100) + window_size - smaller; |
241 | else if (align > -100 && align < 0) |
237 | else if (align >= -100 && align < 0) |
242 | return ((align + 100) * smaller / 100) - image_size; |
238 | return ((align + 100) * smaller / 100) - image_size; |
243 | return 0; |
239 | return 0; |
244 | } |
240 | } |
245 | |
241 | |
246 | static inline int |
242 | static inline int |
247 | make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) |
243 | make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) |
248 | { |
244 | { |
249 | int src_pos = 0; |
245 | int src_pos = 0; |
250 | dst_pos = 0; |
246 | dst_pos = 0; |
251 | dst_size = size; |
247 | dst_size = size; |
252 | if (pos < 0 && size > target_size) |
248 | if (pos < 0) |
253 | { |
249 | { |
254 | src_pos = -pos; |
250 | src_pos = -pos; |
255 | dst_size += pos; |
251 | dst_size += pos; |
256 | } |
252 | } |
257 | else if (pos > 0) |
253 | else if (pos > 0) |
… | |
… | |
388 | w = h = noScale; |
384 | w = h = noScale; |
389 | geom_flags |= WidthValue|HeightValue; |
385 | geom_flags |= WidthValue|HeightValue; |
390 | } |
386 | } |
391 | else if (CHECK_GEOM_OPS ("propscale")) |
387 | else if (CHECK_GEOM_OPS ("propscale")) |
392 | { |
388 | { |
393 | if (w == 0 && h == 0) |
|
|
394 | { |
|
|
395 | w = windowScale; |
|
|
396 | geom_flags |= WidthValue; |
|
|
397 | } |
|
|
398 | new_flags |= propScale; |
389 | new_flags |= propScale; |
399 | } |
390 | } |
400 | else if (CHECK_GEOM_OPS ("hscale")) |
391 | else if (CHECK_GEOM_OPS ("hscale")) |
401 | { |
392 | { |
402 | if (w == 0) w = windowScale; |
393 | if (w == 0) w = windowScale; |
… | |
… | |
424 | x = y = centerAlign; |
415 | x = y = centerAlign; |
425 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
416 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
426 | } |
417 | } |
427 | else if (CHECK_GEOM_OPS ("root")) |
418 | else if (CHECK_GEOM_OPS ("root")) |
428 | { |
419 | { |
|
|
420 | new_flags |= rootAlign; |
429 | w = h = noScale; |
421 | w = h = noScale; |
430 | x = y = rootAlign; |
|
|
431 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
422 | geom_flags |= WidthValue|HeightValue; |
432 | } |
423 | } |
433 | # undef CHECK_GEOM_OPS |
424 | # undef CHECK_GEOM_OPS |
434 | |
425 | |
435 | while (*ops != ':' && *ops != '\0') ++ops; |
426 | while (*ops != ':' && *ops != '\0') ++ops; |
436 | } /* done parsing ops */ |
427 | } /* done parsing ops */ |
… | |
… | |
449 | } |
440 | } |
450 | |
441 | |
451 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
442 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
452 | // flags, h_scale, v_scale, h_align, v_align); |
443 | // flags, h_scale, v_scale, h_align, v_align); |
453 | return (changed > 0); |
444 | return (changed > 0); |
|
|
445 | } |
|
|
446 | |
|
|
447 | void |
|
|
448 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
|
|
449 | { |
|
|
450 | int target_width = target->szHint.width; |
|
|
451 | int target_height = target->szHint.height; |
|
|
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 | { |
|
|
462 | w = h_scale * target_width / 100; |
|
|
463 | h = v_scale * target_height / 100; |
|
|
464 | } |
|
|
465 | |
|
|
466 | if (flags & rootAlign) |
|
|
467 | { |
|
|
468 | target->get_window_origin (x, y); |
|
|
469 | x = -x; |
|
|
470 | y = -y; |
|
|
471 | } |
|
|
472 | else |
|
|
473 | { |
|
|
474 | x = make_align_position (h_align, target_width, w > 0 ? w : image_width); |
|
|
475 | y = make_align_position (v_align, target_height, h > 0 ? h : image_height); |
|
|
476 | } |
|
|
477 | |
|
|
478 | flags &= ~sizeSensitive; |
|
|
479 | if (h_scale != 0 || v_scale != 0 |
|
|
480 | || h_align != 0 || v_align != 0 |
|
|
481 | || image_width > target_width || image_height > target_height) |
|
|
482 | flags |= sizeSensitive; |
454 | } |
483 | } |
455 | |
484 | |
456 | # ifdef HAVE_AFTERIMAGE |
485 | # ifdef HAVE_AFTERIMAGE |
457 | bool |
486 | bool |
458 | bgPixmap_t::render_image (unsigned long background_flags) |
487 | bgPixmap_t::render_image (unsigned long background_flags) |
… | |
… | |
504 | int new_pmap_width = target_width; |
533 | int new_pmap_width = target_width; |
505 | int new_pmap_height = target_height; |
534 | int new_pmap_height = target_height; |
506 | |
535 | |
507 | int x = 0; |
536 | int x = 0; |
508 | int y = 0; |
537 | int y = 0; |
509 | int w = h_scale * target_width / 100; |
538 | int w = 0; |
510 | int h = v_scale * target_height / 100; |
539 | int h = 0; |
511 | |
540 | |
512 | TIMING_TEST_START (asim); |
541 | TIMING_TEST_START (asim); |
513 | |
542 | |
514 | if (original_asim) |
543 | if (original_asim) |
515 | { |
544 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
516 | if (h_align == rootAlign || v_align == rootAlign) |
|
|
517 | { |
|
|
518 | target->get_window_origin (x, y); |
|
|
519 | x = -x; |
|
|
520 | y = -y; |
|
|
521 | } |
|
|
522 | |
|
|
523 | if (h_align != rootAlign) |
|
|
524 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
|
|
525 | |
|
|
526 | if (v_align != rootAlign) |
|
|
527 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
|
|
528 | } |
|
|
529 | |
545 | |
530 | if (!original_asim |
546 | if (!original_asim |
531 | || x >= target_width |
547 | || x >= target_width |
532 | || y >= target_height |
548 | || y >= target_height |
533 | || (w > 0 && x + w <= 0) |
549 | || (w > 0 && x + w <= 0) |
… | |
… | |
565 | 100, ASIMAGE_QUALITY_DEFAULT); |
581 | 100, ASIMAGE_QUALITY_DEFAULT); |
566 | } |
582 | } |
567 | |
583 | |
568 | if (background == NULL) |
584 | if (background == NULL) |
569 | { |
585 | { |
570 | /* if tiling - pixmap has to be sized exactly as the image, |
|
|
571 | but there is no need to make it bigger than the window! */ |
|
|
572 | if (h_scale == 0) |
|
|
573 | new_pmap_width = min (result->width, target_width); |
|
|
574 | if (v_scale == 0) |
|
|
575 | new_pmap_height = min (result->height, target_height); |
|
|
576 | /* we also need to tile our image in one or both directions */ |
|
|
577 | if (h_scale == 0 || v_scale == 0) |
586 | if (h_scale == 0 || v_scale == 0) |
578 | { |
587 | { |
|
|
588 | /* if tiling - pixmap has to be sized exactly as the image, |
|
|
589 | but there is no need to make it bigger than the window! */ |
|
|
590 | new_pmap_width = min (result->width, target_width); |
|
|
591 | new_pmap_height = min (result->height, target_height); |
|
|
592 | |
|
|
593 | /* we also need to tile our image in both directions */ |
579 | ASImage *tmp = tile_asimage (target->asv, result, |
594 | ASImage *tmp = tile_asimage (target->asv, result, |
580 | (h_scale > 0) ? 0 : (int)result->width - x, |
595 | (int)result->width - x, |
581 | (v_scale > 0) ? 0 : (int)result->height - y, |
596 | (int)result->height - y, |
582 | new_pmap_width, |
597 | new_pmap_width, |
583 | new_pmap_height, |
598 | new_pmap_height, |
584 | TINT_LEAVE_SAME, ASA_XImage, |
599 | TINT_LEAVE_SAME, ASA_XImage, |
585 | 100, ASIMAGE_QUALITY_DEFAULT); |
600 | 100, ASIMAGE_QUALITY_DEFAULT); |
586 | if (tmp) |
601 | if (tmp) |
… | |
… | |
684 | |
699 | |
685 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
700 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
686 | int dst_width = result->width, dst_height = result->height; |
701 | int dst_width = result->width, dst_height = result->height; |
687 | if (background == NULL) |
702 | if (background == NULL) |
688 | { |
703 | { |
|
|
704 | if (!(h_scale == 0 || v_scale == 0)) |
|
|
705 | { |
689 | if (h_scale > 0) src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
706 | src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
690 | if (v_scale > 0) src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
707 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
|
|
708 | } |
691 | |
709 | |
692 | if (dst_x > 0 || dst_y > 0 |
710 | if (dst_x > 0 || dst_y > 0 |
693 | || dst_x + dst_width < new_pmap_width |
711 | || dst_x + dst_width < new_pmap_width |
694 | || dst_y + dst_height < new_pmap_height) |
712 | || dst_y + dst_height < new_pmap_height) |
695 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
713 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
… | |
… | |
739 | int new_pmap_width = target_width; |
757 | int new_pmap_width = target_width; |
740 | int new_pmap_height = target_height; |
758 | int new_pmap_height = target_height; |
741 | |
759 | |
742 | int x = 0; |
760 | int x = 0; |
743 | int y = 0; |
761 | int y = 0; |
744 | int w = h_scale * target_width / 100; |
762 | int w = 0; |
745 | int h = v_scale * target_height / 100; |
763 | int h = 0; |
746 | |
764 | |
747 | if (h_align == rootAlign || v_align == rootAlign) |
765 | get_image_geometry (image_width, image_height, w, h, x, y); |
748 | { |
|
|
749 | target->get_window_origin (x, y); |
|
|
750 | x = -x; |
|
|
751 | y = -y; |
|
|
752 | } |
|
|
753 | |
|
|
754 | if (h_align != rootAlign) |
|
|
755 | x = make_align_position (h_align, target_width, w > 0 ? w : image_width); |
|
|
756 | |
|
|
757 | if (v_align != rootAlign) |
|
|
758 | y = make_align_position (v_align, target_height, h > 0 ? h : image_height); |
|
|
759 | |
766 | |
760 | if (x >= target_width |
767 | if (x >= target_width |
761 | || y >= target_height |
768 | || y >= target_height |
762 | || (w > 0 && x + w <= 0) |
769 | || (w > 0 && x + w <= 0) |
763 | || (h > 0 && y + h <= 0)) |
770 | || (h > 0 && y + h <= 0)) |
… | |
… | |
782 | GC gc; |
789 | GC gc; |
783 | |
790 | |
784 | image_width = gdk_pixbuf_get_width (result); |
791 | image_width = gdk_pixbuf_get_width (result); |
785 | image_height = gdk_pixbuf_get_height (result); |
792 | image_height = gdk_pixbuf_get_height (result); |
786 | |
793 | |
787 | if (h_scale == 0) |
794 | if (h_scale == 0 || v_scale == 0) |
|
|
795 | { |
788 | new_pmap_width = min (image_width, target_width); |
796 | new_pmap_width = min (image_width, target_width); |
789 | if (v_scale == 0) |
|
|
790 | new_pmap_height = min (image_height, target_height); |
797 | new_pmap_height = min (image_height, target_height); |
|
|
798 | } |
791 | |
799 | |
792 | if (pixmap) |
800 | if (pixmap) |
793 | { |
801 | { |
794 | if (pmap_width != new_pmap_width |
802 | if (pmap_width != new_pmap_width |
795 | || pmap_height != new_pmap_height |
803 | || pmap_height != new_pmap_height |
… | |
… | |
1037 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1045 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1038 | return true; |
1046 | return true; |
1039 | } |
1047 | } |
1040 | |
1048 | |
1041 | return false; |
1049 | return false; |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | bool |
|
|
1053 | bgPixmap_t::tint_pixmap (Pixmap pixmap) |
|
|
1054 | { |
|
|
1055 | Window root = target->display->root; |
|
|
1056 | Display *dpy = target->dpy; |
|
|
1057 | int window_width = target->szHint.width; |
|
|
1058 | int window_height = target->szHint.height; |
|
|
1059 | bool ret = false; |
|
|
1060 | |
|
|
1061 | if (flags & tintWholesome) |
|
|
1062 | { |
|
|
1063 | XGCValues gcv; |
|
|
1064 | GC gc; |
|
|
1065 | |
|
|
1066 | /* In this case we can tint image server-side getting significant |
|
|
1067 | * performance improvements, as we eliminate XImage transfer |
|
|
1068 | */ |
|
|
1069 | gcv.foreground = Pixel (tint); |
|
|
1070 | gcv.function = GXand; |
|
|
1071 | gcv.fill_style = FillSolid; |
|
|
1072 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1073 | if (gc) |
|
|
1074 | { |
|
|
1075 | XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); |
|
|
1076 | ret = true; |
|
|
1077 | XFreeGC (dpy, gc); |
|
|
1078 | } |
|
|
1079 | } |
|
|
1080 | else |
|
|
1081 | { |
|
|
1082 | # if XFT |
|
|
1083 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1084 | |
|
|
1085 | if (flags & tintSet) |
|
|
1086 | tint.get (c); |
|
|
1087 | |
|
|
1088 | if (shade > 0 && shade < 100) |
|
|
1089 | { |
|
|
1090 | c.r = (c.r * shade) / 100; |
|
|
1091 | c.g = (c.g * shade) / 100; |
|
|
1092 | c.b = (c.b * shade) / 100; |
|
|
1093 | } |
|
|
1094 | else if (shade > 100 && shade < 200) |
|
|
1095 | { |
|
|
1096 | c.r = (c.r * (200 - shade)) / 100; |
|
|
1097 | c.g = (c.g * (200 - shade)) / 100; |
|
|
1098 | c.b = (c.b * (200 - shade)) / 100; |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | XRenderPictFormat pf; |
|
|
1102 | pf.type = PictTypeDirect; |
|
|
1103 | pf.depth = 32; |
|
|
1104 | pf.direct.redMask = 0xff; |
|
|
1105 | pf.direct.greenMask = 0xff; |
|
|
1106 | pf.direct.blueMask = 0xff; |
|
|
1107 | pf.direct.alphaMask = 0xff; |
|
|
1108 | |
|
|
1109 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
1110 | (PictFormatType| |
|
|
1111 | PictFormatDepth| |
|
|
1112 | PictFormatRedMask| |
|
|
1113 | PictFormatGreenMask| |
|
|
1114 | PictFormatBlueMask| |
|
|
1115 | PictFormatAlphaMask), |
|
|
1116 | &pf, |
|
|
1117 | 0); |
|
|
1118 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
1119 | XRenderPictureAttributes pa; |
|
|
1120 | |
|
|
1121 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, root_format, 0, &pa); |
|
|
1122 | |
|
|
1123 | pa.repeat = True; |
|
|
1124 | |
|
|
1125 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1126 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1127 | XFreePixmap (dpy, overlay_pmap); |
|
|
1128 | |
|
|
1129 | pa.component_alpha = True; |
|
|
1130 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1131 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1132 | XFreePixmap (dpy, mask_pmap); |
|
|
1133 | |
|
|
1134 | if (mask_pic && overlay_pic && back_pic) |
|
|
1135 | { |
|
|
1136 | XRenderColor mask_c; |
|
|
1137 | |
|
|
1138 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1139 | mask_c.alpha = 0xffff; |
|
|
1140 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1141 | |
|
|
1142 | mask_c.alpha = 0; |
|
|
1143 | mask_c.red = 0xffff - c.r; |
|
|
1144 | mask_c.green = 0xffff - c.g; |
|
|
1145 | mask_c.blue = 0xffff - c.b; |
|
|
1146 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1147 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
1148 | ret = true; |
|
|
1149 | } |
|
|
1150 | |
|
|
1151 | XRenderFreePicture (dpy, mask_pic); |
|
|
1152 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1153 | XRenderFreePicture (dpy, back_pic); |
|
|
1154 | # if DO_TIMING_TEST |
|
|
1155 | XSync (dpy, False); |
|
|
1156 | # endif |
|
|
1157 | # endif |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | return ret; |
1042 | } |
1161 | } |
1043 | |
1162 | |
1044 | /* make_transparency_pixmap() |
1163 | /* make_transparency_pixmap() |
1045 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1164 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1046 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
1165 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
… | |
… | |
1176 | { |
1295 | { |
1177 | if (!need_client_side_rendering ()) |
1296 | if (!need_client_side_rendering ()) |
1178 | { |
1297 | { |
1179 | if ((flags & tintNeeded)) |
1298 | if ((flags & tintNeeded)) |
1180 | { |
1299 | { |
1181 | if (flags & tintWholesome) |
1300 | if (tint_pixmap (tiled_root_pmap)) |
1182 | { |
|
|
1183 | /* In this case we can tint image server-side getting significant |
|
|
1184 | * performance improvements, as we eliminate XImage transfer |
|
|
1185 | */ |
|
|
1186 | gcv.foreground = Pixel (tint); |
|
|
1187 | gcv.function = GXand; |
|
|
1188 | gcv.fill_style = FillSolid; |
|
|
1189 | if (gc) |
|
|
1190 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1191 | else |
|
|
1192 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
1193 | if (gc) |
|
|
1194 | { |
|
|
1195 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
1196 | result |= transpPmapTinted; |
1301 | result |= transpPmapTinted; |
1197 | } |
|
|
1198 | } |
|
|
1199 | else |
|
|
1200 | { |
|
|
1201 | # if XFT |
|
|
1202 | Picture back_pic = 0; |
|
|
1203 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1204 | |
|
|
1205 | if (flags & tintSet) |
|
|
1206 | tint.get (c); |
|
|
1207 | |
|
|
1208 | if (shade > 0 && shade < 100) |
|
|
1209 | { |
|
|
1210 | c.r = (c.r * shade) / 100; |
|
|
1211 | c.g = (c.g * shade) / 100; |
|
|
1212 | c.b = (c.b * shade) / 100; |
|
|
1213 | } |
|
|
1214 | else if (shade > 100 && shade < 200) |
|
|
1215 | { |
|
|
1216 | c.r = (c.r * (200 - shade)) / 100; |
|
|
1217 | c.g = (c.g * (200 - shade)) / 100; |
|
|
1218 | c.b = (c.b * (200 - shade)) / 100; |
|
|
1219 | } |
|
|
1220 | |
|
|
1221 | XRenderPictFormat pf; |
|
|
1222 | pf.type = PictTypeDirect; |
|
|
1223 | pf.depth = 32; |
|
|
1224 | pf.direct.redMask = 0xff; |
|
|
1225 | pf.direct.greenMask = 0xff; |
|
|
1226 | pf.direct.blueMask = 0xff; |
|
|
1227 | pf.direct.alphaMask = 0xff; |
|
|
1228 | |
|
|
1229 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
1230 | (PictFormatType| |
|
|
1231 | PictFormatDepth| |
|
|
1232 | PictFormatRedMask| |
|
|
1233 | PictFormatGreenMask| |
|
|
1234 | PictFormatBlueMask| |
|
|
1235 | PictFormatAlphaMask), |
|
|
1236 | &pf, |
|
|
1237 | 0); |
|
|
1238 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
1239 | XRenderPictureAttributes pa ; |
|
|
1240 | |
|
|
1241 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
1242 | |
|
|
1243 | pa.repeat = True; |
|
|
1244 | |
|
|
1245 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1246 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1247 | XFreePixmap (dpy, overlay_pmap); |
|
|
1248 | |
|
|
1249 | pa.component_alpha = True; |
|
|
1250 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
1251 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
1252 | XFreePixmap (dpy, mask_pmap); |
|
|
1253 | |
|
|
1254 | if (mask_pic && overlay_pic && back_pic) |
|
|
1255 | { |
|
|
1256 | XRenderColor mask_c; |
|
|
1257 | |
|
|
1258 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
1259 | mask_c.alpha = 0xffff; |
|
|
1260 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1261 | |
|
|
1262 | mask_c.alpha = 0; |
|
|
1263 | mask_c.red = 0xffff - c.r; |
|
|
1264 | mask_c.green = 0xffff - c.g; |
|
|
1265 | mask_c.blue = 0xffff - c.b; |
|
|
1266 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1267 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
1268 | result |= transpPmapTinted; |
|
|
1269 | } |
|
|
1270 | |
|
|
1271 | XRenderFreePicture (dpy, mask_pic); |
|
|
1272 | XRenderFreePicture (dpy, overlay_pic); |
|
|
1273 | XRenderFreePicture (dpy, back_pic); |
|
|
1274 | # if DO_TIMING_TEST |
|
|
1275 | XSync (dpy, False); |
|
|
1276 | # endif |
|
|
1277 | # endif |
|
|
1278 | } |
|
|
1279 | } |
1302 | } |
1280 | } /* server side rendering completed */ |
1303 | } /* server side rendering completed */ |
1281 | |
1304 | |
1282 | if (pixmap) |
1305 | if (pixmap) |
1283 | XFreePixmap (dpy, pixmap); |
1306 | XFreePixmap (dpy, pixmap); |