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