test/testblitspeed.c
changeset 1231 cf59e7b91ed4
parent 1039 68f2b997758e
child 1658 e49147870aac
child 1895 c121d94672cb
     1.1 --- a/test/testblitspeed.c	Thu Jan 05 15:25:19 2006 +0000
     1.2 +++ b/test/testblitspeed.c	Thu Jan 05 16:37:46 2006 +0000
     1.3 @@ -39,12 +39,35 @@
     1.4  {
     1.5      if (_surface->flags & flag)
     1.6          copy_trunc_str(str, strsize, flagstr);
     1.7 -} /* append_sdl_surface_flag */
     1.8 +}
     1.9  
    1.10  
    1.11  #define append_sdl_surface_flag(a, b, c, fl) __append_sdl_surface_flag(a, b, c, fl, " " #fl)
    1.12  #define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" )
    1.13  
    1.14 +static void output_videoinfo_details(void)
    1.15 +{
    1.16 +    const SDL_VideoInfo *info = SDL_GetVideoInfo();
    1.17 +    printf("SDL_GetVideoInfo():\n");
    1.18 +    if (info == NULL)
    1.19 +        printf("  (null.)\n");
    1.20 +    else
    1.21 +    {
    1.22 +        print_tf_state("  hardware surface available", info->hw_available);
    1.23 +        print_tf_state("  window manager available", info->wm_available);
    1.24 +        print_tf_state("  accelerated hardware->hardware blits", info->blit_hw);
    1.25 +        print_tf_state("  accelerated hardware->hardware colorkey blits", info->blit_hw_CC);
    1.26 +        print_tf_state("  accelerated hardware->hardware alpha blits", info->blit_hw_A);
    1.27 +        print_tf_state("  accelerated software->hardware blits", info->blit_sw);
    1.28 +        print_tf_state("  accelerated software->hardware colorkey blits", info->blit_sw_CC);
    1.29 +        print_tf_state("  accelerated software->hardware alpha blits", info->blit_sw_A);
    1.30 +        print_tf_state("  accelerated color fills", info->blit_fill);
    1.31 +        printf("  video memory: (%d)\n", info->video_mem);
    1.32 +    }
    1.33 +
    1.34 +    printf("\n");
    1.35 +}
    1.36 +
    1.37  static void output_surface_details(const char *name, SDL_Surface *surface)
    1.38  {
    1.39      printf("Details for %s:\n", name);
    1.40 @@ -56,24 +79,26 @@
    1.41      else
    1.42      {
    1.43          char f[256];
    1.44 -        printf("  width  : %d\n", surface->w);
    1.45 -        printf("  height : %d\n", surface->h);
    1.46 -        printf("  depth  : %d bits per pixel\n", surface->format->BitsPerPixel);
    1.47 -        printf("  pitch  : %d\n", (int) surface->pitch);
    1.48 +        printf("  width      : %d\n", surface->w);
    1.49 +        printf("  height     : %d\n", surface->h);
    1.50 +        printf("  depth      : %d bits per pixel\n", surface->format->BitsPerPixel);
    1.51 +        printf("  pitch      : %d\n", (int) surface->pitch);
    1.52 +        printf("  alpha      : %d\n", (int) surface->format->alpha);
    1.53 +        printf("  colorkey   : 0x%X\n", (unsigned int) surface->format->colorkey);
    1.54  
    1.55 -        printf("  red    : 0x%08X mask, %d shift, %d loss\n",
    1.56 +        printf("  red bits   : 0x%08X mask, %d shift, %d loss\n",
    1.57                      (int) surface->format->Rmask,
    1.58                      (int) surface->format->Rshift,
    1.59                      (int) surface->format->Rloss);
    1.60 -        printf("  green  : 0x%08X mask, %d shift, %d loss\n",
    1.61 +        printf("  green bits : 0x%08X mask, %d shift, %d loss\n",
    1.62                      (int) surface->format->Gmask,
    1.63                      (int) surface->format->Gshift,
    1.64                      (int) surface->format->Gloss);
    1.65 -        printf("  blue   : 0x%08X mask, %d shift, %d loss\n",
    1.66 +        printf("  blue bits  : 0x%08X mask, %d shift, %d loss\n",
    1.67                      (int) surface->format->Bmask,
    1.68                      (int) surface->format->Bshift,
    1.69                      (int) surface->format->Bloss);
    1.70 -        printf("  alpha  : 0x%08X mask, %d shift, %d loss\n",
    1.71 +        printf("  alpha bits : 0x%08X mask, %d shift, %d loss\n",
    1.72                      (int) surface->format->Amask,
    1.73                      (int) surface->format->Ashift,
    1.74                      (int) surface->format->Aloss);
    1.75 @@ -104,31 +129,15 @@
    1.76          if (f[0] == '\0')
    1.77              strcpy(f, " (none)");
    1.78  
    1.79 -        printf("  flags  :%s\n", f);
    1.80 -
    1.81 -        #if 0
    1.82 -        info = SDL_GetVideoInfo();
    1.83 -        assert(info != NULL);
    1.84 -
    1.85 -        print_tf_state("hardware surface available", info->hw_available);
    1.86 -        print_tf_state("window manager available", info->wm_available);
    1.87 -        print_tf_state("accelerated hardware->hardware blits", info->blit_hw);
    1.88 -        print_tf_state("accelerated hardware->hardware colorkey blits", info->blit_hw_CC);
    1.89 -        print_tf_state("accelerated hardware->hardware alpha blits", info->blit_hw_A);
    1.90 -        print_tf_state("accelerated software->hardware blits", info->blit_sw);
    1.91 -        print_tf_state("accelerated software->hardware colorkey blits", info->blit_sw_CC);
    1.92 -        print_tf_state("accelerated software->hardware alpha blits", info->blit_sw_A);
    1.93 -        print_tf_state("accelerated color fills", info->blit_fill);
    1.94 -
    1.95 -        printf("video memory: (%d)\n", info->video_mem);
    1.96 -        #endif
    1.97 -    } /* else */
    1.98 +        printf("  flags      :%s\n", f);
    1.99 +    }
   1.100  
   1.101      printf("\n");
   1.102  }
   1.103  
   1.104  static void output_details(void)
   1.105  {
   1.106 +    output_videoinfo_details();
   1.107      output_surface_details("Source Surface", src);
   1.108      output_surface_details("Destination Surface", dest);
   1.109  }
   1.110 @@ -195,8 +204,14 @@
   1.111      Uint32 srcflags = 0;
   1.112      int srcw = 640;
   1.113      int srch = 480;
   1.114 +    Uint32 origsrcalphaflags = 0;
   1.115 +    Uint32 origdstalphaflags = 0;
   1.116 +    Uint32 srcalphaflags = 0;
   1.117 +    Uint32 dstalphaflags = 0;
   1.118 +    int srcalpha = 255;
   1.119 +    int dstalpha = 255;
   1.120      int screenSurface = 0;
   1.121 -    int i;
   1.122 +    int i = 0;
   1.123  
   1.124      for (i = 1; i < argc; i++)
   1.125      {
   1.126 @@ -240,7 +255,8 @@
   1.127              screenSurface = 1;
   1.128          else if (strcmp(arg, "--dumpfile") == 0)
   1.129              dumpfile = argv[++i];
   1.130 -        else
   1.131 +        /* !!! FIXME: set colorkey. */
   1.132 +        else if (0)  /* !!! FIXME: we handle some commandlines elsewhere now */
   1.133          {
   1.134              fprintf(stderr, "Unknown commandline option: %s\n", arg);
   1.135              return(0);
   1.136 @@ -288,6 +304,43 @@
   1.137          return(0);
   1.138      }
   1.139  
   1.140 +    /* handle alpha settings... */
   1.141 +    srcalphaflags = (src->flags&SDL_SRCALPHA) | (src->flags&SDL_RLEACCEL);
   1.142 +    dstalphaflags = (dest->flags&SDL_SRCALPHA) | (dest->flags&SDL_RLEACCEL);
   1.143 +    origsrcalphaflags = srcalphaflags;
   1.144 +    origdstalphaflags = dstalphaflags;
   1.145 +    srcalpha = src->format->alpha;
   1.146 +    dstalpha = dest->format->alpha;
   1.147 +    for (i = 1; i < argc; i++)
   1.148 +    {
   1.149 +        const char *arg = argv[i];
   1.150 +
   1.151 +        if (strcmp(arg, "--srcalpha") == 0)
   1.152 +            srcalpha = atoi(argv[++i]);
   1.153 +        else if (strcmp(arg, "--dstalpha") == 0)
   1.154 +            dstalpha = atoi(argv[++i]);
   1.155 +        else if (strcmp(arg, "--srcsrcalpha") == 0)
   1.156 +            srcalphaflags |= SDL_SRCALPHA;
   1.157 +        else if (strcmp(arg, "--srcnosrcalpha") == 0)
   1.158 +            srcalphaflags &= ~SDL_SRCALPHA;
   1.159 +        else if (strcmp(arg, "--srcrleaccel") == 0)
   1.160 +            srcalphaflags |= SDL_RLEACCEL;
   1.161 +        else if (strcmp(arg, "--srcnorleaccel") == 0)
   1.162 +            srcalphaflags &= ~SDL_RLEACCEL;
   1.163 +        else if (strcmp(arg, "--dstsrcalpha") == 0)
   1.164 +            dstalphaflags |= SDL_SRCALPHA;
   1.165 +        else if (strcmp(arg, "--dstnosrcalpha") == 0)
   1.166 +            dstalphaflags &= ~SDL_SRCALPHA;
   1.167 +        else if (strcmp(arg, "--dstrleaccel") == 0)
   1.168 +            dstalphaflags |= SDL_RLEACCEL;
   1.169 +        else if (strcmp(arg, "--dstnorleaccel") == 0)
   1.170 +            dstalphaflags &= ~SDL_RLEACCEL;
   1.171 +    }
   1.172 +    if ((dstalphaflags != origdstalphaflags) || (dstalpha != dest->format->alpha))
   1.173 +        SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
   1.174 +    if ((srcalphaflags != origsrcalphaflags) || (srcalpha != src->format->alpha))
   1.175 +        SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
   1.176 +
   1.177      /* set some sane defaults so we can see if the blit code is broken... */
   1.178      SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
   1.179      SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0));