summaryrefslogtreecommitdiff
path: root/src/resources/sprite/spritedef.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-26 01:24:16 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-26 01:24:16 +0300
commitec6bfe238af2f846a5948e95b1d725cf9abe9afb (patch)
tree0be19bc199cd66bd6949befe86c844dbad62de3b /src/resources/sprite/spritedef.cpp
parent81dca73da50d8f421a74993de8cd5a9d61ef1e2a (diff)
downloadplus-ec6bfe238af2f846a5948e95b1d725cf9abe9afb.tar.gz
plus-ec6bfe238af2f846a5948e95b1d725cf9abe9afb.tar.bz2
plus-ec6bfe238af2f846a5948e95b1d725cf9abe9afb.tar.xz
plus-ec6bfe238af2f846a5948e95b1d725cf9abe9afb.zip
Add memory count functions into Action and Animation.
Diffstat (limited to 'src/resources/sprite/spritedef.cpp')
-rw-r--r--src/resources/sprite/spritedef.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
index d157028ef..ba3abaec9 100644
--- a/src/resources/sprite/spritedef.cpp
+++ b/src/resources/sprite/spritedef.cpp
@@ -593,3 +593,40 @@ bool SpriteDef::addSequence(const int start,
}
return false;
}
+
+int SpriteDef::calcMemoryLocal()
+{
+ int sz = sizeof(SpriteDef) +
+ sizeof(ImageSets) +
+ sizeof(Actions) +
+ sizeof(std::set<std::string>) +
+ Resource::calcMemoryLocal();
+ FOR_EACH (std::set<std::string>::const_iterator, it, mProcessedFiles)
+ {
+ sz += (*it).capacity();
+ }
+ return sz;
+}
+
+int SpriteDef::calcMemoryChilds(const int level)
+{
+ int sz = 0;
+ FOR_EACH (ImageSets::iterator, it, mImageSets)
+ {
+ sz += (*it).first.capacity();
+ ImageSet *const imageSet = (*it).second;
+ sz += imageSet->calcMemory(level + 1);
+ }
+ FOR_EACH (ActionsIter, it, mActions)
+ {
+ sz += sizeof(unsigned);
+ ActionMap *const actionMap = (*it).second;
+ FOR_EACHP (ActionMap::iterator, it2, actionMap)
+ {
+ sz += (*it2).first.capacity();
+ Action *const action = (*it2).second;
+ sz += action->calcMemory(level + 1);
+ }
+ }
+ return sz;
+}