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.209 by sf-exg, Fri May 11 12:21:22 2012 UTC vs.
Revision 1.214 by sf-exg, Thu May 17 10:18:32 2012 UTC

58# endif 58# endif
59 59
60void 60void
61rxvt_term::bg_destroy () 61rxvt_term::bg_destroy ()
62{ 62{
63#ifdef HAVE_PIXBUF
64 if (pixbuf)
65 g_object_unref (pixbuf);
66#endif
67
68 if (bg_pixmap) 63 if (bg_pixmap)
69 XFreePixmap (dpy, bg_pixmap); 64 XFreePixmap (dpy, bg_pixmap);
70} 65}
71 66
72bool 67bool
90 if (bg_flags & BG_IS_TRANSPARENT) 85 if (bg_flags & BG_IS_TRANSPARENT)
91 return true; 86 return true;
92# endif 87# endif
93 88
94# ifdef BG_IMAGE_FROM_FILE 89# ifdef BG_IMAGE_FROM_FILE
95 if (bg_flags & BG_IS_FROM_FILE) 90 if (bg_image.flags & IM_IS_SET)
96 { 91 {
97 if (bg_flags & BG_IS_SIZE_SENSITIVE) 92 if ((bg_image.flags & IM_IS_SIZE_SENSITIVE)
93 || bg_image.width () > szHint.width
94 || bg_image.height () > szHint.height)
98 return true; 95 return true;
99 } 96 }
100# endif 97# endif
101 98
102 return false; 99 return false;
109 if (bg_flags & BG_IS_TRANSPARENT) 106 if (bg_flags & BG_IS_TRANSPARENT)
110 return true; 107 return true;
111# endif 108# endif
112 109
113# ifdef BG_IMAGE_FROM_FILE 110# ifdef BG_IMAGE_FROM_FILE
114 if (bg_flags & BG_IS_FROM_FILE) 111 if (bg_image.flags & IM_IS_SET)
115 { 112 {
116 if (bg_flags & BG_ROOT_ALIGN) 113 if (bg_image.flags & IM_ROOT_ALIGN)
117 return true; 114 return true;
118 } 115 }
119# endif 116# endif
120 117
121 return false; 118 return false;
149 min_it (dst_size, target_size - dst_pos); 146 min_it (dst_size, target_size - dst_pos);
150 return src_pos; 147 return src_pos;
151} 148}
152 149
153bool 150bool
154rxvt_term::bg_set_geometry (const char *geom, bool update) 151rxvt_image::set_geometry (const char *geom, bool update)
155{ 152{
156 bool changed = false; 153 bool changed = false;
157 int geom_flags = 0; 154 int geom_flags = 0;
158 int x = h_align; 155 int x = h_align;
159 int y = v_align; 156 int y = v_align;
170 167
171 for (int i = 0; arr[i]; i++) 168 for (int i = 0; arr[i]; i++)
172 { 169 {
173 if (!strcasecmp (arr[i], "style=tiled")) 170 if (!strcasecmp (arr[i], "style=tiled"))
174 { 171 {
175 new_flags = BG_TILE; 172 new_flags = IM_TILE;
176 w = h = noScale; 173 w = h = noScale;
177 x = y = 0; 174 x = y = 0;
178 geom_flags = WidthValue|HeightValue|XValue|YValue; 175 geom_flags = WidthValue|HeightValue|XValue|YValue;
179 } 176 }
180 else if (!strcasecmp (arr[i], "style=aspect-stretched")) 177 else if (!strcasecmp (arr[i], "style=aspect-stretched"))
181 { 178 {
182 new_flags = BG_KEEP_ASPECT; 179 new_flags = IM_KEEP_ASPECT;
183 w = h = windowScale; 180 w = h = windowScale;
184 x = y = centerAlign; 181 x = y = centerAlign;
185 geom_flags = WidthValue|HeightValue|XValue|YValue; 182 geom_flags = WidthValue|HeightValue|XValue|YValue;
186 } 183 }
187 else if (!strcasecmp (arr[i], "style=stretched")) 184 else if (!strcasecmp (arr[i], "style=stretched"))
197 x = y = centerAlign; 194 x = y = centerAlign;
198 geom_flags = WidthValue|HeightValue|XValue|YValue; 195 geom_flags = WidthValue|HeightValue|XValue|YValue;
199 } 196 }
200 else if (!strcasecmp (arr[i], "style=root-tiled")) 197 else if (!strcasecmp (arr[i], "style=root-tiled"))
201 { 198 {
202 new_flags = BG_TILE|BG_ROOT_ALIGN; 199 new_flags = IM_TILE|IM_ROOT_ALIGN;
203 w = h = noScale; 200 w = h = noScale;
204 geom_flags = WidthValue|HeightValue; 201 geom_flags = WidthValue|HeightValue;
205 } 202 }
206 else if (!strcasecmp (arr[i], "op=tile")) 203 else if (!strcasecmp (arr[i], "op=tile"))
207 new_flags |= BG_TILE; 204 new_flags |= IM_TILE;
208 else if (!strcasecmp (arr[i], "op=keep-aspect")) 205 else if (!strcasecmp (arr[i], "op=keep-aspect"))
209 new_flags |= BG_KEEP_ASPECT; 206 new_flags |= IM_KEEP_ASPECT;
210 else if (!strcasecmp (arr[i], "op=root-align")) 207 else if (!strcasecmp (arr[i], "op=root-align"))
211 new_flags |= BG_ROOT_ALIGN; 208 new_flags |= IM_ROOT_ALIGN;
212 209
213 // deprecated 210 // deprecated
214 else if (!strcasecmp (arr[i], "tile")) 211 else if (!strcasecmp (arr[i], "tile"))
215 { 212 {
216 new_flags |= BG_TILE; 213 new_flags |= IM_TILE;
217 w = h = noScale; 214 w = h = noScale;
218 geom_flags |= WidthValue|HeightValue; 215 geom_flags |= WidthValue|HeightValue;
219 } 216 }
220 else if (!strcasecmp (arr[i], "propscale")) 217 else if (!strcasecmp (arr[i], "propscale"))
221 { 218 {
222 new_flags |= BG_KEEP_ASPECT; 219 new_flags |= IM_KEEP_ASPECT;
223 w = h = windowScale; 220 w = h = windowScale;
224 geom_flags |= WidthValue|HeightValue; 221 geom_flags |= WidthValue|HeightValue;
225 } 222 }
226 else if (!strcasecmp (arr[i], "hscale")) 223 else if (!strcasecmp (arr[i], "hscale"))
227 { 224 {
228 new_flags |= BG_TILE; 225 new_flags |= IM_TILE;
229 w = windowScale; 226 w = windowScale;
230 h = noScale; 227 h = noScale;
231 geom_flags |= WidthValue|HeightValue; 228 geom_flags |= WidthValue|HeightValue;
232 } 229 }
233 else if (!strcasecmp (arr[i], "vscale")) 230 else if (!strcasecmp (arr[i], "vscale"))
234 { 231 {
235 new_flags |= BG_TILE; 232 new_flags |= IM_TILE;
236 h = windowScale; 233 h = windowScale;
237 w = noScale; 234 w = noScale;
238 geom_flags |= WidthValue|HeightValue; 235 geom_flags |= WidthValue|HeightValue;
239 } 236 }
240 else if (!strcasecmp (arr[i], "scale")) 237 else if (!strcasecmp (arr[i], "scale"))
248 x = y = centerAlign; 245 x = y = centerAlign;
249 geom_flags |= WidthValue|HeightValue|XValue|YValue; 246 geom_flags |= WidthValue|HeightValue|XValue|YValue;
250 } 247 }
251 else if (!strcasecmp (arr[i], "root")) 248 else if (!strcasecmp (arr[i], "root"))
252 { 249 {
253 new_flags |= BG_TILE|BG_ROOT_ALIGN; 250 new_flags |= IM_TILE|IM_ROOT_ALIGN;
254 w = h = noScale; 251 w = h = noScale;
255 geom_flags |= WidthValue|HeightValue; 252 geom_flags |= WidthValue|HeightValue;
256 } 253 }
257 254
258 else 255 else
260 } /* done parsing ops */ 257 } /* done parsing ops */
261 258
262 rxvt_free_strsplit (arr); 259 rxvt_free_strsplit (arr);
263 } 260 }
264 261
265 new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; 262 new_flags |= flags & ~IM_GEOMETRY_FLAGS;
266 263
267 if (!update) 264 if (!update)
268 { 265 {
269 if (!(geom_flags & XValue)) 266 if (!(geom_flags & XValue))
270 x = y = defaultAlign; 267 x = y = defaultAlign;
282 min_it (w, 1000); 279 min_it (w, 1000);
283 min_it (h, 1000); 280 min_it (h, 1000);
284 clamp_it (x, -100, 200); 281 clamp_it (x, -100, 200);
285 clamp_it (y, -100, 200); 282 clamp_it (y, -100, 200);
286 283
287 if (bg_flags != new_flags 284 if (flags != new_flags
288 || h_scale != w 285 || h_scale != w
289 || v_scale != h 286 || v_scale != h
290 || h_align != x 287 || h_align != x
291 || v_align != y) 288 || v_align != y)
292 { 289 {
293 bg_flags = new_flags; 290 flags = new_flags;
294 h_scale = w; 291 h_scale = w;
295 v_scale = h; 292 v_scale = h;
296 h_align = x; 293 h_align = x;
297 v_align = y; 294 v_align = y;
298 changed = true; 295 changed = true;
299 } 296 }
300 297
298 if (!(flags & IM_TILE)
299 || h_scale || v_scale
300 || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align)))
301 flags |= IM_IS_SIZE_SENSITIVE;
302 else
303 flags &= ~IM_IS_SIZE_SENSITIVE;
304
301 return changed; 305 return changed;
302} 306}
303 307
304void 308void
305rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) 309rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y)
306{ 310{
311 int image_width = image.width ();
312 int image_height = image.height ();
307 int target_width = szHint.width; 313 int target_width = szHint.width;
308 int target_height = szHint.height; 314 int target_height = szHint.height;
309 315
310 w = h_scale * target_width / 100; 316 w = image.h_scale * target_width / 100;
311 h = v_scale * target_height / 100; 317 h = image.v_scale * target_height / 100;
312 318
313 if (bg_flags & BG_KEEP_ASPECT) 319 if (image.flags & IM_KEEP_ASPECT)
314 { 320 {
315 float scale = (float)w / image_width; 321 float scale = (float)w / image_width;
316 min_it (scale, (float)h / image_height); 322 min_it (scale, (float)h / image_height);
317 w = image_width * scale + 0.5; 323 w = image_width * scale + 0.5;
318 h = image_height * scale + 0.5; 324 h = image_height * scale + 0.5;
319 } 325 }
320 326
321 if (!w) w = image_width; 327 if (!w) w = image_width;
322 if (!h) h = image_height; 328 if (!h) h = image_height;
323 329
324 if (bg_flags & BG_ROOT_ALIGN) 330 if (image.flags & IM_ROOT_ALIGN)
325 { 331 {
326 x = -target_x; 332 x = -target_x;
327 y = -target_y; 333 y = -target_y;
328 } 334 }
329 else 335 else
330 { 336 {
331 x = make_align_position (h_align, target_width, w); 337 x = make_align_position (image.h_align, target_width, w);
332 y = make_align_position (v_align, target_height, h); 338 y = make_align_position (image.v_align, target_height, h);
333 } 339 }
334
335 if (!(bg_flags & BG_TILE)
336 || h_scale || v_scale
337 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
338 || image_width > target_width || image_height > target_height)
339 bg_flags |= BG_IS_SIZE_SENSITIVE;
340 else
341 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
342} 340}
343 341
344# ifdef HAVE_PIXBUF 342# ifdef HAVE_PIXBUF
345bool 343bool
346rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, 344rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
347 int src_x, int src_y, int dst_x, int dst_y, 345 int src_x, int src_y, int dst_x, int dst_y,
348 unsigned int width, unsigned int height) 346 unsigned int width, unsigned int height)
349{ 347{
350 XImage *ximage; 348 XImage *ximage;
351 char *data, *line; 349 char *line;
352 int bytes_per_pixel;
353 int width_r, width_g, width_b, width_a; 350 int width_r, width_g, width_b, width_a;
354 int sh_r, sh_g, sh_b, sh_a; 351 int sh_r, sh_g, sh_b, sh_a;
355 uint32_t alpha_mask; 352 uint32_t alpha_mask;
356 int rowstride; 353 int rowstride;
357 int channels; 354 int channels;
366 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; 363 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha;
367 else 364 else
368#endif 365#endif
369 alpha_mask = 0; 366 alpha_mask = 0;
370 367
371 if (depth == 24 || depth == 32)
372 bytes_per_pixel = 4;
373 else if (depth == 15 || depth == 16)
374 bytes_per_pixel = 2;
375 else
376 return false;
377
378 width_r = ecb_popcount32 (visual->red_mask); 368 width_r = ecb_popcount32 (visual->red_mask);
379 width_g = ecb_popcount32 (visual->green_mask); 369 width_g = ecb_popcount32 (visual->green_mask);
380 width_b = ecb_popcount32 (visual->blue_mask); 370 width_b = ecb_popcount32 (visual->blue_mask);
381 width_a = ecb_popcount32 (alpha_mask); 371 width_a = ecb_popcount32 (alpha_mask);
382 372
386 sh_r = ecb_ctz32 (visual->red_mask); 376 sh_r = ecb_ctz32 (visual->red_mask);
387 sh_g = ecb_ctz32 (visual->green_mask); 377 sh_g = ecb_ctz32 (visual->green_mask);
388 sh_b = ecb_ctz32 (visual->blue_mask); 378 sh_b = ecb_ctz32 (visual->blue_mask);
389 sh_a = ecb_ctz32 (alpha_mask); 379 sh_a = ecb_ctz32 (alpha_mask);
390 380
391 if (width > INT_MAX / height / bytes_per_pixel) 381 if (width > 32767 || height > 32767)
392 return false; 382 return false;
393 383
394 data = (char *)malloc (width * height * bytes_per_pixel); 384 ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, 0,
395 if (!data) 385 width, height, 32, 0);
386 if (!ximage)
396 return false; 387 return false;
397 388
398 ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, data, 389 if (height > INT_MAX / ximage->bytes_per_line
399 width, height, bytes_per_pixel * 8, 0); 390 || !(ximage->data = (char *)malloc (height * ximage->bytes_per_line)))
400 if (!ximage)
401 { 391 {
402 free (data); 392 XDestroyImage (ximage);
403 return false; 393 return false;
404 } 394 }
405 395
406 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 396 ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
407 397
408 rowstride = gdk_pixbuf_get_rowstride (pixbuf); 398 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
409 channels = gdk_pixbuf_get_n_channels (pixbuf); 399 channels = gdk_pixbuf_get_n_channels (pixbuf);
410 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; 400 row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels;
411 line = data; 401 line = ximage->data;
412 402
413 rgba c (0, 0, 0); 403 rgba c (0, 0, 0);
414 404
415 if (channels == 4 && alpha_mask == 0) 405 if (channels == 4 && alpha_mask == 0)
416 { 406 {
446 value = ((r >> (8 - width_r)) << sh_r) 436 value = ((r >> (8 - width_r)) << sh_r)
447 | ((g >> (8 - width_g)) << sh_g) 437 | ((g >> (8 - width_g)) << sh_g)
448 | ((b >> (8 - width_b)) << sh_b) 438 | ((b >> (8 - width_b)) << sh_b)
449 | ((a >> (8 - width_a)) << sh_a); 439 | ((a >> (8 - width_a)) << sh_a);
450 440
451 if (bytes_per_pixel == 4) 441 if (ximage->bits_per_pixel == 32)
452 ((uint32_t *)line)[x] = value; 442 ((uint32_t *)line)[x] = value;
453 else 443 else
454 ((uint16_t *)line)[x] = value; 444 XPutPixel (ximage, x, y, value);
455 } 445 }
456 446
457 row += rowstride; 447 row += rowstride;
458 line += ximage->bytes_per_line; 448 line += ximage->bytes_per_line;
459 } 449 }
462 XDestroyImage (ximage); 452 XDestroyImage (ximage);
463 return true; 453 return true;
464} 454}
465 455
466bool 456bool
467rxvt_term::render_image (bool transparent) 457rxvt_term::render_image (rxvt_image &image, bool transparent)
468{ 458{
459 GdkPixbuf *pixbuf = image.pixbuf;
469 if (!pixbuf) 460 if (!pixbuf)
470 return false; 461 return false;
471 462
472 if (transparent 463 if (transparent
473 && !(bg_flags & BG_HAS_RENDER)) 464 && !(bg_flags & BG_HAS_RENDER))
486 int x = 0; 477 int x = 0;
487 int y = 0; 478 int y = 0;
488 int w = 0; 479 int w = 0;
489 int h = 0; 480 int h = 0;
490 481
491 get_image_geometry (image_width, image_height, w, h, x, y); 482 get_image_geometry (image, w, h, x, y);
492 483
493 if (!(bg_flags & BG_ROOT_ALIGN) 484 if (!(image.flags & IM_ROOT_ALIGN)
494 && (x >= target_width 485 && (x >= target_width
495 || y >= target_height 486 || y >= target_height
496 || x + w <= 0 487 || x + w <= 0
497 || y + h <= 0)) 488 || y + h <= 0))
498 return false; 489 return false;
524 root_pmap = bg_pixmap; 515 root_pmap = bg_pixmap;
525 bg_pixmap = None; 516 bg_pixmap = None;
526 } 517 }
527 else 518 else
528 { 519 {
529 if (bg_flags & BG_TILE) 520 if (image.flags & IM_TILE)
530 { 521 {
531 new_pmap_width = min (image_width, target_width); 522 new_pmap_width = min (image_width, target_width);
532 new_pmap_height = min (image_height, target_height); 523 new_pmap_height = min (image_height, target_height);
533 } 524 }
534 } 525 }
547 gcv.foreground = pix_colors[Color_bg]; 538 gcv.foreground = pix_colors[Color_bg];
548 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 539 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
549 540
550 if (gc) 541 if (gc)
551 { 542 {
552 if (bg_flags & BG_TILE) 543 if (image.flags & IM_TILE)
553 { 544 {
554 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 545 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
555 pixbuf_to_pixmap (result, tile, gc, 546 pixbuf_to_pixmap (result, tile, gc,
556 0, 0, 547 0, 0,
557 0, 0, 548 0, 0,
627 return ret; 618 return ret;
628} 619}
629# endif /* HAVE_PIXBUF */ 620# endif /* HAVE_PIXBUF */
630 621
631bool 622bool
632rxvt_term::bg_set_file (const char *file) 623rxvt_image::set_file (const char *file)
633{ 624{
634 if (!file || !*file) 625 if (!file || !*file)
635 return false; 626 return false;
636 627
637 bool ret = false; 628 bool ret = false;
651 if (image) 642 if (image)
652 { 643 {
653 if (pixbuf) 644 if (pixbuf)
654 g_object_unref (pixbuf); 645 g_object_unref (pixbuf);
655 pixbuf = image; 646 pixbuf = image;
656 bg_flags |= BG_IS_FROM_FILE; 647 flags |= IM_IS_SET;
657 ret = true; 648 ret = true;
658 } 649 }
659# endif 650# endif
660 651
661 if (ret) 652 if (ret)
662 { 653 {
663 if (p) 654 if (p)
664 bg_set_geometry (p + 1); 655 set_geometry (p + 1);
665 else 656 else
666 bg_set_default_geometry (); 657 set_default_geometry ();
667 } 658 }
668 659
669 return ret; 660 return ret;
670} 661}
671 662
672# endif /* BG_IMAGE_FROM_FILE */ 663# endif /* BG_IMAGE_FROM_FILE */
673 664
674# ifdef ENABLE_TRANSPARENCY 665# ifdef ENABLE_TRANSPARENCY
675bool
676rxvt_term::bg_set_transparent ()
677{
678 if (!(bg_flags & BG_IS_TRANSPARENT))
679 {
680 bg_flags |= BG_IS_TRANSPARENT;
681 return true;
682 }
683
684 return false;
685}
686
687bool 666bool
688rxvt_term::bg_set_blur (const char *geom) 667rxvt_term::bg_set_blur (const char *geom)
689{ 668{
690 bool changed = false; 669 bool changed = false;
691 unsigned int hr, vr; 670 unsigned int hr, vr;
710 { 689 {
711 changed = true; 690 changed = true;
712 v_blurRadius = vr; 691 v_blurRadius = vr;
713 } 692 }
714 693
715 if (h_blurRadius && v_blurRadius)
716 bg_flags |= BG_NEEDS_BLUR;
717 else
718 bg_flags &= ~BG_NEEDS_BLUR;
719
720 return changed; 694 return changed;
721}
722
723void
724rxvt_term::set_tint_shade_flags ()
725{
726 if (shade != 100 || (bg_flags & BG_TINT_SET))
727 bg_flags |= BG_NEEDS_TINT;
728 else
729 bg_flags &= ~BG_NEEDS_TINT;
730} 695}
731 696
732bool 697bool
733rxvt_term::bg_set_tint (rxvt_color &new_tint) 698rxvt_term::bg_set_tint (rxvt_color &new_tint)
734{ 699{
744 && (c.b <= 0x00ff || c.b >= 0xff00)) 709 && (c.b <= 0x00ff || c.b >= 0xff00))
745 bg_flags |= BG_TINT_BITAND; 710 bg_flags |= BG_TINT_BITAND;
746 else 711 else
747 bg_flags &= ~BG_TINT_BITAND; 712 bg_flags &= ~BG_TINT_BITAND;
748 713
749 set_tint_shade_flags ();
750 return true; 714 return true;
751 } 715 }
752 716
753 return false; 717 return false;
754} 718}
763 new_shade = 200 - (100 + new_shade); 727 new_shade = 200 - (100 + new_shade);
764 728
765 if (new_shade != shade) 729 if (new_shade != shade)
766 { 730 {
767 shade = new_shade; 731 shade = new_shade;
768 set_tint_shade_flags ();
769 return true; 732 return true;
770 } 733 }
771 734
772 return false; 735 return false;
773} 736}
794 params[i+2] = XDoubleToFixed (kernel[i] / sum); 757 params[i+2] = XDoubleToFixed (kernel[i] / sum);
795} 758}
796#endif 759#endif
797 760
798bool 761bool
799rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth) 762rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height)
800{ 763{
801 bool ret = false; 764 bool ret = false;
802#if XRENDER 765#if XRENDER
803 if (!(bg_flags & BG_HAS_RENDER_CONV)) 766 if (!(bg_flags & BG_HAS_RENDER_CONV))
804 return false; 767 return false;
859#endif 822#endif
860 return ret; 823 return ret;
861} 824}
862 825
863bool 826bool
864rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 827rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height)
865{ 828{
866 bool ret = false; 829 bool ret = false;
867 830
868 if (shade == 100 && (bg_flags & BG_TINT_BITAND)) 831 if (shade == 100 && (bg_flags & BG_TINT_BITAND))
869 { 832 {
1049 1012
1050 if (gc) 1013 if (gc)
1051 { 1014 {
1052 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1015 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1053 ret = true; 1016 ret = true;
1054 unsigned long tr_flags = bg_flags & BG_EFFECTS_FLAGS; 1017 bool need_blur = h_blurRadius && v_blurRadius;
1018 bool need_tint = shade != 100 || (bg_flags & BG_TINT_SET);
1055 1019
1056 if (!(bg_flags & BG_CLIENT_RENDER)) 1020 if (!(bg_flags & BG_CLIENT_RENDER))
1057 { 1021 {
1058 if (bg_flags & BG_NEEDS_BLUR) 1022 if (need_blur)
1059 {
1060 if (blur_pixmap (bg_pixmap, visual, window_width, window_height, depth))
1061 tr_flags &= ~BG_NEEDS_BLUR;
1062 } 1023 {
1063 if (bg_flags & BG_NEEDS_TINT) 1024 if (blur_pixmap (bg_pixmap, window_width, window_height))
1025 need_blur = false;
1064 { 1026 }
1027 if (need_tint)
1028 {
1065 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1029 if (tint_pixmap (bg_pixmap, window_width, window_height))
1066 tr_flags &= ~BG_NEEDS_TINT; 1030 need_tint = false;
1067 } 1031 }
1068 if (tr_flags & BG_NEEDS_TINT) 1032 if (need_tint)
1069 { 1033 {
1070 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); 1034 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1071 if (ximage) 1035 if (ximage)
1072 { 1036 {
1073 /* our own client-side tinting */ 1037 /* our own client-side tinting */
1074 tint_ximage (DefaultVisual (dpy, display->screen), ximage); 1038 tint_ximage (ximage);
1075 1039
1076 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); 1040 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1077 XDestroyImage (ximage); 1041 XDestroyImage (ximage);
1078 } 1042 }
1079 } 1043 }
1114 bg_flags |= BG_IS_VALID; 1078 bg_flags |= BG_IS_VALID;
1115 } 1079 }
1116# endif 1080# endif
1117 1081
1118# ifdef BG_IMAGE_FROM_FILE 1082# ifdef BG_IMAGE_FROM_FILE
1119 if (bg_flags & BG_IS_FROM_FILE) 1083 if (bg_image.flags & IM_IS_SET)
1120 { 1084 {
1121 if (render_image (transparent)) 1085 if (render_image (bg_image, transparent))
1122 bg_flags |= BG_IS_VALID; 1086 bg_flags |= BG_IS_VALID;
1123 } 1087 }
1124# endif 1088# endif
1125 1089
1126 if (!(bg_flags & BG_IS_VALID)) 1090 if (!(bg_flags & BG_IS_VALID))
1180 lookup[i] = (tmp / 0xffff) << sh; 1144 lookup[i] = (tmp / 0xffff) << sh;
1181 } 1145 }
1182} 1146}
1183 1147
1184void 1148void
1185rxvt_term::tint_ximage (Visual *visual, XImage *ximage) 1149rxvt_term::tint_ximage (XImage *ximage)
1186{ 1150{
1187 unsigned int size_r, size_g, size_b; 1151 unsigned int size_r, size_g, size_b;
1188 int sh_r, sh_g, sh_b; 1152 int sh_r, sh_g, sh_b;
1189 uint32_t mask_r, mask_g, mask_b; 1153 uint32_t mask_r, mask_g, mask_b;
1190 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1154 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines