1.1 --- a/test/testblitspeed.c Mon May 29 03:53:21 2006 +0000
1.2 +++ b/test/testblitspeed.c Mon May 29 04:04:35 2006 +0000
1.3 @@ -16,32 +16,32 @@
1.4
1.5
1.6 static int
1.7 -percent (int val, int total)
1.8 +percent(int val, int total)
1.9 {
1.10 return ((int) ((((float) val) / ((float) total)) * 100.0f));
1.11 }
1.12
1.13 static int
1.14 -randRange (int lo, int hi)
1.15 +randRange(int lo, int hi)
1.16 {
1.17 - return (lo + (int) (((double) hi) * rand () / (RAND_MAX + 1.0)));
1.18 + return (lo + (int) (((double) hi) * rand() / (RAND_MAX + 1.0)));
1.19 }
1.20
1.21 static void
1.22 -copy_trunc_str (char *str, size_t strsize, const char *flagstr)
1.23 +copy_trunc_str(char *str, size_t strsize, const char *flagstr)
1.24 {
1.25 - if ((strlen (str) + strlen (flagstr)) >= (strsize - 1))
1.26 - strcpy (str + (strsize - 5), " ...");
1.27 + if ((strlen(str) + strlen(flagstr)) >= (strsize - 1))
1.28 + strcpy(str + (strsize - 5), " ...");
1.29 else
1.30 - strcat (str, flagstr);
1.31 + strcat(str, flagstr);
1.32 }
1.33
1.34 static void
1.35 -__append_sdl_surface_flag (SDL_Surface * _surface, char *str,
1.36 - size_t strsize, Uint32 flag, const char *flagstr)
1.37 +__append_sdl_surface_flag(SDL_Surface * _surface, char *str,
1.38 + size_t strsize, Uint32 flag, const char *flagstr)
1.39 {
1.40 if (_surface->flags & flag)
1.41 - copy_trunc_str (str, strsize, flagstr);
1.42 + copy_trunc_str(str, strsize, flagstr);
1.43 }
1.44
1.45
1.46 @@ -49,106 +49,106 @@
1.47 #define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
1.48
1.49 static void
1.50 -output_videoinfo_details (void)
1.51 +output_videoinfo_details(void)
1.52 {
1.53 - const SDL_VideoInfo *info = SDL_GetVideoInfo ();
1.54 - printf ("SDL_GetVideoInfo():\n");
1.55 + const SDL_VideoInfo *info = SDL_GetVideoInfo();
1.56 + printf("SDL_GetVideoInfo():\n");
1.57 if (info == NULL)
1.58 - printf (" (null.)\n");
1.59 + printf(" (null.)\n");
1.60 else {
1.61 - print_tf_state (" hardware surface available", info->hw_available);
1.62 - print_tf_state (" window manager available", info->wm_available);
1.63 - print_tf_state (" accelerated hardware->hardware blits",
1.64 - info->blit_hw);
1.65 - print_tf_state (" accelerated hardware->hardware colorkey blits",
1.66 - info->blit_hw_CC);
1.67 - print_tf_state (" accelerated hardware->hardware alpha blits",
1.68 - info->blit_hw_A);
1.69 - print_tf_state (" accelerated software->hardware blits",
1.70 - info->blit_sw);
1.71 - print_tf_state (" accelerated software->hardware colorkey blits",
1.72 - info->blit_sw_CC);
1.73 - print_tf_state (" accelerated software->hardware alpha blits",
1.74 - info->blit_sw_A);
1.75 - print_tf_state (" accelerated color fills", info->blit_fill);
1.76 - printf (" video memory: (%d)\n", info->video_mem);
1.77 + print_tf_state(" hardware surface available", info->hw_available);
1.78 + print_tf_state(" window manager available", info->wm_available);
1.79 + print_tf_state(" accelerated hardware->hardware blits",
1.80 + info->blit_hw);
1.81 + print_tf_state(" accelerated hardware->hardware colorkey blits",
1.82 + info->blit_hw_CC);
1.83 + print_tf_state(" accelerated hardware->hardware alpha blits",
1.84 + info->blit_hw_A);
1.85 + print_tf_state(" accelerated software->hardware blits",
1.86 + info->blit_sw);
1.87 + print_tf_state(" accelerated software->hardware colorkey blits",
1.88 + info->blit_sw_CC);
1.89 + print_tf_state(" accelerated software->hardware alpha blits",
1.90 + info->blit_sw_A);
1.91 + print_tf_state(" accelerated color fills", info->blit_fill);
1.92 + printf(" video memory: (%d)\n", info->video_mem);
1.93 }
1.94
1.95 - printf ("\n");
1.96 + printf("\n");
1.97 }
1.98
1.99 static void
1.100 -output_surface_details (const char *name, SDL_Surface * surface)
1.101 +output_surface_details(const char *name, SDL_Surface * surface)
1.102 {
1.103 - printf ("Details for %s:\n", name);
1.104 + printf("Details for %s:\n", name);
1.105
1.106 if (surface == NULL) {
1.107 - printf ("-WARNING- You've got a NULL surface!");
1.108 + printf("-WARNING- You've got a NULL surface!");
1.109 } else {
1.110 char f[256];
1.111 - printf (" width : %d\n", surface->w);
1.112 - printf (" height : %d\n", surface->h);
1.113 - printf (" depth : %d bits per pixel\n",
1.114 - surface->format->BitsPerPixel);
1.115 - printf (" pitch : %d\n", (int) surface->pitch);
1.116 - printf (" alpha : %d\n", (int) surface->format->alpha);
1.117 - printf (" colorkey : 0x%X\n",
1.118 - (unsigned int) surface->format->colorkey);
1.119 + printf(" width : %d\n", surface->w);
1.120 + printf(" height : %d\n", surface->h);
1.121 + printf(" depth : %d bits per pixel\n",
1.122 + surface->format->BitsPerPixel);
1.123 + printf(" pitch : %d\n", (int) surface->pitch);
1.124 + printf(" alpha : %d\n", (int) surface->format->alpha);
1.125 + printf(" colorkey : 0x%X\n",
1.126 + (unsigned int) surface->format->colorkey);
1.127
1.128 - printf (" red bits : 0x%08X mask, %d shift, %d loss\n",
1.129 - (int) surface->format->Rmask,
1.130 - (int) surface->format->Rshift, (int) surface->format->Rloss);
1.131 - printf (" green bits : 0x%08X mask, %d shift, %d loss\n",
1.132 - (int) surface->format->Gmask,
1.133 - (int) surface->format->Gshift, (int) surface->format->Gloss);
1.134 - printf (" blue bits : 0x%08X mask, %d shift, %d loss\n",
1.135 - (int) surface->format->Bmask,
1.136 - (int) surface->format->Bshift, (int) surface->format->Bloss);
1.137 - printf (" alpha bits : 0x%08X mask, %d shift, %d loss\n",
1.138 - (int) surface->format->Amask,
1.139 - (int) surface->format->Ashift, (int) surface->format->Aloss);
1.140 + printf(" red bits : 0x%08X mask, %d shift, %d loss\n",
1.141 + (int) surface->format->Rmask,
1.142 + (int) surface->format->Rshift, (int) surface->format->Rloss);
1.143 + printf(" green bits : 0x%08X mask, %d shift, %d loss\n",
1.144 + (int) surface->format->Gmask,
1.145 + (int) surface->format->Gshift, (int) surface->format->Gloss);
1.146 + printf(" blue bits : 0x%08X mask, %d shift, %d loss\n",
1.147 + (int) surface->format->Bmask,
1.148 + (int) surface->format->Bshift, (int) surface->format->Bloss);
1.149 + printf(" alpha bits : 0x%08X mask, %d shift, %d loss\n",
1.150 + (int) surface->format->Amask,
1.151 + (int) surface->format->Ashift, (int) surface->format->Aloss);
1.152
1.153 f[0] = '\0';
1.154
1.155 /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE); */
1.156 if ((surface->flags & SDL_HWSURFACE) == 0)
1.157 - copy_trunc_str (f, sizeof (f), " SDL_SWSURFACE");
1.158 + copy_trunc_str(f, sizeof(f), " SDL_SWSURFACE");
1.159
1.160 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWSURFACE);
1.161 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_ASYNCBLIT);
1.162 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_ANYFORMAT);
1.163 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWPALETTE);
1.164 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_DOUBLEBUF);
1.165 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_FULLSCREEN);
1.166 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_OPENGL);
1.167 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RESIZABLE);
1.168 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_NOFRAME);
1.169 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWACCEL);
1.170 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCCOLORKEY);
1.171 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCELOK);
1.172 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCEL);
1.173 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCALPHA);
1.174 - append_sdl_surface_flag (surface, f, sizeof (f), SDL_PREALLOC);
1.175 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWSURFACE);
1.176 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_ASYNCBLIT);
1.177 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_ANYFORMAT);
1.178 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWPALETTE);
1.179 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_DOUBLEBUF);
1.180 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_FULLSCREEN);
1.181 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_OPENGL);
1.182 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RESIZABLE);
1.183 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_NOFRAME);
1.184 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWACCEL);
1.185 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCCOLORKEY);
1.186 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCELOK);
1.187 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCEL);
1.188 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCALPHA);
1.189 + append_sdl_surface_flag(surface, f, sizeof(f), SDL_PREALLOC);
1.190
1.191 if (f[0] == '\0')
1.192 - strcpy (f, " (none)");
1.193 + strcpy(f, " (none)");
1.194
1.195 - printf (" flags :%s\n", f);
1.196 + printf(" flags :%s\n", f);
1.197 }
1.198
1.199 - printf ("\n");
1.200 + printf("\n");
1.201 }
1.202
1.203 static void
1.204 -output_details (void)
1.205 +output_details(void)
1.206 {
1.207 - output_videoinfo_details ();
1.208 - output_surface_details ("Source Surface", src);
1.209 - output_surface_details ("Destination Surface", dest);
1.210 + output_videoinfo_details();
1.211 + output_surface_details("Source Surface", src);
1.212 + output_surface_details("Destination Surface", dest);
1.213 }
1.214
1.215 static Uint32
1.216 -blit (SDL_Surface * dst, SDL_Surface * src, int x, int y)
1.217 +blit(SDL_Surface * dst, SDL_Surface * src, int x, int y)
1.218 {
1.219 Uint32 start = 0;
1.220 SDL_Rect srcRect;
1.221 @@ -161,38 +161,38 @@
1.222 dstRect.w = srcRect.w = src->w; /* SDL will clip as appropriate. */
1.223 dstRect.h = srcRect.h = src->h;
1.224
1.225 - start = SDL_GetTicks ();
1.226 - SDL_BlitSurface (src, &srcRect, dst, &dstRect);
1.227 - return (SDL_GetTicks () - start);
1.228 + start = SDL_GetTicks();
1.229 + SDL_BlitSurface(src, &srcRect, dst, &dstRect);
1.230 + return (SDL_GetTicks() - start);
1.231 }
1.232
1.233 static void
1.234 -blitCentered (SDL_Surface * dst, SDL_Surface * src)
1.235 +blitCentered(SDL_Surface * dst, SDL_Surface * src)
1.236 {
1.237 int x = (dst->w - src->w) / 2;
1.238 int y = (dst->h - src->h) / 2;
1.239 - blit (dst, src, x, y);
1.240 + blit(dst, src, x, y);
1.241 }
1.242
1.243 static int
1.244 -atoi_hex (const char *str)
1.245 +atoi_hex(const char *str)
1.246 {
1.247 if (str == NULL)
1.248 return 0;
1.249
1.250 - if (strlen (str) > 2) {
1.251 + if (strlen(str) > 2) {
1.252 int retval = 0;
1.253 if ((str[0] == '0') && (str[1] == 'x'))
1.254 - sscanf (str + 2, "%X", &retval);
1.255 + sscanf(str + 2, "%X", &retval);
1.256 return (retval);
1.257 }
1.258
1.259 - return (atoi (str));
1.260 + return (atoi(str));
1.261 }
1.262
1.263
1.264 static int
1.265 -setup_test (int argc, char **argv)
1.266 +setup_test(int argc, char **argv)
1.267 {
1.268 const char *dumpfile = NULL;
1.269 SDL_Surface *bmp = NULL;
1.270 @@ -224,60 +224,60 @@
1.271 for (i = 1; i < argc; i++) {
1.272 const char *arg = argv[i];
1.273
1.274 - if (strcmp (arg, "--dstbpp") == 0)
1.275 - dstbpp = atoi (argv[++i]);
1.276 - else if (strcmp (arg, "--dstrmask") == 0)
1.277 - dstrmask = atoi_hex (argv[++i]);
1.278 - else if (strcmp (arg, "--dstgmask") == 0)
1.279 - dstgmask = atoi_hex (argv[++i]);
1.280 - else if (strcmp (arg, "--dstbmask") == 0)
1.281 - dstbmask = atoi_hex (argv[++i]);
1.282 - else if (strcmp (arg, "--dstamask") == 0)
1.283 - dstamask = atoi_hex (argv[++i]);
1.284 - else if (strcmp (arg, "--dstwidth") == 0)
1.285 - dstw = atoi (argv[++i]);
1.286 - else if (strcmp (arg, "--dstheight") == 0)
1.287 - dsth = atoi (argv[++i]);
1.288 - else if (strcmp (arg, "--dsthwsurface") == 0)
1.289 + if (strcmp(arg, "--dstbpp") == 0)
1.290 + dstbpp = atoi(argv[++i]);
1.291 + else if (strcmp(arg, "--dstrmask") == 0)
1.292 + dstrmask = atoi_hex(argv[++i]);
1.293 + else if (strcmp(arg, "--dstgmask") == 0)
1.294 + dstgmask = atoi_hex(argv[++i]);
1.295 + else if (strcmp(arg, "--dstbmask") == 0)
1.296 + dstbmask = atoi_hex(argv[++i]);
1.297 + else if (strcmp(arg, "--dstamask") == 0)
1.298 + dstamask = atoi_hex(argv[++i]);
1.299 + else if (strcmp(arg, "--dstwidth") == 0)
1.300 + dstw = atoi(argv[++i]);
1.301 + else if (strcmp(arg, "--dstheight") == 0)
1.302 + dsth = atoi(argv[++i]);
1.303 + else if (strcmp(arg, "--dsthwsurface") == 0)
1.304 dstflags |= SDL_HWSURFACE;
1.305 - else if (strcmp (arg, "--srcbpp") == 0)
1.306 - srcbpp = atoi (argv[++i]);
1.307 - else if (strcmp (arg, "--srcrmask") == 0)
1.308 - srcrmask = atoi_hex (argv[++i]);
1.309 - else if (strcmp (arg, "--srcgmask") == 0)
1.310 - srcgmask = atoi_hex (argv[++i]);
1.311 - else if (strcmp (arg, "--srcbmask") == 0)
1.312 - srcbmask = atoi_hex (argv[++i]);
1.313 - else if (strcmp (arg, "--srcamask") == 0)
1.314 - srcamask = atoi_hex (argv[++i]);
1.315 - else if (strcmp (arg, "--srcwidth") == 0)
1.316 - srcw = atoi (argv[++i]);
1.317 - else if (strcmp (arg, "--srcheight") == 0)
1.318 - srch = atoi (argv[++i]);
1.319 - else if (strcmp (arg, "--srchwsurface") == 0)
1.320 + else if (strcmp(arg, "--srcbpp") == 0)
1.321 + srcbpp = atoi(argv[++i]);
1.322 + else if (strcmp(arg, "--srcrmask") == 0)
1.323 + srcrmask = atoi_hex(argv[++i]);
1.324 + else if (strcmp(arg, "--srcgmask") == 0)
1.325 + srcgmask = atoi_hex(argv[++i]);
1.326 + else if (strcmp(arg, "--srcbmask") == 0)
1.327 + srcbmask = atoi_hex(argv[++i]);
1.328 + else if (strcmp(arg, "--srcamask") == 0)
1.329 + srcamask = atoi_hex(argv[++i]);
1.330 + else if (strcmp(arg, "--srcwidth") == 0)
1.331 + srcw = atoi(argv[++i]);
1.332 + else if (strcmp(arg, "--srcheight") == 0)
1.333 + srch = atoi(argv[++i]);
1.334 + else if (strcmp(arg, "--srchwsurface") == 0)
1.335 srcflags |= SDL_HWSURFACE;
1.336 - else if (strcmp (arg, "--seconds") == 0)
1.337 - testSeconds = atoi (argv[++i]);
1.338 - else if (strcmp (arg, "--screen") == 0)
1.339 + else if (strcmp(arg, "--seconds") == 0)
1.340 + testSeconds = atoi(argv[++i]);
1.341 + else if (strcmp(arg, "--screen") == 0)
1.342 screenSurface = 1;
1.343 - else if (strcmp (arg, "--dumpfile") == 0)
1.344 + else if (strcmp(arg, "--dumpfile") == 0)
1.345 dumpfile = argv[++i];
1.346 /* !!! FIXME: set colorkey. */
1.347 else if (0) { /* !!! FIXME: we handle some commandlines elsewhere now */
1.348 - fprintf (stderr, "Unknown commandline option: %s\n", arg);
1.349 + fprintf(stderr, "Unknown commandline option: %s\n", arg);
1.350 return (0);
1.351 }
1.352 }
1.353
1.354 - if (SDL_Init (SDL_INIT_VIDEO) == -1) {
1.355 - fprintf (stderr, "SDL_Init failed: %s\n", SDL_GetError ());
1.356 + if (SDL_Init(SDL_INIT_VIDEO) == -1) {
1.357 + fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
1.358 return (0);
1.359 }
1.360
1.361 - bmp = SDL_LoadBMP ("sample.bmp");
1.362 + bmp = SDL_LoadBMP("sample.bmp");
1.363 if (bmp == NULL) {
1.364 - fprintf (stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError ());
1.365 - SDL_Quit ();
1.366 + fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError());
1.367 + SDL_Quit();
1.368 return (0);
1.369 }
1.370
1.371 @@ -287,25 +287,23 @@
1.372 srcflags |= SDL_SWSURFACE;
1.373
1.374 if (screenSurface)
1.375 - dest = SDL_SetVideoMode (dstw, dsth, dstbpp, dstflags);
1.376 + dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags);
1.377 else {
1.378 - dest = SDL_CreateRGBSurface (dstflags, dstw, dsth, dstbpp,
1.379 - dstrmask, dstgmask, dstbmask, dstamask);
1.380 + dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp,
1.381 + dstrmask, dstgmask, dstbmask, dstamask);
1.382 }
1.383
1.384 if (dest == NULL) {
1.385 - fprintf (stderr, "dest surface creation failed: %s\n",
1.386 - SDL_GetError ());
1.387 - SDL_Quit ();
1.388 + fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError());
1.389 + SDL_Quit();
1.390 return (0);
1.391 }
1.392
1.393 - src = SDL_CreateRGBSurface (srcflags, srcw, srch, srcbpp,
1.394 - srcrmask, srcgmask, srcbmask, srcamask);
1.395 + src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp,
1.396 + srcrmask, srcgmask, srcbmask, srcamask);
1.397 if (src == NULL) {
1.398 - fprintf (stderr, "src surface creation failed: %s\n",
1.399 - SDL_GetError ());
1.400 - SDL_Quit ();
1.401 + fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError());
1.402 + SDL_Quit();
1.403 return (0);
1.404 }
1.405
1.406 @@ -320,54 +318,54 @@
1.407 for (i = 1; i < argc; i++) {
1.408 const char *arg = argv[i];
1.409
1.410 - if (strcmp (arg, "--srcalpha") == 0)
1.411 - srcalpha = atoi (argv[++i]);
1.412 - else if (strcmp (arg, "--dstalpha") == 0)
1.413 - dstalpha = atoi (argv[++i]);
1.414 - else if (strcmp (arg, "--srcsrcalpha") == 0)
1.415 + if (strcmp(arg, "--srcalpha") == 0)
1.416 + srcalpha = atoi(argv[++i]);
1.417 + else if (strcmp(arg, "--dstalpha") == 0)
1.418 + dstalpha = atoi(argv[++i]);
1.419 + else if (strcmp(arg, "--srcsrcalpha") == 0)
1.420 srcalphaflags |= SDL_SRCALPHA;
1.421 - else if (strcmp (arg, "--srcnosrcalpha") == 0)
1.422 + else if (strcmp(arg, "--srcnosrcalpha") == 0)
1.423 srcalphaflags &= ~SDL_SRCALPHA;
1.424 - else if (strcmp (arg, "--srcrleaccel") == 0)
1.425 + else if (strcmp(arg, "--srcrleaccel") == 0)
1.426 srcalphaflags |= SDL_RLEACCEL;
1.427 - else if (strcmp (arg, "--srcnorleaccel") == 0)
1.428 + else if (strcmp(arg, "--srcnorleaccel") == 0)
1.429 srcalphaflags &= ~SDL_RLEACCEL;
1.430 - else if (strcmp (arg, "--dstsrcalpha") == 0)
1.431 + else if (strcmp(arg, "--dstsrcalpha") == 0)
1.432 dstalphaflags |= SDL_SRCALPHA;
1.433 - else if (strcmp (arg, "--dstnosrcalpha") == 0)
1.434 + else if (strcmp(arg, "--dstnosrcalpha") == 0)
1.435 dstalphaflags &= ~SDL_SRCALPHA;
1.436 - else if (strcmp (arg, "--dstrleaccel") == 0)
1.437 + else if (strcmp(arg, "--dstrleaccel") == 0)
1.438 dstalphaflags |= SDL_RLEACCEL;
1.439 - else if (strcmp (arg, "--dstnorleaccel") == 0)
1.440 + else if (strcmp(arg, "--dstnorleaccel") == 0)
1.441 dstalphaflags &= ~SDL_RLEACCEL;
1.442 }
1.443 if ((dstalphaflags != origdstalphaflags)
1.444 || (dstalpha != dest->format->alpha))
1.445 - SDL_SetAlpha (dest, dstalphaflags, (Uint8) dstalpha);
1.446 + SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
1.447 if ((srcalphaflags != origsrcalphaflags)
1.448 || (srcalpha != src->format->alpha))
1.449 - SDL_SetAlpha (src, srcalphaflags, (Uint8) srcalpha);
1.450 + SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
1.451
1.452 /* set some sane defaults so we can see if the blit code is broken... */
1.453 - SDL_FillRect (dest, NULL, SDL_MapRGB (dest->format, 0, 0, 0));
1.454 - SDL_FillRect (src, NULL, SDL_MapRGB (src->format, 0, 0, 0));
1.455 + SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
1.456 + SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));
1.457
1.458 - blitCentered (src, bmp);
1.459 - SDL_FreeSurface (bmp);
1.460 + blitCentered(src, bmp);
1.461 + SDL_FreeSurface(bmp);
1.462
1.463 if (dumpfile)
1.464 - SDL_SaveBMP (src, dumpfile); /* make sure initial convert is sane. */
1.465 + SDL_SaveBMP(src, dumpfile); /* make sure initial convert is sane. */
1.466
1.467 - output_details ();
1.468 + output_details();
1.469
1.470 return (1);
1.471 }
1.472
1.473
1.474 static void
1.475 -test_blit_speed (void)
1.476 +test_blit_speed(void)
1.477 {
1.478 - Uint32 clearColor = SDL_MapRGB (dest->format, 0, 0, 0);
1.479 + Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0);
1.480 Uint32 iterations = 0;
1.481 Uint32 elasped = 0;
1.482 Uint32 end = 0;
1.483 @@ -376,49 +374,49 @@
1.484 int testms = testSeconds * 1000;
1.485 int wmax = (dest->w - src->w);
1.486 int hmax = (dest->h - src->h);
1.487 - int isScreen = (SDL_GetVideoSurface () == dest);
1.488 + int isScreen = (SDL_GetVideoSurface() == dest);
1.489 SDL_Event event;
1.490
1.491 - printf ("Testing blit speed for %d seconds...\n", testSeconds);
1.492 + printf("Testing blit speed for %d seconds...\n", testSeconds);
1.493
1.494 - now = SDL_GetTicks ();
1.495 + now = SDL_GetTicks();
1.496 end = now + testms;
1.497
1.498 do {
1.499 /* pump the event queue occasionally to keep OS happy... */
1.500 if (now - last > 1000) {
1.501 last = now;
1.502 - while (SDL_PollEvent (&event)) { /* no-op. */
1.503 + while (SDL_PollEvent(&event)) { /* no-op. */
1.504 }
1.505 }
1.506
1.507 iterations++;
1.508 - elasped += blit (dest, src, randRange (0, wmax), randRange (0, hmax));
1.509 + elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax));
1.510 if (isScreen) {
1.511 - SDL_Flip (dest); /* show it! */
1.512 - SDL_FillRect (dest, NULL, clearColor); /* blank it for next time! */
1.513 + SDL_Flip(dest); /* show it! */
1.514 + SDL_FillRect(dest, NULL, clearColor); /* blank it for next time! */
1.515 }
1.516
1.517 - now = SDL_GetTicks ();
1.518 + now = SDL_GetTicks();
1.519 }
1.520 while (now < end);
1.521
1.522 - printf ("Non-blitting crap accounted for %d percent of this run.\n",
1.523 - percent (testms - elasped, testms));
1.524 + printf("Non-blitting crap accounted for %d percent of this run.\n",
1.525 + percent(testms - elasped, testms));
1.526
1.527 - printf ("%d blits took %d ms (%d fps).\n",
1.528 - (int) iterations,
1.529 - (int) elasped,
1.530 - (int) (((float) iterations) / (((float) elasped) / 1000.0f)));
1.531 + printf("%d blits took %d ms (%d fps).\n",
1.532 + (int) iterations,
1.533 + (int) elasped,
1.534 + (int) (((float) iterations) / (((float) elasped) / 1000.0f)));
1.535 }
1.536
1.537 int
1.538 -main (int argc, char **argv)
1.539 +main(int argc, char **argv)
1.540 {
1.541 - int initialized = setup_test (argc, argv);
1.542 + int initialized = setup_test(argc, argv);
1.543 if (initialized) {
1.544 - test_blit_speed ();
1.545 - SDL_Quit ();
1.546 + test_blit_speed();
1.547 + SDL_Quit();
1.548 }
1.549 return (!initialized);
1.550 }