summaryrefslogtreecommitdiff
path: root/src/resources/atlas/textureatlas.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-25 23:48:28 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-25 23:48:28 +0300
commit81dca73da50d8f421a74993de8cd5a9d61ef1e2a (patch)
tree506308ca4243c57eb15c6c537e231f19255c1047 /src/resources/atlas/textureatlas.h
parenta73b1787f1b2c293f00f4e71186753c0df476b77 (diff)
downloadplus-81dca73da50d8f421a74993de8cd5a9d61ef1e2a.tar.gz
plus-81dca73da50d8f421a74993de8cd5a9d61ef1e2a.tar.bz2
plus-81dca73da50d8f421a74993de8cd5a9d61ef1e2a.tar.xz
plus-81dca73da50d8f421a74993de8cd5a9d61ef1e2a.zip
Add memory counting functions into AtlasResource and some other.
Diffstat (limited to 'src/resources/atlas/textureatlas.h')
-rw-r--r--src/resources/atlas/textureatlas.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/resources/atlas/textureatlas.h b/src/resources/atlas/textureatlas.h
index 78b6ff00a..2b9f05930 100644
--- a/src/resources/atlas/textureatlas.h
+++ b/src/resources/atlas/textureatlas.h
@@ -25,8 +25,9 @@
#include "utils/stringvector.h"
-#include <vector>
+#include "resources/memorycounter.h"
+#include <vector>
#include <SDL.h>
#include "localconsts.h"
@@ -37,9 +38,10 @@ class Resource;
struct AtlasItem;
-struct TextureAtlas final
+struct TextureAtlas final : public MemoryCounter
{
TextureAtlas() :
+ MemoryCounter(),
name(),
atlasImage(nullptr),
width(0),
@@ -50,6 +52,23 @@ struct TextureAtlas final
A_DELETE_COPY(TextureAtlas)
+ int calcMemoryLocal() override final
+ {
+ return sizeof(TextureAtlas) +
+ items.capacity() * sizeof(AtlasItem*);
+ }
+
+ int calcMemoryChilds(const int level) override final
+ {
+ int sz = 0;
+ FOR_EACH (std::vector<AtlasItem*>::iterator, it, items)
+ {
+ AtlasItem *const item = *it;
+ sz += item->calcMemory(level + 1);
+ }
+ return sz;
+ }
+
std::string name;
Image *atlasImage;
int width;