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

Generated on Thu Jul 1 06:09:19 2010 for Second Life Viewer by  doxygen 1.4.7