summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/include/graphite/MemoryUsage.h
blob: d59ff165f75aa16a5b4b224e4e169041d43b392e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 2007 SIL International. All rights reserved.

Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.

File: MemoryUsage.h
Responsibility: Sharon Correll
Last reviewed: not yet

Description:
    Data structures to hold the calculations for memory usage.
----------------------------------------------------------------------------------------------*/

#ifdef _MSC_VER
#pragma once
#endif
#ifndef MEMORYUSAGE_INCLUDED
#define MEMORYUSAGE_INCLUDED

//:End Ignore


namespace gr
{

/*----------------------------------------------------------------------------------------------
	A data structure that holds information about the memory usage for font/engine objects
----------------------------------------------------------------------------------------------*/
class FontMemoryUsage
{
	friend class FontCache;
	friend class FontFace;

public:
	FontMemoryUsage()
	{
		initialize();
	}
	void addEngine(GrEngine * pgreng);
	void prettyPrint(std::ostream & strm);

protected:
	// member variables:
	std::vector<size_t> vFontTotalsReg;
	std::vector<size_t> vFontTotalsBold;
	std::vector<size_t> vFontTotalsItalic;
	std::vector<size_t> vFontTotalsBI;
	std::vector<std::string> vstrFontNames;
	std::vector<size_t> vFaceCount;

	size_t	font;
	size_t	fontCache;
	size_t	fontFace;

	size_t	eng_count;
	size_t	eng_overhead;
	size_t	eng_scalars;
	size_t	eng_strings;
	size_t	eng_pointers;
	size_t	eng_cmap;
	size_t	eng_nameTable;

	size_t	pseudoMap;

	size_t	clstbl_counters;
	size_t	clstbl_offsets;
	size_t	clstbl_glyphList;

	size_t	glftbl_general;
	size_t	glftbl_compDefns;
	size_t	glftbl_attrTable;
	size_t	glftbl_attrOffsets;

	size_t	lngtbl_general;
	size_t	lngtbl_entries;
	size_t	lngtbl_featureSets;

	size_t	tman_general;

	size_t	pass_count;
	size_t	pass_general;
	size_t	pass_fsm;
	size_t	pass_ruleExtras;
	size_t	pass_constraintOffsets;
	size_t	pass_constraintCode;
	size_t	pass_actionOffsets;
	size_t	pass_actionCode;

	size_t	engst_general;
	size_t	engst_passState;

	size_t	sstrm_count;
	size_t	sstrm_general;
	size_t	sstrm_chunkMapsUsed;
	size_t	sstrm_chunkMapsAlloc;
	size_t	sstrm_reprocBuf;

	size_t	slot_count;
	size_t	slot_general;
	size_t	slot_abstract;
	size_t	slot_varLenBuf;
	size_t	slot_assocsUsed;
	size_t	slot_assocsAlloc;
	size_t	slot_attachUsed;
	size_t	slot_attachAlloc;

	// methods:
	void initialize();
	int total();
	void add(FontMemoryUsage & fmu);
};

/*----------------------------------------------------------------------------------------------
	A data structure that holds information about the memory usage for segment objects.
----------------------------------------------------------------------------------------------*/
class SegmentMemoryUsage
{
public:
	SegmentMemoryUsage()
	{
		initialize();
	}
	void addSegment(Segment & seg);
	void prettyPrint(std::ostream & strm);

protected:
	// member variables:
	size_t	seg_count;
	size_t	overhead;
	size_t	pointers;
	size_t	scalars;
	size_t	strings;
	size_t	metrics;
	size_t	associations;
	size_t	init;
	size_t	obsolete;

	size_t	slot_count;
	size_t	slot_abstract;
	size_t	slot_varLenBuf;
	size_t	slot_scalars;
	size_t	slot_clusterMembers;

	size_t	glyphInfo_count;
	size_t	glyphInfo;

	size_t	wastedVector;	// allocated space that is not used in vectors

	// methods:
	void initialize();
};

} // namespace gr

#endif // !MEMORYUSAGE_INCLUDED