summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resources/atlas/atlasmanager.cpp26
-rw-r--r--src/resources/atlas/atlasmanager.h4
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);
};