src/video/SDL_RLEaccel.c
changeset 12591 66cd8731c3b1
parent 12503 806492103856
equal deleted inserted replaced
12590:b50bedb4bca0 12591:66cd8731c3b1
    87 
    87 
    88 #include "SDL_video.h"
    88 #include "SDL_video.h"
    89 #include "SDL_sysvideo.h"
    89 #include "SDL_sysvideo.h"
    90 #include "SDL_blit.h"
    90 #include "SDL_blit.h"
    91 #include "SDL_RLEaccel_c.h"
    91 #include "SDL_RLEaccel_c.h"
       
    92 #include "../cpuinfo/SDL_simd.h"
    92 
    93 
    93 #ifndef MIN
    94 #ifndef MIN
    94 #define MIN(a, b) ((a) < (b) ? (a) : (b))
    95 #define MIN(a, b) ((a) < (b) ? (a) : (b))
    95 #endif
    96 #endif
    96 
    97 
  1218 #undef ADD_OPAQUE_COUNTS
  1219 #undef ADD_OPAQUE_COUNTS
  1219 #undef ADD_TRANSL_COUNTS
  1220 #undef ADD_TRANSL_COUNTS
  1220 
  1221 
  1221     /* Now that we have it encoded, release the original pixels */
  1222     /* Now that we have it encoded, release the original pixels */
  1222     if (!(surface->flags & SDL_PREALLOC)) {
  1223     if (!(surface->flags & SDL_PREALLOC)) {
  1223         SDL_free(surface->pixels);
  1224         SDL_SIMDFree(surface->pixels);
  1224         surface->pixels = NULL;
  1225         surface->pixels = NULL;
       
  1226         surface->flags &= ~SDL_SIMD_ALIGNED;
  1225     }
  1227     }
  1226 
  1228 
  1227     /* realloc the buffer to release unused memory */
  1229     /* realloc the buffer to release unused memory */
  1228     {
  1230     {
  1229         Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
  1231         Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
  1381 
  1383 
  1382 #undef ADD_COUNTS
  1384 #undef ADD_COUNTS
  1383 
  1385 
  1384     /* Now that we have it encoded, release the original pixels */
  1386     /* Now that we have it encoded, release the original pixels */
  1385     if (!(surface->flags & SDL_PREALLOC)) {
  1387     if (!(surface->flags & SDL_PREALLOC)) {
  1386         SDL_free(surface->pixels);
  1388         SDL_SIMDFree(surface->pixels);
  1387         surface->pixels = NULL;
  1389         surface->pixels = NULL;
       
  1390         surface->flags &= ~SDL_SIMD_ALIGNED;
  1388     }
  1391     }
  1389 
  1392 
  1390     /* realloc the buffer to release unused memory */
  1393     /* realloc the buffer to release unused memory */
  1391     {
  1394     {
  1392         /* If realloc returns NULL, the original block is left intact */
  1395         /* If realloc returns NULL, the original block is left intact */
  1482         uncopy_transl = uncopy_transl_16;
  1485         uncopy_transl = uncopy_transl_16;
  1483     } else {
  1486     } else {
  1484         uncopy_opaque = uncopy_transl = uncopy_32;
  1487         uncopy_opaque = uncopy_transl = uncopy_32;
  1485     }
  1488     }
  1486 
  1489 
  1487     surface->pixels = SDL_malloc(surface->h * surface->pitch);
  1490     surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
  1488     if (!surface->pixels) {
  1491     if (!surface->pixels) {
  1489         return (SDL_FALSE);
  1492         return (SDL_FALSE);
  1490     }
  1493     }
       
  1494     surface->flags |= SDL_SIMD_ALIGNED;
  1491     /* fill background with transparent pixels */
  1495     /* fill background with transparent pixels */
  1492     SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
  1496     SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
  1493 
  1497 
  1494     dst = surface->pixels;
  1498     dst = surface->pixels;
  1495     srcbuf = (Uint8 *) (df + 1);
  1499     srcbuf = (Uint8 *) (df + 1);
  1547         if (recode && !(surface->flags & SDL_PREALLOC)) {
  1551         if (recode && !(surface->flags & SDL_PREALLOC)) {
  1548             if (surface->map->info.flags & SDL_COPY_RLE_COLORKEY) {
  1552             if (surface->map->info.flags & SDL_COPY_RLE_COLORKEY) {
  1549                 SDL_Rect full;
  1553                 SDL_Rect full;
  1550 
  1554 
  1551                 /* re-create the original surface */
  1555                 /* re-create the original surface */
  1552                 surface->pixels = SDL_malloc(surface->h * surface->pitch);
  1556                 surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
  1553                 if (!surface->pixels) {
  1557                 if (!surface->pixels) {
  1554                     /* Oh crap... */
  1558                     /* Oh crap... */
  1555                     surface->flags |= SDL_RLEACCEL;
  1559                     surface->flags |= SDL_RLEACCEL;
  1556                     return;
  1560                     return;
  1557                 }
  1561                 }
       
  1562                 surface->flags |= SDL_SIMD_ALIGNED;
  1558 
  1563 
  1559                 /* fill it with the background color */
  1564                 /* fill it with the background color */
  1560                 SDL_FillRect(surface, NULL, surface->map->info.colorkey);
  1565                 SDL_FillRect(surface, NULL, surface->map->info.colorkey);
  1561 
  1566 
  1562                 /* now render the encoded surface */
  1567                 /* now render the encoded surface */