diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-21 14:07:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-22 00:00:06 +0300 |
commit | 9ca479839b3a5fc7dbe75e94e15a0dd6da21bf16 (patch) | |
tree | 4aa2d89a08f00cad31d417ea790a4aa5a3455cde /src/resources/image.cpp | |
parent | 20727e946194e9bf984fc9b4dd7687a59fc82fc1 (diff) | |
download | manaverse-9ca479839b3a5fc7dbe75e94e15a0dd6da21bf16.tar.gz manaverse-9ca479839b3a5fc7dbe75e94e15a0dd6da21bf16.tar.bz2 manaverse-9ca479839b3a5fc7dbe75e94e15a0dd6da21bf16.tar.xz manaverse-9ca479839b3a5fc7dbe75e94e15a0dd6da21bf16.zip |
Add memorycounter interface. Impliment it in Image.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r-- | src/resources/image.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index d820adcfb..ad5d0d91c 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -29,6 +29,7 @@ #ifdef USE_OPENGL #include "resources/openglimagehelper.h" #endif // USE_OPENGL +#include "resources/memorymanager.h" #include "resources/sdlimagehelper.h" #include "resources/subimage.h" @@ -473,6 +474,19 @@ void Image::SDLTerminateAlphaCache() mUseAlphaCache = false; } +int Image::calcMemoryLocal() +{ + // +++ this calculation can be wrong for SDL2 + int sz = sizeof(Image) + + sizeof(std::map<float, SDL_Surface*>); + if (mSDLSurface) + { + sz += CAST_S32(mAlphaCache.size()) * + memoryManager.getSurfaceSize(mSDLSurface); + } + return sz; +} + #ifdef USE_OPENGL void Image::decRef() { |