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.217 by sf-exg, Sun May 20 16:34:42 2012 UTC vs.
Revision 1.218 by sf-exg, Mon May 21 12:29:22 2012 UTC

341 341
342# ifdef HAVE_PIXBUF 342# ifdef HAVE_PIXBUF
343bool 343bool
344rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, 344rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
345 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,
346 unsigned int width, unsigned int height) 346 unsigned int width, unsigned int height, bool argb)
347{ 347{
348 XImage *ximage; 348 XImage *ximage;
349 char *line; 349 char *line;
350 int width_r, width_g, width_b, width_a; 350 int width_r, width_g, width_b, width_a;
351 int sh_r, sh_g, sh_b, sh_a; 351 int sh_r, sh_g, sh_b, sh_a;
352 uint32_t alpha_mask; 352 uint32_t red_mask, green_mask, blue_mask, alpha_mask;
353 int rowstride; 353 int rowstride;
354 int channels; 354 int channels;
355 unsigned char *row; 355 unsigned char *row;
356 356
357 if (visual->c_class != TrueColor) 357 if (visual->c_class != TrueColor)
358 return false; 358 return false;
359 359
360 if (argb)
361 {
362 red_mask = 0xff << 16;
363 green_mask = 0xff << 8;
364 blue_mask = 0xff;
365 alpha_mask = 0xff << 24;
366 }
367 else
368 {
369 red_mask = visual->red_mask;
370 green_mask = visual->green_mask;
371 blue_mask = visual->blue_mask;
360#if XRENDER 372#if XRENDER
361 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 373 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
362 if (format) 374 if (format)
363 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; 375 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha;
364 else 376 else
365#endif 377#endif
366 alpha_mask = 0; 378 alpha_mask = 0;
379 }
367 380
368 width_r = ecb_popcount32 (visual->red_mask); 381 width_r = ecb_popcount32 (red_mask);
369 width_g = ecb_popcount32 (visual->green_mask); 382 width_g = ecb_popcount32 (green_mask);
370 width_b = ecb_popcount32 (visual->blue_mask); 383 width_b = ecb_popcount32 (blue_mask);
371 width_a = ecb_popcount32 (alpha_mask); 384 width_a = ecb_popcount32 (alpha_mask);
372 385
373 if (width_r > 8 || width_g > 8 || width_b > 8 || width_a > 8) 386 if (width_r > 8 || width_g > 8 || width_b > 8 || width_a > 8)
374 return false; 387 return false;
375 388
376 sh_r = ecb_ctz32 (visual->red_mask); 389 sh_r = ecb_ctz32 (red_mask);
377 sh_g = ecb_ctz32 (visual->green_mask); 390 sh_g = ecb_ctz32 (green_mask);
378 sh_b = ecb_ctz32 (visual->blue_mask); 391 sh_b = ecb_ctz32 (blue_mask);
379 sh_a = ecb_ctz32 (alpha_mask); 392 sh_a = ecb_ctz32 (alpha_mask);
380 393
381 if (width > 32767 || height > 32767) 394 if (width > 32767 || height > 32767)
382 return false; 395 return false;
383 396
384 ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, 0, 397 ximage = XCreateImage (dpy, visual, argb ? 32 : depth, ZPixmap, 0, 0,
385 width, height, 32, 0); 398 width, height, 32, 0);
386 if (!ximage) 399 if (!ximage)
387 return false; 400 return false;
388 401
389 if (height > INT_MAX / ximage->bytes_per_line 402 if (height > INT_MAX / ximage->bytes_per_line
511 524
512 image_width = gdk_pixbuf_get_width (result); 525 image_width = gdk_pixbuf_get_width (result);
513 image_height = gdk_pixbuf_get_height (result); 526 image_height = gdk_pixbuf_get_height (result);
514 527
515 if (need_blend) 528 if (need_blend)
516 { 529 tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32);
517 tmp_pixmap = bg_pixmap;
518 bg_pixmap = None;
519 }
520 else 530 else
521 { 531 {
522 if (image.flags & IM_TILE) 532 if (image.flags & IM_TILE)
523 { 533 {
524 new_pmap_width = min (image_width, target_width); 534 new_pmap_width = min (image_width, target_width);
525 new_pmap_height = min (image_height, target_height); 535 new_pmap_height = min (image_height, target_height);
526 } 536 }
527 }
528 537
529 if (bg_pixmap == None 538 if (bg_pixmap == None
530 || bg_pmap_width != new_pmap_width 539 || bg_pmap_width != new_pmap_width
531 || bg_pmap_height != new_pmap_height) 540 || bg_pmap_height != new_pmap_height)
532 { 541 {
533 if (bg_pixmap) 542 if (bg_pixmap)
534 XFreePixmap (dpy, bg_pixmap); 543 XFreePixmap (dpy, bg_pixmap);
535 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 544 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
536 bg_pmap_width = new_pmap_width; 545 bg_pmap_width = new_pmap_width;
537 bg_pmap_height = new_pmap_height; 546 bg_pmap_height = new_pmap_height;
547 }
548
549 tmp_pixmap = bg_pixmap;
538 } 550 }
539 551
540 gcv.foreground = pix_colors[Color_bg]; 552 gcv.foreground = pix_colors[Color_bg];
541 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 553 gc = XCreateGC (dpy, tmp_pixmap, GCForeground, &gcv);
542 554
543 if (gc) 555 if (gc)
544 { 556 {
545 if (image.flags & IM_TILE) 557 if (image.flags & IM_TILE)
546 { 558 {
547 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 559 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, need_blend ? 32 : depth);
548 pixbuf_to_pixmap (result, tile, gc, 560 pixbuf_to_pixmap (result, tile, gc,
549 0, 0, 561 0, 0,
550 0, 0, 562 0, 0,
551 image_width, image_height); 563 image_width, image_height, need_blend);
552 564
553 gcv.tile = tile; 565 gcv.tile = tile;
554 gcv.fill_style = FillTiled; 566 gcv.fill_style = FillTiled;
555 gcv.ts_x_origin = x; 567 gcv.ts_x_origin = x;
556 gcv.ts_y_origin = y; 568 gcv.ts_y_origin = y;
557 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 569 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
558 570
559 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 571 XFillRectangle (dpy, tmp_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
560 XFreePixmap (dpy, tile); 572 XFreePixmap (dpy, tile);
561 } 573 }
562 else 574 else
563 { 575 {
564 int src_x, src_y, dst_x, dst_y; 576 int src_x, src_y, dst_x, dst_y;
568 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 580 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
569 581
570 if (dst_x > 0 || dst_y > 0 582 if (dst_x > 0 || dst_y > 0
571 || dst_x + dst_width < new_pmap_width 583 || dst_x + dst_width < new_pmap_width
572 || dst_y + dst_height < new_pmap_height) 584 || dst_y + dst_height < new_pmap_height)
573 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 585 XFillRectangle (dpy, tmp_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
574 586
575 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 587 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
576 pixbuf_to_pixmap (result, bg_pixmap, gc, 588 pixbuf_to_pixmap (result, tmp_pixmap, gc,
577 src_x, src_y, 589 src_x, src_y,
578 dst_x, dst_y, 590 dst_x, dst_y,
579 dst_width, dst_height); 591 dst_width, dst_height, need_blend);
580 } 592 }
581 593
582#if XRENDER 594#if XRENDER
583 if (need_blend) 595 if (need_blend)
584 { 596 {
597 XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
585 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 598 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
586 599
587 Picture src = XRenderCreatePicture (dpy, tmp_pixmap, format, 0, 0); 600 Picture src = XRenderCreatePicture (dpy, tmp_pixmap, argb_format, 0, 0);
588 601
589 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); 602 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0);
590 603
591 Picture mask = create_xrender_mask (dpy, vt, False, False); 604 Picture mask = create_xrender_mask (dpy, vt, False, False);
592 605

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines