aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmemoryview.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llmemoryview.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llmemoryview.cpp')
-rw-r--r--linden/indra/newview/llmemoryview.cpp242
1 files changed, 242 insertions, 0 deletions
diff --git a/linden/indra/newview/llmemoryview.cpp b/linden/indra/newview/llmemoryview.cpp
new file mode 100644
index 0000000..3432c4d
--- /dev/null
+++ b/linden/indra/newview/llmemoryview.cpp
@@ -0,0 +1,242 @@
1/**
2 * @file llmemoryview.cpp
3 * @brief LLMemoryView class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "indra_constants.h"
31#include "llmemoryview.h"
32
33#include "llrect.h"
34#include "llerror.h"
35#include "llgl.h"
36#include "llmath.h"
37#include "llfontgl.h"
38
39#include "viewer.h"
40#include "llui.h"
41#include "llviewercontrol.h"
42#include "llstat.h"
43
44#include "llfasttimer.h"
45
46LLMemoryView::LLMemoryView(const std::string& name, const LLRect& rect)
47: LLView(name, rect, TRUE)
48{
49 setVisible(FALSE);
50}
51
52LLMemoryView::~LLMemoryView()
53{
54}
55
56EWidgetType LLMemoryView::getWidgetType() const
57{
58 return WIDGET_TYPE_MEMORY_VIEW;
59}
60
61LLString LLMemoryView::getWidgetTag() const
62{
63 return LL_MEMORY_VIEW_TAG;
64}
65
66BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask)
67{
68 if (mask & MASK_SHIFT)
69 {
70 }
71 else if (mask & MASK_CONTROL)
72 {
73 }
74 else
75 {
76 }
77 return TRUE;
78}
79
80BOOL LLMemoryView::handleMouseUp(S32 x, S32 y, MASK mask)
81{
82 return TRUE;
83}
84
85
86BOOL LLMemoryView::handleHover(S32 x, S32 y, MASK mask)
87{
88 return FALSE;
89}
90
91//////////////////////////////////////////////////////////////////////////////
92
93struct mtv_display_info {
94 S32 memtype;
95 const char *desc;
96 LLColor4 *color;
97};
98
99static LLColor4 red0(0.5f, 0.0f, 0.0f, 1.0f);
100
101static struct mtv_display_info mtv_display_table[] =
102{
103 { LLMemType::MTYPE_INIT, "Init", &LLColor4::white },
104 { LLMemType::MTYPE_STARTUP, "Startup", &LLColor4::cyan1 },
105 { LLMemType::MTYPE_MAIN, "Main", &LLColor4::cyan2 },
106 { LLMemType::MTYPE_IMAGEBASE, "ImageBase", &LLColor4::yellow1 },
107 { LLMemType::MTYPE_IMAGERAW, "ImageRaw", &LLColor4::yellow2 },
108 { LLMemType::MTYPE_IMAGEFORMATTED, "ImageFmtd", &LLColor4::yellow3 },
109 { LLMemType::MTYPE_APPFMTIMAGE, "ViewerImageFmt", &LLColor4::orange1 },
110 { LLMemType::MTYPE_APPRAWIMAGE, "ViewerImageRaw", &LLColor4::orange2 },
111 { LLMemType::MTYPE_APPAUXRAWIMAGE, "ViewerImageAux", &LLColor4::orange3 },
112 { LLMemType::MTYPE_DRAWABLE, "Drawable", &LLColor4::green1 },
113 { LLMemType::MTYPE_OBJECT, "ViewerObject", &LLColor4::green2 },
114 { LLMemType::MTYPE_PIPELINE, "Pipeline", &LLColor4::green3 },
115 { LLMemType::MTYPE_PARTICLES, "Particles", &LLColor4::green4 },
116 { LLMemType::MTYPE_SPACE_PARTITION, "Space Partition", &LLColor4::blue2 },
117 { LLMemType::MTYPE_AVATAR, "Avatar", &LLColor4::purple1 },
118 { LLMemType::MTYPE_REGIONS, "Regions", &LLColor4::blue1 },
119 { LLMemType::MTYPE_TEMP1, "Temp1", &LLColor4::red1 },
120 { LLMemType::MTYPE_TEMP2, "Temp2", &LLColor4::magenta1 },
121 { LLMemType::MTYPE_TEMP3, "Temp3", &LLColor4::red2 },
122 { LLMemType::MTYPE_TEMP4, "Temp4", &LLColor4::magenta2 },
123 { LLMemType::MTYPE_TEMP5, "Temp5", &LLColor4::red3 },
124 { LLMemType::MTYPE_TEMP6, "Temp6", &LLColor4::magenta3 },
125 { LLMemType::MTYPE_TEMP7, "Temp7", &LLColor4::red4 },
126 { LLMemType::MTYPE_TEMP8, "Temp8", &LLColor4::magenta4 },
127
128 { LLMemType::MTYPE_OTHER, "Other", &red0 },
129};
130static const int MTV_DISPLAY_NUM = (sizeof(mtv_display_table)/sizeof(mtv_display_table[0]));
131
132void LLMemoryView::draw()
133{
134 std::string tdesc;
135 S32 width = mRect.getWidth();
136 S32 height = mRect.getHeight();
137
138 LLGLSUIDefault gls_ui;
139 LLGLSNoTexture gls_no_tex;
140 gl_rect_2d(0, height, width, 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
141
142#if MEM_TRACK_TYPE
143
144 S32 left, top, right, bottom;
145 S32 x, y;
146
147 S32 margin = 10;
148 S32 texth = (S32)LLFontGL::sMonospace->getLineHeight();
149
150 S32 xleft = margin;
151 S32 ytop = height - margin;
152 S32 labelwidth = 0;
153 S32 maxmaxbytes = 1;
154
155 // Make sure all timers are accounted for
156 // Set 'MT_OTHER' to unaccounted ticks last frame
157 {
158 S32 display_memtypes[LLMemType::MTYPE_NUM_TYPES];
159 for (S32 i=0; i < LLMemType::MTYPE_NUM_TYPES; i++)
160 {
161 display_memtypes[i] = 0;
162 }
163 for (S32 i=0; i < MTV_DISPLAY_NUM; i++)
164 {
165 S32 tidx = mtv_display_table[i].memtype;
166 display_memtypes[tidx]++;
167 }
168 LLMemType::sMemCount[LLMemType::MTYPE_OTHER] = 0;
169 LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] = 0;
170 for (S32 tidx = 0; tidx < LLMemType::MTYPE_NUM_TYPES; tidx++)
171 {
172 if (display_memtypes[tidx] == 0)
173 {
174 LLMemType::sMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMemCount[tidx];
175 LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMaxMemCount[tidx];
176 }
177 }
178 }
179
180 // Labels
181 {
182 LLGLSTexture gls_texture;
183 y = ytop;
184 S32 peak = 0;
185 for (S32 i=0; i<MTV_DISPLAY_NUM; i++)
186 {
187 x = xleft;
188
189 int tidx = mtv_display_table[i].memtype;
190 S32 bytes = LLMemType::sMemCount[tidx];
191 S32 maxbytes = LLMemType::sMaxMemCount[tidx];
192 maxmaxbytes = llmax(maxbytes, maxmaxbytes);
193 peak += maxbytes;
194 S32 mbytes = bytes >> 20;
195
196 tdesc = llformat("%s [%4d MB]",mtv_display_table[i].desc,mbytes);
197 LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
198
199 y -= (texth + 2);
200
201 S32 textw = LLFontGL::sMonospace->getWidth(tdesc);
202 if (textw > labelwidth)
203 labelwidth = textw;
204 }
205 x = xleft;
206 tdesc = llformat("Total Bytes: %d MB Overhead: %d KB",
207 LLMemType::sTotalMem >> 20, LLMemType::sOverheadMem >> 10);
208 LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
209 }
210
211 // Bars
212 y = ytop;
213 labelwidth += 8;
214 S32 barw = width - labelwidth - xleft - margin;
215 for (S32 i=0; i<MTV_DISPLAY_NUM; i++)
216 {
217 x = xleft + labelwidth;
218
219 int tidx = mtv_display_table[i].memtype;
220 S32 bytes = LLMemType::sMemCount[tidx];
221 F32 frac = (F32)bytes / (F32)maxmaxbytes;
222 S32 w = (S32)(frac * (F32)barw);
223 left = x; right = x + w;
224 top = y; bottom = y - texth;
225 gl_rect_2d(left, top, right, bottom, *mtv_display_table[i].color);
226
227 S32 maxbytes = LLMemType::sMaxMemCount[tidx];
228 F32 frac2 = (F32)maxbytes / (F32)maxmaxbytes;
229 S32 w2 = (S32)(frac2 * (F32)barw);
230 left = x + w + 1; right = x + w2;
231 top = y; bottom = y - texth;
232 LLColor4 tcolor = *mtv_display_table[i].color;
233 tcolor.setAlpha(.5f);
234 gl_rect_2d(left, top, right, bottom, tcolor);
235
236 y -= (texth + 2);
237 }
238
239#endif
240
241 LLView::draw();
242}