src/video/SDL_blit_N.c
changeset 739 22dbf364c017
parent 431 41cadcba32e8
child 769 b8d311d90021
equal deleted inserted replaced
738:82b85b731fe3 739:22dbf364c017
    29 
    29 
    30 #include "SDL_types.h"
    30 #include "SDL_types.h"
    31 #include "SDL_video.h"
    31 #include "SDL_video.h"
    32 #include "SDL_blit.h"
    32 #include "SDL_blit.h"
    33 #include "SDL_byteorder.h"
    33 #include "SDL_byteorder.h"
    34 
    34 #include "SDL_cpuinfo.h"
    35 /* Function to check the CPU flags */
       
    36 #define MMX_CPU		0x800000
       
    37 #ifdef USE_ASMBLIT
       
    38 #define CPU_Flags()	Hermes_X86_CPU()
       
    39 #else
       
    40 #define CPU_Flags()	0L
       
    41 #endif
       
    42 
    35 
    43 /* Functions to blit from N-bit surfaces to other surfaces */
    36 /* Functions to blit from N-bit surfaces to other surfaces */
    44 
    37 
    45 #ifdef USE_ASMBLIT
    38 #ifdef USE_ASMBLIT
    46 
    39 
  1427 /* Normal N to N optimized blitters */
  1420 /* Normal N to N optimized blitters */
  1428 struct blit_table {
  1421 struct blit_table {
  1429 	Uint32 srcR, srcG, srcB;
  1422 	Uint32 srcR, srcG, srcB;
  1430 	int dstbpp;
  1423 	int dstbpp;
  1431 	Uint32 dstR, dstG, dstB;
  1424 	Uint32 dstR, dstG, dstB;
  1432 	Uint32 cpu_flags;
  1425 	SDL_bool cpu_mmx;
  1433 	void *aux_data;
  1426 	void *aux_data;
  1434 	SDL_loblit blitfunc;
  1427 	SDL_loblit blitfunc;
  1435         enum { NO_ALPHA, SET_ALPHA, COPY_ALPHA } alpha;
  1428         enum { NO_ALPHA, SET_ALPHA, COPY_ALPHA } alpha;
  1436 };
  1429 };
  1437 static const struct blit_table normal_blit_1[] = {
  1430 static const struct blit_table normal_blit_1[] = {
  1464     { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
  1457     { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
  1465 };
  1458 };
  1466 static const struct blit_table normal_blit_4[] = {
  1459 static const struct blit_table normal_blit_4[] = {
  1467 #ifdef USE_ASMBLIT
  1460 #ifdef USE_ASMBLIT
  1468     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
  1461     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
  1469       MMX_CPU, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
  1462       1, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
  1470     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
  1463     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
  1471       0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA },
  1464       0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA },
  1472     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
  1465     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
  1473       MMX_CPU, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA },
  1466       1, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA },
  1474     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
  1467     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
  1475       0, ConvertX86p32_16BGR565, ConvertX86, NO_ALPHA },
  1468       0, ConvertX86p32_16BGR565, ConvertX86, NO_ALPHA },
  1476     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
  1469     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
  1477       MMX_CPU, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA },
  1470       1, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA },
  1478     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
  1471     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
  1479       0, ConvertX86p32_16RGB555, ConvertX86, NO_ALPHA },
  1472       0, ConvertX86p32_16RGB555, ConvertX86, NO_ALPHA },
  1480     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
  1473     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
  1481       MMX_CPU, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA },
  1474       1, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA },
  1482     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
  1475     { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
  1483       0, ConvertX86p32_16BGR555, ConvertX86, NO_ALPHA },
  1476       0, ConvertX86p32_16BGR555, ConvertX86, NO_ALPHA },
  1484     { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x00FF0000,0x0000FF00,0x000000FF,
  1477     { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x00FF0000,0x0000FF00,0x000000FF,
  1485       0, ConvertX86p32_24RGB888, ConvertX86, NO_ALPHA },
  1478       0, ConvertX86p32_24RGB888, ConvertX86, NO_ALPHA },
  1486     { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x000000FF,0x0000FF00,0x00FF0000,
  1479     { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x000000FF,0x0000FF00,0x00FF0000,
  1579 			     dstfmt->BytesPerPixel == table[which].dstbpp &&
  1572 			     dstfmt->BytesPerPixel == table[which].dstbpp &&
  1580 			     dstfmt->Rmask == table[which].dstR &&
  1573 			     dstfmt->Rmask == table[which].dstR &&
  1581 			     dstfmt->Gmask == table[which].dstG &&
  1574 			     dstfmt->Gmask == table[which].dstG &&
  1582 			     dstfmt->Bmask == table[which].dstB &&
  1575 			     dstfmt->Bmask == table[which].dstB &&
  1583 			     (a_need & table[which].alpha) == a_need &&
  1576 			     (a_need & table[which].alpha) == a_need &&
  1584 			     (CPU_Flags()&table[which].cpu_flags) ==
  1577 			     (table[which].cpu_mmx == SDL_HasMMX())) 
  1585 			     table[which].cpu_flags )
       
  1586 				break;
  1578 				break;
  1587 		}
  1579 		}
  1588 		sdata->aux_data = table[which].aux_data;
  1580 		sdata->aux_data = table[which].aux_data;
  1589 		blitfun = table[which].blitfunc;
  1581 		blitfun = table[which].blitfunc;
  1590 		if(a_need == COPY_ALPHA && blitfun == BlitNtoN)
  1582 		if(a_need == COPY_ALPHA && blitfun == BlitNtoN)