src/video/SDL_video.c
changeset 3186 51750b7a966f
parent 3178 72edc980789b
child 3196 413672b09bb3
     1.1 --- a/src/video/SDL_video.c	Wed Jun 10 08:09:04 2009 +0000
     1.2 +++ b/src/video/SDL_video.c	Wed Jun 10 13:34:20 2009 +0000
     1.3 @@ -413,7 +413,7 @@
     1.4  
     1.5      /* Re-sort video modes */
     1.6      SDL_qsort(display->display_modes, display->num_display_modes,
     1.7 -        sizeof(SDL_DisplayMode), cmpmodes);
     1.8 +              sizeof(SDL_DisplayMode), cmpmodes);
     1.9  
    1.10      return SDL_TRUE;
    1.11  }
    1.12 @@ -1634,32 +1634,33 @@
    1.13              int pfmt;
    1.14  
    1.15              /* Pixel formats, sorted by best first */
    1.16 -            static const Uint32 sdl_pformats[]={
    1.17 -               SDL_PIXELFORMAT_ARGB8888,
    1.18 -               SDL_PIXELFORMAT_RGBA8888,
    1.19 -               SDL_PIXELFORMAT_ABGR8888,
    1.20 -               SDL_PIXELFORMAT_BGRA8888,
    1.21 -               SDL_PIXELFORMAT_RGB888,
    1.22 -               SDL_PIXELFORMAT_BGR888,
    1.23 -               SDL_PIXELFORMAT_RGB24,
    1.24 -               SDL_PIXELFORMAT_BGR24,
    1.25 -               SDL_PIXELFORMAT_RGB565,
    1.26 -               SDL_PIXELFORMAT_BGR565,
    1.27 -               SDL_PIXELFORMAT_ARGB1555,
    1.28 -               SDL_PIXELFORMAT_ABGR1555,
    1.29 -               SDL_PIXELFORMAT_RGB555,
    1.30 -               SDL_PIXELFORMAT_BGR555,
    1.31 -               SDL_PIXELFORMAT_ARGB4444,
    1.32 -               SDL_PIXELFORMAT_ABGR4444,
    1.33 -               SDL_PIXELFORMAT_RGB444,
    1.34 -               SDL_PIXELFORMAT_ARGB2101010,
    1.35 -               SDL_PIXELFORMAT_INDEX8,
    1.36 -               SDL_PIXELFORMAT_INDEX4LSB,
    1.37 -               SDL_PIXELFORMAT_INDEX4MSB,
    1.38 -               SDL_PIXELFORMAT_RGB332,
    1.39 -               SDL_PIXELFORMAT_INDEX1LSB,
    1.40 -               SDL_PIXELFORMAT_INDEX1MSB,
    1.41 -               SDL_PIXELFORMAT_UNKNOWN};
    1.42 +            static const Uint32 sdl_pformats[] = {
    1.43 +                SDL_PIXELFORMAT_ARGB8888,
    1.44 +                SDL_PIXELFORMAT_RGBA8888,
    1.45 +                SDL_PIXELFORMAT_ABGR8888,
    1.46 +                SDL_PIXELFORMAT_BGRA8888,
    1.47 +                SDL_PIXELFORMAT_RGB888,
    1.48 +                SDL_PIXELFORMAT_BGR888,
    1.49 +                SDL_PIXELFORMAT_RGB24,
    1.50 +                SDL_PIXELFORMAT_BGR24,
    1.51 +                SDL_PIXELFORMAT_RGB565,
    1.52 +                SDL_PIXELFORMAT_BGR565,
    1.53 +                SDL_PIXELFORMAT_ARGB1555,
    1.54 +                SDL_PIXELFORMAT_ABGR1555,
    1.55 +                SDL_PIXELFORMAT_RGB555,
    1.56 +                SDL_PIXELFORMAT_BGR555,
    1.57 +                SDL_PIXELFORMAT_ARGB4444,
    1.58 +                SDL_PIXELFORMAT_ABGR4444,
    1.59 +                SDL_PIXELFORMAT_RGB444,
    1.60 +                SDL_PIXELFORMAT_ARGB2101010,
    1.61 +                SDL_PIXELFORMAT_INDEX8,
    1.62 +                SDL_PIXELFORMAT_INDEX4LSB,
    1.63 +                SDL_PIXELFORMAT_INDEX4MSB,
    1.64 +                SDL_PIXELFORMAT_RGB332,
    1.65 +                SDL_PIXELFORMAT_INDEX1LSB,
    1.66 +                SDL_PIXELFORMAT_INDEX1MSB,
    1.67 +                SDL_PIXELFORMAT_UNKNOWN
    1.68 +            };
    1.69  
    1.70              bpp = fmt->BitsPerPixel;
    1.71              Rmask = fmt->Rmask;
    1.72 @@ -1667,7 +1668,8 @@
    1.73              Bmask = fmt->Bmask;
    1.74              Amask = fmt->Amask;
    1.75  
    1.76 -            format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
    1.77 +            format =
    1.78 +                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
    1.79              if (!format) {
    1.80                  SDL_SetError("Unknown pixel format");
    1.81                  return 0;
    1.82 @@ -1675,53 +1677,47 @@
    1.83  
    1.84              /* Search requested format in the supported texture */
    1.85              /* formats by current renderer                      */
    1.86 -            for (it=0; it<renderer->info.num_texture_formats; it++)
    1.87 -            {
    1.88 -                if (renderer->info.texture_formats[it]==format)
    1.89 -                {
    1.90 -                   break;
    1.91 +            for (it = 0; it < renderer->info.num_texture_formats; it++) {
    1.92 +                if (renderer->info.texture_formats[it] == format) {
    1.93 +                    break;
    1.94                  }
    1.95              }
    1.96  
    1.97              /* If requested format can't be found, search any best */
    1.98              /* format which renderer provides                      */
    1.99 -            if (it==renderer->info.num_texture_formats)
   1.100 -            {
   1.101 -                pfmt=0;
   1.102 -                for (;;)
   1.103 -                {
   1.104 -                    if (sdl_pformats[pfmt]==SDL_PIXELFORMAT_UNKNOWN)
   1.105 -                    {
   1.106 +            if (it == renderer->info.num_texture_formats) {
   1.107 +                pfmt = 0;
   1.108 +                for (;;) {
   1.109 +                    if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
   1.110                          break;
   1.111                      }
   1.112  
   1.113 -                    for (it=0; it<renderer->info.num_texture_formats; it++)
   1.114 -                    {
   1.115 -                       if (renderer->info.texture_formats[it]==sdl_pformats[pfmt])
   1.116 -                       {
   1.117 -                          break;
   1.118 -                       }
   1.119 +                    for (it = 0; it < renderer->info.num_texture_formats;
   1.120 +                         it++) {
   1.121 +                        if (renderer->info.texture_formats[it] ==
   1.122 +                            sdl_pformats[pfmt]) {
   1.123 +                            break;
   1.124 +                        }
   1.125                      }
   1.126  
   1.127 -                    if (it!=renderer->info.num_texture_formats)
   1.128 -                    {
   1.129 -                       /* The best format has been found */
   1.130 -                       break;
   1.131 +                    if (it != renderer->info.num_texture_formats) {
   1.132 +                        /* The best format has been found */
   1.133 +                        break;
   1.134                      }
   1.135                      pfmt++;
   1.136                  }
   1.137  
   1.138                  /* If any format can't be found, then return an error */
   1.139 -                if (it==renderer->info.num_texture_formats)
   1.140 -                {
   1.141 -                    SDL_SetError("Any of the supported pixel formats can't be found");
   1.142 +                if (it == renderer->info.num_texture_formats) {
   1.143 +                    SDL_SetError
   1.144 +                        ("Any of the supported pixel formats can't be found");
   1.145                      return 0;
   1.146                  }
   1.147  
   1.148                  /* Convert found pixel format back to color masks */
   1.149 -                if (SDL_PixelFormatEnumToMasks(renderer->info.texture_formats[it],
   1.150 -                       &bpp, &Rmask, &Gmask, &Bmask, &Amask)!=SDL_TRUE)
   1.151 -                {
   1.152 +                if (SDL_PixelFormatEnumToMasks
   1.153 +                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
   1.154 +                     &Bmask, &Amask) != SDL_TRUE) {
   1.155                      SDL_SetError("Unknown pixel format");
   1.156                      return 0;
   1.157                  }