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.59 by sf-exg, Wed Sep 8 22:17:06 2010 UTC vs.
Revision 1.78 by sf-exg, Wed Oct 13 10:27:22 2010 UTC

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}
138# endif 141# endif
139 142
140# ifdef BG_IMAGE_FROM_FILE 143# ifdef BG_IMAGE_FROM_FILE
141 if (have_image) 144 if (have_image)
142 { 145 {
143 if (h_scale != 0 || v_scale != 0 146 if (flags & sizeSensitive)
144 || h_align != 0 || v_align != 0)
145 return true; 147 return true;
146 } 148 }
147# endif 149# endif
148 150
149 return false; 151 return false;
158# endif 160# endif
159 161
160# ifdef BG_IMAGE_FROM_FILE 162# ifdef BG_IMAGE_FROM_FILE
161 if (have_image) 163 if (have_image)
162 { 164 {
163 if (h_align == rootAlign || v_align == rootAlign) 165 if (flags & rootAlign)
164 return true; 166 return true;
165 } 167 }
166# endif 168# endif
167 169
168 return false; 170 return false;
208static inline bool 210static inline bool
209check_set_align_value (int geom_flags, int flag, int &align, int new_value) 211check_set_align_value (int geom_flags, int flag, int &align, int new_value)
210{ 212{
211 if (geom_flags & flag) 213 if (geom_flags & flag)
212 { 214 {
213 if (new_value != bgPixmap_t::rootAlign)
214 {
215 if (new_value < -100) 215 if (new_value < -100)
216 new_value = -100; 216 new_value = -100;
217 else if (new_value > 200) 217 else if (new_value > 200)
218 new_value = 200; 218 new_value = 200;
219 }
220 if (new_value != align) 219 if (new_value != align)
221 { 220 {
222 align = new_value; 221 align = new_value;
223 return true; 222 return true;
224 } 223 }
230make_align_position (int align, int window_size, int image_size) 229make_align_position (int align, int window_size, int image_size)
231{ 230{
232 int diff = window_size - image_size; 231 int diff = window_size - image_size;
233 int smaller = min (image_size, window_size); 232 int smaller = min (image_size, window_size);
234 233
235 if (align >= 0 && align <= 50) 234 if (align >= 0 && align <= 100)
236 return diff * align / 100; 235 return diff * align / 100;
237 else if (align > 50 && align <= 100)
238 return window_size - image_size - diff * (100 - align) / 100;
239 else if (align > 100 && align <= 200 ) 236 else if (align > 100 && align <= 200 )
240 return ((align - 100) * smaller / 100) + window_size - smaller; 237 return ((align - 100) * smaller / 100) + window_size - smaller;
241 else if (align > -100 && align < 0) 238 else if (align >= -100 && align < 0)
242 return ((align + 100) * smaller / 100) - image_size; 239 return ((align + 100) * smaller / 100) - image_size;
243 return 0; 240 return 0;
244} 241}
245 242
246static inline int 243static inline int
247make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) 244make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size)
248{ 245{
249 int src_pos = 0; 246 int src_pos = 0;
250 dst_pos = 0; 247 dst_pos = pos;
251 dst_size = size; 248 dst_size = size;
252 if (pos < 0 && size > target_size) 249 if (pos < 0)
253 { 250 {
254 src_pos = -pos; 251 src_pos = -pos;
252 dst_pos = 0;
255 dst_size += pos; 253 dst_size += pos;
256 } 254 }
257 else if (pos > 0)
258 dst_pos = pos;
259 255
260 if (dst_pos + dst_size > target_size) 256 if (dst_pos + dst_size > target_size)
261 dst_size = target_size - dst_pos; 257 dst_size = target_size - dst_pos;
262 return src_pos; 258 return src_pos;
263} 259}
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 */
457bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) 448bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
458{ 449{
459 int target_width = target->szHint.width; 450 int target_width = target->szHint.width;
460 int target_height = target->szHint.height; 451 int target_height = target->szHint.height;
461 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; 462 w = h_scale * target_width / 100;
463 h = v_scale * target_height / 100; 463 h = v_scale * target_height / 100;
464 }
464 465
465 if (h_align == rootAlign || v_align == rootAlign) 466 if (!w) w = image_width;
467 if (!h) h = image_height;
468
469 if (flags & rootAlign)
466 { 470 {
467 target->get_window_origin (x, y); 471 target->get_window_origin (x, y);
468 x = -x; 472 x = -x;
469 y = -y; 473 y = -y;
470 } 474 }
471 475 else
472 if (h_align != rootAlign) 476 {
473 x = make_align_position (h_align, target_width, w > 0 ? w : image_width); 477 x = make_align_position (h_align, target_width, w);
474
475 if (v_align != rootAlign)
476 y = make_align_position (v_align, target_height, h > 0 ? h : image_height); 478 y = make_align_position (v_align, target_height, h);
479 }
480
481 flags &= ~sizeSensitive;
482 if (h_scale != 0 || v_scale != 0
483 || h_align != 0 || v_align != 0
484 || w > target_width || h > target_height)
485 flags |= sizeSensitive;
477} 486}
478 487
479# ifdef HAVE_AFTERIMAGE 488# ifdef HAVE_AFTERIMAGE
480bool 489bool
481bgPixmap_t::render_image (unsigned long background_flags) 490bgPixmap_t::render_image (unsigned long background_flags)
493 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);
494 503
495 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 504 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
496 { 505 {
497 ShadingInfo as_shade; 506 ShadingInfo as_shade;
498 as_shade.shading = (shade == 0) ? 100 : shade; 507 as_shade.shading = shade;
499 508
500 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 509 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
501 if (flags & tintSet) 510 if (flags & tintSet)
502 tint.get (c); 511 tint.get (c);
503 as_shade.tintColor.red = c.r; 512 as_shade.tintColor.red = c.r;
505 as_shade.tintColor.blue = c.b; 514 as_shade.tintColor.blue = c.b;
506 515
507 background_tint = shading2tint32 (&as_shade); 516 background_tint = shading2tint32 (&as_shade);
508 } 517 }
509 518
510 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 519 if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL)
511 { 520 {
512 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,
513 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, 522 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage,
514 100, ASIMAGE_QUALITY_DEFAULT); 523 100, ASIMAGE_QUALITY_DEFAULT);
515 if (tmp) 524 if (tmp)
536 545
537 if (original_asim) 546 if (original_asim)
538 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);
539 548
540 if (!original_asim 549 if (!original_asim
550 || (!(flags & rootAlign)
541 || x >= target_width 551 && (x >= target_width
542 || y >= target_height 552 || y >= target_height
543 || (w > 0 && x + w <= 0) 553 || (x + w <= 0)
544 || (h > 0 && y + h <= 0)) 554 || (y + h <= 0))))
545 { 555 {
546 if (background) 556 if (background)
547 { 557 {
548 new_pmap_width = background->width; 558 new_pmap_width = background->width;
549 new_pmap_height = background->height; 559 new_pmap_height = background->height;
563 } 573 }
564 else 574 else
565 { 575 {
566 result = original_asim; 576 result = original_asim;
567 577
568 if ((w > 0 && w != original_asim->width) 578 if ((w != original_asim->width)
569 || (h > 0 && h != original_asim->height)) 579 || (h != original_asim->height))
570 { 580 {
571 result = scale_asimage (target->asv, original_asim, 581 result = scale_asimage (target->asv, original_asim,
572 w > 0 ? w : original_asim->width, 582 w, h,
573 h > 0 ? h : original_asim->height,
574 background ? ASA_ASImage : ASA_XImage, 583 background ? ASA_ASImage : ASA_XImage,
575 100, ASIMAGE_QUALITY_DEFAULT); 584 100, ASIMAGE_QUALITY_DEFAULT);
576 } 585 }
577 586
578 if (background == NULL) 587 if (background == NULL)
610 layers[0].clip_width = target_width; 619 layers[0].clip_width = target_width;
611 layers[0].clip_height = target_height; 620 layers[0].clip_height = target_height;
612 layers[0].tint = background_tint; 621 layers[0].tint = background_tint;
613 layers[1].im = result; 622 layers[1].im = result;
614 623
615 if (w <= 0) 624 if (h_scale == 0 || v_scale == 0)
616 { 625 {
617 /* tile horizontally */ 626 /* tile horizontally */
618 while (x > 0) x -= (int)result->width; 627 while (x > 0) x -= (int)result->width;
619 layers[1].dst_x = x; 628 layers[1].dst_x = x;
620 layers[1].clip_width = result->width+target_width; 629 layers[1].clip_width = result->width+target_width;
624 /* clip horizontally */ 633 /* clip horizontally */
625 layers[1].dst_x = x; 634 layers[1].dst_x = x;
626 layers[1].clip_width = result->width; 635 layers[1].clip_width = result->width;
627 } 636 }
628 637
629 if (h <= 0) 638 if (h_scale == 0 || v_scale == 0)
630 { 639 {
631 while (y > 0) y -= (int)result->height; 640 while (y > 0) y -= (int)result->height;
632 layers[1].dst_y = y; 641 layers[1].dst_y = y;
633 layers[1].clip_height = result->height + target_height; 642 layers[1].clip_height = result->height + target_height;
634 } 643 }
756 int w = 0; 765 int w = 0;
757 int h = 0; 766 int h = 0;
758 767
759 get_image_geometry (image_width, image_height, w, h, x, y); 768 get_image_geometry (image_width, image_height, w, h, x, y);
760 769
770 if (!(flags & rootAlign)
761 if (x >= target_width 771 && (x >= target_width
762 || y >= target_height 772 || y >= target_height
763 || (w > 0 && x + w <= 0) 773 || (x + w <= 0)
764 || (h > 0 && y + h <= 0)) 774 || (y + h <= 0)))
765 return false; 775 return false;
766 776
767 result = pixbuf; 777 result = pixbuf;
768 778
769 if ((w > 0 && w != image_width) 779 if ((w != image_width)
770 || (h > 0 && h != image_height)) 780 || (h != image_height))
771 { 781 {
772 result = gdk_pixbuf_scale_simple (pixbuf, 782 result = gdk_pixbuf_scale_simple (pixbuf,
773 w > 0 ? w : image_width, 783 w, h,
774 h > 0 ? h : image_height,
775 GDK_INTERP_BILINEAR); 784 GDK_INTERP_BILINEAR);
776 } 785 }
777 786
778 bool ret = false; 787 bool ret = false;
779 788
953static inline unsigned long 962static inline unsigned long
954compute_tint_shade_flags (rxvt_color *tint, int shade) 963compute_tint_shade_flags (rxvt_color *tint, int shade)
955{ 964{
956 unsigned long flags = 0; 965 unsigned long flags = 0;
957 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 966 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
958 bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); 967 bool has_shade = shade != 100;
959 968
960 if (tint) 969 if (tint)
961 { 970 {
962 tint->get (c); 971 tint->get (c);
963# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) 972# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
995} 1004}
996 1005
997bool 1006bool
998bgPixmap_t::set_tint (rxvt_color &new_tint) 1007bgPixmap_t::set_tint (rxvt_color &new_tint)
999{ 1008{
1000 if (tint != new_tint) 1009 if (!(flags & tintSet) || tint != new_tint)
1001 { 1010 {
1002 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 1011 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
1003 tint = new_tint; 1012 tint = new_tint;
1004 flags = (flags & ~tintFlags) | new_flags | tintSet; 1013 flags = (flags & ~tintFlags) | new_flags | tintSet;
1005 return true; 1014 return true;
1023} 1032}
1024 1033
1025bool 1034bool
1026bgPixmap_t::set_shade (const char *shade_str) 1035bgPixmap_t::set_shade (const char *shade_str)
1027{ 1036{
1028 int new_shade = (shade_str) ? atoi (shade_str) : 0; 1037 int new_shade = (shade_str) ? atoi (shade_str) : 100;
1029 1038
1030 if (new_shade < 0 && new_shade > -100) 1039 clamp_it (new_shade, -100, 200);
1040 if (new_shade < 0)
1031 new_shade = 200 - (100 + new_shade); 1041 new_shade = 200 - (100 + new_shade);
1032 else if (new_shade == 100)
1033 new_shade = 0;
1034 1042
1035 if (new_shade != shade) 1043 if (new_shade != shade)
1036 { 1044 {
1037 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);
1038 shade = new_shade; 1046 shade = new_shade;
1039 flags = (flags & (~tintFlags | tintSet)) | new_flags; 1047 flags = (flags & (~tintFlags | tintSet)) | new_flags;
1040 return true; 1048 return true;
1041 } 1049 }
1042 1050
1043 return false; 1051 return false;
1052}
1053
1054bool
1055bgPixmap_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;
1044} 1144}
1045 1145
1046/* make_transparency_pixmap() 1146/* make_transparency_pixmap()
1047 * 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
1048 * 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
1078 || sx >= root_width || sy >= root_height) 1178 || sx >= root_width || sy >= root_height)
1079 return 0; 1179 return 0;
1080 1180
1081 if (root_pixmap != None) 1181 if (root_pixmap != None)
1082 { 1182 {
1083 /* we want to validate the pixmap and get it's size at the same time : */ 1183 /* we want to validate the pixmap and get its size at the same time : */
1084 int junk; 1184 int junk;
1085 unsigned int ujunk; 1185 unsigned int ujunk;
1086 /* root pixmap may be bad - allow a error */ 1186 /* root pixmap may be bad - allow a error */
1087 target->allowedxerror = -1; 1187 target->allowedxerror = -1;
1088 1188
1178 { 1278 {
1179 if (!need_client_side_rendering ()) 1279 if (!need_client_side_rendering ())
1180 { 1280 {
1181 if ((flags & tintNeeded)) 1281 if ((flags & tintNeeded))
1182 { 1282 {
1183 if (flags & tintWholesome) 1283 if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height))
1184 {
1185 /* In this case we can tint image server-side getting significant
1186 * performance improvements, as we eliminate XImage transfer
1187 */
1188 gcv.foreground = Pixel (tint);
1189 gcv.function = GXand;
1190 gcv.fill_style = FillSolid;
1191 if (gc)
1192 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv);
1193 else
1194 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
1195 if (gc)
1196 {
1197 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1198 result |= transpPmapTinted; 1284 result |= transpPmapTinted;
1199 }
1200 }
1201 else
1202 {
1203# if XFT
1204 Picture back_pic = 0;
1205 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1206
1207 if (flags & tintSet)
1208 tint.get (c);
1209
1210 if (shade > 0 && shade < 100)
1211 {
1212 c.r = (c.r * shade) / 100;
1213 c.g = (c.g * shade) / 100;
1214 c.b = (c.b * shade) / 100;
1215 }
1216 else if (shade > 100 && shade < 200)
1217 {
1218 c.r = (c.r * (200 - shade)) / 100;
1219 c.g = (c.g * (200 - shade)) / 100;
1220 c.b = (c.b * (200 - shade)) / 100;
1221 }
1222
1223 XRenderPictFormat pf;
1224 pf.type = PictTypeDirect;
1225 pf.depth = 32;
1226 pf.direct.redMask = 0xff;
1227 pf.direct.greenMask = 0xff;
1228 pf.direct.blueMask = 0xff;
1229 pf.direct.alphaMask = 0xff;
1230
1231 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
1232 (PictFormatType|
1233 PictFormatDepth|
1234 PictFormatRedMask|
1235 PictFormatGreenMask|
1236 PictFormatBlueMask|
1237 PictFormatAlphaMask),
1238 &pf,
1239 0);
1240 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
1241 XRenderPictureAttributes pa ;
1242
1243 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa);
1244
1245 pa.repeat = True;
1246
1247 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1248 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1249 XFreePixmap (dpy, overlay_pmap);
1250
1251 pa.component_alpha = True;
1252 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1253 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
1254 XFreePixmap (dpy, mask_pmap);
1255
1256 if (mask_pic && overlay_pic && back_pic)
1257 {
1258 XRenderColor mask_c;
1259
1260 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c));
1261 mask_c.alpha = 0xffff;
1262 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1263
1264 mask_c.alpha = 0;
1265 mask_c.red = 0xffff - c.r;
1266 mask_c.green = 0xffff - c.g;
1267 mask_c.blue = 0xffff - c.b;
1268 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1269 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
1270 result |= transpPmapTinted;
1271 }
1272
1273 XRenderFreePicture (dpy, mask_pic);
1274 XRenderFreePicture (dpy, overlay_pic);
1275 XRenderFreePicture (dpy, back_pic);
1276# if DO_TIMING_TEST
1277 XSync (dpy, False);
1278# endif
1279# endif
1280 }
1281 } 1285 }
1282 } /* server side rendering completed */ 1286 } /* server side rendering completed */
1283 1287
1284 if (pixmap) 1288 if (pixmap)
1285 XFreePixmap (dpy, pixmap); 1289 XFreePixmap (dpy, pixmap);
1525 int i; 1529 int i;
1526 1530
1527 Visual *visual = term->visual; 1531 Visual *visual = term->visual;
1528 1532
1529 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; 1533 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ;
1530
1531 if (shade == 0)
1532 shade = 100;
1533 1534
1534 /* for convenience */ 1535 /* for convenience */
1535 mask_r = visual->red_mask; 1536 mask_r = visual->red_mask;
1536 mask_g = visual->green_mask; 1537 mask_g = visual->green_mask;
1537 mask_b = visual->blue_mask; 1538 mask_b = visual->blue_mask;
1593 default: 1594 default:
1594 return; /* we do not support this color depth */ 1595 return; /* we do not support this color depth */
1595 } 1596 }
1596 1597
1597 /* prepare limits for color transformation (each channel is handled separately) */ 1598 /* prepare limits for color transformation (each channel is handled separately) */
1598 if (shade < 0) { 1599 if (shade > 100) {
1599 shade = -shade; 1600 shade = 200 - shade;
1600 if (shade < 0) shade = 0;
1601 if (shade > 100) shade = 100;
1602 1601
1603 lower_lim_r = 65535-rm; 1602 lower_lim_r = 65535-rm;
1604 lower_lim_g = 65535-gm; 1603 lower_lim_g = 65535-gm;
1605 lower_lim_b = 65535-bm; 1604 lower_lim_b = 65535-bm;
1606 1605
1608 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);
1609 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);
1610 1609
1611 upper_lim_r = upper_lim_g = upper_lim_b = 65535; 1610 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1612 } else { 1611 } else {
1613 if (shade < 0) shade = 0;
1614 if (shade > 100) shade = 100;
1615 1612
1616 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1613 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1617 1614
1618 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); 1615 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
1619 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); 1616 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines