rayzor

diff src/main.cc @ 11:fe94d9e986ae

optimized 16bpp swap_buffers
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 10 Apr 2014 08:42:33 +0300
parents 235c8b764c0b
children d94a69933a71
line diff
     1.1 --- a/src/main.cc	Thu Apr 10 08:03:52 2014 +0300
     1.2 +++ b/src/main.cc	Thu Apr 10 08:42:33 2014 +0300
     1.3 @@ -199,9 +199,9 @@
     1.4  	 (((g) << gshift) & gmask) | \
     1.5  	 (((b) << bshift) & bmask))
     1.6  
     1.7 -#define UNPACK_RED(c)	((c) & 0xff)
     1.8 +#define UNPACK_RED(c)	(((c) >> 16) & 0xff)
     1.9  #define UNPACK_GREEN(c)	(((c) >> 8) & 0xff)
    1.10 -#define UNPACK_BLUE(c)	(((c) >> 16) & 0xff)
    1.11 +#define UNPACK_BLUE(c)	((c) & 0xff)
    1.12  
    1.13  static void swap_buffers()
    1.14  {
    1.15 @@ -227,7 +227,6 @@
    1.16  		break;
    1.17  
    1.18  	case 16:
    1.19 -	case 15:
    1.20  		{
    1.21  			uint16_t *dest = (uint16_t*)fb;
    1.22  			for(int i=0; i<num_pixels; i++) {
    1.23 @@ -236,7 +235,9 @@
    1.24  				unsigned char g = UNPACK_GREEN(c);
    1.25  				unsigned char b = UNPACK_BLUE(c);
    1.26  
    1.27 -				*dest++ = PACK_RGB(r, g, b);
    1.28 +				*dest++ = (((r) << 8) & 0xf800) |
    1.29 +					(((g) << 3) & 0x7e0) |
    1.30 +					(((b) >> 3) & 0x1f);
    1.31  			}
    1.32  		}
    1.33  		break;