From 5ba68ed7639da163be0566f7f79882d3b597f752 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 17 Apr 2012 18:44:41 -0500 Subject: [PATCH] Updated buy land floater a bit. Fixed a persistent shutdown crash. Updated texture Texture Console. --- indra/newview/llappviewer.cpp | 6 - indra/newview/llfloaterbuyland.cpp | 317 +++++++++++++---------------- indra/newview/llfloaterbuyland.h | 3 +- indra/newview/lltextureview.cpp | 217 +++++++++++++++----- indra/newview/lltextureview.h | 42 ++-- indra/newview/llvoavatar.cpp | 4 +- 6 files changed, 333 insertions(+), 256 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 10871544b..a91538406 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1376,12 +1376,6 @@ extern void cleanup_pose_stand(void); bool LLAppViewer::cleanup() { - - //HACK: the selectmgr may hold a ref to gAgentAvatarp, which will defer the actual - // destruction until LLSelectMgr::cleanupGlobals() is called AFTER the UI has been destroyed. - // This presents issue, as ~LLVOAvatarSelf spawns notifications if DebugAvatarRezTime is true, which will - // crash if the UI has been destroyed before then. - LLSelectMgr::getInstance()->remove(gAgentAvatarp, SELECT_ALL_TES, false); //ditch LLVOAvatarSelf instance gAgentAvatarp = NULL; cleanup_pose_stand(); diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 4926453e0..852b439fe 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -75,12 +75,29 @@ const F64 CURRENCY_ESTIMATE_FREQUENCY = 0.5; // esimate is fetched from the server class LLFloaterBuyLandUI -: public LLFloater +: public LLFloater, public LLSingleton { -private: +public: LLFloaterBuyLandUI(); virtual ~LLFloaterBuyLandUI(); + + /*virtual*/ void onClose(bool app_quitting); + // Left padding for maturity rating icon. + static const S32 ICON_PAD = 2; + +private: + class SelectionObserver : public LLParcelObserver + { + public: + SelectionObserver(LLFloaterBuyLandUI* floater) : mFloater(floater) {} + virtual void changed(); + private: + LLFloaterBuyLandUI* mFloater; + }; + +private: + SelectionObserver mParcelSelectionObserver; LLViewerRegion* mRegion; LLParcelSelectionHandle mParcel; bool mIsClaim; @@ -146,11 +163,7 @@ private: LLViewerParcelMgr::ParcelBuyInfo* mParcelBuyInfo; - static LLFloaterBuyLandUI* sInstance; - public: - static LLFloaterBuyLandUI* soleInstance(bool createIfNeeded); - void setForGroup(bool is_for_group); void setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel); @@ -158,10 +171,10 @@ public: void updateParcelInfo(); void updateCovenantInfo(); static void onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data); - void updateCovenantText(const std::string& string, const LLUUID &asset_id); - void updateEstateName(const std::string& name); - void updateLastModified(const std::string& text); - void updateEstateOwnerName(const std::string& name); + void updateFloaterCovenantText(const std::string& string, const LLUUID &asset_id); + void updateFloaterEstateName(const std::string& name); + void updateFloaterLastModified(const std::string& text); + void updateFloaterEstateOwnerName(const std::string& name); void updateWebSiteInfo(); void finishWebSiteInfo(); @@ -170,10 +183,14 @@ public: void sendBuyLand(); void updateNames(); + // Name cache callback + void updateName(const LLUUID& id, + const std::string& name, + bool is_group); void refreshUI(); - void startTransaction(TransactionType type, LLXMLRPCValue params); + void startTransaction(TransactionType type, const LLXMLRPCValue& params); bool checkTransaction(); void tellUserError(const std::string& message, const std::string& uri); @@ -183,31 +200,16 @@ public: void startBuyPreConfirm(); void startBuyPostConfirm(const std::string& password); - static void onClickBuy(void* data); - static void onClickCancel(void* data); - static void onClickErrorWeb(void* data); + void onClickBuy(); + void onClickCancel(); + void onClickErrorWeb(); virtual void draw(); virtual BOOL canClose(); - virtual void onClose(bool app_quitting); - /*virtual*/ void setMinimized(BOOL b); - -private: - class SelectionObserver : public LLParcelObserver - { - public: - virtual void changed(); - }; -}; -static void cacheNameUpdateRefreshesBuyLand(const LLUUID& id, const std::string& full_name, bool is_group) -{ - LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(false); - if (ui) - { - ui->updateNames(); - } -} + void onVisibilityChange ( const LLSD& new_visibility ); + +}; // static void LLFloaterBuyLand::buyLand( @@ -219,102 +221,55 @@ void LLFloaterBuyLand::buyLand( return; } - LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(true); - ui->setForGroup(is_for_group); - ui->setParcel(region, parcel); - ui->open(); /*Flawfinder: ignore*/ + LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::getInstance(); + if(ui) + { + ui->setForGroup(is_for_group); + ui->setParcel(region, parcel); + ui->open(); /*Flawfinder: ignore*/ + } } // static void LLFloaterBuyLand::updateCovenantText(const std::string& string, const LLUUID &asset_id) { - LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE); + LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::instanceExists() ? LLFloaterBuyLandUI::getInstance() : NULL; if (floater) { - floater->updateCovenantText(string, asset_id); + floater->updateFloaterCovenantText(string, asset_id); } } // static void LLFloaterBuyLand::updateEstateName(const std::string& name) { - LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE); + LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::instanceExists() ? LLFloaterBuyLandUI::getInstance() : NULL; if (floater) { - floater->updateEstateName(name); + floater->updateFloaterEstateName(name); } } // static void LLFloaterBuyLand::updateLastModified(const std::string& text) { - LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE); + LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::instanceExists() ? LLFloaterBuyLandUI::getInstance() : NULL; if (floater) { - floater->updateLastModified(text); + floater->updateFloaterLastModified(text); } } // static void LLFloaterBuyLand::updateEstateOwnerName(const std::string& name) { - LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE); + LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::instanceExists() ? LLFloaterBuyLandUI::getInstance() : NULL; if (floater) { - floater->updateEstateOwnerName(name); + floater->updateFloaterEstateOwnerName(name); } } -// static -BOOL LLFloaterBuyLand::isOpen() -{ - LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE); - if (floater) - { - return floater->getVisible(); - } - return FALSE; -} - -// static -LLFloaterBuyLandUI* LLFloaterBuyLandUI::sInstance = NULL; - -// static -LLFloaterBuyLandUI* LLFloaterBuyLandUI::soleInstance(bool createIfNeeded) -{ -#if !LL_RELEASE_FOR_DOWNLOAD - if (createIfNeeded) - { - delete sInstance; - sInstance = NULL; - } -#endif - if (!sInstance && createIfNeeded) - { - sInstance = new LLFloaterBuyLandUI(); - - LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_buy_land.xml"); - sInstance->center(); - - static bool observingCacheName = false; - if (!observingCacheName) - { - gCacheName->addObserver(cacheNameUpdateRefreshesBuyLand); - observingCacheName = true; - } - - static SelectionObserver* parcelSelectionObserver = NULL; - if (!parcelSelectionObserver) - { - parcelSelectionObserver = new SelectionObserver; - LLViewerParcelMgr::getInstance()->addObserver(parcelSelectionObserver); - } - } - - return sInstance; -} - - #if LL_WINDOWS // passing 'this' during construction generates a warning. The callee // only uses the pointer to hold a reference to 'this' which is @@ -324,39 +279,45 @@ LLFloaterBuyLandUI* LLFloaterBuyLandUI::soleInstance(bool createIfNeeded) #endif LLFloaterBuyLandUI::LLFloaterBuyLandUI() : LLFloater(std::string("Buy Land")), + mParcelSelectionObserver(this), mParcel(0), mBought(false), mParcelValid(false), mSiteValid(false), mChildren(*this), mCurrency(*this), mTransaction(0), mParcelBuyInfo(0) { + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_buy_land.xml"); + LLViewerParcelMgr::getInstance()->addObserver(&mParcelSelectionObserver); } LLFloaterBuyLandUI::~LLFloaterBuyLandUI() { + LLViewerParcelMgr::getInstance()->removeObserver(&mParcelSelectionObserver); LLViewerParcelMgr::getInstance()->deleteParcelBuy(&mParcelBuyInfo); - delete mTransaction; - if (sInstance == this) - { - sInstance = NULL; - } + delete mTransaction; +} + +// virtual +void LLFloaterBuyLandUI::onClose(bool app_quitting) +{ + // This object holds onto observer, transactions, and parcel state. + // Despite being single_instance, destroy it to call destructors and clean + // everything up. + setVisible(FALSE); + destroy(); } void LLFloaterBuyLandUI::SelectionObserver::changed() { - LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(false); - if (ui) + if (LLViewerParcelMgr::getInstance()->selectionEmpty()) { - if (LLViewerParcelMgr::getInstance()->selectionEmpty()) - { - ui->close(); - } - else { - ui->setParcel( - LLViewerParcelMgr::getInstance()->getSelectionRegion(), - LLViewerParcelMgr::getInstance()->getParcelSelection()); - } + mFloater->close(); + } + else + { + mFloater->setParcel(LLViewerParcelMgr::getInstance()->getSelectionRegion(), + LLViewerParcelMgr::getInstance()->getParcelSelection()); } } @@ -531,16 +492,22 @@ void LLFloaterBuyLandUI::updateCovenantInfo() LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); if(!region) return; + U8 sim_access = region->getSimAccess(); + std::string rating = LLViewerRegion::accessToString(sim_access); + LLTextBox* region_name = getChild("region_name_text"); if (region_name) { - region_name->setText(region->getName()); + std::string region_name_txt = region->getName() + " ("+rating +")"; + region_name->setText(region_name_txt); + region_name->setToolTip(region_name->getText()); } LLTextBox* region_type = getChild("region_type_text"); if (region_type) { region_type->setText(region->getLocalizedSimProductName()); + region_type->setToolTip(region->getLocalizedSimProductName()); } LLTextBox* resellable_clause = getChild("resellable_clause"); @@ -574,8 +541,7 @@ void LLFloaterBuyLandUI::updateCovenantInfo() { check->set(false); check->setEnabled(true); - check->setCallbackUserData(this); - check->setCommitCallback(onChangeAgreeCovenant); + check->setCommitCallback(boost::bind(&LLFloaterBuyLandUI::onChangeAgreeCovenant,_1,(void*)this)); } LLTextBox* box = getChild("covenant_text"); @@ -603,51 +569,46 @@ void LLFloaterBuyLandUI::onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data) } } -void LLFloaterBuyLandUI::updateCovenantText(const std::string &string, const LLUUID& asset_id) +void LLFloaterBuyLandUI::updateFloaterCovenantText(const std::string &string, const LLUUID& asset_id) { LLViewerTextEditor* editor = getChild("covenant_editor"); - if (editor) + editor->setHandleEditKeysDirectly(FALSE); + editor->setText(string); + + LLCheckBoxCtrl* check = getChild("agree_covenant"); + LLTextBox* box = getChild("covenant_text"); + if (asset_id.isNull()) { - editor->setHandleEditKeysDirectly(FALSE); - editor->setText(string); + check->set(true); + check->setEnabled(false); + refreshUI(); - LLCheckBoxCtrl* check = getChild("agree_covenant"); - LLTextBox* box = getChild("covenant_text"); - if(check && box) - { - if (asset_id.isNull()) - { - check->set(true); - check->setEnabled(false); - refreshUI(); + // remove the line stating that you must agree + box->setVisible(FALSE); + } + else + { + check->setEnabled(true); - // remove the line stating that you must agree - box->setVisible(FALSE); - } - else - { - check->setEnabled(true); - - // remove the line stating that you must agree - box->setVisible(TRUE); - } - } + // remove the line stating that you must agree + box->setVisible(TRUE); } } -void LLFloaterBuyLandUI::updateEstateName(const std::string& name) +void LLFloaterBuyLandUI::updateFloaterEstateName(const std::string& name) { LLTextBox* box = getChild("estate_name_text"); - if (box) box->setText(name); + box->setText(name); + box->setToolTip(name); } -void LLFloaterBuyLandUI::updateLastModified(const std::string& text) +void LLFloaterBuyLandUI::updateFloaterLastModified(const std::string& text) { LLTextBox* editor = getChild("covenant_timestamp_text"); if (editor) editor->setText(text); } -void LLFloaterBuyLandUI::updateEstateOwnerName(const std::string& name) +void LLFloaterBuyLandUI::updateFloaterEstateOwnerName(const std::string& name) { LLTextBox* box = getChild("estate_owner_text"); if (box) box->setText(name); @@ -743,7 +704,7 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password) return; } - BOOL remove_contribution = childGetValue("remove_contribution").asBoolean(); + BOOL remove_contribution = getChild("remove_contribution")->getValue().asBoolean(); mParcelBuyInfo = LLViewerParcelMgr::getInstance()->setupParcelBuy(gAgent.getID(), gAgent.getSessionID(), gAgent.getGroupID(), mIsForGroup, mIsClaim, remove_contribution); @@ -835,17 +796,34 @@ void LLFloaterBuyLandUI::updateNames() } else if (parcelp->getIsGroupOwned()) { - gCacheName->getGroupName(parcelp->getGroupID(), mParcelSellerName); + mParcelSellerName = "(Loading...)"; + gCacheName->getGroup(parcelp->getGroupID(), + boost::bind(&LLFloaterBuyLandUI::updateName, this, + _1, _2, _3)); } else { - gCacheName->getFullName(parcelp->getOwnerID(), mParcelSellerName); + mParcelSellerName = "(Loading...)"; + gCacheName->get(parcelp->getOwnerID(), false, + boost::bind(&LLFloaterBuyLandUI::updateName, this, + _1, _2, _3)); } } +void LLFloaterBuyLandUI::updateName(const LLUUID& id, + const std::string& name, + bool is_group) +{ + LLParcel* parcelp = mParcel->getParcel(); + if (parcelp + && (is_group ? parcelp->getGroupID() : parcelp->getOwnerID()) == id) + { + // request is current + mParcelSellerName = name; + } +} -void LLFloaterBuyLandUI::startTransaction(TransactionType type, - LLXMLRPCValue params) +void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCValue& params) { delete mTransaction; mTransaction = NULL; @@ -926,11 +904,14 @@ void LLFloaterBuyLandUI::tellUserError( // virtual BOOL LLFloaterBuyLandUI::postBuild() { + setVisibleCallback(boost::bind(&LLFloaterBuyLandUI::onVisibilityChange, this, _2)); mCurrency.prepare(); - childSetAction("buy_btn", onClickBuy, this); - childSetAction("cancel_btn", onClickCancel, this); - childSetAction("error_web", onClickErrorWeb, this); + getChild("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickBuy, this)); + getChild("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickCancel, this)); + getChild("error_web")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickErrorWeb, this)); + + center(); return TRUE; } @@ -996,24 +977,14 @@ BOOL LLFloaterBuyLandUI::canClose() return can_close; } -// virtual -void LLFloaterBuyLandUI::setMinimized(BOOL minimize) +void LLFloaterBuyLandUI::onVisibilityChange ( const LLSD& new_visibility ) { - bool restored = (isMinimized() && !minimize); - LLFloater::setMinimized(minimize); - if (restored) + if (new_visibility.asBoolean()) { refreshUI(); } } -void LLFloaterBuyLandUI::onClose(bool app_quitting) -{ - LLFloater::onClose(app_quitting); - destroy(); -} - - void LLFloaterBuyLandUI::refreshUI() { // section zero: title area @@ -1027,14 +998,14 @@ void LLFloaterBuyLandUI::refreshUI() if (mParcelValid) { - childSetText("info_parcel", mParcelLocation); + getChild("info_parcel")->setValue(mParcelLocation); LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelActualArea); string_args["[AMOUNT2]"] = llformat("%d", mParcelSupportedObjects); string_args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - childSetText("info_size", getString("meters_supports_object", string_args)); + getChild("info_size")->setValue(getString("meters_supports_object", string_args)); F32 cost_per_sqm = 0.0f; if (mParcelActualArea > 0) @@ -1372,26 +1343,20 @@ void LLFloaterBuyLandUI::startBuyPostConfirm(const std::string& password) } -// static -void LLFloaterBuyLandUI::onClickBuy(void* data) +void LLFloaterBuyLandUI::onClickBuy() { - LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data; - self->startBuyPreConfirm(); + startBuyPreConfirm(); } -// static -void LLFloaterBuyLandUI::onClickCancel(void* data) +void LLFloaterBuyLandUI::onClickCancel() { - LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data; - self->close(); + close(); } -// static -void LLFloaterBuyLandUI::onClickErrorWeb(void* data) +void LLFloaterBuyLandUI::onClickErrorWeb() { - LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data; - LLWeb::loadURLExternal(self->mCannotBuyURI); - self->close(); + LLWeb::loadURLExternal(mCannotBuyURI); + close(); } diff --git a/indra/newview/llfloaterbuyland.h b/indra/newview/llfloaterbuyland.h index 82e59a0bc..0d90130a0 100644 --- a/indra/newview/llfloaterbuyland.h +++ b/indra/newview/llfloaterbuyland.h @@ -33,8 +33,8 @@ #ifndef LL_LLFLOATERBUYLAND_H #define LL_LLFLOATERBUYLAND_H +class LLFloater; class LLViewerRegion; -class LLViewerTextEditor; class LLParcelSelection; class LLFloaterBuyLand @@ -47,7 +47,6 @@ public: static void updateEstateName(const std::string& name); static void updateLastModified(const std::string& text); static void updateEstateOwnerName(const std::string& name); - static BOOL isOpen(); }; #endif diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index ab55f6988..a524cd098 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$ */ @@ -44,16 +38,21 @@ #include "llrender.h" #include "llappviewer.h" -#include "llhoverview.h" #include "llselectmgr.h" #include "lltexlayer.h" #include "lltexturecache.h" #include "lltexturefetch.h" #include "llviewercontrol.h" #include "llviewerobject.h" +#include "llviewertexture.h" #include "llviewertexturelist.h" #include "llvovolume.h" #include "llviewerstats.h" + +// For avatar texture view +#include "llvoavatarself.h" +#include "lltexlayer.h" + extern F32 texmem_lower_bound_scale; LLTextureView *gTextureView = NULL; @@ -61,6 +60,7 @@ LLTextureSizeView *gTextureSizeView = NULL; LLTextureSizeView *gTextureCategoryView = NULL; #define HIGH_PRIORITY 100000000.f + //static std::set LLTextureView::sDebugImages; @@ -381,6 +381,98 @@ LLRect LLTextureBar::getRequiredRect() //////////////////////////////////////////////////////////////////////////// +class LLAvatarTexBar : public LLView +{ +public: + + LLAvatarTexBar(const std::string& name, LLTextureView* texview) + : LLView(name, FALSE), + mTextureView(texview) + { + S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); + setRect(LLRect(0,0,100,line_height * 4)); + } + + 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: @@ -410,38 +502,39 @@ 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 = 0; F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024); -// U32 cache_max_entries = LLAppViewer::getTextureCache()->getMaxEntries(); - + U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; - std::string text; - + std::string text = ""; + S32 global_raw_memory; { global_raw_memory = *AIAccess(LLImageRaw::sGlobalRawMemory); } - text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB", + text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d", total_mem, max_total_mem, bound_mem, max_bound_mem, + LLRenderTarget::sBytesAllocated/(1024*1024), global_raw_memory >> 20, discard_bias, - cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded); + cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded, total_http_requests); //, cache_entries, cache_max_entries - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*3, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, text_color, LLFontGL::LEFT, LLFontGL::TOP); //---------------------------------------------------------------------------- #if 0 S32 bar_left = 400; S32 bar_width = 200; - S32 top = line_height*3 - 2; + S32 top = line_height*3 - 2 + v_offset; S32 bottom = top - 6; S32 left = bar_left; S32 right = left + bar_width; @@ -469,7 +562,7 @@ void LLGLTexMemBar::draw() color = (total_mem < llfloor(max_total_mem * texmem_lower_bound_scale)) ? LLColor4::green : (total_mem < max_total_mem) ? LLColor4::yellow : LLColor4::red; color[VALPHA] = .75f; - gGL.diffuseColor4f(color.mV); + gGL.diffuseColor4fv(color.mV); gl_rect_2d(left, top, right, bottom); // red/yellow/green @@ -492,7 +585,7 @@ void LLGLTexMemBar::draw() color = (bound_mem < llfloor(max_bound_mem * texmem_lower_bound_scale)) ? LLColor4::green : (bound_mem < max_bound_mem) ? LLColor4::yellow : LLColor4::red; color[VALPHA] = .75f; - gGL.diffuseColor4f(color.mV); + gGL.diffuseColor4fv(color.mV); gl_rect_2d(left, top, right, bottom); #else @@ -512,7 +605,7 @@ void LLGLTexMemBar::draw() LLAppViewer::getImageDecodeThread()->getPending(), gTextureList.mCreateTextureList.size()); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*2, text_color, LLFontGL::LEFT, LLFontGL::TOP); left += LLFontGL::getFontMonospace()->getWidth(text); @@ -521,40 +614,40 @@ void LLGLTexMemBar::draw() color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; text = llformat("BW:%.0f/%.0f",bandwidth, max_bandwidth); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, line_height*2, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*2, color, LLFontGL::LEFT, LLFontGL::TOP); S32 dx1 = 0; if (LLAppViewer::getTextureFetch()->mDebugPause) { - LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(std::string("!"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mFreezeView) { - LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(std::string("*"), 0, title_x1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mOrderFetch) { - LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string1b, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } else { - LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string1a, 0, title_x1+dx1, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } - LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string2, 0, title_x2, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); - LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string3, 0, title_x3, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); - LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, line_height, + LLFontGL::getFontMonospace()->renderUTF8(title_string4, 0, title_x4, v_offset + line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); } @@ -566,7 +659,7 @@ BOOL LLGLTexMemBar::handleMouseDown(S32 x, S32 y, MASK mask) LLRect LLGLTexMemBar::getRequiredRect() { LLRect rect; - rect.mTop = 8; + rect.mTop = 50; return rect; } @@ -646,6 +739,7 @@ LLTextureView::LLTextureView(const std::string& name, const LLRect& rect) setDisplayChildren(TRUE); mGLTexMemBar = 0; + mAvatarTexBar = 0; } LLTextureView::~LLTextureView() @@ -653,6 +747,9 @@ LLTextureView::~LLTextureView() // Children all cleaned up by default view destructor. delete mGLTexMemBar; mGLTexMemBar = 0; + + delete mAvatarTexBar; + mAvatarTexBar = 0; } typedef std::pair decode_pair_t; @@ -664,6 +761,15 @@ struct compare_decode_pair } }; +struct KillView +{ + void operator()(LLView* viewp) + { + viewp->getParent()->removeChild(viewp); + viewp->die(); + } +}; + void LLTextureView::draw() { if (!mFreezeView) @@ -671,12 +777,23 @@ void LLTextureView::draw() // LLViewerObject *objectp; // S32 te; - for_each(mTextureBars.begin(), mTextureBars.end(), DeletePointer()); + for_each(mTextureBars.begin(), mTextureBars.end(), KillView()); mTextureBars.clear(); - - delete mGLTexMemBar; - mGLTexMemBar = 0; - + + if (mGLTexMemBar) + { + removeChild(mGLTexMemBar); + mGLTexMemBar->die(); + mGLTexMemBar = 0; + } + + if (mAvatarTexBar) + { + removeChild(mAvatarTexBar); + mAvatarTexBar->die(); + mAvatarTexBar = 0; + } + typedef std::multiset display_list_t; display_list_t display_image_list; @@ -813,6 +930,7 @@ void LLTextureView::draw() static S32 max_count = 50; S32 count = 0; + mNumTextureBars = 0 ; for (display_list_t::iterator iter = display_image_list.begin(); iter != display_image_list.end(); iter++) { @@ -840,6 +958,9 @@ void LLTextureView::draw() mGLTexMemBar = new LLGLTexMemBar("gl texmem bar", this); addChild(mGLTexMemBar); + mAvatarTexBar = new LLAvatarTexBar("gl avatartex bar", this); + addChild(mAvatarTexBar); + reshape(getRect().getWidth(), getRect().getHeight(), TRUE); /* @@ -920,7 +1041,7 @@ BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent) } //----------------------------------------------------------------- -LLTextureSizeView::LLTextureSizeView(const std::string& name) : LLView(name, FALSE) +LLTextureSizeView::LLTextureSizeView(const std::string& name) : LLContainerView(name, LLRect()) { setVisible(FALSE) ; diff --git a/indra/newview/lltextureview.h b/indra/newview/lltextureview.h index 221e42b7a..9555e26ca 100644 --- a/indra/newview/lltextureview.h +++ b/indra/newview/lltextureview.h @@ -2,31 +2,25 @@ * @file lltextureview.h * @brief LLTextureView class header file * - * $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$ */ @@ -38,11 +32,13 @@ class LLViewerFetchedTexture; class LLTextureBar; class LLGLTexMemBar; +class LLAvatarTexBar; class LLTextureView : public LLContainerView { friend class LLTextureBar; friend class LLGLTexMemBar; + friend class LLAvatarTexBar; public: LLTextureView(const std::string& name, const LLRect& rect); ~LLTextureView(); @@ -71,13 +67,13 @@ private: U32 mNumTextureBars; LLGLTexMemBar* mGLTexMemBar; - + LLAvatarTexBar* mAvatarTexBar; public: static std::set sDebugImages; }; class LLGLTexSizeBar; -class LLTextureSizeView : public LLView +class LLTextureSizeView : public LLContainerView { public: LLTextureSizeView(const std::string& name); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e10ae247a..bcbd473e5 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -824,7 +824,9 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, //------------------------------------------------------------------------ LLVOAvatar::~LLVOAvatar() { - if (gSavedSettings.getBOOL("DebugAvatarRezTime")) + //App teardown is a mess. Avatar destruction can be unpredictable due to all potential refs to the smartptr. + //Cannot guarantee that LLNotificationUtil will be usable during shutdown chain. + if (!LLApp::isQuitting() && gSavedSettings.getBOOL("DebugAvatarRezTime")) { if (!mFullyLoaded) {