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