ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.102 by root, Sat Jul 7 07:00:17 2012 UTC vs.
Revision 1.103 by root, Sat Jul 14 08:26:56 2012 UTC

349 for (int y = 0; y < height; y++) 349 for (int y = 0; y < height; y++)
350 { 350 {
351 unsigned char *src = row; 351 unsigned char *src = row;
352 uint32_t *dst = (uint32_t *)line; 352 uint32_t *dst = (uint32_t *)line;
353 353
354 if (!pb_has_alpha)
355 for (int x = 0; x < width; x++) 354 for (int x = 0; x < width; x++)
356 { 355 {
357 uint8_t r = *src++; 356 uint8_t r = *src++;
358 uint8_t g = *src++; 357 uint8_t g = *src++;
359 uint8_t b = *src++; 358 uint8_t b = *src++;
359 uint8_t a = *src;
360 360
361 // this is done so it can be jump-free, but newer gcc's clone inner the loop
362 a = pb_has_alpha ? a : 255;
363 src += pb_has_alpha;
364
365 r = (r * a + 127) / 255;
366 g = (g * a + 127) / 255;
367 b = (b * a + 127) / 255;
368
361 uint32_t v = (255 << 24) | (r << 16) | (g << 8) | b; 369 uint32_t v = (a << 24) | (r << 16) | (g << 8) | b;
362 370
363 if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch) 371 if (ecb_big_endian () ? !byte_order_mismatch : byte_order_mismatch)
364 v = ecb_bswap32 (v); 372 v = ecb_bswap32 (v);
365 373
366 *dst++ = v; 374 *dst++ = v;
367 } 375 }
368 else
369 for (int x = 0; x < width; x++)
370 {
371 uint32_t v = *(uint32_t *)src; src += 4;
372
373 if (ecb_big_endian ())
374 v = ecb_bswap32 (v);
375
376 v = ecb_rotl32 (v, 8); // abgr to bgra
377
378 if (!byte_order_mismatch)
379 v = ecb_bswap32 (v);
380
381 *dst++ = v;
382 }
383 376
384 row += rowstride; 377 row += rowstride;
385 line += xi.bytes_per_line; 378 line += xi.bytes_per_line;
386 } 379 }
387 380
604 composer cc (this, new rxvt_img (s, format, 0, 0, w * 2, h, repeat)); 597 composer cc (this, new rxvt_img (s, format, 0, 0, w * 2, h, repeat));
605 598
606 // why the hell does XRenderSetPictureTransform want a writable matrix :( 599 // why the hell does XRenderSetPictureTransform want a writable matrix :(
607 // that keeps us from just static const'ing this matrix. 600 // that keeps us from just static const'ing this matrix.
608 XTransform h_double = { 601 XTransform h_double = {
609 32768, 0, 0, 602 0x8000, 0, 0,
610 0, 65536, 0, 603 0, 0x1000, 0,
611 0, 0, 65536 604 0, 0, 0x1000
612 }; 605 };
613 606
614 XRenderSetPictureFilter (cc.dpy, cc.src, "nearest", 0, 0); 607 XRenderSetPictureFilter (cc.dpy, cc.src, "nearest", 0, 0);
615 XRenderSetPictureTransform (cc.dpy, cc.src, &h_double); 608 XRenderSetPictureTransform (cc.dpy, cc.src, &h_double);
616 XRenderComposite (cc.dpy, PictOpSrc, cc.src, None, cc.dst, 0, 0, 0, 0, 0, 0, w * 2, h); 609 XRenderComposite (cc.dpy, PictOpSrc, cc.src, None, cc.dst, 0, 0, 0, 0, 0, 0, w * 2, h);
638 XDoubleToFixed (3), XDoubleToFixed (1), 631 XDoubleToFixed (3), XDoubleToFixed (1),
639 XDoubleToFixed (0), XDoubleToFixed (mul), XDoubleToFixed (add) 632 XDoubleToFixed (0), XDoubleToFixed (mul), XDoubleToFixed (add)
640 }; 633 };
641 634
642 XTransform h_halve = { 635 XTransform h_halve = {
643 131072, 0, 0, 636 0x2000, 0, 0,
644 0, 65536, 0, 637 0, 0x1000, 0,
645 0, 0, 65536 638 0, 0, 0x1000
646 }; 639 };
647 640
648 XRenderSetPictureFilter (cc.dpy, cc2.src, "nearest", 0, 0); 641 XRenderSetPictureFilter (cc.dpy, cc2.src, "nearest", 0, 0);
649 XRenderSetPictureTransform (cc.dpy, cc2.src, &h_halve); 642 XRenderSetPictureTransform (cc.dpy, cc2.src, &h_halve);
650 XRenderSetPictureFilter (cc.dpy, cc2.src, FilterConvolution, kernel, ecb_array_length (kernel)); 643 XRenderSetPictureFilter (cc.dpy, cc2.src, FilterConvolution, kernel, ecb_array_length (kernel));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines