Refactored to use render_loadTestFace()
authorSam Lantinga
Wed, 18 Nov 2009 07:34:05 +0000
changeset 3445de72b49bb695
parent 3444 50fca98abc24
child 3446 0f969d273f65
Refactored to use render_loadTestFace()
test/automated/render/render.c
     1.1 --- a/test/automated/render/render.c	Wed Nov 18 07:22:22 2009 +0000
     1.2 +++ b/test/automated/render/render.c	Wed Nov 18 07:34:05 2009 +0000
     1.3 @@ -543,7 +543,6 @@
     1.4  {
     1.5     int ret;
     1.6     SDL_Rect rect;
     1.7 -   SDL_Surface *face;
     1.8     SDL_TextureID tface;
     1.9     int i, j, ni, nj;
    1.10  
    1.11 @@ -556,34 +555,15 @@
    1.12        return 0;
    1.13  
    1.14     /* Create face surface. */
    1.15 -   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
    1.16 -         img_face.width, img_face.height, 32, img_face.width*4,
    1.17 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
    1.18 -         0xff000000, /* Red bit mask. */
    1.19 -         0x00ff0000, /* Green bit mask. */
    1.20 -         0x0000ff00, /* Blue bit mask. */
    1.21 -         0x000000ff /* Alpha bit mask. */
    1.22 -#else
    1.23 -         0x000000ff, /* Red bit mask. */
    1.24 -         0x0000ff00, /* Green bit mask. */
    1.25 -         0x00ff0000, /* Blue bit mask. */
    1.26 -         0xff000000 /* Alpha bit mask. */
    1.27 -#endif
    1.28 -         );
    1.29 -   if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
    1.30 -      return -1;
    1.31 -   tface = SDL_CreateTextureFromSurface( 0, face );
    1.32 -   if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
    1.33 +   tface = render_loadTestFace();
    1.34 +   if (SDL_ATassert( "render_loadTestFace()", tface != 0))
    1.35        return -1;
    1.36  
    1.37     /* Constant values. */
    1.38 -   rect.w = face->w;
    1.39 -   rect.h = face->h;
    1.40 -   ni     = SCREEN_W - face->w;
    1.41 -   nj     = SCREEN_H - face->h;
    1.42 -
    1.43 -   /* Clean up. */
    1.44 -   SDL_FreeSurface( face );
    1.45 +   rect.w = img_face.width;
    1.46 +   rect.h = img_face.height;
    1.47 +   ni     = SCREEN_W - img_face.width;
    1.48 +   nj     = SCREEN_H - img_face.height;
    1.49  
    1.50     /* Loop blit. */
    1.51     for (j=0; j <= nj; j+=4) {
    1.52 @@ -615,7 +595,6 @@
    1.53  {
    1.54     int ret;
    1.55     SDL_Rect rect;
    1.56 -   SDL_Surface *face;
    1.57     SDL_TextureID tface;
    1.58     int i, j, ni, nj;
    1.59  
    1.60 @@ -628,34 +607,15 @@
    1.61        return 0;
    1.62  
    1.63     /* Create face surface. */
    1.64 -   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
    1.65 -         img_face.width, img_face.height, 32, img_face.width*4,
    1.66 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
    1.67 -         0xff000000, /* Red bit mask. */
    1.68 -         0x00ff0000, /* Green bit mask. */
    1.69 -         0x0000ff00, /* Blue bit mask. */
    1.70 -         0x000000ff /* Alpha bit mask. */
    1.71 -#else
    1.72 -         0x000000ff, /* Red bit mask. */
    1.73 -         0x0000ff00, /* Green bit mask. */
    1.74 -         0x00ff0000, /* Blue bit mask. */
    1.75 -         0xff000000 /* Alpha bit mask. */
    1.76 -#endif
    1.77 -         );
    1.78 -   if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
    1.79 -      return -1;
    1.80 -   tface = SDL_CreateTextureFromSurface( 0, face );
    1.81 -   if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
    1.82 +   tface = render_loadTestFace();
    1.83 +   if (SDL_ATassert( "render_loadTestFace()", tface != 0))
    1.84        return -1;
    1.85  
    1.86     /* Constant values. */
    1.87 -   rect.w = face->w;
    1.88 -   rect.h = face->h;
    1.89 -   ni     = SCREEN_W - face->w;
    1.90 -   nj     = SCREEN_H - face->h;
    1.91 -
    1.92 -   /* Clean up. */
    1.93 -   SDL_FreeSurface( face );
    1.94 +   rect.w = img_face.width;
    1.95 +   rect.h = img_face.height;
    1.96 +   ni     = SCREEN_W - img_face.width;
    1.97 +   nj     = SCREEN_H - img_face.height;
    1.98  
    1.99     /* Test blitting with colour mod. */
   1.100     for (j=0; j <= nj; j+=4) {
   1.101 @@ -693,7 +653,6 @@
   1.102  {
   1.103     int ret;
   1.104     SDL_Rect rect;
   1.105 -   SDL_Surface *face;
   1.106     SDL_TextureID tface;
   1.107     int i, j, ni, nj;
   1.108  
   1.109 @@ -706,34 +665,15 @@
   1.110        return 0;
   1.111  
   1.112     /* Create face surface. */
   1.113 -   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
   1.114 -         img_face.width, img_face.height, 32, img_face.width*4,
   1.115 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   1.116 -         0xff000000, /* Red bit mask. */
   1.117 -         0x00ff0000, /* Green bit mask. */
   1.118 -         0x0000ff00, /* Blue bit mask. */
   1.119 -         0x000000ff /* Alpha bit mask. */
   1.120 -#else
   1.121 -         0x000000ff, /* Red bit mask. */
   1.122 -         0x0000ff00, /* Green bit mask. */
   1.123 -         0x00ff0000, /* Blue bit mask. */
   1.124 -         0xff000000 /* Alpha bit mask. */
   1.125 -#endif
   1.126 -         );
   1.127 -   if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
   1.128 -      return -1;
   1.129 -   tface = SDL_CreateTextureFromSurface( 0, face );
   1.130 -   if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
   1.131 +   tface = render_loadTestFace();
   1.132 +   if (SDL_ATassert( "render_loadTestFace()", tface != 0))
   1.133        return -1;
   1.134  
   1.135     /* Constant values. */
   1.136 -   rect.w = face->w;
   1.137 -   rect.h = face->h;
   1.138 -   ni     = SCREEN_W - face->w;
   1.139 -   nj     = SCREEN_H - face->h;
   1.140 -
   1.141 -   /* Clean up. */
   1.142 -   SDL_FreeSurface( face );
   1.143 +   rect.w = img_face.width;
   1.144 +   rect.h = img_face.height;
   1.145 +   ni     = SCREEN_W - img_face.width;
   1.146 +   nj     = SCREEN_H - img_face.height;
   1.147  
   1.148     /* Clear surface. */
   1.149     if (render_clearScreen())
   1.150 @@ -817,7 +757,6 @@
   1.151  {
   1.152     int ret;
   1.153     SDL_Rect rect;
   1.154 -   SDL_Surface *face;
   1.155     SDL_TextureID tface;
   1.156     int i, j, ni, nj;
   1.157     int mode;
   1.158 @@ -831,24 +770,8 @@
   1.159        return 0;
   1.160  
   1.161     /* Create face surface. */
   1.162 -   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
   1.163 -         img_face.width, img_face.height, 32, img_face.width*4,
   1.164 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   1.165 -         0xff000000, /* Red bit mask. */
   1.166 -         0x00ff0000, /* Green bit mask. */
   1.167 -         0x0000ff00, /* Blue bit mask. */
   1.168 -         0x000000ff /* Alpha bit mask. */
   1.169 -#else
   1.170 -         0x000000ff, /* Red bit mask. */
   1.171 -         0x0000ff00, /* Green bit mask. */
   1.172 -         0x00ff0000, /* Blue bit mask. */
   1.173 -         0xff000000 /* Alpha bit mask. */
   1.174 -#endif
   1.175 -         );
   1.176 -   if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
   1.177 -      return -1;
   1.178 -   tface = SDL_CreateTextureFromSurface( 0, face );
   1.179 -   if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
   1.180 +   tface = render_loadTestFace();
   1.181 +   if (SDL_ATassert( "render_loadTestFace()", tface != 0))
   1.182        return -1;
   1.183  
   1.184     /* Steps to take. */
   1.185 @@ -856,11 +779,8 @@
   1.186     nj     = SCREEN_H - FACE_H;
   1.187  
   1.188     /* Constant values. */
   1.189 -   rect.w = face->w;
   1.190 -   rect.h = face->h;
   1.191 -
   1.192 -   /* Clean up. */
   1.193 -   SDL_FreeSurface( face );
   1.194 +   rect.w = img_face.width;
   1.195 +   rect.h = img_face.height;
   1.196  
   1.197     /* Set alpha mod. */
   1.198     ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 );