summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-25 15:36:23 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-25 15:36:23 +0300
commit735a20bc923d0a7bf4b0ca0e4d005413ca8de0f8 (patch)
tree6c8bd501bee54a9320206ed1792ead2b15743471 /src/resources
parent2ed588669e77c3dc9d6cae36ee148cab3125b901 (diff)
downloadmanaverse-735a20bc923d0a7bf4b0ca0e4d005413ca8de0f8.tar.gz
manaverse-735a20bc923d0a7bf4b0ca0e4d005413ca8de0f8.tar.bz2
manaverse-735a20bc923d0a7bf4b0ca0e4d005413ca8de0f8.tar.xz
manaverse-735a20bc923d0a7bf4b0ca0e4d005413ca8de0f8.zip
add code for image creation/deletion.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/atlasmanager.cpp9
-rw-r--r--src/resources/image.cpp11
-rw-r--r--src/resources/resourcemanager.cpp9
-rw-r--r--src/resources/subimage.cpp10
4 files changed, 39 insertions, 0 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index a5d7c2ccc..01ea66233 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -123,6 +123,9 @@ void AtlasManager::loadImages(const StringVect &files,
if (image)
{
image->mIdPath = str;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", image, image->mIdPath.c_str());
+#endif
images.push_back(image);
}
}
@@ -268,6 +271,9 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
return;
image->mIdPath = atlas->name;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", image, image->mIdPath.c_str());
+#endif
image->incRef();
FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
@@ -282,6 +288,9 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
if (image2)
{
image2->mIdPath = item->name;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", image2, image2->mIdPath.c_str());
+#endif
image2->incRef();
}
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 7f2fd6fbd..49650fef3 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -65,6 +65,10 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
mIsAlphaVisible(hasAlphaChannel0),
mIsAlphaCalculated(false)
{
+#ifdef DEBUG_IMAGES
+ logger->log("created: %p", this);
+#endif
+
mBounds.x = 0;
mBounds.y = 0;
@@ -102,6 +106,10 @@ Image::Image(const GLuint glimage, const int width, const int height,
mIsAlphaVisible(true),
mIsAlphaCalculated(false)
{
+#ifdef DEBUG_IMAGES
+ logger->log("created: %p", this);
+#endif
+
mBounds.x = 0;
mBounds.y = 0;
mBounds.w = static_cast<uint16_t>(width);
@@ -121,6 +129,9 @@ Image::Image(const GLuint glimage, const int width, const int height,
Image::~Image()
{
+#ifdef DEBUG_IMAGES
+ logger->log("delete: %p, %s, %s", this, mIdPath.c_str(), mSource.c_str());
+#endif
unload();
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 03cc2bc41..a3adce7bb 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -448,6 +448,9 @@ bool ResourceManager::addResource(const std::string &idPath,
{
resource->incRef();
resource->mIdPath = idPath;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", resource, resource->mIdPath.c_str());
+#endif
mResources[idPath] = resource;
return true;
}
@@ -517,6 +520,9 @@ Resource *ResourceManager::get(const std::string &idPath, const generator fun,
{
resource->incRef();
resource->mIdPath = idPath;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", resource, resource->mIdPath.c_str());
+#endif
mResources[idPath] = resource;
cleanOrphans();
}
@@ -531,6 +537,9 @@ Resource *ResourceManager::get(const std::string &idPath, const generator fun,
{
resource->incRef();
resource->mIdPath = idPath;
+#ifdef DEBUG_IMAGES
+ logger->log("set name %p, %s", resource, resource->mIdPath.c_str());
+#endif
}
else
{
diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp
index c7e250b78..b2343c71c 100644
--- a/src/resources/subimage.cpp
+++ b/src/resources/subimage.cpp
@@ -28,6 +28,10 @@
#include "safeopenglgraphics.h"
#endif
+#ifdef DEBUG_IMAGES
+#include "logger.h"
+#endif
+
#include "client.h"
#include "debug.h"
@@ -47,6 +51,9 @@ SubImage::SubImage(Image *const parent, SDL_Surface *const image,
mIsAlphaVisible = mHasAlphaChannel;
mAlphaChannel = mParent->SDLgetAlphaChannel();
mSource = parent->getIdPath();
+#ifdef DEBUG_IMAGES
+ logger->log("set name2 %p, %s", this, mSource.c_str());
+#endif
#ifdef DEBUG_BIND_TEXTURE
mIdPath = parent->getIdPath();
#endif
@@ -103,6 +110,9 @@ SubImage::SubImage(Image *const parent, const GLuint image,
mInternalBounds.w = mParent->mBounds.w;
mInternalBounds.h = mParent->mBounds.h;
mSource = parent->getIdPath();
+#ifdef DEBUG_IMAGES
+ logger->log("set name2 %p, %s", this, mSource.c_str());
+#endif
#ifdef DEBUG_BIND_TEXTURE
mIdPath = parent->getIdPath();
#endif