GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/atlas/textureatlas.h Lines: 0 13 0.0 %
Date: 2017-11-29 Branches: 0 8 0.0 %

Line Branch Exec Source
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
#ifndef RESOURCES_ATLAS_TEXTUREATLAS_H
22
#define RESOURCES_ATLAS_TEXTUREATLAS_H
23
24
#ifdef USE_OPENGL
25
26
#include "utils/foreach.h"
27
#include "utils/stringvector.h"
28
29
#include "resources/atlas/atlasitem.h"
30
31
#include "localconsts.h"
32
33
class AtlasResource;
34
class Image;
35
class Resource;
36
37
struct AtlasItem;
38
39
struct TextureAtlas final : public MemoryCounter
40
{
41
    TextureAtlas() :
42
        MemoryCounter(),
43
        name(),
44
        atlasImage(nullptr),
45
        width(0),
46
        height(0),
47
        items()
48
    {
49
    }
50
51
    A_DELETE_COPY(TextureAtlas)
52
53
    int calcMemoryLocal() const override final
54
    {
55
        return static_cast<int>(sizeof(TextureAtlas) +
56
            items.capacity() * sizeof(AtlasItem*));
57
    }
58
59
    int calcMemoryChilds(const int level) const override final
60
    {
61
        int sz = 0;
62
        FOR_EACH (STD_VECTOR<AtlasItem*>::const_iterator, it, items)
63
        {
64
            AtlasItem *const item = *it;
65
            sz += item->calcMemory(level + 1);
66
        }
67
        return sz;
68
    }
69
70
    std::string getCounterName() const override
71
    { return name; }
72
73
    std::string name;
74
    Image *atlasImage;
75
    int width;
76
    int height;
77
    STD_VECTOR <AtlasItem*> items;
78
};
79
80
#endif  // USE_OPENGL
81
#endif  // RESOURCES_ATLAS_TEXTUREATLAS_H