ManaPlus
atlasresource.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2017 The ManaPlus Developers
4  *
5  * This file is part of The ManaPlus Client.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifdef USE_OPENGL
22 
24 
27 
29 
30 #include "debug.h"
31 
33 {
34  FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, atlases)
35  {
36  TextureAtlas *const atlas = *it;
37  if (atlas != nullptr)
38  {
39  FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it2, atlas->items)
40  {
41  AtlasItem *const item = *it2;
42  if (item != nullptr)
43  {
44  Image *const image2 = item->image;
45  if (image2 != nullptr)
46  image2->decRef();
47  delete item;
48  }
49  }
50  Image *const image = atlas->atlasImage;
51  if (image != nullptr)
52  image->decRef();
53  delete atlas;
54  }
55  }
57 }
58 
60 {
61  if (mRefCount == 0u)
64 }
65 
67 {
69  if (mRefCount == 0u)
71 }
72 
74 {
75  return static_cast<int>(sizeof(AtlasResource)) +
77  static_cast<int>(atlases.capacity() * sizeof(TextureAtlas*));
78 }
79 
80 int AtlasResource::calcMemoryChilds(const int level) const
81 {
82  int sz = 0;
83  FOR_EACH (STD_VECTOR<TextureAtlas*>::const_iterator, it, atlases)
84  {
85  TextureAtlas *const atlas = *it;
86  sz += atlas->calcMemory(level + 1);
87  }
88  return sz;
89 }
90 
91 #endif // USE_OPENGL
Image * image
Definition: atlasitem.h:53
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
virtual void decRef()
Definition: resource.cpp:49
int calcMemoryLocal() const
Definition: resource.cpp:75
unsigned int mRefCount
Definition: resource.h:86
int calcMemory(const int level) const
void clearDeleted(const bool full)
std::vector< TextureAtlas * > atlases
Definition: atlasresource.h:51
static void moveToDeleted(AtlasResource *const resource)
virtual void incRef()
Definition: resource.cpp:37
Image * atlasImage
Definition: textureatlas.h:74
Definition: image.h:61
std::vector< AtlasItem * > items
Definition: textureatlas.h:77
static void injectToResources(const AtlasResource *const resource)
void decRef()
Definition: image.cpp:521
int calcMemoryChilds(const int level) const
int calcMemoryLocal() const