changeset 3439:0acec8c9f5c9

Fixed some bugs in the automated test suite, revealed by working SDL_RenderReadPixels()
author Sam Lantinga <slouken@libsdl.org>
date Tue, 17 Nov 2009 05:17:11 +0000
parents ca5663493497
children e9502d56ae94
files test/automated/common/common.c test/automated/common/common.h test/automated/surface/surface.c
diffstat 3 files changed, 48 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/test/automated/common/common.c	Tue Nov 17 04:53:15 2009 +0000
+++ b/test/automated/common/common.c	Tue Nov 17 05:17:11 2009 +0000
@@ -46,9 +46,26 @@
                break;
 
             case 4:
-               ret += !( (p[0] == pd[0]) &&
-                         (p[1] == pd[1]) &&
-                         (p[2] == pd[2]) );
+               {
+                  int fail;
+                  Uint8 R, G, B, A;
+
+                  SDL_GetRGBA(*(Uint32*)p, sur->format, &R, &G, &B, &A);
+
+                  if (img->bytes_per_pixel == 3) {
+                     fail = !( (R == pd[0]) &&
+                               (G == pd[1]) &&
+                               (B == pd[2]) );
+                  } else {
+                     fail = !( (R == pd[0]) &&
+                               (G == pd[1]) &&
+                               (B == pd[2]) &&
+                               (A == pd[3]) );
+                  }
+                  if (fail) {
+                     ++ret;
+                  }
+               }
                break;
          }
       }
--- a/test/automated/common/common.h	Tue Nov 17 04:53:15 2009 +0000
+++ b/test/automated/common/common.h	Tue Nov 17 05:17:11 2009 +0000
@@ -11,19 +11,11 @@
 #  define COMMON_H
 
 
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-#  define FORMAT  SDL_PIXELFORMAT_RGBA8888
-#  define RMASK   0xff000000 /**< Red bit mask. */
-#  define GMASK   0x00ff0000 /**< Green bit mask. */
-#  define BMASK   0x0000ff00 /**< Blue bit mask. */
-#  define AMASK   0x000000ff /**< Alpha bit mask. */
-#else
-#  define FORMAT  SDL_PIXELFORMAT_ABGR8888
-#  define RMASK   0x000000ff /**< Red bit mask. */
+#  define FORMAT SDL_PIXELFORMAT_ARGB8888
+#  define AMASK   0xff000000 /**< Alpha bit mask. */
+#  define RMASK   0x00ff0000 /**< Red bit mask. */
 #  define GMASK   0x0000ff00 /**< Green bit mask. */
-#  define BMASK   0x00ff0000 /**< Blue bit mask. */
-#  define AMASK   0xff000000 /**< Alpha bit mask. */
-#endif
+#  define BMASK   0x000000ff /**< Blue bit mask. */
 
 
 typedef struct SurfaceImage_s {
--- a/test/automated/surface/surface.c	Tue Nov 17 04:53:15 2009 +0000
+++ b/test/automated/surface/surface.c	Tue Nov 17 05:17:11 2009 +0000
@@ -97,12 +97,6 @@
    if (SDL_ATassert( "SDL_FillRect", ret == 0))
       return;
 
-   /* Create the surface. */
-   testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, 
-         RMASK, GMASK, BMASK, AMASK );
-   if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
-      return;
-
    /* Draw a rectangle. */
    rect.x = 40;
    rect.y = 0;
@@ -263,7 +257,18 @@
    /* Create face surface. */
    face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
          img_face.width, img_face.height, 32, img_face.width*4,
-         RMASK, GMASK, BMASK, AMASK );
+#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+         0xff000000, /* Red bit mask. */
+         0x00ff0000, /* Green bit mask. */
+         0x0000ff00, /* Blue bit mask. */
+         0x000000ff /* Alpha bit mask. */
+#else
+         0x000000ff, /* Red bit mask. */
+         0x0000ff00, /* Green bit mask. */
+         0x00ff0000, /* Blue bit mask. */
+         0xff000000 /* Alpha bit mask. */
+#endif
+         );
    if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
       return;
 
@@ -424,7 +429,18 @@
    /* Create the blit surface. */
    face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
          img_face.width, img_face.height, 32, img_face.width*4,
-         RMASK, GMASK, BMASK, AMASK );
+#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+         0xff000000, /* Red bit mask. */
+         0x00ff0000, /* Green bit mask. */
+         0x0000ff00, /* Blue bit mask. */
+         0x000000ff /* Alpha bit mask. */
+#else
+         0x000000ff, /* Red bit mask. */
+         0x0000ff00, /* Green bit mask. */
+         0x00ff0000, /* Blue bit mask. */
+         0xff000000 /* Alpha bit mask. */
+#endif
+         );
    if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
       return;