test/testblitspeed.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 01 May 2006 06:58:33 +0000
branchSDL-1.3
changeset 1658 e49147870aac
parent 1231 cf59e7b91ed4
child 1662 782fd950bd46
permissions -rw-r--r--
glSDL support
icculus@1039
     1
/*
icculus@1039
     2
 * Benchmarks surface-to-surface blits in various formats.
icculus@1039
     3
 *
icculus@1039
     4
 *  Written by Ryan C. Gordon.
icculus@1039
     5
 */
icculus@1039
     6
icculus@1039
     7
#include <stdio.h>
icculus@1039
     8
#include <stdlib.h>
icculus@1039
     9
#include <string.h>
icculus@1039
    10
icculus@1039
    11
#include "SDL.h"
icculus@1039
    12
icculus@1039
    13
static SDL_Surface *dest = NULL;
icculus@1039
    14
static SDL_Surface *src = NULL;
icculus@1039
    15
static int testSeconds = 10;
icculus@1039
    16
icculus@1039
    17
icculus@1039
    18
static int percent(int val, int total)
icculus@1039
    19
{
icculus@1039
    20
    return((int) ((((float) val) / ((float) total)) * 100.0f));
icculus@1039
    21
}
icculus@1039
    22
icculus@1039
    23
static int randRange(int lo, int hi)
icculus@1039
    24
{
icculus@1039
    25
    return(lo + (int) (((double) hi)*rand()/(RAND_MAX+1.0)));
icculus@1039
    26
}
icculus@1039
    27
icculus@1039
    28
static void copy_trunc_str(char *str, size_t strsize, const char *flagstr)
icculus@1039
    29
{
icculus@1039
    30
    if ( (strlen(str) + strlen(flagstr)) >= (strsize - 1) )
icculus@1039
    31
        strcpy(str + (strsize - 5), " ...");
icculus@1039
    32
    else
icculus@1039
    33
        strcat(str, flagstr);
icculus@1039
    34
}
icculus@1039
    35
icculus@1039
    36
static void __append_sdl_surface_flag(SDL_Surface *_surface, char *str,
icculus@1039
    37
                                      size_t strsize, Uint32 flag,
icculus@1039
    38
                                      const char *flagstr)
icculus@1039
    39
{
icculus@1039
    40
    if (_surface->flags & flag)
icculus@1039
    41
        copy_trunc_str(str, strsize, flagstr);
icculus@1231
    42
}
icculus@1039
    43
icculus@1039
    44
icculus@1039
    45
#define append_sdl_surface_flag(a, b, c, fl) __append_sdl_surface_flag(a, b, c, fl, " " #fl)
icculus@1039
    46
#define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
icculus@1039
    47
icculus@1231
    48
static void output_videoinfo_details(void)
icculus@1231
    49
{
icculus@1231
    50
    const SDL_VideoInfo *info = SDL_GetVideoInfo();
icculus@1231
    51
    printf("SDL_GetVideoInfo():\n");
icculus@1231
    52
    if (info == NULL)
icculus@1231
    53
        printf("  (null.)\n");
icculus@1231
    54
    else
icculus@1231
    55
    {
icculus@1231
    56
        print_tf_state("  hardware surface available", info->hw_available);
icculus@1231
    57
        print_tf_state("  window manager available", info->wm_available);
icculus@1231
    58
        print_tf_state("  accelerated hardware->hardware blits", info->blit_hw);
icculus@1231
    59
        print_tf_state("  accelerated hardware->hardware colorkey blits", info->blit_hw_CC);
icculus@1231
    60
        print_tf_state("  accelerated hardware->hardware alpha blits", info->blit_hw_A);
icculus@1231
    61
        print_tf_state("  accelerated software->hardware blits", info->blit_sw);
icculus@1231
    62
        print_tf_state("  accelerated software->hardware colorkey blits", info->blit_sw_CC);
icculus@1231
    63
        print_tf_state("  accelerated software->hardware alpha blits", info->blit_sw_A);
icculus@1231
    64
        print_tf_state("  accelerated color fills", info->blit_fill);
icculus@1231
    65
        printf("  video memory: (%d)\n", info->video_mem);
icculus@1231
    66
    }
icculus@1231
    67
icculus@1231
    68
    printf("\n");
icculus@1231
    69
}
icculus@1231
    70
icculus@1039
    71
static void output_surface_details(const char *name, SDL_Surface *surface)
icculus@1039
    72
{
icculus@1039
    73
    printf("Details for %s:\n", name);
icculus@1039
    74
icculus@1039
    75
    if (surface == NULL)
icculus@1039
    76
    {
icculus@1039
    77
        printf("-WARNING- You've got a NULL surface!");
icculus@1039
    78
    }
icculus@1039
    79
    else
icculus@1039
    80
    {
icculus@1039
    81
        char f[256];
icculus@1231
    82
        printf("  width      : %d\n", surface->w);
icculus@1231
    83
        printf("  height     : %d\n", surface->h);
icculus@1231
    84
        printf("  depth      : %d bits per pixel\n", surface->format->BitsPerPixel);
icculus@1231
    85
        printf("  pitch      : %d\n", (int) surface->pitch);
icculus@1231
    86
        printf("  alpha      : %d\n", (int) surface->format->alpha);
icculus@1231
    87
        printf("  colorkey   : 0x%X\n", (unsigned int) surface->format->colorkey);
icculus@1039
    88
icculus@1231
    89
        printf("  red bits   : 0x%08X mask, %d shift, %d loss\n",
icculus@1039
    90
                    (int) surface->format->Rmask,
icculus@1039
    91
                    (int) surface->format->Rshift,
icculus@1039
    92
                    (int) surface->format->Rloss);
icculus@1231
    93
        printf("  green bits : 0x%08X mask, %d shift, %d loss\n",
icculus@1039
    94
                    (int) surface->format->Gmask,
icculus@1039
    95
                    (int) surface->format->Gshift,
icculus@1039
    96
                    (int) surface->format->Gloss);
icculus@1231
    97
        printf("  blue bits  : 0x%08X mask, %d shift, %d loss\n",
icculus@1039
    98
                    (int) surface->format->Bmask,
icculus@1039
    99
                    (int) surface->format->Bshift,
icculus@1039
   100
                    (int) surface->format->Bloss);
icculus@1231
   101
        printf("  alpha bits : 0x%08X mask, %d shift, %d loss\n",
icculus@1039
   102
                    (int) surface->format->Amask,
icculus@1039
   103
                    (int) surface->format->Ashift,
icculus@1039
   104
                    (int) surface->format->Aloss);
icculus@1039
   105
icculus@1039
   106
        f[0] = '\0';
icculus@1039
   107
icculus@1039
   108
        /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE);*/
icculus@1039
   109
        if ((surface->flags & SDL_HWSURFACE) == 0)
icculus@1039
   110
            copy_trunc_str(f, sizeof (f), " SDL_SWSURFACE");
icculus@1039
   111
icculus@1039
   112
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWSURFACE);
icculus@1039
   113
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_ASYNCBLIT);
icculus@1039
   114
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_ANYFORMAT);
icculus@1039
   115
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWPALETTE);
icculus@1039
   116
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_DOUBLEBUF);
icculus@1039
   117
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_FULLSCREEN);
icculus@1039
   118
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_OPENGL);
icculus@1039
   119
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_RESIZABLE);
icculus@1039
   120
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_NOFRAME);
icculus@1039
   121
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_HWACCEL);
icculus@1039
   122
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_SRCCOLORKEY);
icculus@1039
   123
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_RLEACCELOK);
icculus@1039
   124
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_RLEACCEL);
icculus@1039
   125
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_SRCALPHA);
icculus@1039
   126
        append_sdl_surface_flag(surface, f, sizeof (f), SDL_PREALLOC);
icculus@1039
   127
icculus@1039
   128
        if (f[0] == '\0')
icculus@1039
   129
            strcpy(f, " (none)");
icculus@1039
   130
icculus@1231
   131
        printf("  flags      :%s\n", f);
icculus@1231
   132
    }
icculus@1039
   133
icculus@1039
   134
    printf("\n");
icculus@1039
   135
}
icculus@1039
   136
icculus@1039
   137
static void output_details(void)
icculus@1039
   138
{
icculus@1231
   139
    output_videoinfo_details();
icculus@1039
   140
    output_surface_details("Source Surface", src);
icculus@1039
   141
    output_surface_details("Destination Surface", dest);
icculus@1039
   142
}
icculus@1039
   143
icculus@1039
   144
static Uint32 blit(SDL_Surface *dst, SDL_Surface *src, int x, int y)
icculus@1039
   145
{
icculus@1039
   146
    Uint32 start = 0;
icculus@1039
   147
    SDL_Rect srcRect;
icculus@1039
   148
    SDL_Rect dstRect;
icculus@1039
   149
icculus@1039
   150
    srcRect.x = 0;
icculus@1039
   151
    srcRect.y = 0;
icculus@1039
   152
    dstRect.x = x;
icculus@1039
   153
    dstRect.y = y;
icculus@1039
   154
    dstRect.w = srcRect.w = src->w;  /* SDL will clip as appropriate. */
icculus@1039
   155
    dstRect.h = srcRect.h = src->h;
icculus@1039
   156
icculus@1039
   157
    start = SDL_GetTicks();
icculus@1039
   158
    SDL_BlitSurface(src, &srcRect, dst, &dstRect);
icculus@1039
   159
    return(SDL_GetTicks() - start);
icculus@1039
   160
}
icculus@1039
   161
icculus@1039
   162
static void blitCentered(SDL_Surface *dst, SDL_Surface *src)
icculus@1039
   163
{
icculus@1039
   164
    int x = (dst->w - src->w) / 2;
icculus@1039
   165
    int y = (dst->h - src->h) / 2;
icculus@1039
   166
    blit(dst, src, x, y);
icculus@1039
   167
}
icculus@1039
   168
icculus@1039
   169
static int atoi_hex(const char *str)
icculus@1039
   170
{
icculus@1039
   171
    if (str == NULL)
icculus@1039
   172
        return 0;
icculus@1039
   173
icculus@1039
   174
    if (strlen(str) > 2)
icculus@1039
   175
    {
icculus@1039
   176
        int retval = 0;
icculus@1039
   177
        if ((str[0] == '0') && (str[1] == 'x'))
icculus@1039
   178
            sscanf(str + 2, "%X", &retval);
icculus@1039
   179
        return(retval);
icculus@1039
   180
    }
icculus@1039
   181
icculus@1039
   182
    return(atoi(str));
icculus@1039
   183
}
icculus@1039
   184
icculus@1039
   185
icculus@1039
   186
static int setup_test(int argc, char **argv)
icculus@1039
   187
{
icculus@1039
   188
    const char *dumpfile = NULL;
icculus@1039
   189
    SDL_Surface *bmp = NULL;
icculus@1039
   190
    Uint32 dstbpp = 32;
icculus@1039
   191
    Uint32 dstrmask = 0x00FF0000;
icculus@1039
   192
    Uint32 dstgmask = 0x0000FF00;
icculus@1039
   193
    Uint32 dstbmask = 0x000000FF;
icculus@1039
   194
    Uint32 dstamask = 0x00000000;
icculus@1039
   195
    Uint32 dstflags = 0;
icculus@1039
   196
    int dstw = 640;
icculus@1039
   197
    int dsth = 480;
icculus@1039
   198
    Uint32 srcbpp = 32;
icculus@1039
   199
    Uint32 srcrmask = 0x00FF0000;
icculus@1039
   200
    Uint32 srcgmask = 0x0000FF00;
icculus@1039
   201
    Uint32 srcbmask = 0x000000FF;
icculus@1039
   202
    Uint32 srcamask = 0x00000000;
icculus@1039
   203
    Uint32 srcflags = 0;
icculus@1039
   204
    int srcw = 640;
icculus@1039
   205
    int srch = 480;
icculus@1231
   206
    Uint32 origsrcalphaflags = 0;
icculus@1231
   207
    Uint32 origdstalphaflags = 0;
icculus@1231
   208
    Uint32 srcalphaflags = 0;
icculus@1231
   209
    Uint32 dstalphaflags = 0;
icculus@1231
   210
    int srcalpha = 255;
icculus@1231
   211
    int dstalpha = 255;
icculus@1039
   212
    int screenSurface = 0;
icculus@1231
   213
    int i = 0;
icculus@1039
   214
icculus@1039
   215
    for (i = 1; i < argc; i++)
icculus@1039
   216
    {
icculus@1039
   217
        const char *arg = argv[i];
icculus@1039
   218
icculus@1039
   219
        if (strcmp(arg, "--dstbpp") == 0)
icculus@1039
   220
            dstbpp = atoi(argv[++i]);
icculus@1039
   221
        else if (strcmp(arg, "--dstrmask") == 0)
icculus@1039
   222
            dstrmask = atoi_hex(argv[++i]);
icculus@1039
   223
        else if (strcmp(arg, "--dstgmask") == 0)
icculus@1039
   224
            dstgmask = atoi_hex(argv[++i]);
icculus@1039
   225
        else if (strcmp(arg, "--dstbmask") == 0)
icculus@1039
   226
            dstbmask = atoi_hex(argv[++i]);
icculus@1039
   227
        else if (strcmp(arg, "--dstamask") == 0)
icculus@1039
   228
            dstamask = atoi_hex(argv[++i]);
icculus@1039
   229
        else if (strcmp(arg, "--dstwidth") == 0)
icculus@1039
   230
            dstw = atoi(argv[++i]);
icculus@1039
   231
        else if (strcmp(arg, "--dstheight") == 0)
icculus@1039
   232
            dsth = atoi(argv[++i]);
icculus@1039
   233
        else if (strcmp(arg, "--dsthwsurface") == 0)
icculus@1039
   234
            dstflags |= SDL_HWSURFACE;
icculus@1039
   235
        else if (strcmp(arg, "--srcbpp") == 0)
icculus@1039
   236
            srcbpp = atoi(argv[++i]);
icculus@1039
   237
        else if (strcmp(arg, "--srcrmask") == 0)
icculus@1039
   238
            srcrmask = atoi_hex(argv[++i]);
icculus@1039
   239
        else if (strcmp(arg, "--srcgmask") == 0)
icculus@1039
   240
            srcgmask = atoi_hex(argv[++i]);
icculus@1039
   241
        else if (strcmp(arg, "--srcbmask") == 0)
icculus@1039
   242
            srcbmask = atoi_hex(argv[++i]);
icculus@1039
   243
        else if (strcmp(arg, "--srcamask") == 0)
icculus@1039
   244
            srcamask = atoi_hex(argv[++i]);
icculus@1039
   245
        else if (strcmp(arg, "--srcwidth") == 0)
icculus@1039
   246
            srcw = atoi(argv[++i]);
icculus@1039
   247
        else if (strcmp(arg, "--srcheight") == 0)
icculus@1039
   248
            srch = atoi(argv[++i]);
icculus@1039
   249
        else if (strcmp(arg, "--srchwsurface") == 0)
icculus@1039
   250
            srcflags |= SDL_HWSURFACE;
icculus@1039
   251
        else if (strcmp(arg, "--seconds") == 0)
icculus@1039
   252
            testSeconds = atoi(argv[++i]);
icculus@1039
   253
        else if (strcmp(arg, "--screen") == 0)
icculus@1039
   254
            screenSurface = 1;
icculus@1039
   255
        else if (strcmp(arg, "--dumpfile") == 0)
icculus@1039
   256
            dumpfile = argv[++i];
icculus@1231
   257
        /* !!! FIXME: set colorkey. */
icculus@1231
   258
        else if (0)  /* !!! FIXME: we handle some commandlines elsewhere now */
icculus@1039
   259
        {
icculus@1039
   260
            fprintf(stderr, "Unknown commandline option: %s\n", arg);
icculus@1039
   261
            return(0);
icculus@1039
   262
        }
icculus@1039
   263
    }
icculus@1039
   264
icculus@1039
   265
    if (SDL_Init(SDL_INIT_VIDEO) == -1)
icculus@1039
   266
    {
icculus@1039
   267
        fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
icculus@1039
   268
        return(0);
icculus@1039
   269
    }
icculus@1039
   270
icculus@1039
   271
    bmp = SDL_LoadBMP("sample.bmp");
icculus@1039
   272
    if (bmp == NULL)
icculus@1039
   273
    {
icculus@1039
   274
        fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError());
icculus@1039
   275
        SDL_Quit();
icculus@1039
   276
        return(0);
icculus@1039
   277
    }
icculus@1039
   278
icculus@1039
   279
    if ((dstflags & SDL_HWSURFACE) == 0) dstflags |= SDL_SWSURFACE;
icculus@1039
   280
    if ((srcflags & SDL_HWSURFACE) == 0) srcflags |= SDL_SWSURFACE;
icculus@1039
   281
icculus@1039
   282
    if (screenSurface)
icculus@1039
   283
        dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags);
icculus@1039
   284
    else
icculus@1039
   285
    {
icculus@1039
   286
        dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp,
icculus@1039
   287
                                    dstrmask, dstgmask, dstbmask, dstamask);
icculus@1039
   288
    }
icculus@1039
   289
icculus@1039
   290
    if (dest == NULL)
icculus@1039
   291
    {
icculus@1039
   292
        fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError());
icculus@1039
   293
        SDL_Quit();
icculus@1039
   294
        return(0);
icculus@1039
   295
    }
icculus@1039
   296
icculus@1039
   297
    src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp,
icculus@1039
   298
                               srcrmask, srcgmask, srcbmask, srcamask);
icculus@1039
   299
    if (src == NULL)
icculus@1039
   300
    {
icculus@1039
   301
        fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError());
icculus@1039
   302
        SDL_Quit();
icculus@1039
   303
        return(0);
icculus@1039
   304
    }
icculus@1039
   305
icculus@1231
   306
    /* handle alpha settings... */
icculus@1231
   307
    srcalphaflags = (src->flags&SDL_SRCALPHA) | (src->flags&SDL_RLEACCEL);
icculus@1231
   308
    dstalphaflags = (dest->flags&SDL_SRCALPHA) | (dest->flags&SDL_RLEACCEL);
icculus@1231
   309
    origsrcalphaflags = srcalphaflags;
icculus@1231
   310
    origdstalphaflags = dstalphaflags;
icculus@1231
   311
    srcalpha = src->format->alpha;
icculus@1231
   312
    dstalpha = dest->format->alpha;
icculus@1231
   313
    for (i = 1; i < argc; i++)
icculus@1231
   314
    {
icculus@1231
   315
        const char *arg = argv[i];
icculus@1231
   316
icculus@1231
   317
        if (strcmp(arg, "--srcalpha") == 0)
icculus@1231
   318
            srcalpha = atoi(argv[++i]);
icculus@1231
   319
        else if (strcmp(arg, "--dstalpha") == 0)
icculus@1231
   320
            dstalpha = atoi(argv[++i]);
icculus@1231
   321
        else if (strcmp(arg, "--srcsrcalpha") == 0)
icculus@1231
   322
            srcalphaflags |= SDL_SRCALPHA;
icculus@1231
   323
        else if (strcmp(arg, "--srcnosrcalpha") == 0)
icculus@1231
   324
            srcalphaflags &= ~SDL_SRCALPHA;
icculus@1231
   325
        else if (strcmp(arg, "--srcrleaccel") == 0)
icculus@1231
   326
            srcalphaflags |= SDL_RLEACCEL;
icculus@1231
   327
        else if (strcmp(arg, "--srcnorleaccel") == 0)
icculus@1231
   328
            srcalphaflags &= ~SDL_RLEACCEL;
icculus@1231
   329
        else if (strcmp(arg, "--dstsrcalpha") == 0)
icculus@1231
   330
            dstalphaflags |= SDL_SRCALPHA;
icculus@1231
   331
        else if (strcmp(arg, "--dstnosrcalpha") == 0)
icculus@1231
   332
            dstalphaflags &= ~SDL_SRCALPHA;
icculus@1231
   333
        else if (strcmp(arg, "--dstrleaccel") == 0)
icculus@1231
   334
            dstalphaflags |= SDL_RLEACCEL;
icculus@1231
   335
        else if (strcmp(arg, "--dstnorleaccel") == 0)
icculus@1231
   336
            dstalphaflags &= ~SDL_RLEACCEL;
icculus@1231
   337
    }
icculus@1231
   338
    if ((dstalphaflags != origdstalphaflags) || (dstalpha != dest->format->alpha))
icculus@1231
   339
        SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
icculus@1231
   340
    if ((srcalphaflags != origsrcalphaflags) || (srcalpha != src->format->alpha))
icculus@1231
   341
        SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
icculus@1231
   342
icculus@1039
   343
    /* set some sane defaults so we can see if the blit code is broken... */
icculus@1039
   344
    SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
icculus@1039
   345
    SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));
icculus@1039
   346
icculus@1039
   347
    blitCentered(src, bmp);
icculus@1039
   348
    SDL_FreeSurface(bmp);
icculus@1039
   349
icculus@1039
   350
    if (dumpfile)
icculus@1039
   351
        SDL_SaveBMP(src, dumpfile);  /* make sure initial convert is sane. */
icculus@1039
   352
icculus@1039
   353
    output_details();
icculus@1039
   354
icculus@1039
   355
    return(1);
icculus@1039
   356
}
icculus@1039
   357
icculus@1039
   358
icculus@1039
   359
static void test_blit_speed(void)
icculus@1039
   360
{
icculus@1039
   361
    Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0);
icculus@1039
   362
    Uint32 iterations = 0;
icculus@1039
   363
    Uint32 elasped = 0;
icculus@1039
   364
    Uint32 end = 0;
icculus@1039
   365
    Uint32 now = 0;
icculus@1039
   366
    Uint32 last = 0;
icculus@1039
   367
    int testms = testSeconds * 1000;
icculus@1039
   368
    int wmax = (dest->w - src->w);
icculus@1039
   369
    int hmax = (dest->h - src->h);
icculus@1039
   370
    int isScreen = (SDL_GetVideoSurface() == dest);
icculus@1039
   371
    SDL_Event event;
icculus@1039
   372
icculus@1039
   373
    printf("Testing blit speed for %d seconds...\n", testSeconds);
icculus@1039
   374
icculus@1039
   375
    now = SDL_GetTicks();
icculus@1039
   376
    end = now + testms;
icculus@1039
   377
icculus@1039
   378
    do
icculus@1039
   379
    {
icculus@1039
   380
        /* pump the event queue occasionally to keep OS happy... */
icculus@1039
   381
        if (now - last > 1000)
icculus@1039
   382
        {
icculus@1039
   383
            last = now;
icculus@1039
   384
            while (SDL_PollEvent(&event)) { /* no-op. */ }
icculus@1039
   385
        }
icculus@1039
   386
icculus@1039
   387
        iterations++;
icculus@1039
   388
        elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax));
icculus@1039
   389
        if (isScreen)
icculus@1039
   390
        {
icculus@1039
   391
            SDL_Flip(dest);  /* show it! */
icculus@1039
   392
            SDL_FillRect(dest, NULL, clearColor); /* blank it for next time! */
icculus@1039
   393
        }
icculus@1039
   394
icculus@1039
   395
        now = SDL_GetTicks();
icculus@1039
   396
    } while (now < end);
icculus@1039
   397
icculus@1039
   398
    printf("Non-blitting crap accounted for %d percent of this run.\n",
icculus@1039
   399
            percent(testms - elasped, testms));
icculus@1039
   400
icculus@1039
   401
    printf("%d blits took %d ms (%d fps).\n",
icculus@1039
   402
            (int) iterations,
icculus@1039
   403
            (int) elasped,
icculus@1039
   404
            (int) (((float)iterations) / (((float)elasped) / 1000.0f)));
icculus@1039
   405
}
icculus@1039
   406
icculus@1039
   407
int main(int argc, char **argv)
icculus@1039
   408
{
icculus@1039
   409
    int initialized = setup_test(argc, argv);
icculus@1039
   410
    if (initialized)
icculus@1039
   411
    {
icculus@1039
   412
        test_blit_speed();
icculus@1039
   413
        SDL_Quit();
icculus@1039
   414
    }
icculus@1039
   415
    return(!initialized);
icculus@1039
   416
}
icculus@1039
   417
icculus@1039
   418
/* end of testblitspeed.c ... */
icculus@1039
   419