Fixed some bugs in the automated test suite, revealed by working SDL_RenderReadPixels()
authorSam Lantinga <slouken@libsdl.org>
Tue, 17 Nov 2009 05:17:11 +0000
changeset 34390acec8c9f5c9
parent 3438 ca5663493497
child 3440 e9502d56ae94
Fixed some bugs in the automated test suite, revealed by working SDL_RenderReadPixels()
test/automated/common/common.c
test/automated/common/common.h
test/automated/surface/surface.c
     1.1 --- a/test/automated/common/common.c	Tue Nov 17 04:53:15 2009 +0000
     1.2 +++ b/test/automated/common/common.c	Tue Nov 17 05:17:11 2009 +0000
     1.3 @@ -46,9 +46,26 @@
     1.4                 break;
     1.5  
     1.6              case 4:
     1.7 -               ret += !( (p[0] == pd[0]) &&
     1.8 -                         (p[1] == pd[1]) &&
     1.9 -                         (p[2] == pd[2]) );
    1.10 +               {
    1.11 +                  int fail;
    1.12 +                  Uint8 R, G, B, A;
    1.13 +
    1.14 +                  SDL_GetRGBA(*(Uint32*)p, sur->format, &R, &G, &B, &A);
    1.15 +
    1.16 +                  if (img->bytes_per_pixel == 3) {
    1.17 +                     fail = !( (R == pd[0]) &&
    1.18 +                               (G == pd[1]) &&
    1.19 +                               (B == pd[2]) );
    1.20 +                  } else {
    1.21 +                     fail = !( (R == pd[0]) &&
    1.22 +                               (G == pd[1]) &&
    1.23 +                               (B == pd[2]) &&
    1.24 +                               (A == pd[3]) );
    1.25 +                  }
    1.26 +                  if (fail) {
    1.27 +                     ++ret;
    1.28 +                  }
    1.29 +               }
    1.30                 break;
    1.31           }
    1.32        }
     2.1 --- a/test/automated/common/common.h	Tue Nov 17 04:53:15 2009 +0000
     2.2 +++ b/test/automated/common/common.h	Tue Nov 17 05:17:11 2009 +0000
     2.3 @@ -11,19 +11,11 @@
     2.4  #  define COMMON_H
     2.5  
     2.6  
     2.7 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
     2.8 -#  define FORMAT  SDL_PIXELFORMAT_RGBA8888
     2.9 -#  define RMASK   0xff000000 /**< Red bit mask. */
    2.10 -#  define GMASK   0x00ff0000 /**< Green bit mask. */
    2.11 -#  define BMASK   0x0000ff00 /**< Blue bit mask. */
    2.12 -#  define AMASK   0x000000ff /**< Alpha bit mask. */
    2.13 -#else
    2.14 -#  define FORMAT  SDL_PIXELFORMAT_ABGR8888
    2.15 -#  define RMASK   0x000000ff /**< Red bit mask. */
    2.16 +#  define FORMAT SDL_PIXELFORMAT_ARGB8888
    2.17 +#  define AMASK   0xff000000 /**< Alpha bit mask. */
    2.18 +#  define RMASK   0x00ff0000 /**< Red bit mask. */
    2.19  #  define GMASK   0x0000ff00 /**< Green bit mask. */
    2.20 -#  define BMASK   0x00ff0000 /**< Blue bit mask. */
    2.21 -#  define AMASK   0xff000000 /**< Alpha bit mask. */
    2.22 -#endif
    2.23 +#  define BMASK   0x000000ff /**< Blue bit mask. */
    2.24  
    2.25  
    2.26  typedef struct SurfaceImage_s {
     3.1 --- a/test/automated/surface/surface.c	Tue Nov 17 04:53:15 2009 +0000
     3.2 +++ b/test/automated/surface/surface.c	Tue Nov 17 05:17:11 2009 +0000
     3.3 @@ -97,12 +97,6 @@
     3.4     if (SDL_ATassert( "SDL_FillRect", ret == 0))
     3.5        return;
     3.6  
     3.7 -   /* Create the surface. */
     3.8 -   testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, 
     3.9 -         RMASK, GMASK, BMASK, AMASK );
    3.10 -   if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
    3.11 -      return;
    3.12 -
    3.13     /* Draw a rectangle. */
    3.14     rect.x = 40;
    3.15     rect.y = 0;
    3.16 @@ -263,7 +257,18 @@
    3.17     /* Create face surface. */
    3.18     face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
    3.19           img_face.width, img_face.height, 32, img_face.width*4,
    3.20 -         RMASK, GMASK, BMASK, AMASK );
    3.21 +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
    3.22 +         0xff000000, /* Red bit mask. */
    3.23 +         0x00ff0000, /* Green bit mask. */
    3.24 +         0x0000ff00, /* Blue bit mask. */
    3.25 +         0x000000ff /* Alpha bit mask. */
    3.26 +#else
    3.27 +         0x000000ff, /* Red bit mask. */
    3.28 +         0x0000ff00, /* Green bit mask. */
    3.29 +         0x00ff0000, /* Blue bit mask. */
    3.30 +         0xff000000 /* Alpha bit mask. */
    3.31 +#endif
    3.32 +         );
    3.33     if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
    3.34        return;
    3.35  
    3.36 @@ -424,7 +429,18 @@
    3.37     /* Create the blit surface. */
    3.38     face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
    3.39           img_face.width, img_face.height, 32, img_face.width*4,
    3.40 -         RMASK, GMASK, BMASK, AMASK );
    3.41 +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
    3.42 +         0xff000000, /* Red bit mask. */
    3.43 +         0x00ff0000, /* Green bit mask. */
    3.44 +         0x0000ff00, /* Blue bit mask. */
    3.45 +         0x000000ff /* Alpha bit mask. */
    3.46 +#else
    3.47 +         0x000000ff, /* Red bit mask. */
    3.48 +         0x0000ff00, /* Green bit mask. */
    3.49 +         0x00ff0000, /* Blue bit mask. */
    3.50 +         0xff000000 /* Alpha bit mask. */
    3.51 +#endif
    3.52 +         );
    3.53     if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
    3.54        return;
    3.55