diff options
Diffstat (limited to 'linden/indra/newview/lltextureview.cpp')
-rw-r--r-- | linden/indra/newview/lltextureview.cpp | 636 |
1 files changed, 559 insertions, 77 deletions
diff --git a/linden/indra/newview/lltextureview.cpp b/linden/indra/newview/lltextureview.cpp index 75abb39..d28ee74 100644 --- a/linden/indra/newview/lltextureview.cpp +++ b/linden/indra/newview/lltextureview.cpp | |||
@@ -33,48 +33,509 @@ | |||
33 | 33 | ||
34 | #include "llrect.h" | 34 | #include "llrect.h" |
35 | #include "llerror.h" | 35 | #include "llerror.h" |
36 | 36 | #include "lllfsthread.h" | |
37 | #include "viewer.h" | ||
38 | #include "llui.h" | 37 | #include "llui.h" |
38 | #include "llimageworker.h" | ||
39 | 39 | ||
40 | #include "llviewerimagelist.h" | 40 | #include "llhoverview.h" |
41 | #include "llselectmgr.h" | 41 | #include "llselectmgr.h" |
42 | #include "lltexlayer.h" | ||
43 | #include "lltexturecache.h" | ||
44 | #include "lltexturefetch.h" | ||
45 | #include "lltexturetable.h" | ||
42 | #include "llviewerobject.h" | 46 | #include "llviewerobject.h" |
43 | #include "llviewerimage.h" | 47 | #include "llviewerimage.h" |
44 | #include "llhoverview.h" | 48 | #include "llviewerimagelist.h" |
49 | #include "viewer.h" | ||
50 | |||
51 | extern F32 texmem_lower_bound_scale; | ||
45 | 52 | ||
46 | LLTextureView *gTextureView = NULL; | 53 | LLTextureView *gTextureView = NULL; |
47 | 54 | ||
48 | //static | 55 | //static |
49 | std::set<LLViewerImage*> LLTextureView::sDebugImages; | 56 | std::set<LLViewerImage*> LLTextureView::sDebugImages; |
50 | 57 | ||
58 | //////////////////////////////////////////////////////////////////////////// | ||
59 | |||
60 | static LLString title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); | ||
61 | static LLString title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); | ||
62 | static LLString title_string2("State"); | ||
63 | static LLString title_string3("Pkt Bnd"); | ||
64 | static LLString title_string4(" W x H (Dis) Mem"); | ||
65 | |||
66 | static S32 title_x1 = 0; | ||
67 | static S32 title_x2 = 440; | ||
68 | static S32 title_x3 = title_x2 + 40; | ||
69 | static S32 title_x4 = title_x3 + 50; | ||
70 | static S32 texture_bar_height = 8; | ||
71 | |||
72 | //////////////////////////////////////////////////////////////////////////// | ||
73 | |||
74 | class LLTextureBar : public LLView | ||
75 | { | ||
76 | public: | ||
77 | LLPointer<LLViewerImage> mImagep; | ||
78 | S32 mHilite; | ||
79 | |||
80 | public: | ||
81 | LLTextureBar(const std::string& name, const LLRect& r, LLTextureView* texview) | ||
82 | : LLView(name, r, FALSE), | ||
83 | mHilite(0), | ||
84 | mTextureView(texview) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEXTURE_BAR; } | ||
89 | virtual LLString getWidgetTag() const { return LL_TEXTURE_BAR_TAG; } | ||
90 | |||
91 | virtual void draw(); | ||
92 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
93 | virtual LLRect getRequiredRect(); // Return the height of this object, given the set options. | ||
94 | |||
51 | // Used for sorting | 95 | // Used for sorting |
52 | struct SortTextureBars | 96 | struct sort |
97 | { | ||
98 | bool operator()(const LLView* i1, const LLView* i2) | ||
99 | { | ||
100 | LLTextureBar* bar1p = (LLTextureBar*)i1; | ||
101 | LLTextureBar* bar2p = (LLTextureBar*)i2; | ||
102 | LLViewerImage *i1p = bar1p->mImagep; | ||
103 | LLViewerImage *i2p = bar2p->mImagep; | ||
104 | F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority | ||
105 | F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority | ||
106 | if (pri1 > pri2) | ||
107 | return true; | ||
108 | else if (pri2 > pri1) | ||
109 | return false; | ||
110 | else | ||
111 | return i1p->getID() < i2p->getID(); | ||
112 | } | ||
113 | }; | ||
114 | |||
115 | struct sort_fetch | ||
116 | { | ||
117 | bool operator()(const LLView* i1, const LLView* i2) | ||
118 | { | ||
119 | LLTextureBar* bar1p = (LLTextureBar*)i1; | ||
120 | LLTextureBar* bar2p = (LLTextureBar*)i2; | ||
121 | LLViewerImage *i1p = bar1p->mImagep; | ||
122 | LLViewerImage *i2p = bar2p->mImagep; | ||
123 | U32 pri1 = i1p->mFetchPriority; | ||
124 | U32 pri2 = i2p->mFetchPriority; | ||
125 | if (pri1 > pri2) | ||
126 | return true; | ||
127 | else if (pri2 > pri1) | ||
128 | return false; | ||
129 | else | ||
130 | return i1p->getID() < i2p->getID(); | ||
131 | } | ||
132 | }; | ||
133 | private: | ||
134 | LLTextureView* mTextureView; | ||
135 | }; | ||
136 | |||
137 | void LLTextureBar::draw() | ||
53 | { | 138 | { |
54 | bool operator()(const LLView* i1, const LLView* i2) | 139 | if (!mImagep) |
55 | { | 140 | { |
56 | LLTextureBar* bar1p = (LLTextureBar*)i1; | 141 | return; |
57 | LLTextureBar* bar2p = (LLTextureBar*)i2; | 142 | } |
58 | LLViewerImage *i1p = bar1p->mImagep; | 143 | |
59 | LLViewerImage *i2p = bar2p->mImagep; | 144 | LLColor4 color; |
60 | F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority | 145 | if (mImagep->getID() == gTextureFetch->mDebugID) |
61 | F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority | 146 | { |
62 | if (pri1 > pri2) | 147 | color = LLColor4::cyan2; |
63 | return true; | 148 | } |
64 | else if (pri2 > pri1) | 149 | else if (mHilite) |
65 | return false; | 150 | { |
151 | S32 idx = llclamp(mHilite,1,3); | ||
152 | if (idx==1) color = LLColor4::orange; | ||
153 | else if (idx==2) color = LLColor4::yellow; | ||
154 | else color = LLColor4::pink2; | ||
155 | } | ||
156 | else if (mImagep->mDontDiscard) | ||
157 | { | ||
158 | color = LLColor4::green4; | ||
159 | } | ||
160 | else if (mImagep->getBoostLevel()) | ||
161 | { | ||
162 | color = LLColor4::magenta; | ||
163 | } | ||
164 | else if (mImagep->getDecodePriority() == 0.0f) | ||
165 | { | ||
166 | color = LLColor4::grey; color[VALPHA] = .7f; | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | color = LLColor4::white; color[VALPHA] = .7f; | ||
171 | } | ||
172 | |||
173 | // We need to draw: | ||
174 | // The texture UUID or name | ||
175 | // The progress bar for the texture, highlighted if it's being download | ||
176 | // Various numerical stats. | ||
177 | char tex_str[256]; | ||
178 | S32 left, right; | ||
179 | S32 top = 0; | ||
180 | S32 bottom = top + 6; | ||
181 | LLColor4 clr; | ||
182 | |||
183 | LLGLSUIDefault gls_ui; | ||
184 | |||
185 | // Get the name or UUID of the image. | ||
186 | gTextureTable.getName(mImagep->mID); | ||
187 | |||
188 | // Name, pixel_area, requested pixel area, decode priority | ||
189 | char uuid_str[255]; | ||
190 | mImagep->mID.toString(uuid_str); | ||
191 | uuid_str[8] = 0; | ||
192 | if (mTextureView->mOrderFetch) | ||
193 | { | ||
194 | sprintf(tex_str, "%s %7.0f %d(%d) 0x%08x(%8.0f)", | ||
195 | uuid_str, | ||
196 | mImagep->mMaxVirtualSize, | ||
197 | mImagep->mDesiredDiscardLevel, | ||
198 | mImagep->mRequestedDiscardLevel, | ||
199 | mImagep->mFetchPriority, | ||
200 | mImagep->getDecodePriority()); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | sprintf(tex_str, "%s %7.0f %d(%d) %8.0f(0x%08x)", | ||
205 | uuid_str, | ||
206 | mImagep->mMaxVirtualSize, | ||
207 | mImagep->mDesiredDiscardLevel, | ||
208 | mImagep->mRequestedDiscardLevel, | ||
209 | mImagep->getDecodePriority(), | ||
210 | mImagep->mFetchPriority); | ||
211 | } | ||
212 | |||
213 | LLFontGL::sMonospace->renderUTF8(tex_str, 0, title_x1, mRect.getHeight(), | ||
214 | color, LLFontGL::LEFT, LLFontGL::TOP); | ||
215 | |||
216 | // State | ||
217 | // Hack: mirrored from lltexturefetch.cpp | ||
218 | struct { const char* desc; LLColor4 color; } fetch_state_desc[] = { | ||
219 | { "---", LLColor4::red }, // INVALID | ||
220 | { "INI", LLColor4::white }, // INIT | ||
221 | { "DSK", LLColor4::cyan }, // LOAD_FROM_TEXTURE_CACHE | ||
222 | { "DSK", LLColor4::blue }, // CACHE_POST | ||
223 | { "NET", LLColor4::green }, // LOAD_FROM_NETWORK | ||
224 | { "SIM", LLColor4::green }, // LOAD_FROM_SIMULATOR | ||
225 | { "URL", LLColor4::green2 },// LOAD_FROM_HTTP_GET_URL | ||
226 | { "HTP", LLColor4::green }, // LOAD_FROM_HTTP_GET_DATA | ||
227 | { "DEC", LLColor4::yellow },// DECODE_IMAGE | ||
228 | { "DEC", LLColor4::yellow },// DECODE_IMAGE_UPDATE | ||
229 | { "WRT", LLColor4::purple },// WRITE_TO_CACHE | ||
230 | { "WRT", LLColor4::orange },// WAIT_ON_WRITE | ||
231 | { "END", LLColor4::red }, // DONE | ||
232 | #define LAST_STATE 12 | ||
233 | { "CRE", LLColor4::magenta }, // LAST_STATE+1 | ||
234 | { "FUL", LLColor4::green }, // LAST_STATE+2 | ||
235 | { "BAD", LLColor4::red }, // LAST_STATE+3 | ||
236 | { "MIS", LLColor4::red }, // LAST_STATE+4 | ||
237 | { "---", LLColor4::white }, // LAST_STATE+5 | ||
238 | }; | ||
239 | const S32 fetch_state_desc_size = (S32)(sizeof(fetch_state_desc)/sizeof(fetch_state_desc[0])); | ||
240 | S32 state = | ||
241 | mImagep->mNeedsCreateTexture ? LAST_STATE+1 : | ||
242 | mImagep->mFullyLoaded ? LAST_STATE+2 : | ||
243 | mImagep->mMinDiscardLevel > 0 ? LAST_STATE+3 : | ||
244 | mImagep->mIsMissingAsset ? LAST_STATE+4 : | ||
245 | !mImagep->mIsFetching ? LAST_STATE+5 : | ||
246 | mImagep->mFetchState; | ||
247 | state = llclamp(state,0,fetch_state_desc_size-1); | ||
248 | |||
249 | LLFontGL::sMonospace->renderUTF8(fetch_state_desc[state].desc, 0, title_x2, mRect.getHeight(), | ||
250 | fetch_state_desc[state].color, | ||
251 | LLFontGL::LEFT, LLFontGL::TOP); | ||
252 | LLGLSNoTexture gls_no_texture; | ||
253 | |||
254 | // Draw the progress bar. | ||
255 | S32 bar_width = 100; | ||
256 | S32 bar_left = 280; | ||
257 | left = bar_left; | ||
258 | right = left + bar_width; | ||
259 | |||
260 | glColor4f(0.f, 0.f, 0.f, 0.75f); | ||
261 | gl_rect_2d(left, top, right, bottom); | ||
262 | |||
263 | F32 data_progress = mImagep->mDownloadProgress; | ||
264 | |||
265 | if (data_progress > 0.0f) | ||
266 | { | ||
267 | // Downloaded bytes | ||
268 | right = left + llfloor(data_progress * (F32)bar_width); | ||
269 | if (right > left) | ||
270 | { | ||
271 | glColor4f(0.f, 0.f, 1.f, 0.75f); | ||
272 | gl_rect_2d(left, top, right, bottom); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | S32 pip_width = 6; | ||
277 | S32 pip_space = 14; | ||
278 | S32 pip_x = title_x3 + pip_space/2; | ||
279 | |||
280 | // Draw the packet pip | ||
281 | F32 last_event = mImagep->mLastPacketTimer.getElapsedTimeF32(); | ||
282 | if (last_event < 1.f) | ||
283 | { | ||
284 | clr = LLColor4::white; | ||
285 | } | ||
286 | else | ||
287 | { | ||
288 | last_event = mImagep->mRequestDeltaTime; | ||
289 | if (last_event < 1.f) | ||
290 | { | ||
291 | clr = LLColor4::green; | ||
292 | } | ||
66 | else | 293 | else |
67 | return i1p->getID() < i2p->getID(); | 294 | { |
295 | last_event = mImagep->mFetchDeltaTime; | ||
296 | if (last_event < 1.f) | ||
297 | { | ||
298 | clr = LLColor4::yellow; | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | if (last_event < 1.f) | ||
303 | { | ||
304 | clr.setAlpha(1.f - last_event); | ||
305 | glColor4fv(clr.mV); | ||
306 | gl_rect_2d(pip_x, top, pip_x + pip_width, bottom); | ||
68 | } | 307 | } |
308 | pip_x += pip_width + pip_space; | ||
309 | |||
310 | // we don't want to show bind/resident pips for textures using the default texture | ||
311 | if (mImagep->getHasGLTexture()) | ||
312 | { | ||
313 | // Draw the bound pip | ||
314 | last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime; | ||
315 | if (last_event < 1.f) | ||
316 | { | ||
317 | clr = mImagep->getMissed() ? LLColor4::red : LLColor4::magenta1; | ||
318 | clr.setAlpha(1.f - last_event); | ||
319 | glColor4fv(clr.mV); | ||
320 | gl_rect_2d(pip_x, top, pip_x + pip_width, bottom); | ||
321 | } | ||
322 | } | ||
323 | pip_x += pip_width + pip_space; | ||
324 | |||
325 | |||
326 | { | ||
327 | LLGLSUIDefault gls_ui; | ||
328 | // draw the packet data | ||
329 | // { | ||
330 | // LLString num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); | ||
331 | // LLFontGL::sMonospace->renderUTF8(num_str, 0, bar_left + 100, mRect.getHeight(), color, | ||
332 | // LLFontGL::LEFT, LLFontGL::TOP); | ||
333 | // } | ||
334 | |||
335 | // draw the image size at the end | ||
336 | { | ||
337 | LLString num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), | ||
338 | mImagep->getDiscardLevel(), mImagep->mTextureMemory); | ||
339 | LLFontGL::sMonospace->renderUTF8(num_str, 0, title_x4, mRect.getHeight(), color, | ||
340 | LLFontGL::LEFT, LLFontGL::TOP); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | } | ||
345 | |||
346 | BOOL LLTextureBar::handleMouseDown(S32 x, S32 y, MASK mask) | ||
347 | { | ||
348 | if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == MASK_ALT) | ||
349 | { | ||
350 | gTextureFetch->mDebugID = mImagep->getID(); | ||
351 | return TRUE; | ||
352 | } | ||
353 | return LLView::handleMouseDown(x,y,mask); | ||
354 | } | ||
355 | |||
356 | LLRect LLTextureBar::getRequiredRect() | ||
357 | { | ||
358 | LLRect rect; | ||
359 | |||
360 | rect.mTop = texture_bar_height; | ||
361 | |||
362 | return rect; | ||
363 | } | ||
364 | |||
365 | //////////////////////////////////////////////////////////////////////////// | ||
366 | |||
367 | class LLGLTexMemBar : public LLView | ||
368 | { | ||
369 | public: | ||
370 | LLGLTexMemBar(const std::string& name, LLTextureView* texview) | ||
371 | : LLView(name, FALSE), | ||
372 | mTextureView(texview) | ||
373 | { | ||
374 | S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f); | ||
375 | setRect(LLRect(0,0,100,line_height * 4)); | ||
376 | updateRect(); | ||
377 | } | ||
378 | |||
379 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEX_MEM_BAR; }; | ||
380 | virtual LLString getWidgetTag() const { return LL_GL_TEX_MEM_BAR_TAG; }; | ||
381 | |||
382 | virtual void draw(); | ||
383 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
384 | virtual LLRect getRequiredRect(); // Return the height of this object, given the set options. | ||
385 | |||
386 | private: | ||
387 | LLTextureView* mTextureView; | ||
69 | }; | 388 | }; |
70 | 389 | ||
390 | void LLGLTexMemBar::draw() | ||
391 | { | ||
392 | S32 bound_mem = LLViewerImage::sBoundTextureMemory; | ||
393 | S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMem; | ||
394 | S32 total_mem = LLViewerImage::sTotalTextureMemory; | ||
395 | S32 max_total_mem = LLViewerImage::sMaxTotalTextureMem; | ||
396 | F32 discard_bias = LLViewerImage::sDesiredDiscardBias; | ||
397 | S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f); | ||
398 | |||
399 | //---------------------------------------------------------------------------- | ||
400 | LLGLSUIDefault gls_ui; | ||
401 | F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; | ||
402 | |||
403 | std::string text; | ||
404 | text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f", | ||
405 | total_mem/(1024*1024), | ||
406 | max_total_mem/(1024*1024), | ||
407 | bound_mem/(1024*1024), | ||
408 | max_bound_mem/(1024*1024), | ||
409 | discard_bias); | ||
410 | |||
411 | LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3, | ||
412 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
413 | |||
414 | //---------------------------------------------------------------------------- | ||
415 | S32 bar_left = 380; | ||
416 | S32 bar_width = 200; | ||
417 | S32 top = line_height*3 - 2; | ||
418 | S32 bottom = top - 6; | ||
419 | S32 left = bar_left; | ||
420 | S32 right = left + bar_width; | ||
421 | |||
422 | F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f); | ||
423 | |||
424 | LLGLSNoTexture gls_no_texture; | ||
425 | |||
426 | glColor4f(0.5f, 0.5f, 0.5f, 0.75f); | ||
427 | gl_rect_2d(left, top, right, bottom); | ||
428 | |||
429 | |||
430 | left = bar_left; | ||
431 | right = left + llfloor(bound_mem * bar_scale); | ||
432 | if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) | ||
433 | { | ||
434 | glColor4f(0.f, 1.f, 0.f, 0.75f); | ||
435 | } | ||
436 | else if (bound_mem < max_bound_mem) | ||
437 | { | ||
438 | glColor4f(1.f, 1.f, 0.f, 0.75f); | ||
439 | } | ||
440 | else | ||
441 | { | ||
442 | glColor4f(1.f, 0.f, 0.f, 0.75f); | ||
443 | } | ||
444 | gl_rect_2d(left, top, right, bottom); | ||
445 | |||
446 | bar_scale = (F32)bar_width / (max_total_mem * 1.5f); | ||
447 | |||
448 | top = bottom - 2; | ||
449 | bottom = top - 6; | ||
450 | left = bar_left; | ||
451 | right = left + llfloor(total_mem * bar_scale); | ||
452 | if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) | ||
453 | { | ||
454 | glColor4f(0.f, 1.f, 0.f, 0.75f); | ||
455 | } | ||
456 | else if (total_mem < max_total_mem) | ||
457 | { | ||
458 | glColor4f(1.f, 1.f, 0.f, 0.75f); | ||
459 | } | ||
460 | else | ||
461 | { | ||
462 | glColor4f(1.f, 0.f, 0.f, 0.75f); | ||
463 | } | ||
464 | gl_rect_2d(left, top, right, bottom); | ||
465 | |||
466 | //---------------------------------------------------------------------------- | ||
467 | |||
468 | LLGLEnable tex(GL_TEXTURE_2D); | ||
469 | |||
470 | text = llformat("Textures: Count: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d(%d) RAW:%d", | ||
471 | gImageList.getNumImages(), | ||
472 | gTextureFetch->getNumRequests(), gTextureFetch->getNumDeletes(), | ||
473 | gTextureFetch->mPacketCount, gTextureFetch->mBadPacketCount, | ||
474 | gTextureCache->getNumReads(), gTextureCache->getNumWrites(), | ||
475 | LLLFSThread::sLocal->getPending(), | ||
476 | LLImageWorker::sCount, LLImageWorker::getWorkerThread()->getNumDeletes(), | ||
477 | LLImageRaw::sRawImageCount); | ||
478 | |||
479 | LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*2, | ||
480 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
481 | |||
482 | S32 dx1 = 0; | ||
483 | if (gTextureFetch->mDebugPause) | ||
484 | { | ||
485 | LLFontGL::sMonospace->renderUTF8("!", 0, title_x1, line_height, | ||
486 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
487 | dx1 += 8; | ||
488 | } | ||
489 | if (mTextureView->mFreezeView) | ||
490 | { | ||
491 | LLFontGL::sMonospace->renderUTF8("*", 0, title_x1, line_height, | ||
492 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
493 | dx1 += 8; | ||
494 | } | ||
495 | if (mTextureView->mOrderFetch) | ||
496 | { | ||
497 | LLFontGL::sMonospace->renderUTF8(title_string1b, 0, title_x1+dx1, line_height, | ||
498 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
499 | } | ||
500 | else | ||
501 | { | ||
502 | LLFontGL::sMonospace->renderUTF8(title_string1a, 0, title_x1+dx1, line_height, | ||
503 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
504 | } | ||
505 | |||
506 | LLFontGL::sMonospace->renderUTF8(title_string2, 0, title_x2, line_height, | ||
507 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
508 | |||
509 | LLFontGL::sMonospace->renderUTF8(title_string3, 0, title_x3, line_height, | ||
510 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
511 | |||
512 | LLFontGL::sMonospace->renderUTF8(title_string4, 0, title_x4, line_height, | ||
513 | text_color, LLFontGL::LEFT, LLFontGL::TOP); | ||
514 | } | ||
515 | |||
516 | BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask) | ||
517 | { | ||
518 | return FALSE; | ||
519 | } | ||
520 | |||
521 | LLRect LLGLTexMemBar::getRequiredRect() | ||
522 | { | ||
523 | LLRect rect; | ||
524 | rect.mTop = 8; | ||
525 | return rect; | ||
526 | } | ||
527 | |||
528 | //////////////////////////////////////////////////////////////////////////// | ||
529 | |||
71 | LLTextureView::LLTextureView(const std::string& name, const LLRect& rect) | 530 | LLTextureView::LLTextureView(const std::string& name, const LLRect& rect) |
72 | : LLContainerView(name, rect) | 531 | : LLContainerView(name, rect), |
532 | mFreezeView(FALSE), | ||
533 | mOrderFetch(FALSE), | ||
534 | mPrintList(FALSE), | ||
535 | mNumTextureBars(0) | ||
73 | { | 536 | { |
74 | setVisible(FALSE); | 537 | setVisible(FALSE); |
75 | mFreezeView = FALSE; | ||
76 | 538 | ||
77 | mNumTextureBars = 0; | ||
78 | setDisplayChildren(TRUE); | 539 | setDisplayChildren(TRUE); |
79 | mGLTexMemBar = 0; | 540 | mGLTexMemBar = 0; |
80 | } | 541 | } |
@@ -122,46 +583,79 @@ void LLTextureView::draw() | |||
122 | typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t; | 583 | typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t; |
123 | display_list_t display_image_list; | 584 | display_list_t display_image_list; |
124 | 585 | ||
125 | for (LLViewerImageList::image_list_t::iterator iter = gImageList.mImageList.begin(); | 586 | if (mPrintList) |
587 | { | ||
588 | llinfos << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << llendl; | ||
589 | } | ||
590 | |||
591 | for (LLViewerImageList::image_priority_list_t::iterator iter = gImageList.mImageList.begin(); | ||
126 | iter != gImageList.mImageList.end(); ) | 592 | iter != gImageList.mImageList.end(); ) |
127 | { | 593 | { |
128 | LLPointer<LLViewerImage> imagep = *iter++; | 594 | LLPointer<LLViewerImage> imagep = *iter++; |
129 | #if 1 | 595 | |
596 | S32 cur_discard = imagep->getDiscardLevel(); | ||
597 | S32 desired_discard = imagep->mDesiredDiscardLevel; | ||
598 | |||
599 | if (mPrintList) | ||
600 | { | ||
601 | llinfos << imagep->getID() | ||
602 | << "\t" << imagep->mTextureMemory | ||
603 | << "\t" << imagep->getBoostLevel() | ||
604 | << "\t" << imagep->getDecodePriority() | ||
605 | << "\t" << imagep->getWidth() | ||
606 | << "\t" << imagep->getHeight() | ||
607 | << "\t" << cur_discard | ||
608 | << llendl; | ||
609 | } | ||
610 | |||
611 | #if 0 | ||
130 | if (imagep->getDontDiscard()) | 612 | if (imagep->getDontDiscard()) |
131 | { | 613 | { |
132 | continue; | 614 | continue; |
133 | } | 615 | } |
134 | #endif | 616 | |
135 | if (imagep->isMissingAsset()) | 617 | if (imagep->isMissingAsset()) |
136 | { | 618 | { |
137 | continue; | 619 | continue; |
138 | } | 620 | } |
139 | 621 | #endif | |
140 | #define HIGH_PRIORITY 100000000.f | ||
141 | F32 pri = imagep->getDecodePriority(); | ||
142 | 622 | ||
143 | if (sDebugImages.find(imagep) != sDebugImages.end()) | 623 | #define HIGH_PRIORITY 100000000.f |
624 | F32 pri; | ||
625 | if (mOrderFetch) | ||
626 | { | ||
627 | pri = ((F32)imagep->mFetchPriority)/256.f; | ||
628 | } | ||
629 | else | ||
144 | { | 630 | { |
145 | pri += 3*HIGH_PRIORITY; | 631 | pri = imagep->getDecodePriority(); |
146 | } | 632 | } |
147 | 633 | ||
634 | if (sDebugImages.find(imagep) != sDebugImages.end()) | ||
635 | { | ||
636 | pri += 4*HIGH_PRIORITY; | ||
637 | } | ||
638 | |||
639 | if (!mOrderFetch) | ||
640 | { | ||
148 | #if 1 | 641 | #if 1 |
149 | if (pri < HIGH_PRIORITY && gSelectMgr) | 642 | if (pri < HIGH_PRIORITY && gSelectMgr) |
150 | { | 643 | { |
151 | S32 te; | 644 | S32 te; |
152 | LLViewerObject *objectp; | 645 | LLViewerObject *objectp; |
153 | for (gSelectMgr->getFirstTE(&objectp, &te); objectp; gSelectMgr->getNextTE(&objectp, &te)) | 646 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); |
647 | for (selection->getFirstTE(&objectp, &te); objectp; selection->getNextTE(&objectp, &te)) | ||
154 | { | 648 | { |
155 | if (imagep == objectp->getTEImage(te)) | 649 | if (imagep == objectp->getTEImage(te)) |
156 | { | 650 | { |
157 | pri += 2*HIGH_PRIORITY; | 651 | pri += 3*HIGH_PRIORITY; |
158 | break; | 652 | break; |
159 | } | 653 | } |
160 | } | 654 | } |
161 | } | 655 | } |
162 | #endif | 656 | #endif |
163 | #if 1 | 657 | #if 1 |
164 | if (pri < HIGH_PRIORITY) | 658 | if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) |
165 | { | 659 | { |
166 | LLViewerObject *objectp = gHoverView->getLastHoverObject(); | 660 | LLViewerObject *objectp = gHoverView->getLastHoverObject(); |
167 | if (objectp) | 661 | if (objectp) |
@@ -178,31 +672,29 @@ void LLTextureView::draw() | |||
178 | } | 672 | } |
179 | } | 673 | } |
180 | #endif | 674 | #endif |
181 | #if 0 | ||
182 | if (pri < HIGH_PRIORITY) | ||
183 | { | ||
184 | if (imagep->mBoostPriority) | ||
185 | { | ||
186 | pri += 4*HIGH_PRIORITY; | ||
187 | } | ||
188 | } | ||
189 | #endif | ||
190 | #if 1 | 675 | #if 1 |
191 | if (pri > 0.f && pri < HIGH_PRIORITY) | 676 | if (pri > 0.f && pri < HIGH_PRIORITY) |
192 | { | 677 | { |
193 | if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || | 678 | if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || |
194 | imagep->mLastDecodeTime.getElapsedTimeF32() < 1.f) | 679 | imagep->mFetchDeltaTime < 0.25f) |
195 | { | 680 | { |
196 | pri += 1*HIGH_PRIORITY; | 681 | pri += 1*HIGH_PRIORITY; |
197 | } | 682 | } |
198 | } | 683 | } |
199 | #endif | 684 | #endif |
200 | // if (pri > 0.0f) | 685 | } |
686 | |||
687 | if (pri > 0.0f) | ||
201 | { | 688 | { |
202 | display_image_list.insert(std::make_pair(pri, imagep)); | 689 | display_image_list.insert(std::make_pair(pri, imagep)); |
203 | } | 690 | } |
204 | } | 691 | } |
205 | 692 | ||
693 | if (mPrintList) | ||
694 | { | ||
695 | mPrintList = FALSE; | ||
696 | } | ||
697 | |||
206 | static S32 max_count = 50; | 698 | static S32 max_count = 50; |
207 | S32 count = 0; | 699 | S32 count = 0; |
208 | for (display_list_t::iterator iter = display_image_list.begin(); | 700 | for (display_list_t::iterator iter = display_image_list.begin(); |
@@ -224,9 +716,12 @@ void LLTextureView::draw() | |||
224 | } | 716 | } |
225 | } | 717 | } |
226 | 718 | ||
227 | sortChildren(SortTextureBars()); | 719 | if (mOrderFetch) |
228 | 720 | sortChildren(LLTextureBar::sort_fetch()); | |
229 | mGLTexMemBar = new LLGLTexMemBar("gl texmem bar"); | 721 | else |
722 | sortChildren(LLTextureBar::sort()); | ||
723 | |||
724 | mGLTexMemBar = new LLGLTexMemBar("gl texmem bar", this); | ||
230 | addChild(mGLTexMemBar); | 725 | addChild(mGLTexMemBar); |
231 | 726 | ||
232 | reshape(mRect.getWidth(), mRect.getHeight(), TRUE); | 727 | reshape(mRect.getWidth(), mRect.getHeight(), TRUE); |
@@ -256,54 +751,46 @@ void LLTextureView::draw() | |||
256 | 751 | ||
257 | BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite) | 752 | BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite) |
258 | { | 753 | { |
259 | if (!imagep) | 754 | llassert(imagep); |
260 | { | 755 | |
261 | return FALSE; | ||
262 | } | ||
263 | |||
264 | LLTextureBar *barp; | 756 | LLTextureBar *barp; |
265 | LLRect r; | 757 | LLRect r; |
266 | 758 | ||
267 | mNumTextureBars++; | 759 | mNumTextureBars++; |
268 | 760 | ||
269 | for (std::vector<LLTextureBar*>::iterator iter = mTextureBars.begin(); | 761 | barp = new LLTextureBar("texture bar", r, this); |
270 | iter != mTextureBars.end(); iter++) | ||
271 | { | ||
272 | LLTextureBar* barp = *iter; | ||
273 | if (barp->mImagep == imagep) | ||
274 | { | ||
275 | barp->mHilite = hilite; | ||
276 | return FALSE; | ||
277 | } | ||
278 | } | ||
279 | |||
280 | barp = new LLTextureBar("texture bar", r); | ||
281 | barp->mImagep = imagep; | 762 | barp->mImagep = imagep; |
282 | barp->mHilite = hilite; | 763 | barp->mHilite = hilite; |
283 | 764 | ||
284 | addChild(barp); | 765 | addChild(barp); |
285 | mTextureBars.push_back(barp); | 766 | mTextureBars.push_back(barp); |
286 | 767 | ||
287 | // Rearrange all child bars. | ||
288 | reshape(mRect.getWidth(), mRect.getHeight()); | ||
289 | return TRUE; | 768 | return TRUE; |
290 | } | 769 | } |
291 | 770 | ||
292 | BOOL LLTextureView::handleMouseDown(S32 x, S32 y, MASK mask) | 771 | BOOL LLTextureView::handleMouseDown(S32 x, S32 y, MASK mask) |
293 | { | 772 | { |
294 | if (mask & MASK_SHIFT) | 773 | if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == (MASK_ALT|MASK_SHIFT)) |
295 | { | 774 | { |
296 | mFreezeView = !mFreezeView; | 775 | mPrintList = TRUE; |
297 | return TRUE; | 776 | return TRUE; |
298 | } | 777 | } |
299 | else if (mask & MASK_CONTROL) | 778 | if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == (MASK_CONTROL|MASK_SHIFT)) |
300 | { | 779 | { |
301 | return FALSE; | 780 | gTextureFetch->mDebugPause = !gTextureFetch->mDebugPause; |
781 | return TRUE; | ||
302 | } | 782 | } |
303 | else | 783 | if (mask & MASK_SHIFT) |
304 | { | 784 | { |
305 | return FALSE; | 785 | mFreezeView = !mFreezeView; |
786 | return TRUE; | ||
306 | } | 787 | } |
788 | if (mask & MASK_CONTROL) | ||
789 | { | ||
790 | mOrderFetch = !mOrderFetch; | ||
791 | return TRUE; | ||
792 | } | ||
793 | return LLView::handleMouseDown(x,y,mask); | ||
307 | } | 794 | } |
308 | 795 | ||
309 | BOOL LLTextureView::handleMouseUp(S32 x, S32 y, MASK mask) | 796 | BOOL LLTextureView::handleMouseUp(S32 x, S32 y, MASK mask) |
@@ -313,11 +800,6 @@ BOOL LLTextureView::handleMouseUp(S32 x, S32 y, MASK mask) | |||
313 | 800 | ||
314 | BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent) | 801 | BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent) |
315 | { | 802 | { |
316 | if (key == ' ') | ||
317 | { | ||
318 | mFreezeView = !mFreezeView; | ||
319 | return TRUE; | ||
320 | } | ||
321 | return FALSE; | 803 | return FALSE; |
322 | } | 804 | } |
323 | 805 | ||