diff options
Diffstat (limited to 'indra/newview/lltextureview.cpp')
-rw-r--r-- | indra/newview/lltextureview.cpp | 265 |
1 files changed, 187 insertions, 78 deletions
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 43913f3632..6a75e4b009 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -2,31 +2,25 @@ * @file lltextureview.cpp * @brief LLTextureView class implementation * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -54,12 +48,19 @@ #include "llviewertexture.h" #include "llviewertexturelist.h" #include "llvovolume.h" + +// For avatar texture view +#include "llvoavatarself.h" +#include "lltexlayer.h" + extern F32 texmem_lower_bound_scale; LLTextureView *gTextureView = NULL; LLTextureSizeView *gTextureSizeView = NULL; LLTextureSizeView *gTextureCategoryView = NULL; +#define HIGH_PRIORITY 100000000.f + //static std::set<LLViewerFetchedTexture*> LLTextureView::sDebugImages; @@ -375,6 +376,105 @@ LLRect LLTextureBar::getRequiredRect() //////////////////////////////////////////////////////////////////////////// +class LLAvatarTexBar : public LLView +{ +public: + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Mandatory<LLTextureView*> texture_view; + Params() + : texture_view("texture_view") + { + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + rect(LLRect(0,0,100,line_height * 4)); + } + }; + + LLAvatarTexBar(const Params& p) + : LLView(p), + mTextureView(p.texture_view) + {} + + virtual void draw(); + virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual LLRect getRequiredRect(); // Return the height of this object, given the set options. + +private: + LLTextureView* mTextureView; +}; + +void LLAvatarTexBar::draw() +{ + if (!gSavedSettings.getBOOL("DebugAvatarRezTime")) return; + + LLVOAvatarSelf* avatarp = gAgentAvatarp; + if (!avatarp) return; + + const S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + const S32 v_offset = 0; + const S32 l_offset = 3; + + //---------------------------------------------------------------------------- + LLGLSUIDefault gls_ui; + LLColor4 color; + + U32 line_num = 1; + for (LLVOAvatarDefines::LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().begin(); + baked_iter != LLVOAvatarDefines::LLVOAvatarDictionary::getInstance()->getBakedTextures().end(); + ++baked_iter) + { + const LLVOAvatarDefines::EBakedTextureIndex baked_index = baked_iter->first; + const LLTexLayerSet *layerset = avatarp->debugGetLayerSet(baked_index); + if (!layerset) continue; + const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite(); + if (!layerset_buffer) continue; + + LLColor4 text_color = LLColor4::white; + + if (layerset_buffer->uploadNeeded()) + { + text_color = LLColor4::red; + } + if (layerset_buffer->uploadInProgress()) + { + text_color = LLColor4::magenta; + } + std::string text = layerset_buffer->dumpTextureInfo(); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, l_offset, v_offset + line_height*line_num, + text_color, LLFontGL::LEFT, LLFontGL::TOP); //, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); + line_num++; + } + const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureUploadTimeout"); + const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + + LLColor4 header_color(1.f, 1.f, 1.f, 0.9f); + + const std::string texture_timeout_str = texture_timeout ? llformat("%d",texture_timeout) : "Disabled"; + const std::string override_tex_discard_level_str = override_tex_discard_level ? llformat("%d",override_tex_discard_level) : "Disabled"; + std::string header_text = llformat("[ Timeout('AvatarBakedTextureUploadTimeout'):%s ] [ LOD_Override('TextureDiscardLevel'):%s ]", texture_timeout_str.c_str(), override_tex_discard_level_str.c_str()); + LLFontGL::getFontMonospace()->renderUTF8(header_text, 0, l_offset, v_offset + line_height*line_num, + header_color, LLFontGL::LEFT, LLFontGL::TOP); //, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); + line_num++; + std::string section_text = "Avatar Textures Information:"; + LLFontGL::getFontMonospace()->renderUTF8(section_text, 0, 0, v_offset + line_height*line_num, + header_color, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::BOLD, LLFontGL::DROP_SHADOW_SOFT); +} + +BOOL LLAvatarTexBar::handleMouseDown(S32 x, S32 y, MASK mask) +{ + return FALSE; +} + +LLRect LLAvatarTexBar::getRequiredRect() +{ + LLRect rect; + rect.mTop = 100; + if (!gSavedSettings.getBOOL("DebugAvatarRezTime")) rect.mTop = 0; + return rect; +} + +//////////////////////////////////////////////////////////////////////////// + class LLGLTexMemBar : public LLView { public: @@ -412,13 +512,17 @@ void LLGLTexMemBar::draw() F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); - S32 v_offset = (S32)((texture_bar_height + 2.5f) * mTextureView->mNumTextureBars + 2.5f); + S32 v_offset = (S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; - std::string text; + std::string text = ""; + + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", total_mem, max_total_mem, @@ -560,7 +664,8 @@ BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask) LLRect LLGLTexMemBar::getRequiredRect() { LLRect rect; - rect.mTop = 8; + //rect.mTop = 50; + rect.mTop = 0; return rect; } @@ -640,6 +745,7 @@ LLTextureView::LLTextureView(const LLTextureView::Params& p) setDisplayChildren(TRUE); mGLTexMemBar = 0; + mAvatarTexBar = 0; } LLTextureView::~LLTextureView() @@ -647,6 +753,9 @@ LLTextureView::~LLTextureView() // Children all cleaned up by default view destructor. delete mGLTexMemBar; mGLTexMemBar = 0; + + delete mAvatarTexBar; + mAvatarTexBar = 0; } typedef std::pair<F32,LLViewerFetchedTexture*> decode_pair_t; @@ -684,6 +793,13 @@ void LLTextureView::draw() mGLTexMemBar = 0; } + if (mAvatarTexBar) + { + removeChild(mAvatarTexBar); + mAvatarTexBar->die(); + mAvatarTexBar = 0; + } + typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t; display_list_t display_image_list; @@ -708,7 +824,7 @@ void LLTextureView::draw() { S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory() : 0 ; llinfos << imagep->getID() - << "\t" << tex_mem + << "\t" << tex_mem << "\t" << imagep->getBoostLevel() << "\t" << imagep->getDecodePriority() << "\t" << imagep->getWidth() @@ -723,19 +839,6 @@ void LLTextureView::draw() ++debug_count; // for breakpoints } -#if 0 - if (imagep->getDontDiscard()) - { - continue; - } - - if (imagep->isMissingAsset()) - { - continue; - } -#endif - -#define HIGH_PRIORITY 100000000.f F32 pri; if (mOrderFetch) { @@ -754,59 +857,55 @@ void LLTextureView::draw() if (!mOrderFetch) { -#if 1 - if (pri < HIGH_PRIORITY && LLSelectMgr::getInstance()) - { - struct f : public LLSelectedTEFunctor + if (pri < HIGH_PRIORITY && LLSelectMgr::getInstance()) { - LLViewerFetchedTexture* mImage; - f(LLViewerFetchedTexture* image) : mImage(image) {} - virtual bool apply(LLViewerObject* object, S32 te) + struct f : public LLSelectedTEFunctor { - return (mImage == object->getTEImage(te)); + LLViewerFetchedTexture* mImage; + f(LLViewerFetchedTexture* image) : mImage(image) {} + virtual bool apply(LLViewerObject* object, S32 te) + { + return (mImage == object->getTEImage(te)); + } + } func(imagep); + const bool firstonly = true; + bool match = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, firstonly); + if (match) + { + pri += 3*HIGH_PRIORITY; } - } func(imagep); - const bool firstonly = true; - bool match = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, firstonly); - if (match) - { - pri += 3*HIGH_PRIORITY; } - } -#endif -#if 1 - if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) - { - LLSelectNode* hover_node = LLSelectMgr::instance().getHoverNode(); - if (hover_node) + + if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) { - LLViewerObject *objectp = hover_node->getObject(); - if (objectp) + LLSelectNode* hover_node = LLSelectMgr::instance().getHoverNode(); + if (hover_node) { - S32 tex_count = objectp->getNumTEs(); - for (S32 i = 0; i < tex_count; i++) + LLViewerObject *objectp = hover_node->getObject(); + if (objectp) { - if (imagep == objectp->getTEImage(i)) + S32 tex_count = objectp->getNumTEs(); + for (S32 i = 0; i < tex_count; i++) { - pri += 2*HIGH_PRIORITY; - break; + if (imagep == objectp->getTEImage(i)) + { + pri += 2*HIGH_PRIORITY; + break; + } } } } } - } -#endif -#if 1 - if (pri > 0.f && pri < HIGH_PRIORITY) - { - if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || - imagep->mFetchDeltaTime < 0.25f) + + if (pri > 0.f && pri < HIGH_PRIORITY) { - pri += 1*HIGH_PRIORITY; + if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || + imagep->mFetchDeltaTime < 0.25f) + { + pri += 1*HIGH_PRIORITY; + } } } -#endif - } if (pri > 0.0f) { @@ -847,11 +946,21 @@ void LLTextureView::draw() sortChildren(LLTextureBar::sort()); LLGLTexMemBar::Params tmbp; + LLRect tmbr; tmbp.name("gl texmem bar"); + tmbp.rect(tmbr); tmbp.texture_view(this); mGLTexMemBar = LLUICtrlFactory::create<LLGLTexMemBar>(tmbp); - addChild(mGLTexMemBar); - + addChildInBack(mGLTexMemBar); + + LLAvatarTexBar::Params atbp; + LLRect atbr; + atbp.name("gl avatartex bar"); + atbp.texture_view(this); + atbp.rect(atbr); + mAvatarTexBar = LLUICtrlFactory::create<LLAvatarTexBar>(atbp); + addChild(mAvatarTexBar); + reshape(getRect().getWidth(), getRect().getHeight(), TRUE); /* |