Mercurial > sdl-ios-xcode
comparison test/automated/surface/surface.c @ 3722:d8772964e402 gsoc2009_unit_tests
Added more strict warning flags.
Fixed bugs/issues uncovered by warning flags.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Thu, 09 Jul 2009 10:42:56 +0000 |
parents | 9bb7758a9741 |
children | 1496cdbb6055 |
comparison
equal
deleted
inserted
replaced
3721:9bb7758a9741 | 3722:d8772964e402 |
---|---|
23 # define AMASK 0xff000000 /**< Alpha bit mask. */ | 23 # define AMASK 0xff000000 /**< Alpha bit mask. */ |
24 #endif | 24 #endif |
25 | 25 |
26 | 26 |
27 typedef struct SurfaceImage_s { | 27 typedef struct SurfaceImage_s { |
28 unsigned int width; | 28 int width; |
29 unsigned int height; | 29 int height; |
30 unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ | 30 unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ |
31 const unsigned char pixel_data[]; | 31 const unsigned char pixel_data[]; |
32 } SurfaceImage_t; | 32 } SurfaceImage_t; |
33 | 33 |
34 | 34 |
51 */ | 51 */ |
52 static int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img ) | 52 static int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img ) |
53 { | 53 { |
54 int ret; | 54 int ret; |
55 int i,j; | 55 int i,j; |
56 Uint32 pix; | |
57 int bpp; | 56 int bpp; |
58 Uint8 *p, *pd; | 57 Uint8 *p, *pd; |
59 | 58 |
60 /* Make sure size is the same. */ | 59 /* Make sure size is the same. */ |
61 if ((sur->w != img->width) || (sur->h != img->height)) | 60 if ((sur->w != img->width) || (sur->h != img->height)) |
266 /* Draw blended lines, lines for everyone. */ | 265 /* Draw blended lines, lines for everyone. */ |
267 for (i=0; i<testsur->w; i+=2) { | 266 for (i=0; i<testsur->w; i+=2) { |
268 ret = SDL_BlendLine( testsur, 0, 0, i, 59, | 267 ret = SDL_BlendLine( testsur, 0, 0, i, 59, |
269 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : | 268 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
270 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, | 269 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
271 60+2*j, 240-2*j, 50, 3*j ); | 270 60+2*i, 240-2*i, 50, 3*i ); |
272 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) | 271 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) |
273 return; | 272 return; |
274 } | 273 } |
275 for (i=0; i<testsur->h; i+=2) { | 274 for (i=0; i<testsur->h; i+=2) { |
276 ret = SDL_BlendLine( testsur, 0, 0, 79, i, | 275 ret = SDL_BlendLine( testsur, 0, 0, 79, i, |
277 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : | 276 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : |
278 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, | 277 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD, |
279 60+2*j, 240-2*j, 50, 3*j ); | 278 60+2*i, 240-2*i, 50, 3*i ); |
280 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) | 279 if (SDL_ATassert( "SDL_BlendLine", ret == 0)) |
281 return; | 280 return; |
282 } | 281 } |
283 | 282 |
284 /* Draw points. */ | 283 /* Draw points. */ |
312 { | 311 { |
313 int ret; | 312 int ret; |
314 SDL_Rect rect; | 313 SDL_Rect rect; |
315 SDL_Surface *face, *testsur; | 314 SDL_Surface *face, *testsur; |
316 int i, j, ni, nj; | 315 int i, j, ni, nj; |
317 int mode; | |
318 | 316 |
319 SDL_ATbegin( "Blit Tests" ); | 317 SDL_ATbegin( "Blit Tests" ); |
320 | 318 |
321 /* Create face surface. */ | 319 /* Create face surface. */ |
322 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, | 320 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, |
495 | 493 |
496 /* Set alpha mod. */ | 494 /* Set alpha mod. */ |
497 ret = SDL_SetSurfaceAlphaMod( face, 100 ); | 495 ret = SDL_SetSurfaceAlphaMod( face, 100 ); |
498 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) | 496 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) |
499 return; | 497 return; |
498 | |
499 /* Steps to take. */ | |
500 ni = testsur->w - face->w; | |
501 nj = testsur->h - face->h; | |
502 | |
503 /* Constant values. */ | |
504 rect.w = face->w; | |
505 rect.h = face->h; | |
500 | 506 |
501 /* Test None. */ | 507 /* Test None. */ |
502 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE )) | 508 if (surface_testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE )) |
503 return; | 509 return; |
504 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).", | 510 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).", |
586 /** | 592 /** |
587 * @brief Entry point. | 593 * @brief Entry point. |
588 */ | 594 */ |
589 int main( int argc, const char *argv[] ) | 595 int main( int argc, const char *argv[] ) |
590 { | 596 { |
597 (void) argc; | |
598 (void) argv; | |
599 | |
591 SDL_ATinit( "SDL_Surface" ); | 600 SDL_ATinit( "SDL_Surface" ); |
592 | 601 |
593 /* Initializes the SDL subsystems. */ | 602 /* Initializes the SDL subsystems. */ |
594 SDL_Init(0); | 603 SDL_Init(0); |
595 | 604 |