Commit c635254f authored by Sam Lantinga's avatar Sam Lantinga

Fixed some bugs in the automated test suite, revealed by working SDL_RenderReadPixels()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404180
parent 82d400cc
...@@ -46,9 +46,26 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img ) ...@@ -46,9 +46,26 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
break; break;
case 4: case 4:
ret += !( (p[0] == pd[0]) && {
(p[1] == pd[1]) && int fail;
(p[2] == pd[2]) ); 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; break;
} }
} }
......
...@@ -11,19 +11,11 @@ ...@@ -11,19 +11,11 @@
# define COMMON_H # define COMMON_H
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) # define FORMAT SDL_PIXELFORMAT_ARGB8888
# 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 GMASK 0x0000ff00 /**< Green bit mask. */
# define BMASK 0x00ff0000 /**< Blue bit mask. */
# define AMASK 0xff000000 /**< Alpha bit mask. */ # define AMASK 0xff000000 /**< Alpha bit mask. */
#endif # define RMASK 0x00ff0000 /**< Red bit mask. */
# define GMASK 0x0000ff00 /**< Green bit mask. */
# define BMASK 0x000000ff /**< Blue bit mask. */
typedef struct SurfaceImage_s { typedef struct SurfaceImage_s {
......
...@@ -97,12 +97,6 @@ static void surface_testPrimitives( SDL_Surface *testsur ) ...@@ -97,12 +97,6 @@ static void surface_testPrimitives( SDL_Surface *testsur )
if (SDL_ATassert( "SDL_FillRect", ret == 0)) if (SDL_ATassert( "SDL_FillRect", ret == 0))
return; 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. */ /* Draw a rectangle. */
rect.x = 40; rect.x = 40;
rect.y = 0; rect.y = 0;
...@@ -263,7 +257,18 @@ static void surface_testBlit( SDL_Surface *testsur ) ...@@ -263,7 +257,18 @@ static void surface_testBlit( SDL_Surface *testsur )
/* Create face surface. */ /* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
img_face.width, img_face.height, 32, img_face.width*4, 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)) if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return; return;
...@@ -424,7 +429,18 @@ static void surface_testBlitBlend( SDL_Surface *testsur ) ...@@ -424,7 +429,18 @@ static void surface_testBlitBlend( SDL_Surface *testsur )
/* Create the blit surface. */ /* Create the blit surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
img_face.width, img_face.height, 32, img_face.width*4, 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)) if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment