diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-29 20:52:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-29 20:52:59 +0300 |
commit | 5f6e0176cc64824a28391070ddb249a6efff0b7c (patch) | |
tree | b9199e1e235705e129b5f83cc91826ebd3ddb63c /src | |
parent | 83958df001482b940812080db776efd2cf3c2d91 (diff) | |
download | manaplus-5f6e0176cc64824a28391070ddb249a6efff0b7c.tar.gz manaplus-5f6e0176cc64824a28391070ddb249a6efff0b7c.tar.bz2 manaplus-5f6e0176cc64824a28391070ddb249a6efff0b7c.tar.xz manaplus-5f6e0176cc64824a28391070ddb249a6efff0b7c.zip |
Add memory counting into AbmientLayer.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/ambientlayer.cpp | 11 | ||||
-rw-r--r-- | src/resources/ambientlayer.h | 13 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 18 |
3 files changed, 35 insertions, 7 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 644c71578..389a2942d 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -31,7 +31,8 @@ #include "debug.h" -AmbientLayer::AmbientLayer(Image *const img, +AmbientLayer::AmbientLayer(const std::string &name, + Image *const img, const float parallaxX, const float parallaxY, const float posX, @@ -40,6 +41,8 @@ AmbientLayer::AmbientLayer(Image *const img, const float speedY, const bool keepRatio, const int mask) : + MemoryCounter(), + mName(name), mImage(img), mParallaxX(parallaxX), mParallaxY(parallaxY), @@ -142,3 +145,9 @@ void AmbientLayer::draw(Graphics *const graphics, const int x, * graphics->mHeight); } } + +int AmbientLayer::calcMemoryLocal() const +{ + return sizeof(AmbientLayer) + + mName.capacity(); +} diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h index f8e140be9..9aabf0a91 100644 --- a/src/resources/ambientlayer.h +++ b/src/resources/ambientlayer.h @@ -22,13 +22,15 @@ #ifndef RESOURCES_AMBIENTLAYER_H #define RESOURCES_AMBIENTLAYER_H +#include "resources/memorycounter.h" + #include "localconsts.h" class Graphics; class Image; class Map; -class AmbientLayer final +class AmbientLayer final : public MemoryCounter { public: friend class Map; @@ -43,7 +45,8 @@ class AmbientLayer final * @param keepRatio rescale the image to keep * the same ratio than in 800x600 resolution mode. */ - AmbientLayer(Image *const img, + AmbientLayer(const std::string &name, + Image *const img, const float parallax, const float parallaxY, const float posX, @@ -65,7 +68,13 @@ class AmbientLayer final const int x, const int y) const A_NONNULL(2); + int calcMemoryLocal() const override; + + std::string getCounterName() const override final + { return mName; } + private: + const std::string mName; Image *mImage; float mParallaxX; float mParallaxY; diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index e958068f2..01f646877 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -243,7 +243,9 @@ void Map::initializeAmbientLayers() restrict2 if (!mask) mask = 1; const float parallax = getFloatProperty(name + "parallax"); - mForegrounds.push_back(new AmbientLayer(img, + mForegrounds.push_back(new AmbientLayer( + name, + img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), getFloatProperty(name + "posX"), @@ -273,7 +275,9 @@ void Map::initializeAmbientLayers() restrict2 mask = 1; const float parallax = getFloatProperty(name + "parallax"); - mBackgrounds.push_back(new AmbientLayer(img, + mBackgrounds.push_back(new AmbientLayer( + name, + img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), getFloatProperty(name + "posX"), @@ -1727,8 +1731,14 @@ int Map::calcMemoryChilds(const int level) const { sz += (*it)->calcMemory(level + 1); } - // +++ need calc mBackgrounds - // +++ need calc mForegrounds + FOR_EACH (AmbientLayerVectorCIter, it, mBackgrounds) + { + sz += (*it)->calcMemory(level + 1); + } + FOR_EACH (AmbientLayerVectorCIter, it, mForegrounds) + { + sz += (*it)->calcMemory(level + 1); + } if (mSpecialLayer) mSpecialLayer->calcMemory(level + 1); if (mTempLayer) |