diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lltexturebar.cpp | 412 |
1 files changed, 0 insertions, 412 deletions
diff --git a/linden/indra/newview/lltexturebar.cpp b/linden/indra/newview/lltexturebar.cpp deleted file mode 100644 index d3be39e..0000000 --- a/linden/indra/newview/lltexturebar.cpp +++ /dev/null | |||
@@ -1,412 +0,0 @@ | |||
1 | /** | ||
2 | * @file lltexturebar.cpp | ||
3 | * @brief LLTextureBar 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 "lltexturebar.h" | ||
31 | #include "llviewerimage.h" | ||
32 | #include "lltexturetable.h" | ||
33 | #include "llfontgl.h" | ||
34 | #include "llui.h" | ||
35 | #include "llassetstorage.h" | ||
36 | #include "llglheaders.h" | ||
37 | #include "llviewerimagelist.h" | ||
38 | |||
39 | #include "lltexlayer.h" | ||
40 | |||
41 | // colors used for highlighting textures | ||
42 | const F32 select_colors[][4] = { {1.0f, 1.0f, 1.0f, 0.7f}, // default = white | ||
43 | {1.0f, 1.0f, 0.3f, 1.0f}, // selected = yellow | ||
44 | {0.3f, 1.0f, 1.0f, 1.0f}, // flagged = cyan | ||
45 | {1.0f, 0.3f, 1.0f, 1.0f}, // boosted = magenta | ||
46 | {0.5f, 0.5f, 1.0f, 1.0f}, // blue | ||
47 | {0.5f, 1.0f, 0.5f, 1.0f}, // green | ||
48 | {1.0f, 0.5f, 0.5f, 1.0f}, // updated this frame = red | ||
49 | {1.0f, 0.8f, 0.8f, 1.0f}, // nodiscard = pale red | ||
50 | {0.8f, 1.0f, 0.8f, 1.0f}, // fullres = pale green | ||
51 | {0.8f, 0.8f, 0.8f, 0.7f} // 0 priority = grey | ||
52 | }; | ||
53 | |||
54 | LLTextureBar::LLTextureBar(const std::string& name, const LLRect& r) | ||
55 | : LLView(name, r, FALSE) | ||
56 | { | ||
57 | mHilite = 0; | ||
58 | } | ||
59 | |||
60 | static LLString title_string1("Tex UUID Area DDis(Req) DecodePri(Req) [decode] pkts/max"); | ||
61 | static LLString title_string2("W x H (Dis) Mem"); | ||
62 | |||
63 | static S32 pip_base = 480; | ||
64 | static S32 pip_width = 6; | ||
65 | |||
66 | EWidgetType LLTextureBar::getWidgetType() const | ||
67 | { | ||
68 | return WIDGET_TYPE_TEXTURE_BAR; | ||
69 | } | ||
70 | |||
71 | LLString LLTextureBar::getWidgetTag() const | ||
72 | { | ||
73 | return LL_TEXTURE_BAR_TAG; | ||
74 | } | ||
75 | |||
76 | |||
77 | void LLTextureBar::draw() | ||
78 | { | ||
79 | if (!mImagep) | ||
80 | { | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | S32 color; | ||
85 | if (mHilite) | ||
86 | { | ||
87 | color = llclamp(mHilite,0,4); | ||
88 | } | ||
89 | else if (mImagep->getBoostLevel()) | ||
90 | { | ||
91 | color = 3; | ||
92 | } | ||
93 | else if (mImagep->mDontDiscard) | ||
94 | { | ||
95 | color = 7; | ||
96 | } | ||
97 | else if (!mImagep->getUseMipMaps()) | ||
98 | { | ||
99 | color = 8; | ||
100 | } | ||
101 | else if (mImagep->getDecodePriority() == 0.0f) | ||
102 | { | ||
103 | color = 9; | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | color = 0; | ||
108 | } | ||
109 | |||
110 | // We need to draw: | ||
111 | // The texture UUID or name | ||
112 | // The progress bar for the texture, highlighted if it's being download | ||
113 | // Various numerical stats. | ||
114 | char tex_str[256]; | ||
115 | S32 left, right; | ||
116 | S32 top = 0; | ||
117 | S32 bottom = top + 6; | ||
118 | |||
119 | // Get the name or UUID of the image. | ||
120 | gTextureTable.getName(mImagep->mID); | ||
121 | |||
122 | // Name, pixel_area, requested pixel area, decode priority | ||
123 | char uuid_str[255]; | ||
124 | mImagep->mID.toString(uuid_str); | ||
125 | uuid_str[8] = 0; | ||
126 | sprintf(tex_str, "%s %7.0f %d(%d) %8.2f(%8.2f)", | ||
127 | uuid_str, | ||
128 | mImagep->mMaxVirtualSize, | ||
129 | mImagep->mDesiredDiscardLevel, | ||
130 | mImagep->mRequestedDiscardLevel, | ||
131 | mImagep->getDecodePriority(), | ||
132 | mImagep->mRequestedDownloadPriority); | ||
133 | |||
134 | |||
135 | LLGLSUIDefault gls_ui; | ||
136 | LLFontGL::sMonospace->renderUTF8(tex_str, 0, 0, mRect.getHeight(), | ||
137 | select_colors[color], | ||
138 | LLFontGL::LEFT, LLFontGL::TOP); | ||
139 | |||
140 | LLGLSNoTexture gls_no_texture; | ||
141 | F32 last_event; | ||
142 | LLColor4 clr; | ||
143 | |||
144 | // Draw the packet pip | ||
145 | last_event = mImagep->mLastPacketTimer.getElapsedTimeF32(); | ||
146 | if (last_event < 1.f) | ||
147 | { | ||
148 | clr = LLColor4::white; clr.setAlpha(1.f - last_event); | ||
149 | glColor4fv(clr.mV); | ||
150 | gl_rect_2d(pip_base, top, pip_base + pip_width, bottom); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | last_event = mImagep->mRequestTime.getElapsedTimeF32() * 1.f/5.f; | ||
155 | if (last_event < 1.f) | ||
156 | { | ||
157 | clr = LLColor4::green; clr.setAlpha(1.f - last_event); | ||
158 | glColor4fv(clr.mV); | ||
159 | gl_rect_2d(pip_base, top, pip_base + pip_width, bottom); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // Draw the decode pip | ||
164 | if (mImagep->getDiscardLevel() < 0) | ||
165 | last_event = 1.f; | ||
166 | else | ||
167 | last_event = mImagep->mLastDecodeTime.getElapsedTimeF32(); | ||
168 | if (last_event < 1.f) | ||
169 | { | ||
170 | clr = LLColor4::yellow; clr.setAlpha(1.f - last_event); | ||
171 | glColor4fv(clr.mV); | ||
172 | gl_rect_2d(pip_base + pip_width*2, top, pip_base + pip_width*3, bottom); | ||
173 | } | ||
174 | |||
175 | // we don't want to show bind/resident pips for textures using the default texture | ||
176 | if (mImagep->getHasGLTexture()) | ||
177 | { | ||
178 | BOOL miss = FALSE; | ||
179 | // Draw the bound pip | ||
180 | last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime; | ||
181 | if (last_event < 1.f) | ||
182 | { | ||
183 | clr = LLColor4::magenta1; clr.setAlpha(1.f - last_event); | ||
184 | glColor4fv(clr.mV); | ||
185 | gl_rect_2d(pip_base + pip_width*4, top, pip_base + pip_width*5, bottom); | ||
186 | |||
187 | miss = mImagep->getMissed(); | ||
188 | } | ||
189 | |||
190 | // Draw the miss pip | ||
191 | if (miss) | ||
192 | { | ||
193 | clr = LLColor4::red; | ||
194 | glColor4fv(clr.mV); | ||
195 | gl_rect_2d(pip_base + pip_width*6, top, pip_base + pip_width*7, bottom); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | // Draw the progress bar. | ||
200 | S32 bar_width = 100; | ||
201 | S32 bar_left = 280; | ||
202 | left = bar_left; | ||
203 | right = left + bar_width; | ||
204 | |||
205 | glColor4f(0.f, 0.f, 0.f, 0.75f); | ||
206 | gl_rect_2d(left, top, right, bottom); | ||
207 | |||
208 | F32 data_progress = 0.0f; | ||
209 | F32 decode_progress = mImagep->getDecodeProgress(&data_progress); | ||
210 | |||
211 | if (data_progress > 0.0f) | ||
212 | { | ||
213 | // Decoded bytes | ||
214 | right = left + llfloor(decode_progress * (F32)bar_width); | ||
215 | |||
216 | if (left < right) | ||
217 | { | ||
218 | if (mImagep->getDiscardLevel() >= 0) | ||
219 | { | ||
220 | glColor4f(0.f, 0.f, 1.f, 0.75f); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | glColor4f(0.5f, 0.0f, 0.5f, 0.75f); | ||
225 | } | ||
226 | gl_rect_2d(left, top, right, bottom); | ||
227 | } | ||
228 | |||
229 | // Downloaded bytes | ||
230 | left = right; | ||
231 | right = left + llfloor((data_progress - decode_progress) * (F32)bar_width); | ||
232 | |||
233 | if (left < right) | ||
234 | { | ||
235 | glColor4f(1.f, 0.f, 0.f, 0.75f); | ||
236 | gl_rect_2d(left, top, right, bottom); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | { | ||
241 | LLGLSUIDefault gls_ui; | ||
242 | // draw the packet data | ||
243 | { | ||
244 | LLString num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); | ||
245 | LLFontGL::sMonospace->renderUTF8(num_str, 0, bar_left + 100, mRect.getHeight(), select_colors[color], | ||
246 | LLFontGL::LEFT, LLFontGL::TOP); | ||
247 | } | ||
248 | |||
249 | // draw the image size at the end | ||
250 | { | ||
251 | LLString num_str = llformat("%4d x %4d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), | ||
252 | mImagep->getDiscardLevel(), mImagep->mTextureMemory); | ||
253 | LLFontGL::sMonospace->renderUTF8(num_str, 0, pip_base + pip_width*8, mRect.getHeight(), select_colors[color], | ||
254 | LLFontGL::LEFT, LLFontGL::TOP); | ||
255 | } | ||
256 | } | ||
257 | |||
258 | } | ||
259 | |||
260 | BOOL LLTextureBar::handleMouseDown(S32 x, S32 y, MASK mask) | ||
261 | { | ||
262 | return FALSE; | ||
263 | } | ||
264 | |||
265 | LLRect LLTextureBar::getRequiredRect() | ||
266 | { | ||
267 | LLRect rect; | ||
268 | |||
269 | rect.mTop = 8; | ||
270 | |||
271 | return rect; | ||
272 | } | ||
273 | |||
274 | //============================================================================== | ||
275 | |||
276 | LLGLTexMemBar::LLGLTexMemBar(const std::string& name) | ||
277 | : LLView(name, FALSE) | ||
278 | { | ||
279 | S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f); | ||
280 | setRect(LLRect(0,0,100,line_height * 4)); | ||
281 | updateRect(); | ||
282 | } | ||
283 | |||
284 | EWidgetType LLGLTexMemBar::getWidgetType() const | ||
285 | { | ||
286 | return WIDGET_TYPE_TEX_MEM_BAR; | ||
287 | } | ||
288 | |||
289 | LLString LLGLTexMemBar::getWidgetTag() const | ||
290 | { | ||
291 | return LL_GL_TEX_MEM_BAR_TAG; | ||
292 | } | ||
293 | |||
294 | |||
295 | extern F32 texmem_lower_bound_scale; | ||
296 | |||
297 | void LLGLTexMemBar::draw() | ||
298 | { | ||
299 | S32 bound_mem = LLViewerImage::sBoundTextureMemory; | ||
300 | S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMem; | ||
301 | S32 total_mem = LLViewerImage::sTotalTextureMemory; | ||
302 | S32 max_total_mem = LLViewerImage::sMaxTotalTextureMem; | ||
303 | F32 discard_bias = LLViewerImage::sDesiredDiscardBias; | ||
304 | S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f); | ||
305 | |||
306 | //---------------------------------------------------------------------------- | ||
307 | LLGLSUIDefault gls_ui; | ||
308 | F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; | ||
309 | |||
310 | std::string text; | ||
311 | text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f", | ||
312 | total_mem/(1024*1024), | ||
313 | max_total_mem/(1024*1024), | ||
314 | bound_mem/(1024*1024), | ||
315 | max_bound_mem/(1024*1024), | ||
316 | discard_bias); | ||
317 | |||
318 | LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3, | ||
319 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
320 | |||
321 | //---------------------------------------------------------------------------- | ||
322 | S32 bar_left = 350; | ||
323 | S32 bar_width = 200; | ||
324 | S32 top = line_height*3 - 2; | ||
325 | S32 bottom = top - 6; | ||
326 | S32 left = bar_left; | ||
327 | S32 right = left + bar_width; | ||
328 | |||
329 | F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f); | ||
330 | |||
331 | LLGLSNoTexture gls_no_texture; | ||
332 | |||
333 | glColor4f(0.5f, 0.5f, 0.5f, 0.75f); | ||
334 | gl_rect_2d(left, top, right, bottom); | ||
335 | |||
336 | |||
337 | left = bar_left; | ||
338 | right = left + llfloor(bound_mem * bar_scale); | ||
339 | if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) | ||
340 | { | ||
341 | glColor4f(0.f, 1.f, 0.f, 0.75f); | ||
342 | } | ||
343 | else if (bound_mem < max_bound_mem) | ||
344 | { | ||
345 | glColor4f(1.f, 1.f, 0.f, 0.75f); | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | glColor4f(1.f, 0.f, 0.f, 0.75f); | ||
350 | } | ||
351 | gl_rect_2d(left, top, right, bottom); | ||
352 | |||
353 | bar_scale = (F32)bar_width / (max_total_mem * 1.5f); | ||
354 | |||
355 | top = bottom - 2; | ||
356 | bottom = top - 6; | ||
357 | left = bar_left; | ||
358 | right = left + llfloor(total_mem * bar_scale); | ||
359 | if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) | ||
360 | { | ||
361 | glColor4f(0.f, 1.f, 0.f, 0.75f); | ||
362 | } | ||
363 | else if (total_mem < max_total_mem) | ||
364 | { | ||
365 | glColor4f(1.f, 1.f, 0.f, 0.75f); | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | glColor4f(1.f, 0.f, 0.f, 0.75f); | ||
370 | } | ||
371 | gl_rect_2d(left, top, right, bottom); | ||
372 | |||
373 | //---------------------------------------------------------------------------- | ||
374 | text = llformat("TexStaticImageList Raw: %d GL: %d TGA: %d", | ||
375 | gTexStaticImageList.mRawBytes, gTexStaticImageList.mGLBytes, gTexStaticImageList.mTGABytes); | ||
376 | |||
377 | LLGLEnable tex(GL_TEXTURE_2D); | ||
378 | LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*2, | ||
379 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
380 | |||
381 | |||
382 | //---------------------------------------------------------------------------- | ||
383 | |||
384 | S32 x = 0; | ||
385 | LLFontGL::sMonospace->renderUTF8(title_string1, 0, x, line_height, | ||
386 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
387 | S32 dx = 24; | ||
388 | x = pip_base - dx; | ||
389 | LLFontGL::sMonospace->renderUTF8("pkt", 0, x, line_height, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); | ||
390 | x += dx; | ||
391 | LLFontGL::sMonospace->renderUTF8("dec", 0, x, line_height, LLColor4::yellow, LLFontGL::LEFT, LLFontGL::TOP); | ||
392 | x += dx; | ||
393 | LLFontGL::sMonospace->renderUTF8("bnd", 0, x, line_height, LLColor4::magenta1, LLFontGL::LEFT, LLFontGL::TOP); | ||
394 | x += dx; | ||
395 | LLFontGL::sMonospace->renderUTF8("mis", 0, x, line_height, LLColor4::red, LLFontGL::LEFT, LLFontGL::TOP); | ||
396 | x += dx; | ||
397 | LLFontGL::sMonospace->renderUTF8(title_string2, 0, x, line_height, | ||
398 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
399 | } | ||
400 | |||
401 | BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask) | ||
402 | { | ||
403 | return FALSE; | ||
404 | } | ||
405 | |||
406 | LLRect LLGLTexMemBar::getRequiredRect() | ||
407 | { | ||
408 | LLRect rect; | ||
409 | rect.mTop = 8; | ||
410 | return rect; | ||
411 | } | ||
412 | |||