diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-28 16:30:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-29 00:18:56 +0300 |
commit | 57726c7324f165c70671fc5b05d6c0964f56b870 (patch) | |
tree | 8a9f37914c18f9c6ec6d64da08834af245afe0f3 /src/resources | |
parent | ee1a05faf157c8c9f0f43cf5b906d84f39ded497 (diff) | |
download | mv-57726c7324f165c70671fc5b05d6c0964f56b870.tar.gz mv-57726c7324f165c70671fc5b05d6c0964f56b870.tar.bz2 mv-57726c7324f165c70671fc5b05d6c0964f56b870.tar.xz mv-57726c7324f165c70671fc5b05d6c0964f56b870.zip |
improve debug checkers.
add missing surface functions for debugging.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.cpp | 10 | ||||
-rw-r--r-- | src/resources/resource.cpp | 14 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 8 | ||||
-rw-r--r-- | src/resources/subimage.cpp | 8 |
4 files changed, 31 insertions, 9 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index cd8231e7b..71c29ba53 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -69,7 +69,7 @@ Image::Image(SDL_Texture *const image, const int width, const int height) : mIsAlphaCalculated(false) { #ifdef DEBUG_IMAGES - logger->log("created: %p", this); + logger->log("created image: %p", this); #endif mBounds.x = 0; @@ -115,7 +115,7 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0, mIsAlphaCalculated(false) { #ifdef DEBUG_IMAGES - logger->log("created: %p", static_cast<void*>(this)); + logger->log("created image: %p", static_cast<void*>(this)); #endif mBounds.x = 0; @@ -159,7 +159,7 @@ Image::Image(const GLuint glimage, const int width, const int height, mIsAlphaCalculated(false) { #ifdef DEBUG_IMAGES - logger->log("created: %p", static_cast<void*>(this)); + logger->log("created image: %p", static_cast<void*>(this)); #endif mBounds.x = 0; @@ -182,8 +182,8 @@ Image::Image(const GLuint glimage, const int width, const int height, Image::~Image() { #ifdef DEBUG_IMAGES - logger->log("delete: %p, %s, %s", static_cast<void*>(this), - mIdPath.c_str(), mSource.c_str()); + logger->log("delete image: %p", static_cast<void*>(this)); + logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str()); #endif unload(); } diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index b67fe644b..b12e2f511 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -35,11 +35,21 @@ Resource::~Resource() void Resource::incRef() { +#ifdef DEBUG_IMAGES + logger->log("before incRef for: %p", static_cast<void*>(this)); mRefCount++; + logger->log("after incRef: %p, %d", static_cast<void*>(this), mRefCount); +#else + mRefCount++; +#endif } void Resource::decRef() { +#ifdef DEBUG_IMAGES + logger->log("before decRef for: %p", static_cast<void*>(this)); +#endif + // Reference may not already have reached zero if (mRefCount == 0) { @@ -49,6 +59,10 @@ void Resource::decRef() mRefCount--; +#ifdef DEBUG_IMAGES + logger->log("after decRef: %p, %d", static_cast<void*>(this), mRefCount); +#endif + if (mRefCount == 0 && !mNotCount) { // Warn the manager that this resource is no longer used. diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index cf8d1d04a..e7d7bacd6 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -156,11 +156,11 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage, // Convert the surface to the current display format if (hasAlpha) { - image = SDL_DisplayFormatAlpha(tmpImage); + image = MSDL_DisplayFormatAlpha(tmpImage); } else { - image = SDL_DisplayFormat(tmpImage); + image = MSDL_DisplayFormat(tmpImage); // We also delete the alpha channel since // it's not used. @@ -252,11 +252,11 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const // Convert the surface to the current display format if (hasAlpha) { - image = SDL_DisplayFormatAlpha(tmpImage); + image = MSDL_DisplayFormatAlpha(tmpImage); } else { - image = SDL_DisplayFormat(tmpImage); + image = MSDL_DisplayFormat(tmpImage); // We also delete the alpha channel since // it's not used. diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp index a13a885bb..d3dec55d5 100644 --- a/src/resources/subimage.cpp +++ b/src/resources/subimage.cpp @@ -185,6 +185,10 @@ SubImage::SubImage(Image *const parent, const GLuint image, SubImage::~SubImage() { +#ifdef DEBUG_IMAGES + logger->log("delete subimage: %p", static_cast<void*>(this)); + logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str()); +#endif // Avoid destruction of the image mSDLSurface = nullptr; // Avoid possible destruction of its alpha channel @@ -198,6 +202,10 @@ SubImage::~SubImage() #endif if (mParent) { +#ifdef DEBUG_IMAGES + logger->log("decref from subminage: %p, parent: %p", + static_cast<void*>(this), static_cast<void*>(mParent)); +#endif mParent->decRef(); mParent = nullptr; } |