← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/use_sdl_image_in_one_place into lp:widelands

 

Added a streamlining idea.

Diff comments:

> === modified file 'src/map_io/CMakeLists.txt'
> --- src/map_io/CMakeLists.txt	2014-11-22 15:27:45 +0000
> +++ src/map_io/CMakeLists.txt	2014-11-28 07:33:28 +0000
> @@ -84,7 +84,6 @@
>      map_terrain_packet.h
>      map_version_packet.cc
>      map_version_packet.h
> -  USES_SDL2_IMAGE
>    DEPENDS
>      base_deprecated
>      base_exceptions
> 
> === modified file 'src/map_io/map_extradata_packet.cc'
> --- src/map_io/map_extradata_packet.cc	2014-11-24 07:10:03 +0000
> +++ src/map_io/map_extradata_packet.cc	2014-11-28 07:33:28 +0000
> @@ -19,9 +19,8 @@
>  
>  #include "map_io/map_extradata_packet.h"
>  
> -#include <SDL_image.h>
> -
>  #include "graphic/graphic.h"
> +#include "graphic/image_io.h"
>  #include "graphic/in_memory_image.h"
>  #include "graphic/texture.h"
>  #include "io/fileread.h"
> @@ -60,13 +59,7 @@
>  					const std::string hash = std::string("map:") + FileSystem::fs_filename(pname->c_str());
>  					const Image* image = nullptr;
>  					if (!g_gr->images().has(hash)) {
> -						FileRead fr;
> -
> -						fr.open(fs, *pname);
> -						SDL_Surface * const surf =
> -							IMG_Load_RW(SDL_RWFromMem(fr.data(0), fr.get_size()), 1);
> -						if (!surf)
> -							continue; //  Illegal pic. Skip it.
> +						SDL_Surface* surf = load_image_as_sdl_surface(*pname, &fs);

Why not use load_image, which will give you the texture straight away?

image = g_gr->images().insert(new_in_memory_image(hash, load_image(*pname, &fs));

>  						image = g_gr->images().insert(new_in_memory_image(hash, new Texture(surf)));
>  					} else {
>  						image = g_gr->images().get(hash);
> 


-- 
https://code.launchpad.net/~widelands-dev/widelands/use_sdl_image_in_one_place/+merge/243120
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/use_sdl_image_in_one_place into lp:widelands.


References