this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added GPU_LoadImage_RW(). Removed renderer's LoadImage(), replaced by using GPU_LoadSurface() and CopyImageFromSurface() where needed. Simplified logic in surface and image loading to delegate to the _RW functions.

+22 -59
+3
include/SDL_gpu.h
··· 981 981 /*! Load image from an image file that is supported by this renderer. Don't forget to GPU_FreeImage() it. */ 982 982 DECLSPEC GPU_Image* SDLCALL GPU_LoadImage(const char* filename); 983 983 984 + /*! Load image from an image file in memory. Don't forget to GPU_FreeImage() it. */ 985 + DECLSPEC GPU_Image* SDLCALL GPU_LoadImage_RW(SDL_RWops* rwops, Uint8 free_rwops); 986 + 984 987 /*! Creates an image that aliases the given image. Aliases can be used to store image settings (e.g. modulation color) for easy switching. 985 988 * GPU_FreeImage() frees the alias's memory, but does not affect the original. */ 986 989 DECLSPEC GPU_Image* SDLCALL GPU_CreateAliasImage(GPU_Image* image);
-3
include/SDL_gpu_RendererImpl.h
··· 61 61 /*! \see GPU_CreateImageUsingTexture() */ 62 62 GPU_Image* (SDLCALL *CreateImageUsingTexture)(GPU_Renderer* renderer, Uint32 handle, Uint8 take_ownership); 63 63 64 - /*! \see GPU_LoadImage() */ 65 - GPU_Image* (SDLCALL *LoadImage)(GPU_Renderer* renderer, const char* filename); 66 - 67 64 /*! \see GPU_CreateAliasImage() */ 68 65 GPU_Image* (SDLCALL *CreateAliasImage)(GPU_Renderer* renderer, GPU_Image* image); 69 66
+19 -30
src/SDL_gpu.c
··· 902 902 903 903 GPU_Image* GPU_LoadImage(const char* filename) 904 904 { 905 + return GPU_LoadImage_RW(SDL_RWFromFile(filename, "r"), 1); 906 + } 907 + 908 + GPU_Image* GPU_LoadImage_RW(SDL_RWops* rwops, Uint8 free_rwops) 909 + { 910 + GPU_Image* result; 911 + SDL_Surface* surface; 905 912 if(_gpu_current_renderer == NULL || _gpu_current_renderer->current_context_target == NULL) 906 913 return NULL; 914 + 915 + surface = GPU_LoadSurface_RW(rwops, free_rwops); 916 + if(surface == NULL) 917 + { 918 + GPU_PushErrorCode("GPU_LoadImage_RW", GPU_ERROR_DATA_ERROR, "Failed to load image data."); 919 + return NULL; 920 + } 907 921 908 - return _gpu_current_renderer->impl->LoadImage(_gpu_current_renderer, filename); 922 + result = _gpu_current_renderer->impl->CopyImageFromSurface(_gpu_current_renderer, surface); 923 + SDL_FreeSurface(surface); 924 + 925 + return result; 909 926 } 910 927 911 928 GPU_Image* GPU_CreateAliasImage(GPU_Image* image) ··· 1086 1103 1087 1104 SDL_Surface* GPU_LoadSurface(const char* filename) 1088 1105 { 1089 - int width, height, channels; 1090 - unsigned char* data; 1091 - SDL_Surface* result; 1092 - 1093 - if(filename == NULL) 1094 - { 1095 - GPU_PushErrorCode("GPU_LoadSurface", GPU_ERROR_NULL_ARGUMENT, "filename"); 1096 - return NULL; 1097 - } 1098 - 1099 - #ifdef __ANDROID__ 1100 - // Must use SDL_RWops to access the assets directory automatically 1101 - if(strlen(filename) > 0 && filename[0] != '/') 1102 - return GPU_LoadSurface_RW(SDL_RWFromFile(filename, "r"), 1); 1103 - #endif 1104 - 1105 - data = stbi_load(filename, &width, &height, &channels, 0); 1106 - 1107 - if(data == NULL) 1108 - { 1109 - GPU_PushErrorCode(__func__, GPU_ERROR_DATA_ERROR, "Failed to load \"%s\": %s", filename, stbi_failure_reason()); 1110 - return NULL; 1111 - } 1112 - 1113 - result = gpu_copy_raw_surface_data(data, width, height, channels); 1114 - 1115 - stbi_image_free(data); 1116 - 1117 - return result; 1106 + return GPU_LoadSurface_RW(SDL_RWFromFile(filename, "r"), 1); 1118 1107 } 1119 1108 1120 1109 // From http://stackoverflow.com/questions/5309471/getting-file-extension-in-c
-17
src/renderer_GL_common.inl
··· 2280 2280 #endif 2281 2281 } 2282 2282 2283 - static GPU_Image* LoadImage(GPU_Renderer* renderer, const char* filename) 2284 - { 2285 - GPU_Image* result; 2286 - SDL_Surface* surface = GPU_LoadSurface(filename); 2287 - if(surface == NULL) 2288 - { 2289 - GPU_PushErrorCode("GPU_LoadImage", GPU_ERROR_DATA_ERROR, "Failed to load image data."); 2290 - return NULL; 2291 - } 2292 - 2293 - result = renderer->impl->CopyImageFromSurface(renderer, surface); 2294 - SDL_FreeSurface(surface); 2295 - 2296 - return result; 2297 - } 2298 - 2299 2283 2300 2284 static GPU_Image* CreateAliasImage(GPU_Renderer* renderer, GPU_Image* image) 2301 2285 { ··· 6450 6434 \ 6451 6435 impl->CreateImage = &CreateImage; \ 6452 6436 impl->CreateImageUsingTexture = &CreateImageUsingTexture; \ 6453 - impl->LoadImage = &LoadImage; \ 6454 6437 impl->CreateAliasImage = &CreateAliasImage; \ 6455 6438 impl->SaveImage = &SaveImage; \ 6456 6439 impl->CopyImage = &CopyImage; \
-9
tests/renderer/main.c
··· 472 472 } 473 473 474 474 475 - static GPU_Image* LoadImage(GPU_Renderer* renderer, const char* filename) 476 - { 477 - GPU_Log(" %s (dummy)\n", __func__); 478 - 479 - return renderer->impl->CreateImage(renderer, 100, 100, GPU_FORMAT_RGBA); 480 - } 481 - 482 - 483 475 static GPU_Image* CreateAliasImage(GPU_Renderer* renderer, GPU_Image* image) 484 476 { 485 477 GPU_Image* result; ··· 1197 1189 1198 1190 impl->CreateImage = &CreateImage; 1199 1191 impl->CreateImageUsingTexture = &CreateImageUsingTexture; 1200 - impl->LoadImage = &LoadImage; 1201 1192 impl->CreateAliasImage = &CreateAliasImage; 1202 1193 impl->SaveImage = &SaveImage; 1203 1194 impl->CopyImage = &CopyImage;