lltextureview.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include <set>
00035 
00036 #include "lltextureview.h"
00037 
00038 #include "llrect.h"
00039 #include "llerror.h"
00040 #include "lllfsthread.h"
00041 #include "llui.h"
00042 #include "llimageworker.h"
00043 #include "llglimmediate.h"
00044 
00045 #include "llhoverview.h"
00046 #include "llselectmgr.h"
00047 #include "lltexlayer.h"
00048 #include "lltexturecache.h"
00049 #include "lltexturefetch.h"
00050 #include "llviewerobject.h"
00051 #include "llviewerimage.h"
00052 #include "llviewerimagelist.h"
00053 #include "llappviewer.h"
00054 
00055 extern F32 texmem_lower_bound_scale;
00056 
00057 LLTextureView *gTextureView = NULL;
00058 
00059 //static
00060 std::set<LLViewerImage*> LLTextureView::sDebugImages;
00061 
00063 
00064 static LLString title_string1a("Tex UUID Area  DDis(Req)  DecodePri(Fetch)     [download]        pk/max");
00065 static LLString title_string1b("Tex UUID Area  DDis(Req)  Fetch(DecodePri)     [download]        pk/max");
00066 static LLString title_string2("State");
00067 static LLString title_string3("Pkt Bnd");
00068 static LLString title_string4("  W x H (Dis) Mem");
00069 
00070 static S32 title_x1 = 0;
00071 static S32 title_x2 = 440;
00072 static S32 title_x3 = title_x2 + 40;
00073 static S32 title_x4 = title_x3 + 50;
00074 static S32 texture_bar_height = 8;
00075 
00077 
00078 class LLTextureBar : public LLView
00079 {
00080 public:
00081         LLPointer<LLViewerImage> mImagep;
00082         S32 mHilite;
00083 
00084 public:
00085         LLTextureBar(const std::string& name, const LLRect& r, LLTextureView* texview)
00086                 : LLView(name, r, FALSE),
00087                   mHilite(0),
00088                   mTextureView(texview)
00089         {
00090         }
00091 
00092         virtual void draw();
00093         virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00094         virtual LLRect getRequiredRect();       // Return the height of this object, given the set options.
00095 
00096 // Used for sorting
00097         struct sort
00098         {
00099                 bool operator()(const LLView* i1, const LLView* i2)
00100                 {
00101                         LLTextureBar* bar1p = (LLTextureBar*)i1;
00102                         LLTextureBar* bar2p = (LLTextureBar*)i2;
00103                         LLViewerImage *i1p = bar1p->mImagep;
00104                         LLViewerImage *i2p = bar2p->mImagep;
00105                         F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority
00106                         F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority
00107                         if (pri1 > pri2)
00108                                 return true;
00109                         else if (pri2 > pri1)
00110                                 return false;
00111                         else
00112                                 return i1p->getID() < i2p->getID();
00113                 }
00114         };
00115 
00116         struct sort_fetch
00117         {
00118                 bool operator()(const LLView* i1, const LLView* i2)
00119                 {
00120                         LLTextureBar* bar1p = (LLTextureBar*)i1;
00121                         LLTextureBar* bar2p = (LLTextureBar*)i2;
00122                         LLViewerImage *i1p = bar1p->mImagep;
00123                         LLViewerImage *i2p = bar2p->mImagep;
00124                         U32 pri1 = i1p->mFetchPriority;
00125                         U32 pri2 = i2p->mFetchPriority;
00126                         if (pri1 > pri2)
00127                                 return true;
00128                         else if (pri2 > pri1)
00129                                 return false;
00130                         else
00131                                 return i1p->getID() < i2p->getID();
00132                 }
00133         };      
00134 private:
00135         LLTextureView* mTextureView;
00136 };
00137 
00138 void LLTextureBar::draw()
00139 {
00140         if (!mImagep)
00141         {
00142                 return;
00143         }
00144 
00145         LLColor4 color;
00146         if (mImagep->getID() == LLAppViewer::getTextureFetch()->mDebugID)
00147         {
00148                 color = LLColor4::cyan2;
00149         }
00150         else if (mHilite)
00151         {
00152                 S32 idx = llclamp(mHilite,1,3);
00153                 if (idx==1) color = LLColor4::orange;
00154                 else if (idx==2) color = LLColor4::yellow;
00155                 else color = LLColor4::pink2;
00156         }
00157         else if (mImagep->mDontDiscard)
00158         {
00159                 color = LLColor4::green4;
00160         }
00161         else if (mImagep->getBoostLevel())
00162         {
00163                 color = LLColor4::magenta;
00164         }
00165         else if (mImagep->getDecodePriority() == 0.0f)
00166         {
00167                 color = LLColor4::grey; color[VALPHA] = .7f;
00168         }
00169         else
00170         {
00171                 color = LLColor4::white; color[VALPHA] = .7f;
00172         }
00173 
00174         // We need to draw:
00175         // The texture UUID or name
00176         // The progress bar for the texture, highlighted if it's being download
00177         // Various numerical stats.
00178         char tex_str[256];
00179         S32 left, right;
00180         S32 top = 0;
00181         S32 bottom = top + 6;
00182         LLColor4 clr;
00183 
00184         LLGLSUIDefault gls_ui;
00185         
00186         // Name, pixel_area, requested pixel area, decode priority
00187         char uuid_str[255];
00188         mImagep->mID.toString(uuid_str);
00189         uuid_str[8] = 0;
00190         if (mTextureView->mOrderFetch)
00191         {
00192                 sprintf(tex_str, "%s %7.0f %d(%d) 0x%08x(%8.0f)",
00193                                 uuid_str,
00194                                 mImagep->mMaxVirtualSize,
00195                                 mImagep->mDesiredDiscardLevel,
00196                                 mImagep->mRequestedDiscardLevel,
00197                                 mImagep->mFetchPriority,
00198                                 mImagep->getDecodePriority());
00199         }
00200         else
00201         {
00202                 sprintf(tex_str, "%s %7.0f %d(%d) %8.0f(0x%08x)",
00203                                 uuid_str,
00204                                 mImagep->mMaxVirtualSize,
00205                                 mImagep->mDesiredDiscardLevel,
00206                                 mImagep->mRequestedDiscardLevel,
00207                                 mImagep->getDecodePriority(),
00208                                 mImagep->mFetchPriority);
00209         }
00210 
00211         LLFontGL::sMonospace->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(),
00212                                                                          color, LLFontGL::LEFT, LLFontGL::TOP);
00213 
00214         // State
00215         // Hack: mirrored from lltexturefetch.cpp
00216         struct { const char* desc; LLColor4 color; } fetch_state_desc[] = {
00217                 { "---", LLColor4::red },       // INVALID
00218                 { "INI", LLColor4::white },     // INIT
00219                 { "DSK", LLColor4::cyan },      // LOAD_FROM_TEXTURE_CACHE
00220                 { "DSK", LLColor4::blue },      // CACHE_POST
00221                 { "NET", LLColor4::green },     // LOAD_FROM_NETWORK
00222                 { "SIM", LLColor4::green },     // LOAD_FROM_SIMULATOR
00223                 { "URL", LLColor4::green2 },// LOAD_FROM_HTTP_GET_URL
00224                 { "HTP", LLColor4::green },     // LOAD_FROM_HTTP_GET_DATA
00225                 { "DEC", LLColor4::yellow },// DECODE_IMAGE
00226                 { "DEC", LLColor4::yellow },// DECODE_IMAGE_UPDATE
00227                 { "WRT", LLColor4::purple },// WRITE_TO_CACHE
00228                 { "WRT", LLColor4::orange },// WAIT_ON_WRITE
00229                 { "END", LLColor4::red },   // DONE
00230 #define LAST_STATE 12
00231                 { "CRE", LLColor4::magenta }, // LAST_STATE+1
00232                 { "FUL", LLColor4::green }, // LAST_STATE+2
00233                 { "BAD", LLColor4::red }, // LAST_STATE+3
00234                 { "MIS", LLColor4::red }, // LAST_STATE+4
00235                 { "---", LLColor4::white }, // LAST_STATE+5
00236         };
00237         const S32 fetch_state_desc_size = (S32)(sizeof(fetch_state_desc)/sizeof(fetch_state_desc[0]));
00238         S32 state =
00239                 mImagep->mNeedsCreateTexture ? LAST_STATE+1 :
00240                 mImagep->mFullyLoaded ? LAST_STATE+2 :
00241                 mImagep->mMinDiscardLevel > 0 ? LAST_STATE+3 :
00242                 mImagep->mIsMissingAsset ? LAST_STATE+4 :
00243                 !mImagep->mIsFetching ? LAST_STATE+5 :
00244                 mImagep->mFetchState;
00245         state = llclamp(state,0,fetch_state_desc_size-1);
00246 
00247         LLFontGL::sMonospace->renderUTF8(fetch_state_desc[state].desc, 0, title_x2, getRect().getHeight(),
00248                                                                          fetch_state_desc[state].color,
00249                                                                          LLFontGL::LEFT, LLFontGL::TOP);
00250         LLGLSNoTexture gls_no_texture;
00251 
00252         // Draw the progress bar.
00253         S32 bar_width = 100;
00254         S32 bar_left = 280;
00255         left = bar_left;
00256         right = left + bar_width;
00257 
00258         gGL.color4f(0.f, 0.f, 0.f, 0.75f);
00259         gl_rect_2d(left, top, right, bottom);
00260 
00261         F32 data_progress = mImagep->mDownloadProgress;
00262         
00263         if (data_progress > 0.0f)
00264         {
00265                 // Downloaded bytes
00266                 right = left + llfloor(data_progress * (F32)bar_width);
00267                 if (right > left)
00268                 {
00269                         gGL.color4f(0.f, 0.f, 1.f, 0.75f);
00270                         gl_rect_2d(left, top, right, bottom);
00271                 }
00272         }
00273 
00274         S32 pip_width = 6;
00275         S32 pip_space = 14;
00276         S32 pip_x = title_x3 + pip_space/2;
00277         
00278         // Draw the packet pip
00279         F32 last_event = mImagep->mLastPacketTimer.getElapsedTimeF32();
00280         if (last_event < 1.f)
00281         {
00282                 clr = LLColor4::white; 
00283         }
00284         else
00285         {
00286                 last_event = mImagep->mRequestDeltaTime;
00287                 if (last_event < 1.f)
00288                 {
00289                         clr = LLColor4::green;
00290                 }
00291                 else
00292                 {
00293                         last_event = mImagep->mFetchDeltaTime;
00294                         if (last_event < 1.f)
00295                         {
00296                                 clr = LLColor4::yellow;
00297                         }
00298                 }
00299         }
00300         if (last_event < 1.f)
00301         {
00302                 clr.setAlpha(1.f - last_event);
00303                 gGL.color4fv(clr.mV);
00304                 gl_rect_2d(pip_x, top, pip_x + pip_width, bottom);
00305         }
00306         pip_x += pip_width + pip_space;
00307 
00308         // we don't want to show bind/resident pips for textures using the default texture
00309         if (mImagep->getHasGLTexture())
00310         {
00311                 // Draw the bound pip
00312                 last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime;
00313                 if (last_event < 1.f)
00314                 {
00315                         clr = mImagep->getMissed() ? LLColor4::red : LLColor4::magenta1;
00316                         clr.setAlpha(1.f - last_event);
00317                         gGL.color4fv(clr.mV);
00318                         gl_rect_2d(pip_x, top, pip_x + pip_width, bottom);
00319                 }
00320         }
00321         pip_x += pip_width + pip_space;
00322 
00323         
00324         {
00325                 LLGLSUIDefault gls_ui;
00326                 // draw the packet data
00327 //              {
00328 //                      LLString num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets);
00329 //                      LLFontGL::sMonospace->renderUTF8(num_str, 0, bar_left + 100, getRect().getHeight(), color,
00330 //                                                                                       LLFontGL::LEFT, LLFontGL::TOP);
00331 //              }
00332                 
00333                 // draw the image size at the end
00334                 {
00335                         LLString num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(),
00336                                                                                 mImagep->getDiscardLevel(), mImagep->mTextureMemory);
00337                         LLFontGL::sMonospace->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color,
00338                                                                                         LLFontGL::LEFT, LLFontGL::TOP);
00339                 }
00340         }
00341 
00342 }
00343 
00344 BOOL LLTextureBar::handleMouseDown(S32 x, S32 y, MASK mask)
00345 {
00346         if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == MASK_ALT)
00347         {
00348                 LLAppViewer::getTextureFetch()->mDebugID = mImagep->getID();
00349                 return TRUE;
00350         }
00351         return LLView::handleMouseDown(x,y,mask);
00352 }
00353 
00354 LLRect LLTextureBar::getRequiredRect()
00355 {
00356         LLRect rect;
00357 
00358         rect.mTop = texture_bar_height;
00359 
00360         return rect;
00361 }
00362 
00364 
00365 class LLGLTexMemBar : public LLView
00366 {
00367 public:
00368         LLGLTexMemBar(const std::string& name, LLTextureView* texview)
00369                 : LLView(name, FALSE),
00370                   mTextureView(texview)
00371         {
00372                 S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f);
00373                 setRect(LLRect(0,0,100,line_height * 4));
00374         }
00375 
00376         virtual void draw();    
00377         virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00378         virtual LLRect getRequiredRect();       // Return the height of this object, given the set options.
00379 
00380 private:
00381         LLTextureView* mTextureView;
00382 };
00383 
00384 void LLGLTexMemBar::draw()
00385 {
00386         S32 bound_mem = LLViewerImage::sBoundTextureMemory;
00387         S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMem;
00388         S32 total_mem = LLViewerImage::sTotalTextureMemory;
00389         S32 max_total_mem = LLViewerImage::sMaxTotalTextureMem;
00390         F32 discard_bias = LLViewerImage::sDesiredDiscardBias;
00391         S32 line_height = (S32)(LLFontGL::sMonospace->getLineHeight() + .5f);
00392         
00393         //----------------------------------------------------------------------------
00394         LLGLSUIDefault gls_ui;
00395         F32 text_color[] = {1.f, 1.f, 1.f, 0.75f};
00396         
00397         std::string text;
00398         text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Discard Bias: %.2f",
00399                                         total_mem/(1024*1024),
00400                                         max_total_mem/(1024*1024),
00401                                         bound_mem/(1024*1024),
00402                                         max_bound_mem/(1024*1024),
00403                                         discard_bias);
00404 
00405         LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*3,
00406                                                                          text_color, LLFontGL::LEFT, LLFontGL::TOP);
00407 
00408         //----------------------------------------------------------------------------
00409         S32 bar_left = 380;
00410         S32 bar_width = 200;
00411         S32 top = line_height*3 - 2;
00412         S32 bottom = top - 6;
00413         S32 left = bar_left;
00414         S32 right = left + bar_width;
00415 
00416         F32 bar_scale = (F32)bar_width / (max_bound_mem * 1.5f);
00417         
00418         LLGLSNoTexture gls_no_texture;
00419         
00420         gGL.color4f(0.5f, 0.5f, 0.5f, 0.75f);
00421         gl_rect_2d(left, top, right, bottom);
00422 
00423         
00424         left = bar_left;
00425         right = left + llfloor(bound_mem * bar_scale);
00426         if (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale))
00427         {
00428                 gGL.color4f(0.f, 1.f, 0.f, 0.75f);
00429         }
00430         else if (bound_mem < max_bound_mem)
00431         {
00432                 gGL.color4f(1.f, 1.f, 0.f, 0.75f);
00433         }
00434         else
00435         {
00436                 gGL.color4f(1.f, 0.f, 0.f, 0.75f);
00437         }
00438         gl_rect_2d(left, top, right, bottom);
00439 
00440         bar_scale = (F32)bar_width / (max_total_mem * 1.5f);
00441         
00442         top = bottom - 2;
00443         bottom = top - 6;
00444         left = bar_left;
00445         right = left + llfloor(total_mem * bar_scale);
00446         if (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale))
00447         {
00448                 gGL.color4f(0.f, 1.f, 0.f, 0.75f);
00449         }
00450         else if (total_mem < max_total_mem)
00451         {
00452                 gGL.color4f(1.f, 1.f, 0.f, 0.75f);
00453         }
00454         else
00455         {
00456                 gGL.color4f(1.f, 0.f, 0.f, 0.75f);
00457         }
00458         gl_rect_2d(left, top, right, bottom);
00459 
00460         //----------------------------------------------------------------------------
00461 
00462         text = llformat("Textures: Count: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d(%d) RAW:%d",
00463                                         gImageList.getNumImages(),
00464                                         LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(),
00465                                         LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, 
00466                                         LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(),
00467                                         LLLFSThread::sLocal->getPending(),
00468                                         LLImageWorker::sCount, LLImageWorker::getWorkerThread()->getNumDeletes(),
00469                                         LLImageRaw::sRawImageCount);
00470 
00471         LLFontGL::sMonospace->renderUTF8(text, 0, 0, line_height*2,
00472                                                                          text_color, LLFontGL::LEFT, LLFontGL::TOP);
00473         
00474         S32 dx1 = 0;
00475         if (LLAppViewer::getTextureFetch()->mDebugPause)
00476         {
00477                 LLFontGL::sMonospace->renderUTF8("!", 0, title_x1, line_height,
00478                                                                                  text_color, LLFontGL::LEFT, LLFontGL::TOP);
00479                 dx1 += 8;
00480         }
00481         if (mTextureView->mFreezeView)
00482         {
00483                 LLFontGL::sMonospace->renderUTF8("*", 0, title_x1, line_height,
00484                                                                                  text_color, LLFontGL::LEFT, LLFontGL::TOP);
00485                 dx1 += 8;
00486         }
00487         if (mTextureView->mOrderFetch)
00488         {
00489                 LLFontGL::sMonospace->renderUTF8(title_string1b, 0, title_x1+dx1, line_height,
00490                                                                                  text_color, LLFontGL::LEFT, LLFontGL::TOP);
00491         }
00492         else
00493         {       
00494                 LLFontGL::sMonospace->renderUTF8(title_string1a, 0, title_x1+dx1, line_height,
00495                                                                                  text_color, LLFontGL::LEFT, LLFontGL::TOP);
00496         }
00497         
00498         LLFontGL::sMonospace->renderUTF8(title_string2, 0, title_x2, line_height,
00499                                                                          text_color, LLFontGL::LEFT, LLFontGL::TOP);
00500 
00501         LLFontGL::sMonospace->renderUTF8(title_string3, 0, title_x3, line_height,
00502                                                                          text_color, LLFontGL::LEFT, LLFontGL::TOP);
00503 
00504         LLFontGL::sMonospace->renderUTF8(title_string4, 0, title_x4, line_height,
00505                                                                          text_color, LLFontGL::LEFT, LLFontGL::TOP);
00506 }
00507 
00508 BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask)
00509 {
00510         return FALSE;
00511 }
00512 
00513 LLRect LLGLTexMemBar::getRequiredRect()
00514 {
00515         LLRect rect;
00516         rect.mTop = 8;
00517         return rect;
00518 }
00519 
00521 
00522 LLTextureView::LLTextureView(const std::string& name, const LLRect& rect)
00523         :       LLContainerView(name, rect),
00524                 mFreezeView(FALSE),
00525                 mOrderFetch(FALSE),
00526                 mPrintList(FALSE),
00527                 mNumTextureBars(0)
00528 {
00529         setVisible(FALSE);
00530         
00531         setDisplayChildren(TRUE);
00532         mGLTexMemBar = 0;
00533 }
00534 
00535 LLTextureView::~LLTextureView()
00536 {
00537         // Children all cleaned up by default view destructor.
00538         delete mGLTexMemBar;
00539         mGLTexMemBar = 0;
00540 }
00541 
00542 typedef std::pair<F32,LLViewerImage*> decode_pair_t;
00543 struct compare_decode_pair
00544 {
00545         bool operator()(const decode_pair_t& a, const decode_pair_t& b)
00546         {
00547                 return a.first > b.first;
00548         }
00549 };
00550 
00551 void LLTextureView::draw()
00552 {
00553         if (!mFreezeView)
00554         {
00555 //              LLViewerObject *objectp;
00556 //              S32 te;
00557 
00558                 for_each(mTextureBars.begin(), mTextureBars.end(), DeletePointer());
00559                 mTextureBars.clear();
00560         
00561                 delete mGLTexMemBar;
00562                 mGLTexMemBar = 0;
00563         
00564                 typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t;
00565                 display_list_t display_image_list;
00566         
00567                 if (mPrintList)
00568                 {
00569                         llinfos << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << llendl;
00570                 }
00571         
00572                 for (LLViewerImageList::image_priority_list_t::iterator iter = gImageList.mImageList.begin();
00573                          iter != gImageList.mImageList.end(); )
00574                 {
00575                         LLPointer<LLViewerImage> imagep = *iter++;
00576 
00577                         S32 cur_discard = imagep->getDiscardLevel();
00578                         S32 desired_discard = imagep->mDesiredDiscardLevel;
00579                         
00580                         if (mPrintList)
00581                         {
00582                                 llinfos << imagep->getID()
00583                                                 << "\t" <<  imagep->mTextureMemory
00584                                                 << "\t" << imagep->getBoostLevel()
00585                                                 << "\t" << imagep->getDecodePriority()
00586                                                 << "\t" << imagep->getWidth()
00587                                                 << "\t" << imagep->getHeight()
00588                                                 << "\t" << cur_discard
00589                                                 << llendl;
00590                         }
00591                 
00592 #if 0
00593                         if (imagep->getDontDiscard())
00594                         {
00595                                 continue;
00596                         }
00597 
00598                         if (imagep->isMissingAsset())
00599                         {
00600                                 continue;
00601                         }
00602 #endif
00603 
00604 #define HIGH_PRIORITY 100000000.f
00605                         F32 pri;
00606                         if (mOrderFetch)
00607                         {
00608                                 pri = ((F32)imagep->mFetchPriority)/256.f;
00609                         }
00610                         else
00611                         {
00612                                 pri = imagep->getDecodePriority();
00613                         }
00614                         
00615                         if (sDebugImages.find(imagep) != sDebugImages.end())
00616                         {
00617                                 pri += 4*HIGH_PRIORITY;
00618                         }
00619 
00620                         if (!mOrderFetch)
00621                         {
00622 #if 1
00623                         if (pri < HIGH_PRIORITY && LLSelectMgr::getInstance())
00624                         {
00625                                 struct f : public LLSelectedTEFunctor
00626                                 {
00627                                         LLViewerImage* mImage;
00628                                         f(LLViewerImage* image) : mImage(image) {}
00629                                         virtual bool apply(LLViewerObject* object, S32 te)
00630                                         {
00631                                                 return (mImage == object->getTEImage(te));
00632                                         }
00633                                 } func(imagep);
00634                                 const bool firstonly = true;
00635                                 bool match = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, firstonly);
00636                                 if (match)
00637                                 {
00638                                         pri += 3*HIGH_PRIORITY;
00639                                 }
00640                         }
00641 #endif
00642 #if 1
00643                         if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard))
00644                         {
00645                                 LLViewerObject *objectp = gHoverView->getLastHoverObject();
00646                                 if (objectp)
00647                                 {
00648                                         S32 tex_count = objectp->getNumTEs();
00649                                         for (S32 i = 0; i < tex_count; i++)
00650                                         {
00651                                                 if (imagep == objectp->getTEImage(i))
00652                                                 {
00653                                                         pri += 2*HIGH_PRIORITY;
00654                                                         break;
00655                                                 }
00656                                         }
00657                                 }
00658                         }
00659 #endif
00660 #if 1
00661                         if (pri > 0.f && pri < HIGH_PRIORITY)
00662                         {
00663                                 if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f ||
00664                                         imagep->mFetchDeltaTime < 0.25f)
00665                                 {
00666                                         pri += 1*HIGH_PRIORITY;
00667                                 }
00668                         }
00669 #endif
00670                         }
00671                         
00672                         if (pri > 0.0f)
00673                         {
00674                                 display_image_list.insert(std::make_pair(pri, imagep));
00675                         }
00676                 }
00677                 
00678                 if (mPrintList)
00679                 {
00680                         mPrintList = FALSE;
00681                 }
00682                 
00683                 static S32 max_count = 50;
00684                 S32 count = 0;
00685                 for (display_list_t::iterator iter = display_image_list.begin();
00686                          iter != display_image_list.end(); iter++)
00687                 {
00688                         LLViewerImage* imagep = iter->second;
00689                         S32 hilite = 0;
00690                         F32 pri = iter->first;
00691                         if (pri >= 1 * HIGH_PRIORITY)
00692                         {
00693                                 hilite = (S32)((pri+1) / HIGH_PRIORITY) - 1;
00694                         }
00695                         if ((hilite || count < max_count-10) && (count < max_count))
00696                         {
00697                                 if (addBar(imagep, hilite))
00698                                 {
00699                                         count++;
00700                                 }
00701                         }
00702                 }
00703 
00704                 if (mOrderFetch)
00705                         sortChildren(LLTextureBar::sort_fetch());
00706                 else
00707                         sortChildren(LLTextureBar::sort());
00708 
00709                 mGLTexMemBar = new LLGLTexMemBar("gl texmem bar", this);
00710                 addChild(mGLTexMemBar);
00711         
00712                 reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
00713 
00714                 /*
00715                   count = gImageList.getNumImages();
00716                   char info_string[512];
00717                   sprintf(info_string, "Global Info:\nTexture Count: %d", count);
00718                   mInfoTextp->setText(info_string);
00719                 */
00720 
00721 
00722                 for (child_list_const_iter_t child_iter = getChildList()->begin();
00723                          child_iter != getChildList()->end(); ++child_iter)
00724                 {
00725                         LLView *viewp = *child_iter;
00726                         if (viewp->getRect().mBottom < 0)
00727                         {
00728                                 viewp->setVisible(FALSE);
00729                         }
00730                 }
00731         }
00732         
00733         LLContainerView::draw();
00734 
00735 }
00736 
00737 BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite)
00738 {
00739         llassert(imagep);
00740         
00741         LLTextureBar *barp;
00742         LLRect r;
00743 
00744         mNumTextureBars++;
00745 
00746         barp = new LLTextureBar("texture bar", r, this);
00747         barp->mImagep = imagep; 
00748         barp->mHilite = hilite;
00749 
00750         addChild(barp);
00751         mTextureBars.push_back(barp);
00752 
00753         return TRUE;
00754 }
00755 
00756 BOOL LLTextureView::handleMouseDown(S32 x, S32 y, MASK mask)
00757 {
00758         if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == (MASK_ALT|MASK_SHIFT))
00759         {
00760                 mPrintList = TRUE;
00761                 return TRUE;
00762         }
00763         if ((mask & (MASK_CONTROL|MASK_SHIFT|MASK_ALT)) == (MASK_CONTROL|MASK_SHIFT))
00764         {
00765                 LLAppViewer::getTextureFetch()->mDebugPause = !LLAppViewer::getTextureFetch()->mDebugPause;
00766                 return TRUE;
00767         }
00768         if (mask & MASK_SHIFT)
00769         {
00770                 mFreezeView = !mFreezeView;
00771                 return TRUE;
00772         }
00773         if (mask & MASK_CONTROL)
00774         {
00775                 mOrderFetch = !mOrderFetch;
00776                 return TRUE;
00777         }
00778         return LLView::handleMouseDown(x,y,mask);
00779 }
00780 
00781 BOOL LLTextureView::handleMouseUp(S32 x, S32 y, MASK mask)
00782 {
00783         return FALSE;
00784 }
00785 
00786 BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent)
00787 {
00788         return FALSE;
00789 }
00790 
00791 

Generated on Fri May 16 08:34:05 2008 for SecondLife by  doxygen 1.5.5