Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Use testsur as a parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 11, 2009
1 parent f9c9a46 commit ebf2eda
Showing 1 changed file with 54 additions and 46 deletions.
100 changes: 54 additions & 46 deletions test/automated/surface/surface.c
Expand Up @@ -96,13 +96,19 @@ static int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
/**
* @brief Tests sprite loading.
*/
static void surface_testLoad (void)
static void surface_testLoad( SDL_Surface *testsur )
{
int ret;
SDL_Surface *face, *rface, *testsur;
SDL_Surface *face, *rface;

SDL_ATbegin( "Load Test" );

/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
if (SDL_ATassert( "SDL_FillRect", ret == 0))
return;

/* Create the blit surface. */
face = SDL_LoadBMP("../icon.bmp");
if (SDL_ATassert( "SDL_CreateLoadBmp", face != NULL))
Expand All @@ -116,12 +122,6 @@ static void surface_testLoad (void)
return;
}

/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
return;

/* Convert to 32 bit to compare. */
rface = SDL_ConvertSurface( face, testsur->format, 0 );
if (SDL_ATassert( "SDL_ConvertSurface", rface != NULL))
Expand All @@ -133,7 +133,6 @@ static void surface_testLoad (void)
return;

/* Clean up. */
SDL_FreeSurface( testsur );
SDL_FreeSurface( rface );
SDL_FreeSurface( face );

Expand All @@ -144,15 +143,20 @@ static void surface_testLoad (void)
/**
* @brief Tests the SDL primitives for rendering.
*/
static void surface_testPrimitives (void)
static void surface_testPrimitives( SDL_Surface *testsur )
{
int ret;
int x, y;
SDL_Rect rect;
SDL_Surface *testsur;

SDL_ATbegin( "Primitives Test" );

/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
if (SDL_ATassert( "SDL_FillRect", ret == 0))
return;

/* Create the surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
Expand Down Expand Up @@ -211,29 +215,25 @@ static void surface_testPrimitives (void)
surface_compare( testsur, &img_primitives )==0 ))
return;

/* Clean up. */
SDL_FreeSurface( testsur );

SDL_ATend();
}


/**
* @brief Tests the SDL primitives with alpha for rendering.
*/
static void surface_testPrimitivesBlend (void)
static void surface_testPrimitivesBlend( SDL_Surface *testsur )
{
int ret;
int i, j;
SDL_Rect rect;
SDL_Surface *testsur;

SDL_ATbegin( "Primitives Blend Test" );

/* Create the surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
if (SDL_ATassert( "SDL_FillRect", ret == 0))
return;

/* Create some rectangles for each blend mode. */
Expand Down Expand Up @@ -297,38 +297,35 @@ static void surface_testPrimitivesBlend (void)
surface_compare( testsur, &img_blend )==0 ))
return;

/* Clean up. */
SDL_FreeSurface( testsur );

SDL_ATend();
}


/**
* @brief Tests some blitting routines.
*/
static void surface_testBlit (void)
static void surface_testBlit( SDL_Surface *testsur )
{
int ret;
SDL_Rect rect;
SDL_Surface *face, *testsur;
SDL_Surface *face;
int i, j, ni, nj;

SDL_ATbegin( "Blit Tests" );

/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
if (SDL_ATassert( "SDL_FillRect", ret == 0))
return;

/* 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_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return;

/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
return;

/* Constant values. */
rect.w = face->w;
rect.h = face->h;
Expand Down Expand Up @@ -415,7 +412,6 @@ static void surface_testBlit (void)

/* Clean up. */
SDL_FreeSurface( face );
SDL_FreeSurface( testsur );

SDL_ATend();
}
Expand Down Expand Up @@ -468,29 +464,29 @@ static int surface_testBlitBlendMode( SDL_Surface *testsur, SDL_Surface *face, i
/**
* @brief Tests some more blitting routines.
*/
static void surface_testBlitBlend (void)
static void surface_testBlitBlend( SDL_Surface *testsur )
{
int ret;
SDL_Rect rect;
SDL_Surface *face, *testsur;
SDL_Surface *face;
int i, j, ni, nj;
int mode;

SDL_ATbegin( "Blit Blending Tests" );

/* Clear surface. */
ret = SDL_FillRect( testsur, NULL,
SDL_MapRGB( testsur->format, 0, 0, 0 ) );
if (SDL_ATassert( "SDL_FillRect", ret == 0))
return;

/* 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_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return;

/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
return;

/* Set alpha mod. */
ret = SDL_SetSurfaceAlphaMod( face, 100 );
if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0))
Expand Down Expand Up @@ -585,7 +581,6 @@ static void surface_testBlitBlend (void)

/* Clean up. */
SDL_FreeSurface( face );
SDL_FreeSurface( testsur );

SDL_ATend();
}
Expand All @@ -598,17 +593,30 @@ int main( int argc, const char *argv[] )
{
(void) argc;
(void) argv;
SDL_Surface *testsur;

SDL_ATinit( "SDL_Surface" );

/* Initializes the SDL subsystems. */
SDL_Init(0);

surface_testLoad();
surface_testPrimitives();
surface_testPrimitivesBlend();
surface_testBlit();
surface_testBlitBlend();
SDL_ATbegin( "Creating Testsurface" );
/* Create the test surface. */
testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
RMASK, GMASK, BMASK, AMASK );
if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
return -1;
SDL_ATend();

/* Software blitting. */
surface_testLoad( testsur );
surface_testPrimitives( testsur );
surface_testPrimitivesBlend( testsur );
surface_testBlit( testsur );
surface_testBlitBlend( testsur );

/* Clean up. */
SDL_FreeSurface( testsur );

/* Exit SDL. */
SDL_Quit();
Expand Down

0 comments on commit ebf2eda

Please sign in to comment.