void LLMemoryView::draw() { std::string tdesc; S32 width = mRect.getWidth(); S32 height = mRect.getHeight(); LLGLSUIDefault gls_ui; LLGLSNoTexture gls_no_tex; gl_rect_2d(0, height, width, 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); #if MEM_TRACK_TYPE S32 left, top, right, bottom; S32 x, y; S32 margin = 10; S32 texth = (S32)LLFontGL::sMonospace->getLineHeight(); S32 xleft = margin; S32 ytop = height - margin; S32 labelwidth = 0; S32 maxmaxbytes = 1; // Make sure all timers are accounted for // Set 'MT_OTHER' to unaccounted ticks last frame { S32 display_memtypes[LLMemType::MTYPE_NUM_TYPES]; for (S32 i=0; i < LLMemType::MTYPE_NUM_TYPES; i++) { display_memtypes[i] = 0; } for (S32 i=0; i < MTV_DISPLAY_NUM; i++) { S32 tidx = mtv_display_table[i].memtype; display_memtypes[tidx]++; } LLMemType::sMemCount[LLMemType::MTYPE_OTHER] = 0; LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] = 0; for (S32 tidx = 0; tidx < LLMemType::MTYPE_NUM_TYPES; tidx++) { if (display_memtypes[tidx] == 0) { LLMemType::sMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMemCount[tidx]; LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMaxMemCount[tidx]; } } } // Labels { LLGLSTexture gls_texture; y = ytop; S32 peak = 0; for (S32 i=0; i<MTV_DISPLAY_NUM; i++) { x = xleft; int tidx = mtv_display_table[i].memtype; S32 bytes = LLMemType::sMemCount[tidx]; S32 maxbytes = LLMemType::sMaxMemCount[tidx]; maxmaxbytes = llmax(maxbytes, maxmaxbytes); peak += maxbytes; S32 mbytes = bytes >> 20; tdesc = llformat("%s [%4d MB]",mtv_display_table[i].desc,mbytes); LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); S32 textw = LLFontGL::sMonospace->getWidth(tdesc); if (textw > labelwidth) labelwidth = textw; } x = xleft; tdesc = llformat("Total Bytes: %d MB Overhead: %d KB", LLMemType::sTotalMem >> 20, LLMemType::sOverheadMem >> 10); LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); } // Bars y = ytop; labelwidth += 8; S32 barw = width - labelwidth - xleft - margin; for (S32 i=0; i<MTV_DISPLAY_NUM; i++) { x = xleft + labelwidth; int tidx = mtv_display_table[i].memtype; S32 bytes = LLMemType::sMemCount[tidx]; F32 frac = (F32)bytes / (F32)maxmaxbytes; S32 w = (S32)(frac * (F32)barw); left = x; right = x + w; top = y; bottom = y - texth; gl_rect_2d(left, top, right, bottom, *mtv_display_table[i].color); S32 maxbytes = LLMemType::sMaxMemCount[tidx]; F32 frac2 = (F32)maxbytes / (F32)maxmaxbytes; S32 w2 = (S32)(frac2 * (F32)barw); left = x + w + 1; right = x + w2; top = y; bottom = y - texth; LLColor4 tcolor = *mtv_display_table[i].color; tcolor.setAlpha(.5f); gl_rect_2d(left, top, right, bottom, tcolor); y -= (texth + 2); } #endif LLView::draw(); }
void LLTextureBar::draw() { if (!mImagep) { return; } LLColor4 color; if (mImagep->getID() == LLAppViewer::getTextureFetch()->mDebugID) { color = LLColor4::cyan2; } else if (mHilite) { S32 idx = llclamp(mHilite,1,3); if (idx==1) color = LLColor4::orange; else if (idx==2) color = LLColor4::yellow; else color = LLColor4::pink2; } else if (mImagep->mDontDiscard) { color = LLColor4::green4; } else if (mImagep->getBoostLevel()) { color = LLColor4::magenta; } else if (mImagep->getDecodePriority() == 0.0f) { color = LLColor4::grey; color[VALPHA] = .7f; } else { color = LLColor4::white; color[VALPHA] = .7f; } // We need to draw: // The texture UUID or name // The progress bar for the texture, highlighted if it's being download // Various numerical stats. std::string tex_str; S32 left, right; S32 top = 0; S32 bottom = top + 6; LLColor4 clr; LLGLSUIDefault gls_ui; // Name, pixel_area, requested pixel area, decode priority std::string uuid_str; mImagep->mID.toString(uuid_str); uuid_str = uuid_str.substr(0,7); if (mTextureView->mOrderFetch) { tex_str = llformat("%s %7.0f %d(%d) 0x%08x(%8.0f)", uuid_str.c_str(), mImagep->mMaxVirtualSize, mImagep->mDesiredDiscardLevel, mImagep->mRequestedDiscardLevel, mImagep->mFetchPriority, mImagep->getDecodePriority()); } else { tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x)", uuid_str.c_str(), mImagep->mMaxVirtualSize, mImagep->mDesiredDiscardLevel, mImagep->mRequestedDiscardLevel, mImagep->getDecodePriority(), mImagep->mFetchPriority); } LLFontGL::sMonospace->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); // State // Hack: mirrored from lltexturefetch.cpp struct { const std::string desc; LLColor4 color; } fetch_state_desc[] = { { "---", LLColor4::red }, // INVALID { "INI", LLColor4::white }, // INIT { "DSK", LLColor4::cyan }, // LOAD_FROM_TEXTURE_CACHE { "DSK", LLColor4::blue }, // CACHE_POST { "NET", LLColor4::green }, // LOAD_FROM_NETWORK { "SIM", LLColor4::green }, // LOAD_FROM_SIMULATOR { "URL", LLColor4::green2 },// LOAD_FROM_HTTP_GET_URL { "HTP", LLColor4::green }, // LOAD_FROM_HTTP_GET_DATA { "DEC", LLColor4::yellow },// DECODE_IMAGE { "DEC", LLColor4::yellow },// DECODE_IMAGE_UPDATE { "WRT", LLColor4::purple },// WRITE_TO_CACHE { "WRT", LLColor4::orange },// WAIT_ON_WRITE { "END", LLColor4::red }, // DONE #define LAST_STATE 12 { "CRE", LLColor4::magenta }, // LAST_STATE+1 { "FUL", LLColor4::green }, // LAST_STATE+2 { "BAD", LLColor4::red }, // LAST_STATE+3 { "MIS", LLColor4::red }, // LAST_STATE+4 { "---", LLColor4::white }, // LAST_STATE+5 }; const S32 fetch_state_desc_size = (S32)(sizeof(fetch_state_desc)/sizeof(fetch_state_desc[0])); S32 state = mImagep->mNeedsCreateTexture ? LAST_STATE+1 : mImagep->mFullyLoaded ? LAST_STATE+2 : mImagep->mMinDiscardLevel > 0 ? LAST_STATE+3 : mImagep->mIsMissingAsset ? LAST_STATE+4 : !mImagep->mIsFetching ? LAST_STATE+5 : mImagep->mFetchState; state = llclamp(state,0,fetch_state_desc_size-1); LLFontGL::sMonospace->renderUTF8(fetch_state_desc[state].desc, 0, title_x2, getRect().getHeight(), fetch_state_desc[state].color, LLFontGL::LEFT, LLFontGL::TOP); LLGLSNoTexture gls_no_texture; // Draw the progress bar. S32 bar_width = 100; S32 bar_left = 280; left = bar_left; right = left + bar_width; gGL.color4f(0.f, 0.f, 0.f, 0.75f); gl_rect_2d(left, top, right, bottom); F32 data_progress = mImagep->mDownloadProgress; if (data_progress > 0.0f) { // Downloaded bytes right = left + llfloor(data_progress * (F32)bar_width); if (right > left) { gGL.color4f(0.f, 0.f, 1.f, 0.75f); gl_rect_2d(left, top, right, bottom); } } S32 pip_width = 6; S32 pip_space = 14; S32 pip_x = title_x3 + pip_space/2; // Draw the packet pip F32 last_event = mImagep->mLastPacketTimer.getElapsedTimeF32(); if (last_event < 1.f) { clr = LLColor4::white; } else { last_event = mImagep->mRequestDeltaTime; if (last_event < 1.f) { clr = LLColor4::green; } else { last_event = mImagep->mFetchDeltaTime; if (last_event < 1.f) { clr = LLColor4::yellow; } } } if (last_event < 1.f) { clr.setAlpha(1.f - last_event); gGL.color4fv(clr.mV); gl_rect_2d(pip_x, top, pip_x + pip_width, bottom); } pip_x += pip_width + pip_space; // we don't want to show bind/resident pips for textures using the default texture if (mImagep->getHasGLTexture()) { // Draw the bound pip last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime; if (last_event < 1.f) { clr = mImagep->getMissed() ? LLColor4::red : LLColor4::magenta1; clr.setAlpha(1.f - last_event); gGL.color4fv(clr.mV); gl_rect_2d(pip_x, top, pip_x + pip_width, bottom); } } pip_x += pip_width + pip_space; { LLGLSUIDefault gls_ui; // draw the packet data // { // std::string num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); // LLFontGL::sMonospace->renderUTF8(num_str, 0, bar_left + 100, getRect().getHeight(), color, // LLFontGL::LEFT, LLFontGL::TOP); // } // draw the image size at the end { std::string num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), mImagep->getDiscardLevel(), mImagep->mTextureMemory); LLFontGL::sMonospace->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); } } }