diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-29 00:47:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-29 00:47:21 +0300 |
commit | ab65923161edd3dab8d2623b3895485ad932a951 (patch) | |
tree | 7fcdb4b564b6620bb19b5b79fcece3e709c7c15a /src/resources | |
parent | 442a2dd0a4417182cbdd9f9fefb45bda4914e3d7 (diff) | |
download | manaverse-ab65923161edd3dab8d2623b3895485ad932a951.tar.gz manaverse-ab65923161edd3dab8d2623b3895485ad932a951.tar.bz2 manaverse-ab65923161edd3dab8d2623b3895485ad932a951.tar.xz manaverse-ab65923161edd3dab8d2623b3895485ad932a951.zip |
Dont return temp surface in atlasmanager.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/atlas/atlasmanager.cpp | 26 | ||||
-rw-r--r-- | src/resources/atlas/atlasmanager.h | 4 |
2 files changed, 7 insertions, 23 deletions
diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp index bc1bf8224..19ab3b09f 100644 --- a/src/resources/atlas/atlasmanager.cpp +++ b/src/resources/atlas/atlasmanager.cpp @@ -79,23 +79,8 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, if (!atlas) continue; - // create atlas base on sorted images - SDL_Surface *const surface = createSDLAtlas(atlas); - - if (!surface) - continue; - - // debug save -// ImageWriter::writePNG(surface, settings.tempDir -// + "/atlas" + name + toString(k) + ".png"); -// k ++; - - // convert SDL images to OpenGL + createSDLAtlas(atlas); convertAtlas(atlas); - - // free SDL atlas surface - MSDL_FreeSurface(surface); - resource->atlases.push_back(atlas); } @@ -281,7 +266,7 @@ void AtlasManager::simpleSort(const std::string &restrict name, BLOCK_END("AtlasManager::simpleSort") } -SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) +void AtlasManager::createSDLAtlas(TextureAtlas *const atlas) { BLOCK_START("AtlasManager::createSDLAtlas") #if SDL_BYTEORDER == SDL_BIG_ENDIAN @@ -300,7 +285,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) if (atlas->items.size() == 1) { BLOCK_END("AtlasManager::createSDLAtlas") - return nullptr; + return; } // using only power of two sizes. @@ -316,11 +301,13 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) if (!surface) { BLOCK_END("AtlasManager::createSDLAtlas") - return nullptr; + return; } BLOCK_END("AtlasManager::createSDLAtlas create surface") Image *image = imageHelper->loadSurface(surface); + // free SDL atlas surface + MSDL_FreeSurface(surface); // drawing SDL images to surface FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items) @@ -334,7 +321,6 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) } atlas->atlasImage = image; BLOCK_END("AtlasManager::createSDLAtlas") - return surface; } void AtlasManager::convertAtlas(TextureAtlas *const atlas) diff --git a/src/resources/atlas/atlasmanager.h b/src/resources/atlas/atlasmanager.h index fdee09ecf..84f66e845 100644 --- a/src/resources/atlas/atlasmanager.h +++ b/src/resources/atlas/atlasmanager.h @@ -63,9 +63,7 @@ class AtlasManager final const std::vector<Image*> &restrict images, int size); - static SDL_Surface *createSDLAtlas(TextureAtlas *const atlas) - A_WARN_UNUSED A_NONNULL(1); - + static void createSDLAtlas(TextureAtlas *const atlas) A_NONNULL(1); static void convertAtlas(TextureAtlas *const atlas) A_NONNULL(1); }; |