src/render/SDL_render.c
changeset 5268 c5a04f3c3908
parent 5262 b530ef003506
child 5270 7aba0406c273
equal deleted inserted replaced
5267:93ea62a5ba8f 5268:c5a04f3c3908
   204 
   204 
   205 static Uint32
   205 static Uint32
   206 GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format)
   206 GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format)
   207 {
   207 {
   208     Uint32 i;
   208     Uint32 i;
   209     SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format);
   209 
   210 
   210     if (SDL_ISPIXELFORMAT_FOURCC(format)) {
   211     /* We just want to match the first format that has the same channels */
   211         /* Look for an exact match */
   212     for (i = 0; i < renderer->info.num_texture_formats; ++i) {
   212         for (i = 0; i < renderer->info.num_texture_formats; ++i) {
   213         if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) {
   213             if (renderer->info.texture_formats[i] == format) {
   214             return renderer->info.texture_formats[i];
   214                 return renderer->info.texture_formats[i];
       
   215             }
       
   216         }
       
   217     } else {
       
   218         SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format);
       
   219 
       
   220         /* We just want to match the first format that has the same channels */
       
   221         for (i = 0; i < renderer->info.num_texture_formats; ++i) {
       
   222             if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) {
       
   223                 return renderer->info.texture_formats[i];
       
   224             }
   215         }
   225         }
   216     }
   226     }
   217     return renderer->info.texture_formats[0];
   227     return renderer->info.texture_formats[0];
   218 }
   228 }
   219 
   229 
   311     } else {
   321     } else {
   312         needAlpha = SDL_FALSE;
   322         needAlpha = SDL_FALSE;
   313     }
   323     }
   314     format = renderer->info.texture_formats[0];
   324     format = renderer->info.texture_formats[0];
   315     for (i = 0; i < renderer->info.num_texture_formats; ++i) {
   325     for (i = 0; i < renderer->info.num_texture_formats; ++i) {
   316         if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
   326         if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&
       
   327             SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
   317             format = renderer->info.texture_formats[i];
   328             format = renderer->info.texture_formats[i];
   318             break;
   329             break;
   319         }
   330         }
   320     }
   331     }
   321 
   332