diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-26 16:09:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-26 16:52:08 +0300 |
commit | 929aeb1591e739588cd8cf629e7d7ac5a95261b1 (patch) | |
tree | 2b61b477d0e0ffed31a90ba2d6c019da926282aa /src/resources | |
parent | b661524e8b7b41cec237492ecd52fdda7b9be394 (diff) | |
download | manaverse-929aeb1591e739588cd8cf629e7d7ac5a95261b1.tar.gz manaverse-929aeb1591e739588cd8cf629e7d7ac5a95261b1.tar.bz2 manaverse-929aeb1591e739588cd8cf629e7d7ac5a95261b1.tar.xz manaverse-929aeb1591e739588cd8cf629e7d7ac5a95261b1.zip |
add surface allocation debug code.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/atlasmanager.cpp | 5 | ||||
-rw-r--r-- | src/resources/image.cpp | 6 | ||||
-rw-r--r-- | src/resources/imagehelper.cpp | 8 | ||||
-rw-r--r-- | src/resources/openglimagehelper.cpp | 11 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 5 | ||||
-rw-r--r-- | src/resources/sdl2imagehelper.cpp | 12 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 12 | ||||
-rw-r--r-- | src/resources/surfaceimagehelper.cpp | 12 |
8 files changed, 41 insertions, 30 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 01ea66233..80b0ad253 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -31,6 +31,7 @@ #include "utils/mathutils.h" #include "utils/physfsrwops.h" +#include "utils/sdlcheckutils.h" #include "resources/dye.h" #include "resources/fboinfo.h" @@ -79,7 +80,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, convertAtlas(atlas); // free SDL atlas surface - SDL_FreeSurface(surface); + MSDL_FreeSurface(surface); resource->atlases.push_back(atlas); } @@ -226,7 +227,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) const int width = atlas->width; const int height = atlas->height; // temp SDL surface for atlas - SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_SWSURFACE, + SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); if (!surface) return nullptr; diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 759a3a055..b5a852996 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -39,6 +39,8 @@ #include "resources/sdlimagehelper.h" #include "resources/subimage.h" +#include "utils/sdlcheckutils.h" + #include <SDL_image.h> #ifndef USE_SDL2 #include <SDL_rotozoom.h> @@ -208,7 +210,7 @@ void Image::unload() { SDLCleanCache(); // Free the image surface. - SDL_FreeSurface(mSDLSurface); + MSDL_FreeSurface(mSDLSurface); mSDLSurface = nullptr; delete [] mAlphaChannel; @@ -398,7 +400,7 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const if (scaledSurface) { scaledImage = imageHelper->load(scaledSurface); - SDL_FreeSurface(scaledSurface); + MSDL_FreeSurface(scaledSurface); } } #endif diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index 65af2755a..8a97b4a81 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -31,6 +31,8 @@ #include "resources/image.h" +#include "utils/sdlcheckutils.h" + #include <SDL_image.h> #include "debug.h" @@ -51,7 +53,7 @@ Image *ImageHelper::load(SDL_RWops *const rw) const Image *const image = load(tmpImage); - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); return image; } @@ -94,7 +96,7 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage) RGBAFormat.Ashift = 0; RGBAFormat.Aloss = 0; #endif - return SDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE); + return MSDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE); } void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image) const @@ -128,7 +130,7 @@ SDL_Surface *ImageHelper::loadPng(SDL_RWops *const rw) logger->log("Error, image is not png"); return nullptr; } - SDL_Surface *const tmpImage = IMG_LoadPNG_RW(rw); + SDL_Surface *const tmpImage = MIMG_LoadPNG_RW(rw); SDL_RWclose(rw); return tmpImage; } diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 0debbe988..6e60cc647 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -37,6 +37,7 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include "utils/sdlcheckutils.h" #include "utils/stringutils.h" #include <SDL_image.h> @@ -60,7 +61,7 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const } SDL_Surface *const surf = convertTo32Bit(tmpImage); - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); @@ -90,7 +91,7 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const } Image *const image = load(surf); - SDL_FreeSurface(surf); + MSDL_FreeSurface(surf); return image; } @@ -182,7 +183,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, #ifdef USE_SDL2 SDL_SetSurfaceBlendMode (oldImage, SDL_BLENDMODE_NONE); #endif - tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, + tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, rmask, gmask, bmask, amask); if (!tmpImage) @@ -260,7 +261,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, SDL_UnlockSurface(tmpImage); if (oldImage) - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); GLenum error = glGetError(); if (error) @@ -315,7 +316,7 @@ SDL_Surface *OpenGLImageHelper::create32BitSurface(int width, int height) const width = powerOfTwo(width); height = powerOfTwo(height); - return SDL_CreateRGBSurface(SDL_SWSURFACE, + return MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 6015347a9..662024f36 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -42,6 +42,7 @@ #include "utils/mkdir.h" #include "utils/physfsrwops.h" +#include "utils/sdlcheckutils.h" #include <SDL_image.h> #include <cassert> @@ -1047,7 +1048,7 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) const logger->log("Error, image is not png: " + filename); return nullptr; } - SDL_Surface *const surface = IMG_LoadPNG_RW(rw); + SDL_Surface *const surface = MIMG_LoadPNG_RW(rw); SDL_RWclose(rw); return surface; } @@ -1063,7 +1064,7 @@ void ResourceManager::clearScheduled() { BLOCK_START("ResourceManager::clearScheduled") FOR_EACH (std::set<SDL_Surface*>::iterator, i, deletedSurfaces) - SDL_FreeSurface(*i); + MSDL_FreeSurface(*i); deletedSurfaces.clear(); BLOCK_END("ResourceManager::clearScheduled") } diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp index ee342ee26..66e280c59 100644 --- a/src/resources/sdl2imagehelper.cpp +++ b/src/resources/sdl2imagehelper.cpp @@ -33,6 +33,8 @@ #include "resources/image.h" +#include "utils/sdlcheckutils.h" + #include <SDL_image.h> #include "debug.h" @@ -68,9 +70,9 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const rgba.Amask = 0x000000FF; #endif - SDL_Surface *const surf = SDL_ConvertSurface( + SDL_Surface *const surf = MSDL_ConvertSurface( tmpImage, &rgba, SDL_SWSURFACE); - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); @@ -100,7 +102,7 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const } Image *const image = load(surf); - SDL_FreeSurface(surf); + MSDL_FreeSurface(surf); return image; } @@ -128,7 +130,7 @@ SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage) if (!tmpImage || !tmpImage->format) return nullptr; - return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); + return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); } Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const @@ -163,7 +165,7 @@ SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const const int amask = 0xff000000; #endif - return SDL_CreateRGBSurface(SDL_SWSURFACE, + return MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); } diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 7a7de1906..cc5460fde 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -68,9 +68,9 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const rgba.Amask = 0x000000FF; #endif - SDL_Surface *const surf = SDL_ConvertSurface( + SDL_Surface *const surf = MSDL_ConvertSurface( tmpImage, &rgba, SDL_SWSURFACE); - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); @@ -100,7 +100,7 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye) const } Image *const image = load(surf); - SDL_FreeSurface(surf); + MSDL_FreeSurface(surf); return image; } @@ -183,7 +183,7 @@ SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage) if (!tmpImage || !tmpImage->format) return nullptr; - return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); + return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); } Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const @@ -270,7 +270,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const } if (converted) - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); return new Image(image, hasAlpha, alphaChannel); } @@ -293,7 +293,7 @@ SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const const int amask = 0xff000000; #endif - return SDL_CreateRGBSurface(SDL_SWSURFACE, + return MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); } diff --git a/src/resources/surfaceimagehelper.cpp b/src/resources/surfaceimagehelper.cpp index 45a7d95fd..75e311a36 100644 --- a/src/resources/surfaceimagehelper.cpp +++ b/src/resources/surfaceimagehelper.cpp @@ -33,6 +33,8 @@ #include "resources/image.h" +#include "utils/sdlcheckutils.h" + #include <SDL_image.h> #include "debug.h" @@ -65,9 +67,9 @@ Image *SurfaceImageHelper::load(SDL_RWops *const rw, Dye const &dye) const rgba.Amask = 0x000000FF; #endif - SDL_Surface *const surf = SDL_ConvertSurface( + SDL_Surface *const surf = MSDL_ConvertSurface( tmpImage, &rgba, SDL_SWSURFACE); - SDL_FreeSurface(tmpImage); + MSDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); @@ -97,7 +99,7 @@ Image *SurfaceImageHelper::load(SDL_RWops *const rw, Dye const &dye) const } Image *const image = load(surf); - SDL_FreeSurface(surf); + MSDL_FreeSurface(surf); return image; } @@ -130,7 +132,7 @@ SDL_Surface* SurfaceImageHelper::SDLDuplicateSurface(SDL_Surface *const if (!tmpImage || !tmpImage->format) return nullptr; - return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); + return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE); } Image *SurfaceImageHelper::_SDLload(SDL_Surface *tmpImage) const @@ -161,7 +163,7 @@ SDL_Surface *SurfaceImageHelper::create32BitSurface(int width, int height) const const int amask = 0xff000000; #endif - return SDL_CreateRGBSurface(SDL_SWSURFACE, + return MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); } |