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.109 by sf-exg, Tue Nov 2 22:01:47 2010 UTC vs.
Revision 1.132 by sf-exg, Mon Jan 10 20:46:20 2011 UTC

28 28
29#if XRENDER 29#if XRENDER
30# include <X11/extensions/Xrender.h> 30# include <X11/extensions/Xrender.h>
31#endif 31#endif
32 32
33#ifndef FilterConvolution
34#define FilterConvolution "convolution"
35#endif
36
33#define DO_TIMING_TEST 0 37#define DO_TIMING_TEST 0
34 38
35#if DO_TIMING_TEST 39#if DO_TIMING_TEST
36# include <sys/time.h> 40# include <sys/time.h>
37#define TIMING_TEST_START(id) \ 41#define TIMING_TEST_START(id) \
62 * 66 *
63 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. 67 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%.
64 * W and H are percentages of the terminal window size. 68 * W and H are percentages of the terminal window size.
65 * X and Y are also percentages; e.g., +50+50 centers 69 * X and Y are also percentages; e.g., +50+50 centers
66 * the image in the window. 70 * the image in the window.
67 * WxH+X Assumes Y == X
68 * WxH Assumes Y == X == 50 (centers the image)
69 * W+X+Y Assumes H == W
70 * W+X Assumes H == W and Y == X
71 * W Assumes H == W and Y == X == 50
72 *
73 * Adjusting position only :
74 * =+X+Y Set position to X% by Y% (absolute).
75 * =+X Set position to X% by X%.
76 * +X+Y Adjust position horizontally X% and vertically Y%
77 * from current position (relative).
78 * +X Adjust position horizontally X% and vertically X%
79 * from current position.
80 *
81 * Adjusting scale only :
82 * Wx0 Multiply horizontal scaling factor by W%
83 * 0xH Multiply vertical scaling factor by H%
84 * 0x0 No scaling (show image at normal size).
85 * 71 *
86 * Pixmap Operations : (should be prepended by a colon) 72 * Pixmap Operations : (should be prepended by a colon)
87 * tile Tile image. Scaling/position modifiers above will affect 73 * tile Tile image. Scaling/position modifiers above will affect
88 * the tile size and origin. 74 * the tile size and origin.
89 * propscale When scaling, scale proportionally. That is, maintain the 75 * propscale When scaling, scale proportionally. That is, maintain the
117#endif 103#endif
118 flags = 0; 104 flags = 0;
119 pixmap = None; 105 pixmap = None;
120 valid_since = invalid_since = 0; 106 valid_since = invalid_since = 0;
121 target = 0; 107 target = 0;
108 target_x = target_y = 0;
122} 109}
123 110
124void 111void
125bgPixmap_t::destroy () 112bgPixmap_t::destroy ()
126{ 113{
137 if (pixmap && target) 124 if (pixmap && target)
138 XFreePixmap (target->dpy, pixmap); 125 XFreePixmap (target->dpy, pixmap);
139} 126}
140 127
141bool 128bool
129bgPixmap_t::set_position (int x, int y)
130{
131
132 if (target_x != x
133 || target_y != y)
134 {
135 target_x = x;
136 target_y = y;
137 return true;
138 }
139 return false;
140}
141
142bool
142bgPixmap_t::window_size_sensitive () 143bgPixmap_t::window_size_sensitive ()
143{ 144{
144# ifdef ENABLE_TRANSPARENCY 145# ifdef ENABLE_TRANSPARENCY
145 if (flags & isTransparent) 146 if (flags & isTransparent)
146 return true; 147 return true;
171 if (flags & rootAlign) 172 if (flags & rootAlign)
172 return true; 173 return true;
173 } 174 }
174# endif 175# endif
175 176
176 return false;
177};
178
179bool bgPixmap_t::need_client_side_rendering ()
180{
181# ifdef HAVE_AFTERIMAGE
182 if (original_asim)
183 return true;
184# endif
185 return false; 177 return false;
186} 178}
187 179
188# ifdef BG_IMAGE_FROM_FILE 180# ifdef BG_IMAGE_FROM_FILE
189static inline bool 181static inline bool
252 dst_size = target_size - dst_pos; 244 dst_size = target_size - dst_pos;
253 return src_pos; 245 return src_pos;
254} 246}
255 247
256bool 248bool
257bgPixmap_t::set_geometry (const char *geom) 249bgPixmap_t::set_geometry (const char *geom, bool update)
258{ 250{
251 bool changed = false;
259 int geom_flags = 0, changed = 0; 252 int geom_flags = 0;
260 int x = 0, y = 0; 253 int x = 0, y = 0;
261 unsigned int w = 0, h = 0; 254 unsigned int w = 0, h = 0;
262 unsigned int n; 255 unsigned int n;
263 unsigned long new_flags = (flags & (~geometryFlags)); 256 unsigned long new_flags = (flags & (~geometryFlags));
264 const char *p; 257 const char *ops;
265# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 258# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
266 259
267 if (geom == NULL) 260 if (geom == NULL)
268 return false; 261 return false;
269 262
270 char str[MAXLEN_GEOM]; 263 char str[MAXLEN_GEOM];
271 264
272 while (isspace(*geom)) ++geom;
273 if ((p = strchr (geom, ';')) == NULL)
274 p = strchr (geom, '\0'); 265 ops = strchr (geom, ':');
275 266 if (ops == NULL)
267 n = strlen (geom);
268 else
276 n = (p - geom); 269 n = ops - geom;
270
277 if (n < MAXLEN_GEOM) 271 if (n >= MAXLEN_GEOM)
278 { 272 return false;
279 char *ops;
280 new_flags |= geometrySet;
281 273
282 memcpy (str, geom, n); 274 memcpy (str, geom, n);
283 str[n] = '\0'; 275 str[n] = '\0';
284 if (str[0] == ':') 276 rxvt_strtrim (str);
285 ops = &str[0];
286 else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0]))
287 ops = &str[0];
288 else
289 {
290 char *tmp;
291 ops = strchr (str, ':');
292 if (ops != NULL)
293 {
294 for (tmp = ops-1; tmp >= str && isspace(*tmp); --tmp);
295 *(++tmp) = '\0';
296 if (ops == tmp) ++ops;
297 }
298 }
299 277
300 if (ops > str || ops == NULL) 278 if (str[0])
301 { 279 {
302 /* we have geometry string - let's handle it prior to applying ops */ 280 /* we have geometry string - let's handle it prior to applying ops */
303 geom_flags = XParseGeometry (str, &x, &y, &w, &h); 281 geom_flags = XParseGeometry (str, &x, &y, &w, &h);
304
305 if ((geom_flags & XValue) && !(geom_flags & YValue))
306 {
307 y = x;
308 geom_flags |= YValue;
309 }
310
311 if (flags & geometrySet)
312 {
313 /* new geometry is an adjustment to the old one ! */
314 if ((geom_flags & WidthValue) && (geom_flags & HeightValue))
315 {
316 if (w == 0 && h != 0)
317 {
318 w = h_scale;
319 h = (v_scale * h) / 100;
320 }
321 else if (h == 0 && w != 0)
322 {
323 w = (h_scale * w) / 100;
324 h = v_scale;
325 }
326 }
327 if (geom_flags & XValue)
328 {
329 if (str[0] != '=')
330 {
331 y += v_align;
332 x += h_align;
333 }
334 }
335 }
336 else /* setting up geometry from scratch */
337 {
338 if (!(geom_flags & XValue))
339 {
340 /* use default geometry - centered */
341 x = y = defaultAlign;
342 }
343 else if (!(geom_flags & YValue))
344 y = x;
345
346 if ((geom_flags & (WidthValue|HeightValue)) == 0)
347 {
348 /* use default geometry - scaled */
349 w = h = defaultScale;
350 }
351 else if (geom_flags & WidthValue)
352 {
353 if (!(geom_flags & HeightValue))
354 h = w;
355 }
356 else
357 w = h;
358 }
359 } /* done parsing geometry string */ 282 } /* done parsing geometry string */
360 else if (!(flags & geometrySet)) 283
361 { 284 if (!update)
362 /* default geometry - scaled and centered */ 285 {
286 if (!(geom_flags & XValue))
363 x = y = defaultAlign; 287 x = y = defaultAlign;
288 else if (!(geom_flags & YValue))
289 y = x;
290
291 if (!(geom_flags & (WidthValue|HeightValue)))
364 w = h = defaultScale; 292 w = h = defaultScale;
365 } 293 else if (!(geom_flags & HeightValue))
294 h = w;
295 else if (!(geom_flags & WidthValue))
296 w = h;
366 297
367 if (!(flags & geometrySet))
368 geom_flags |= WidthValue|HeightValue|XValue|YValue; 298 geom_flags |= WidthValue|HeightValue|XValue|YValue;
299 }
369 300
370 if (ops) 301 if (ops)
371 { 302 {
372 while (*ops) 303 char **arr = rxvt_strsplit (':', ops + 1);
304
305 for (int i = 0; arr[i]; i++)
373 { 306 {
374 while (*ops == ':' || isspace(*ops)) ++ops;
375
376# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) 307# define CHECK_GEOM_OPS(op_str) (strcasecmp (arr[i], (op_str)) == 0)
377 if (CHECK_GEOM_OPS ("tile")) 308 if (CHECK_GEOM_OPS ("tile"))
378 { 309 {
379 w = h = noScale; 310 w = h = noScale;
380 geom_flags |= WidthValue|HeightValue; 311 geom_flags |= WidthValue|HeightValue;
381 } 312 }
382 else if (CHECK_GEOM_OPS ("propscale")) 313 else if (CHECK_GEOM_OPS ("propscale"))
383 { 314 {
384 new_flags |= propScale; 315 new_flags |= propScale;
385 } 316 }
386 else if (CHECK_GEOM_OPS ("hscale")) 317 else if (CHECK_GEOM_OPS ("hscale"))
387 { 318 {
388 if (w == 0) w = windowScale; 319 if (w == 0) w = windowScale;
389 320
390 h = noScale; 321 h = noScale;
391 geom_flags |= WidthValue|HeightValue; 322 geom_flags |= WidthValue|HeightValue;
392 } 323 }
393 else if (CHECK_GEOM_OPS ("vscale")) 324 else if (CHECK_GEOM_OPS ("vscale"))
394 { 325 {
395 if (h == 0) h = windowScale; 326 if (h == 0) h = windowScale;
396 327
397 w = noScale; 328 w = noScale;
398 geom_flags |= WidthValue|HeightValue; 329 geom_flags |= WidthValue|HeightValue;
399 } 330 }
400 else if (CHECK_GEOM_OPS ("scale")) 331 else if (CHECK_GEOM_OPS ("scale"))
401 { 332 {
402 if (h == 0) h = windowScale; 333 if (h == 0) h = windowScale;
403 if (w == 0) w = windowScale; 334 if (w == 0) w = windowScale;
404 335
405 geom_flags |= WidthValue|HeightValue; 336 geom_flags |= WidthValue|HeightValue;
406 } 337 }
407 else if (CHECK_GEOM_OPS ("auto")) 338 else if (CHECK_GEOM_OPS ("auto"))
408 { 339 {
409 w = h = windowScale; 340 w = h = windowScale;
410 x = y = centerAlign; 341 x = y = centerAlign;
411 geom_flags |= WidthValue|HeightValue|XValue|YValue; 342 geom_flags |= WidthValue|HeightValue|XValue|YValue;
412 } 343 }
413 else if (CHECK_GEOM_OPS ("root")) 344 else if (CHECK_GEOM_OPS ("root"))
414 { 345 {
415 new_flags |= rootAlign; 346 new_flags |= rootAlign;
416 w = h = noScale; 347 w = h = noScale;
417 geom_flags |= WidthValue|HeightValue; 348 geom_flags |= WidthValue|HeightValue;
418 } 349 }
419# undef CHECK_GEOM_OPS 350# undef CHECK_GEOM_OPS
420
421 while (*ops != ':' && *ops != '\0') ++ops;
422 } /* done parsing ops */ 351 } /* done parsing ops */
423 }
424 352
353 rxvt_free_strsplit (arr);
354 }
355
425 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) ++changed; 356 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true;
426 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) ++changed; 357 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true;
427 if (check_set_align_value (geom_flags, XValue, h_align, x)) ++changed; 358 if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true;
428 if (check_set_align_value (geom_flags, YValue, v_align, y)) ++changed; 359 if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true;
429 }
430 360
431 if (new_flags != flags) 361 if (new_flags != flags)
432 { 362 {
433 flags = new_flags; 363 flags = new_flags;
434 changed++; 364 changed = true;
435 } 365 }
436 366
437 return (changed > 0); 367 return changed;
438} 368}
439 369
440void 370void
441bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) 371bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
442{ 372{
459 if (!w) w = image_width; 389 if (!w) w = image_width;
460 if (!h) h = image_height; 390 if (!h) h = image_height;
461 391
462 if (flags & rootAlign) 392 if (flags & rootAlign)
463 { 393 {
464 target->get_window_origin (x, y);
465 x = -x; 394 x = -target_x;
466 y = -y; 395 y = -target_y;
467 } 396 }
468 else 397 else
469 { 398 {
470 x = make_align_position (h_align, target_width, w); 399 x = make_align_position (h_align, target_width, w);
471 y = make_align_position (v_align, target_height, h); 400 y = make_align_position (v_align, target_height, h);
665 if (result) 594 if (result)
666 { 595 {
667 XGCValues gcv; 596 XGCValues gcv;
668 GC gc; 597 GC gc;
669 598
670 if (pixmap)
671 {
672 if (pmap_width != new_pmap_width
673 || pmap_height != new_pmap_height
674 || pmap_depth != target->depth)
675 {
676 XFreePixmap (target->dpy, pixmap);
677 pixmap = None;
678 }
679 }
680
681 /* create Pixmap */ 599 /* create Pixmap */
682 if (pixmap == None) 600 if (pixmap == None
601 || pmap_width != new_pmap_width
602 || pmap_height != new_pmap_height
603 || pmap_depth != target->depth)
683 { 604 {
605 if (pixmap)
606 XFreePixmap (target->dpy, pixmap);
684 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 607 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
685 pmap_width = new_pmap_width; 608 pmap_width = new_pmap_width;
686 pmap_height = new_pmap_height; 609 pmap_height = new_pmap_height;
687 pmap_depth = target->depth; 610 pmap_depth = target->depth;
688 } 611 }
724 return ret; 647 return ret;
725} 648}
726# endif /* HAVE_AFTERIMAGE */ 649# endif /* HAVE_AFTERIMAGE */
727 650
728# ifdef HAVE_PIXBUF 651# ifdef HAVE_PIXBUF
652bool
653bgPixmap_t::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
654 int src_x, int src_y, int dst_x, int dst_y,
655 unsigned int width, unsigned int height)
656{
657 XImage *ximage;
658 char *data, *line;
659 int bytes_per_pixel;
660 int width_r, width_g, width_b;
661 int sh_r, sh_g, sh_b;
662 int rowstride;
663 int channels;
664 unsigned char *row;
665 Visual *visual = target->visual;
666 int depth = target->depth;
667
668 if (visual->c_class != TrueColor)
669 return false;
670
671 if (depth == 24 || depth == 32)
672 bytes_per_pixel = 4;
673 else if (depth == 15 || depth == 16)
674 bytes_per_pixel = 2;
675 else
676 return false;
677
678 width_r = rxvt_popcount (visual->red_mask);
679 width_g = rxvt_popcount (visual->green_mask);
680 width_b = rxvt_popcount (visual->blue_mask);
681
682 if (width_r > 8 || width_g > 8 || width_b > 8)
683 return false;
684
685 sh_r = rxvt_ctz (visual->red_mask);
686 sh_g = rxvt_ctz (visual->green_mask);
687 sh_b = rxvt_ctz (visual->blue_mask);
688
689 if (width > INT_MAX / height / bytes_per_pixel)
690 return false;
691
692 data = (char *)malloc (width * height * bytes_per_pixel);
693 if (!data)
694 return false;
695
696 ximage = XCreateImage (target->dpy, visual, depth, ZPixmap, 0, data,
697 width, height, bytes_per_pixel * 8, 0);
698 if (!ximage)
699 {
700 free (data);
701 return false;
702 }
703
704 ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst;
705
706 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
707 channels = gdk_pixbuf_get_n_channels (pixbuf);
708 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
709 line = data;
710
711 for (int y = 0; y < height; y++)
712 {
713 for (int x = 0; x < width; x++)
714 {
715 unsigned char *pixel = row + x * channels;
716 uint32_t value;
717
718 value = ((pixel[0] >> (8 - width_r)) << sh_r)
719 | ((pixel[1] >> (8 - width_g)) << sh_g)
720 | ((pixel[2] >> (8 - width_b)) << sh_b);
721
722 if (bytes_per_pixel == 4)
723 ((uint32_t *)line)[x] = value;
724 else
725 ((uint16_t *)line)[x] = value;
726 }
727
728 row += rowstride;
729 line += ximage->bytes_per_line;
730 }
731
732 XPutImage (target->dpy, pixmap, gc, ximage, 0, 0, dst_x, dst_y, width, height);
733 XDestroyImage (ximage);
734 return true;
735}
736
729bool 737bool
730bgPixmap_t::render_image (unsigned long background_flags) 738bgPixmap_t::render_image (unsigned long background_flags)
731{ 739{
732 if (target == NULL) 740 if (target == NULL)
733 return false; 741 return false;
796 new_pmap_width = min (image_width, target_width); 804 new_pmap_width = min (image_width, target_width);
797 new_pmap_height = min (image_height, target_height); 805 new_pmap_height = min (image_height, target_height);
798 } 806 }
799 } 807 }
800 808
801 if (pixmap)
802 {
803 if (pmap_width != new_pmap_width
804 || pmap_height != new_pmap_height
805 || pmap_depth != target->depth)
806 {
807 XFreePixmap (target->dpy, pixmap);
808 pixmap = None;
809 }
810 }
811
812 if (pixmap == None) 809 if (pixmap == None
810 || pmap_width != new_pmap_width
811 || pmap_height != new_pmap_height
812 || pmap_depth != target->depth)
813 { 813 {
814 if (pixmap)
815 XFreePixmap (target->dpy, pixmap);
814 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 816 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
815 pmap_width = new_pmap_width; 817 pmap_width = new_pmap_width;
816 pmap_height = new_pmap_height; 818 pmap_height = new_pmap_height;
817 pmap_depth = target->depth; 819 pmap_depth = target->depth;
818 } 820 }
821 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); 823 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv);
822 824
823 if (h_scale == 0 || v_scale == 0) 825 if (h_scale == 0 || v_scale == 0)
824 { 826 {
825 Pixmap tile = XCreatePixmap (target->dpy, target->vt, image_width, image_height, target->depth); 827 Pixmap tile = XCreatePixmap (target->dpy, target->vt, image_width, image_height, target->depth);
826 gdk_pixbuf_xlib_render_to_drawable (result, tile, gc, 828 pixbuf_to_pixmap (result, tile, gc,
827 0, 0, 829 0, 0,
828 0, 0, 830 0, 0,
829 image_width, image_height, 831 image_width, image_height);
830 XLIB_RGB_DITHER_NONE,
831 0, 0);
832 832
833 gcv.tile = tile; 833 gcv.tile = tile;
834 gcv.fill_style = FillTiled; 834 gcv.fill_style = FillTiled;
835 gcv.ts_x_origin = x; 835 gcv.ts_x_origin = x;
836 gcv.ts_y_origin = y; 836 gcv.ts_y_origin = y;
851 || dst_x + dst_width < new_pmap_width 851 || dst_x + dst_width < new_pmap_width
852 || dst_y + dst_height < new_pmap_height) 852 || dst_y + dst_height < new_pmap_height)
853 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 853 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
854 854
855 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 855 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
856 gdk_pixbuf_xlib_render_to_drawable (result, pixmap, gc, 856 pixbuf_to_pixmap (result, pixmap, gc,
857 src_x, src_y, 857 src_x, src_y,
858 dst_x, dst_y, 858 dst_x, dst_y,
859 dst_width, dst_height, 859 dst_width, dst_height);
860 XLIB_RGB_DITHER_NONE,
861 0, 0);
862 } 860 }
863 861
864#if XRENDER 862#if XRENDER
865 if (background_flags) 863 if (background_flags)
866 { 864 {
933 if (image) 931 if (image)
934 { 932 {
935 if (original_asim) 933 if (original_asim)
936 safe_asimage_destroy (original_asim); 934 safe_asimage_destroy (original_asim);
937 original_asim = image; 935 original_asim = image;
936 flags |= CLIENT_RENDER;
938 have_image = true; 937 have_image = true;
939 return true; 938 return true;
940 } 939 }
941# endif 940# endif
942 941
971} 970}
972 971
973bool 972bool
974bgPixmap_t::set_blur_radius (const char *geom) 973bgPixmap_t::set_blur_radius (const char *geom)
975{ 974{
976 int changed = 0; 975 bool changed = false;
977 unsigned int hr, vr; 976 unsigned int hr, vr;
978 int junk; 977 int junk;
979 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); 978 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);
980 979
981 if (!(geom_flags & WidthValue)) 980 if (!(geom_flags & WidthValue))
986 min_it (hr, 128); 985 min_it (hr, 128);
987 min_it (vr, 128); 986 min_it (vr, 128);
988 987
989 if (h_blurRadius != hr) 988 if (h_blurRadius != hr)
990 { 989 {
991 ++changed; 990 changed = true;
992 h_blurRadius = hr; 991 h_blurRadius = hr;
993 } 992 }
994 993
995 if (v_blurRadius != vr) 994 if (v_blurRadius != vr)
996 { 995 {
997 ++changed; 996 changed = true;
998 v_blurRadius = vr; 997 v_blurRadius = vr;
999 } 998 }
1000 999
1001 if (v_blurRadius == 0 && h_blurRadius == 0) 1000 if (v_blurRadius == 0 && h_blurRadius == 0)
1002 flags &= ~blurNeeded; 1001 flags &= ~blurNeeded;
1003 else 1002 else
1004 flags |= blurNeeded; 1003 flags |= blurNeeded;
1005 1004
1006 return (changed > 0); 1005 return changed;
1007} 1006}
1008 1007
1009static inline unsigned long 1008static inline unsigned long
1010compute_tint_shade_flags (rxvt_color *tint, int shade) 1009compute_tint_shade_flags (rxvt_color *tint, int shade)
1011{ 1010{
1014 bool has_shade = shade != 100; 1013 bool has_shade = shade != 100;
1015 1014
1016 if (tint) 1015 if (tint)
1017 { 1016 {
1018 tint->get (c); 1017 tint->get (c);
1019# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) 1018# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x00ff || (cmp) >= 0xff00)
1019 if (!has_shade
1020 if (!has_shade && IS_COMPONENT_WHOLESOME (c.r) 1020 && IS_COMPONENT_WHOLESOME (c.r)
1021 && IS_COMPONENT_WHOLESOME (c.g) 1021 && IS_COMPONENT_WHOLESOME (c.g)
1022 && IS_COMPONENT_WHOLESOME (c.b)) 1022 && IS_COMPONENT_WHOLESOME (c.b))
1023 flags |= bgPixmap_t::tintWholesome; 1023 flags |= bgPixmap_t::tintWholesome;
1024# undef IS_COMPONENT_WHOLESOME 1024# undef IS_COMPONENT_WHOLESOME
1025 } 1025 }
1026 1026
1027 if (has_shade) 1027 if (has_shade || tint)
1028 flags |= bgPixmap_t::tintNeeded; 1028 flags |= bgPixmap_t::tintNeeded;
1029 else if (tint)
1030 {
1031 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
1032 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
1033 {
1034 flags |= bgPixmap_t::tintNeeded;
1035 }
1036 }
1037 1029
1038 return flags; 1030 return flags;
1039} 1031}
1040 1032
1041bool 1033bool
1044 if (!(flags & tintSet) || tint != new_tint) 1036 if (!(flags & tintSet) || tint != new_tint)
1045 { 1037 {
1046 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 1038 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
1047 tint = new_tint; 1039 tint = new_tint;
1048 flags = (flags & ~tintFlags) | new_flags | tintSet; 1040 flags = (flags & ~tintFlags) | new_flags | tintSet;
1049 return true;
1050 }
1051
1052 return false;
1053}
1054
1055bool
1056bgPixmap_t::unset_tint ()
1057{
1058 unsigned long new_flags = compute_tint_shade_flags (NULL, shade);
1059
1060 if (new_flags != (flags & tintFlags))
1061 {
1062 flags = (flags & ~tintFlags) | new_flags;
1063 return true; 1041 return true;
1064 } 1042 }
1065 1043
1066 return false; 1044 return false;
1067} 1045}
1212 c.g = (c.g * shade) / 100; 1190 c.g = (c.g * shade) / 100;
1213 c.b = (c.b * shade) / 100; 1191 c.b = (c.b * shade) / 100;
1214 } 1192 }
1215 else 1193 else
1216 { 1194 {
1217 c.r = ((0xffff - c.r) * (200 - shade)) / 100; 1195 c.r = (c.r * (200 - shade)) / 100;
1218 c.g = ((0xffff - c.g) * (200 - shade)) / 100; 1196 c.g = (c.g * (200 - shade)) / 100;
1219 c.b = ((0xffff - c.b) * (200 - shade)) / 100; 1197 c.b = (c.b * (200 - shade)) / 100;
1220 } 1198 }
1221 1199
1222 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); 1200 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1223 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1201 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1224 XRenderPictureAttributes pa; 1202 XRenderPictureAttributes pa;
1238 1216
1239 if (mask_pic && overlay_pic && back_pic) 1217 if (mask_pic && overlay_pic && back_pic)
1240 { 1218 {
1241 XRenderColor mask_c; 1219 XRenderColor mask_c;
1242 1220
1243 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); 1221 mask_c.red = mask_c.green = mask_c.blue = 0;
1244 mask_c.alpha = 0xffff; 1222 mask_c.alpha = 0xffff;
1245 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1223 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1246 1224
1247 mask_c.alpha = 0; 1225 mask_c.alpha = 0;
1248 mask_c.red = 0xffff - c.r; 1226 mask_c.red = 0xffff - c.r;
1249 mask_c.green = 0xffff - c.g; 1227 mask_c.green = 0xffff - c.g;
1250 mask_c.blue = 0xffff - c.b; 1228 mask_c.blue = 0xffff - c.b;
1251 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1229 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1252 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); 1230 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1231
1232 if (shade > 100)
1233 {
1234 mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100;
1235 mask_c.alpha = 0;
1236 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1237
1238 XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height);
1239 }
1240
1253 ret = true; 1241 ret = true;
1254 } 1242 }
1255 1243
1256 XRenderFreePicture (dpy, mask_pic); 1244 XRenderFreePicture (dpy, mask_pic);
1257 XRenderFreePicture (dpy, overlay_pic); 1245 XRenderFreePicture (dpy, overlay_pic);
1288 int window_height = target->szHint.height; 1276 int window_height = target->szHint.height;
1289 int sx, sy; 1277 int sx, sy;
1290 XGCValues gcv; 1278 XGCValues gcv;
1291 GC gc; 1279 GC gc;
1292 1280
1293 target->get_window_origin (sx, sy); 1281 sx = target_x;
1282 sy = target_y;
1294 1283
1295 /* check if we are outside of the visible part of the virtual screen : */ 1284 /* check if we are outside of the visible part of the virtual screen : */
1296 if (sx + window_width <= 0 || sy + window_height <= 0 1285 if (sx + window_width <= 0 || sy + window_height <= 0
1297 || sx >= root_width || sy >= root_height) 1286 || sx >= root_width || sy >= root_height)
1298 return 0; 1287 return 0;
1351 1340
1352 if (tiled_root_pmap == None) /* something really bad happened - abort */ 1341 if (tiled_root_pmap == None) /* something really bad happened - abort */
1353 return 0; 1342 return 0;
1354 1343
1355 /* straightforward pixmap copy */ 1344 /* straightforward pixmap copy */
1345 while (sx < 0) sx += (int)root_width;
1346 while (sy < 0) sy += (int)root_height;
1347
1356 gcv.tile = recoded_root_pmap; 1348 gcv.tile = recoded_root_pmap;
1357 gcv.fill_style = FillTiled; 1349 gcv.fill_style = FillTiled;
1358
1359 while (sx < 0) sx += (int)root_width;
1360 while (sy < 0) sy += (int)root_height;
1361
1362 gcv.ts_x_origin = -sx; 1350 gcv.ts_x_origin = -sx;
1363 gcv.ts_y_origin = -sy; 1351 gcv.ts_y_origin = -sy;
1364 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1352 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1365 1353
1366 if (gc) 1354 if (gc)
1367 { 1355 {
1368 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1356 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1369 result |= transpPmapTiled; 1357 result |= transpPmapTiled;
1370 XFreeGC (dpy, gc); 1358 XFreeGC (dpy, gc);
1371 }
1372 1359
1373 if (tiled_root_pmap != None) 1360 if (!(flags & CLIENT_RENDER))
1374 {
1375 if (!need_client_side_rendering ())
1376 { 1361 {
1377 if ((flags & blurNeeded) 1362 if ((flags & blurNeeded)
1378 && (flags & HAS_RENDER_CONV)) 1363 && (flags & HAS_RENDER_CONV))
1379 { 1364 {
1380 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height)) 1365 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1394 pixmap = tiled_root_pmap; 1379 pixmap = tiled_root_pmap;
1395 pmap_width = window_width; 1380 pmap_width = window_width;
1396 pmap_height = window_height; 1381 pmap_height = window_height;
1397 pmap_depth = target->depth; 1382 pmap_depth = target->depth;
1398 } 1383 }
1384 else
1385 XFreePixmap (dpy, tiled_root_pmap);
1399 1386
1400 if (recoded_root_pmap != root_pixmap) 1387 if (recoded_root_pmap != root_pixmap)
1401 XFreePixmap (dpy, recoded_root_pmap); 1388 XFreePixmap (dpy, recoded_root_pmap);
1402 1389
1403 return result; 1390 return result;
1404} 1391}
1405 1392
1406void 1393void
1407bgPixmap_t::set_root_pixmap () 1394bgPixmap_t::set_root_pixmap ()
1408{ 1395{
1409 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1396 Pixmap new_root_pixmap = target->get_pixmap_property (target->xa[XA_XROOTPMAP_ID]);
1410 if (new_root_pixmap == None) 1397 if (new_root_pixmap == None)
1411 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1398 new_root_pixmap = target->get_pixmap_property (target->xa[XA_ESETROOT_PMAP_ID]);
1412 1399
1413 root_pixmap = new_root_pixmap; 1400 root_pixmap = new_root_pixmap;
1414} 1401}
1415# endif /* ENABLE_TRANSPARENCY */ 1402# endif /* ENABLE_TRANSPARENCY */
1416 1403
1417# ifndef HAVE_AFTERIMAGE 1404#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1418static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1405static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c);
1419# endif 1406# endif
1420 1407
1421bool 1408bool
1422bgPixmap_t::render () 1409bgPixmap_t::render ()
1423{ 1410{
1433 /* we need to re-generate transparency pixmap in that case ! */ 1420 /* we need to re-generate transparency pixmap in that case ! */
1434 background_flags = make_transparency_pixmap (); 1421 background_flags = make_transparency_pixmap ();
1435 if (background_flags == 0) 1422 if (background_flags == 0)
1436 return false; 1423 return false;
1437 else if ((background_flags & transpTransformations) == (flags & transpTransformations)) 1424 else if ((background_flags & transpTransformations) == (flags & transpTransformations))
1438 flags = flags & ~isInvalid; 1425 flags &= ~isInvalid;
1439 } 1426 }
1440# endif 1427# endif
1441 1428
1442# ifdef BG_IMAGE_FROM_FILE 1429# ifdef BG_IMAGE_FROM_FILE
1443 if (have_image 1430 if (have_image
1444 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1431 || (background_flags & transpTransformations) != (flags & transpTransformations))
1445 { 1432 {
1446 if (render_image (background_flags)) 1433 if (render_image (background_flags))
1447 flags = flags & ~isInvalid; 1434 flags &= ~isInvalid;
1448 } 1435 }
1449# endif 1436# endif
1450 1437
1438# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1451 XImage *result = NULL; 1439 XImage *result = NULL;
1452 1440
1453 if (background_flags && (flags & isInvalid)) 1441 if (background_flags && (flags & isInvalid))
1454 { 1442 {
1455 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1443 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1456 } 1444 }
1457 1445
1458 if (result) 1446 if (result)
1459 { 1447 {
1460# if !defined(HAVE_AFTERIMAGE) && !XRENDER
1461 /* our own client-side tinting */ 1448 /* our own client-side tinting */
1462 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1449 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1463 { 1450 {
1464 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1451 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1465 if (flags & tintSet) 1452 if (flags & tintSet)
1466 tint.get (c); 1453 tint.get (c);
1467 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); 1454 shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c);
1468 } 1455 }
1469# endif
1470 1456
1471 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1457 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1472 1458
1473 if (gc) 1459 if (gc)
1474 { 1460 {
1475 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1461 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1476 1462
1477 XFreeGC (target->dpy, gc); 1463 XFreeGC (target->dpy, gc);
1478 flags = flags & ~isInvalid; 1464 flags &= ~isInvalid;
1479 } 1465 }
1480 1466
1481 XDestroyImage (result); 1467 XDestroyImage (result);
1482 } 1468 }
1469# endif
1483 1470
1484 if (flags & isInvalid) 1471 if (flags & isInvalid)
1485 { 1472 {
1486 if (pixmap != None) 1473 if (pixmap != None)
1487 { 1474 {
1573 flags |= hasChanged; 1560 flags |= hasChanged;
1574} 1561}
1575 1562
1576#endif /* HAVE_BG_PIXMAP */ 1563#endif /* HAVE_BG_PIXMAP */
1577 1564
1578#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER 1565#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1579/* taken from aterm-0.4.2 */ 1566/* taken from aterm-0.4.2 */
1580 1567
1581static void 1568static void
1582ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1569shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c)
1583{ 1570{
1584 int sh_r, sh_g, sh_b; 1571 int sh_r, sh_g, sh_b;
1585 uint32_t mask_r, mask_g, mask_b; 1572 uint32_t mask_r, mask_g, mask_b;
1586 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1573 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1587 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1574 rgba low;
1588 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 1575 rgba high;
1589 int i; 1576 int i;
1590 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; 1577 int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst;
1591 1578
1592 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; 1579 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1593 1580
1594 /* for convenience */ 1581 /* for convenience */
1595 mask_r = visual->red_mask; 1582 mask_r = visual->red_mask;
1596 mask_g = visual->green_mask; 1583 mask_g = visual->green_mask;
1597 mask_b = visual->blue_mask; 1584 mask_b = visual->blue_mask;
1598 1585
1599 /* boring lookup table pre-initialization */ 1586 /* boring lookup table pre-initialization */
1600 switch (srcImage->depth) 1587 switch (ximage->depth)
1601 { 1588 {
1602 case 15: 1589 case 15:
1603 if ((mask_r != 0x7c00) || 1590 if ((mask_r != 0x7c00) ||
1604 (mask_g != 0x03e0) || 1591 (mask_g != 0x03e0) ||
1605 (mask_b != 0x001f)) 1592 (mask_b != 0x001f))
1658 /* prepare limits for color transformation (each channel is handled separately) */ 1645 /* prepare limits for color transformation (each channel is handled separately) */
1659 if (shade > 100) 1646 if (shade > 100)
1660 { 1647 {
1661 shade = 200 - shade; 1648 shade = 200 - shade;
1662 1649
1663 lower_lim_r = 65535-rm; 1650 high.r = c.r * shade / 100;
1664 lower_lim_g = 65535-gm; 1651 high.g = c.g * shade / 100;
1665 lower_lim_b = 65535-bm; 1652 high.b = c.b * shade / 100;
1666 1653
1667 lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); 1654 low.r = 65535 * (100 - shade) / 100;
1668 lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); 1655 low.g = 65535 * (100 - shade) / 100;
1669 lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); 1656 low.b = 65535 * (100 - shade) / 100;
1670
1671 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1672 } 1657 }
1673 else 1658 else
1674 { 1659 {
1660 high.r = c.r * shade / 100;
1661 high.g = c.g * shade / 100;
1662 high.b = c.b * shade / 100;
1675 1663
1676 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1664 low.r = low.g = low.b = 0;
1677
1678 upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100);
1679 upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100);
1680 upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100);
1681 } 1665 }
1682 1666
1683 /* fill our lookup tables */ 1667 /* fill our lookup tables */
1684 for (i = 0; i <= mask_r>>sh_r; i++) 1668 for (i = 0; i <= mask_r>>sh_r; i++)
1685 { 1669 {
1686 uint32_t tmp; 1670 uint32_t tmp;
1687 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); 1671 tmp = i * high.r;
1688 tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); 1672 tmp += (mask_r>>sh_r) * low.r;
1689 lookup_r[i] = (tmp/65535)<<sh_r; 1673 lookup_r[i] = (tmp/65535)<<sh_r;
1690 } 1674 }
1691 for (i = 0; i <= mask_g>>sh_g; i++) 1675 for (i = 0; i <= mask_g>>sh_g; i++)
1692 { 1676 {
1693 uint32_t tmp; 1677 uint32_t tmp;
1694 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); 1678 tmp = i * high.g;
1695 tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); 1679 tmp += (mask_g>>sh_g) * low.g;
1696 lookup_g[i] = (tmp/65535)<<sh_g; 1680 lookup_g[i] = (tmp/65535)<<sh_g;
1697 } 1681 }
1698 for (i = 0; i <= mask_b>>sh_b; i++) 1682 for (i = 0; i <= mask_b>>sh_b; i++)
1699 { 1683 {
1700 uint32_t tmp; 1684 uint32_t tmp;
1701 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); 1685 tmp = i * high.b;
1702 tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); 1686 tmp += (mask_b>>sh_b) * low.b;
1703 lookup_b[i] = (tmp/65535)<<sh_b; 1687 lookup_b[i] = (tmp/65535)<<sh_b;
1704 } 1688 }
1705 1689
1706 /* apply table to input image (replacing colors by newly calculated ones) */ 1690 /* apply table to input image (replacing colors by newly calculated ones) */
1707 if (srcImage->bits_per_pixel == 32 1691 if (ximage->bits_per_pixel == 32
1708 && (srcImage->depth == 24 || srcImage->depth == 32) 1692 && (ximage->depth == 24 || ximage->depth == 32)
1709 && srcImage->byte_order == host_byte_order) 1693 && ximage->byte_order == host_byte_order)
1710 { 1694 {
1711 uint32_t *p1, *pf, *p, *pl; 1695 uint32_t *p1, *pf, *p, *pl;
1712 p1 = (uint32_t *) srcImage->data; 1696 p1 = (uint32_t *) ximage->data;
1713 pf = (uint32_t *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); 1697 pf = (uint32_t *) (ximage->data + ximage->height * ximage->bytes_per_line);
1714 1698
1715 while (p1 < pf) 1699 while (p1 < pf)
1716 { 1700 {
1717 p = p1; 1701 p = p1;
1718 pl = p1 + srcImage->width; 1702 pl = p1 + ximage->width;
1719 for (; p < pl; p++) 1703 for (; p < pl; p++)
1720 { 1704 {
1721 *p = lookup_r[(*p & 0xff0000) >> 16] | 1705 *p = lookup_r[(*p & 0xff0000) >> 16] |
1722 lookup_g[(*p & 0x00ff00) >> 8] | 1706 lookup_g[(*p & 0x00ff00) >> 8] |
1723 lookup_b[(*p & 0x0000ff)] | 1707 lookup_b[(*p & 0x0000ff)] |
1724 (*p & 0xff000000); 1708 (*p & 0xff000000);
1725 } 1709 }
1726 p1 = (uint32_t *) ((char *) p1 + srcImage->bytes_per_line); 1710 p1 = (uint32_t *) ((char *) p1 + ximage->bytes_per_line);
1727 } 1711 }
1728 } 1712 }
1729 else 1713 else
1730 { 1714 {
1731 for (int y = 0; y < srcImage->height; y++) 1715 for (int y = 0; y < ximage->height; y++)
1732 for (int x = 0; x < srcImage->width; x++) 1716 for (int x = 0; x < ximage->width; x++)
1733 { 1717 {
1734 unsigned long pixel = XGetPixel (srcImage, x, y); 1718 unsigned long pixel = XGetPixel (ximage, x, y);
1735 pixel = lookup_r[(pixel & mask_r) >> sh_r] | 1719 pixel = lookup_r[(pixel & mask_r) >> sh_r] |
1736 lookup_g[(pixel & mask_g) >> sh_g] | 1720 lookup_g[(pixel & mask_g) >> sh_g] |
1737 lookup_b[(pixel & mask_b) >> sh_b]; 1721 lookup_b[(pixel & mask_b) >> sh_b];
1738 XPutPixel (srcImage, x, y, pixel); 1722 XPutPixel (ximage, x, y, pixel);
1739 } 1723 }
1740 } 1724 }
1741 1725
1742 free (lookup); 1726 free (lookup);
1743} 1727}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines