diff options
Diffstat (limited to 'indra')
169 files changed, 1099 insertions, 6290 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 5117224ddb..23a5dc24c0 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -98,7 +98,7 @@ set(llcommon_SOURCE_FILES llstringtable.cpp llsys.cpp llthread.cpp - llthreadlocalstorage.cpp + llthreadlocalstorage.cpp llthreadsafequeue.cpp lltimer.cpp lltrace.cpp @@ -107,9 +107,6 @@ set(llcommon_SOURCE_FILES lluri.cpp lluuid.cpp llworkerthread.cpp - metaclass.cpp - metaproperty.cpp - reflective.cpp timing.cpp u64.cpp ) @@ -119,7 +116,6 @@ set(llcommon_HEADER_FILES bitpack.h ctype_workaround.h - doublelinkedlist.h fix_macros.h imageids.h indra_constants.h @@ -133,7 +129,6 @@ set(llcommon_HEADER_FILES llapp.h llapr.h llassettype.h - llassoclist.h llavatarconstants.h llbase32.h llbase64.h @@ -147,18 +142,13 @@ set(llcommon_HEADER_FILES llcriticaldamp.h llcursortypes.h lldarray.h - lldarrayptr.h lldate.h lldefs.h lldependencies.h - lldeleteutils.h lldepthstack.h lldictionary.h - lldlinked.h lldoubledispatch.h - lldqueueptr.h llendianswizzle.h - llenum.h llerror.h llerrorcontrol.h llerrorlegacy.h @@ -182,18 +172,15 @@ set(llcommon_HEADER_FILES llhash.h llheartbeat.h llhttpstatuscodes.h - llindexedqueue.h llinitparam.h llinstancetracker.h llkeythrottle.h - lllazy.h llleap.h llleaplistener.h lllistenerwrapper.h lllinkedqueue.h llliveappconfig.h lllivefile.h - lllocalidhashmap.h lllog.h lllslconstants.h llmap.h @@ -228,8 +215,6 @@ set(llcommon_HEADER_FILES llsecondlifeurls.h llsimplehash.h llsingleton.h - llsortedvector.h - llstack.h llstacktrace.h llstatenums.h llstl.h @@ -247,7 +232,6 @@ set(llcommon_HEADER_FILES lltracerecording.h lltracethreadrecorder.h lltreeiterators.h - lltypeinfolookup.h llunit.h lluri.h lluuid.h @@ -257,12 +241,6 @@ set(llcommon_HEADER_FILES llwin32headerslean.h llworkerthread.h ll_template_cast.h - metaclass.h - metaclasst.h - metaproperty.h - metapropertyt.h - reflective.h - reflectivet.h roles_constants.h stdenums.h stdtypes.h @@ -334,7 +312,6 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(llerror "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llframetimer "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llinstancetracker "" "${test_libs}") - LL_ADD_INTEGRATION_TEST(lllazy "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llprocessor "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llrand "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llsdserialize "" "${test_libs}") @@ -343,7 +320,6 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lluri "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llunits "" "${test_libs}") - LL_ADD_INTEGRATION_TEST(reflection "" "${test_libs}") LL_ADD_INTEGRATION_TEST(stringize "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llprocess "" "${test_libs}") diff --git a/indra/llcommon/doublelinkedlist.h b/indra/llcommon/doublelinkedlist.h deleted file mode 100644 index 0aeaa69df3..0000000000 --- a/indra/llcommon/doublelinkedlist.h +++ /dev/null @@ -1,1397 +0,0 @@ -/** - * @file doublelinkedlist.h - * @brief Provides a standard doubly linked list for fun and profit. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_DOUBLELINKEDLIST_H -#define LL_DOUBLELINKEDLIST_H - -#include "llerror.h" -#include "llrand.h" - -// node that actually contains the data -template <class DATA_TYPE> class LLDoubleLinkedNode -{ -public: - DATA_TYPE *mDatap; - LLDoubleLinkedNode *mNextp; - LLDoubleLinkedNode *mPrevp; - - -public: - // assign the mDatap pointer - LLDoubleLinkedNode(DATA_TYPE *data); - - // destructor does not, by default, destroy associated data - // however, the mDatap must be NULL to ensure that we aren't causing memory leaks - ~LLDoubleLinkedNode(); - - // delete associated data and NULL out pointer - void deleteData(); - - // remove associated data and NULL out pointer - void removeData(); -}; - - -const U32 LLDOUBLE_LINKED_LIST_STATE_STACK_DEPTH = 4; - -template <class DATA_TYPE> class LLDoubleLinkedList -{ -private: - LLDoubleLinkedNode<DATA_TYPE> mHead; // head node - LLDoubleLinkedNode<DATA_TYPE> mTail; // tail node - LLDoubleLinkedNode<DATA_TYPE> *mQueuep; // The node in the batter's box - LLDoubleLinkedNode<DATA_TYPE> *mCurrentp; // The node we're talking about - - // The state stack allows nested exploration of the LLDoubleLinkedList - // but should be used with great care - LLDoubleLinkedNode<DATA_TYPE> *mQueuepStack[LLDOUBLE_LINKED_LIST_STATE_STACK_DEPTH]; - LLDoubleLinkedNode<DATA_TYPE> *mCurrentpStack[LLDOUBLE_LINKED_LIST_STATE_STACK_DEPTH]; - U32 mStateStackDepth; - U32 mCount; - - // mInsertBefore is a pointer to a user-set function that returns - // TRUE if "first" should be located before "second" - // NOTE: mInsertBefore() should never return TRUE when ("first" == "second") - // or never-ending loops can occur - BOOL (*mInsertBefore)(DATA_TYPE *first, DATA_TYPE *second); - -public: - LLDoubleLinkedList(); - - // destructor destroys list and nodes, but not data in nodes - ~LLDoubleLinkedList(); - - // put data into a node and stick it at the front of the list - // set mCurrentp to mQueuep - void addData(DATA_TYPE *data); - - // put data into a node and stick it at the end of the list - // set mCurrentp to mQueuep - void addDataAtEnd(DATA_TYPE *data); - - S32 getLength() const; - // search the list starting at mHead.mNextp and remove the link with mDatap == data - // set mCurrentp to mQueuep - // return TRUE if found, FALSE if not found - BOOL removeData(const DATA_TYPE *data); - - // search the list starting at mHead.mNextp and delete the link with mDatap == data - // set mCurrentp to mQueuep - // return TRUE if found, FALSE if not found - BOOL deleteData(DATA_TYPE *data); - - // remove all nodes from the list and delete the associated data - void deleteAllData(); - - // remove all nodes from the list but do not delete data - void removeAllNodes(); - - BOOL isEmpty(); - - // check to see if data is in list - // set mCurrentp and mQueuep to the target of search if found, otherwise set mCurrentp to mQueuep - // return TRUE if found, FALSE if not found - BOOL checkData(const DATA_TYPE *data); - - // NOTE: This next two funtions are only included here - // for those too familiar with the LLLinkedList template class. - // They are depreciated. resetList() is unecessary while - // getCurrentData() is identical to getNextData() and has - // a misleading name. - // - // The recommended way to loop through a list is as follows: - // - // datap = list.getFirstData(); - // while (datap) - // { - // /* do stuff */ - // datap = list.getNextData(); - // } - - // place mQueuep on mHead node - void resetList(); - - // return the data currently pointed to, - // set mCurrentp to that node and bump mQueuep down the list - // NOTE: this function is identical to getNextData() - DATA_TYPE *getCurrentData(); - - - // reset the list and return the data currently pointed to, - // set mCurrentp to that node and bump mQueuep down the list - DATA_TYPE *getFirstData(); - - - // reset the list and return the data at position n, set mCurentp - // to that node and bump mQueuep down the list - // Note: n=0 will behave like getFirstData() - DATA_TYPE *getNthData(U32 n); - - // reset the list and return the last data in it, - // set mCurrentp to that node and bump mQueuep up the list - DATA_TYPE *getLastData(); - - // return data in mQueuep, - // set mCurrentp mQueuep and bump mQueuep down the list - DATA_TYPE *getNextData(); - - // return the data in mQueuep, - // set mCurrentp to mQueuep and bump mQueuep up the list - DATA_TYPE *getPreviousData(); - - // remove the Node at mCurrentp - // set mCurrentp to mQueuep - void removeCurrentData(); - - // delete the Node at mCurrentp - // set mCurrentp to mQueuep - void deleteCurrentData(); - - // remove the Node at mCurrentp and insert it into newlist - // set mCurrentp to mQueuep - void moveCurrentData(LLDoubleLinkedList<DATA_TYPE> *newlist); - - // insert the node in front of mCurrentp - // set mCurrentp to mQueuep - void insertNode(LLDoubleLinkedNode<DATA_TYPE> *node); - - // insert the data in front of mCurrentp - // set mCurrentp to mQueuep - void insertData(DATA_TYPE *data); - - // if mCurrentp has a previous node then : - // * swaps mCurrentp with its previous - // * set mCurrentp to mQueuep - // (convenient for forward bubble-sort) - // otherwise does nothing - void swapCurrentWithPrevious(); - - // if mCurrentp has a next node then : - // * swaps mCurrentp with its next - // * set mCurrentp to mQueuep - // (convenient for backwards bubble-sort) - // otherwise does nothing - void swapCurrentWithNext(); - - // move mCurrentp to the front of the list - // set mCurrentp to mQueuep - void moveCurrentToFront(); - - // move mCurrentp to the end of the list - // set mCurrentp to mQueuep - void moveCurrentToEnd(); - - // set mInsertBefore - void setInsertBefore(BOOL (*insert_before)(DATA_TYPE *first, DATA_TYPE *second)); - - // add data in front of first node for which mInsertBefore(datap, node->mDatap) returns TRUE - // set mCurrentp to mQueuep - BOOL addDataSorted(DATA_TYPE *datap); - - // sort the list using bubble-sort - // Yes, this is a different name than the same function in LLLinkedList. - // When it comes time for a name consolidation hopefully this one will win. - BOOL bubbleSort(); - - // does a single bubble sort pass on the list - BOOL lazyBubbleSort(); - - // returns TRUE if state successfully pushed (state stack not full) - BOOL pushState(); - - // returns TRUE if state successfully popped (state stack not empty) - BOOL popState(); - - // empties the state stack - void clearStateStack(); - - // randomly move the the links in the list for debug or (Discordian) purposes - // sets mCurrentp and mQueuep to top of list - void scramble(); - -private: - // add node to beginning of list - // set mCurrentp to mQueuep - void addNode(LLDoubleLinkedNode<DATA_TYPE> *node); - - // add node to end of list - // set mCurrentp to mQueuep - void addNodeAtEnd(LLDoubleLinkedNode<DATA_TYPE> *node); -}; - -//#endif - -//////////////////////////////////////////////////////////////////////////////////////////// - -// doublelinkedlist.cpp -// LLDoubleLinkedList template class implementation file. -// Provides a standard doubly linked list for fun and profit. -// -// Copyright 2001, Linden Research, Inc. - -//#include "llerror.h" -//#include "doublelinkedlist.h" - -////////////////////////////////////////////////////////////////////////////////////////// -// LLDoubleLinkedNode -////////////////////////////////////////////////////////////////////////////////////////// - - -// assign the mDatap pointer -template <class DATA_TYPE> -LLDoubleLinkedNode<DATA_TYPE>::LLDoubleLinkedNode(DATA_TYPE *data) : - mDatap(data), mNextp(NULL), mPrevp(NULL) -{ -} - - -// destructor does not, by default, destroy associated data -// however, the mDatap must be NULL to ensure that we aren't causing memory leaks -template <class DATA_TYPE> -LLDoubleLinkedNode<DATA_TYPE>::~LLDoubleLinkedNode() -{ - if (mDatap) - { - llerror("Attempting to call LLDoubleLinkedNode destructor with a non-null mDatap!", 1); - } -} - - -// delete associated data and NULL out pointer -template <class DATA_TYPE> -void LLDoubleLinkedNode<DATA_TYPE>::deleteData() -{ - delete mDatap; - mDatap = NULL; -} - - -template <class DATA_TYPE> -void LLDoubleLinkedNode<DATA_TYPE>::removeData() -{ - mDatap = NULL; -} - - -////////////////////////////////////////////////////////////////////////////////////// -// LLDoubleLinkedList -////////////////////////////////////////////////////////////////////////////////////// - -// <------- up ------- -// -// mCurrentp -// mQueuep | -// | | -// | | -// .------. .------. .------. .------. -// | |---->| |---->| |----->| |-----> NULL -// NULL <-----| |<----| |<----| |<-----| | -// _'------' '------' '------' '------:_ -// .------. /| | | |\ .------. -// NULL <-----|mHead |/ | mQueuep \|mTail |-----> NULL -// | | mCurrentp | | -// '------' '------' -// -------- down ---------> - -template <class DATA_TYPE> -LLDoubleLinkedList<DATA_TYPE>::LLDoubleLinkedList() -: mHead(NULL), mTail(NULL), mQueuep(NULL) -{ - mCurrentp = mHead.mNextp; - mQueuep = mHead.mNextp; - mStateStackDepth = 0; - mCount = 0; - mInsertBefore = NULL; -} - - -// destructor destroys list and nodes, but not data in nodes -template <class DATA_TYPE> -LLDoubleLinkedList<DATA_TYPE>::~LLDoubleLinkedList() -{ - removeAllNodes(); -} - - -// put data into a node and stick it at the front of the list -// doesn't change mCurrentp nor mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::addData(DATA_TYPE *data) -{ - // don't allow NULL to be passed to addData - if (!data) - { - llerror("NULL pointer passed to LLDoubleLinkedList::addData()", 0); - } - - // make the new node - LLDoubleLinkedNode<DATA_TYPE> *temp = new LLDoubleLinkedNode<DATA_TYPE> (data); - - // add the node to the front of the list - temp->mPrevp = NULL; - temp->mNextp = mHead.mNextp; - mHead.mNextp = temp; - - // if there's something in the list, fix its back pointer - if (temp->mNextp) - { - temp->mNextp->mPrevp = temp; - } - // otherwise, fix the tail of the list - else - { - mTail.mPrevp = temp; - } - - mCount++; -} - - -// put data into a node and stick it at the end of the list -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::addDataAtEnd(DATA_TYPE *data) -{ - // don't allow NULL to be passed to addData - if (!data) - { - llerror("NULL pointer passed to LLDoubleLinkedList::addData()", 0); - } - - // make the new node - LLDoubleLinkedNode<DATA_TYPE> *nodep = new LLDoubleLinkedNode<DATA_TYPE>(data); - - addNodeAtEnd(nodep); - mCount++; -} - - -// search the list starting at mHead.mNextp and remove the link with mDatap == data -// set mCurrentp to mQueuep, or NULL if mQueuep points to node with mDatap == data -// return TRUE if found, FALSE if not found -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::removeData(const DATA_TYPE *data) -{ - BOOL b_found = FALSE; - // don't allow NULL to be passed to addData - if (!data) - { - llerror("NULL pointer passed to LLDoubleLinkedList::removeData()", 0); - } - - mCurrentp = mHead.mNextp; - - while (mCurrentp) - { - if (mCurrentp->mDatap == data) - { - b_found = TRUE; - - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // remove the node - mCurrentp->removeData(); - delete mCurrentp; - mCount--; - break; - } - mCurrentp = mCurrentp->mNextp; - } - - // reset the list back to where it was - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - - return b_found; -} - - -// search the list starting at mHead.mNextp and delete the link with mDatap == data -// set mCurrentp to mQueuep, or NULL if mQueuep points to node with mDatap == data -// return TRUE if found, FALSE if not found -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::deleteData(DATA_TYPE *data) -{ - BOOL b_found = FALSE; - // don't allow NULL to be passed to addData - if (!data) - { - llerror("NULL pointer passed to LLDoubleLinkedList::deleteData()", 0); - } - - mCurrentp = mHead.mNextp; - - while (mCurrentp) - { - if (mCurrentp->mDatap == data) - { - b_found = TRUE; - - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // remove the node - mCurrentp->deleteData(); - delete mCurrentp; - mCount--; - break; - } - mCurrentp = mCurrentp->mNextp; - } - - // reset the list back to where it was - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - - return b_found; -} - - -// remove all nodes from the list and delete the associated data -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::deleteAllData() -{ - mCurrentp = mHead.mNextp; - - while (mCurrentp) - { - mQueuep = mCurrentp->mNextp; - mCurrentp->deleteData(); - delete mCurrentp; - mCurrentp = mQueuep; - } - - // reset mHead and mQueuep - mHead.mNextp = NULL; - mTail.mPrevp = NULL; - mCurrentp = mHead.mNextp; - mQueuep = mHead.mNextp; - mStateStackDepth = 0; - mCount = 0; -} - - -// remove all nodes from the list but do not delete associated data -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::removeAllNodes() -{ - mCurrentp = mHead.mNextp; - - while (mCurrentp) - { - mQueuep = mCurrentp->mNextp; - mCurrentp->removeData(); - delete mCurrentp; - mCurrentp = mQueuep; - } - - // reset mHead and mCurrentp - mHead.mNextp = NULL; - mTail.mPrevp = NULL; - mCurrentp = mHead.mNextp; - mQueuep = mHead.mNextp; - mStateStackDepth = 0; - mCount = 0; -} - -template <class DATA_TYPE> -S32 LLDoubleLinkedList<DATA_TYPE>::getLength() const -{ -// U32 length = 0; -// for (LLDoubleLinkedNode<DATA_TYPE>* temp = mHead.mNextp; temp != NULL; temp = temp->mNextp) -// { -// length++; -// } - return mCount; -} - -// check to see if data is in list -// set mCurrentp and mQueuep to the target of search if found, otherwise set mCurrentp to mQueuep -// return TRUE if found, FALSE if not found -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::checkData(const DATA_TYPE *data) -{ - mCurrentp = mHead.mNextp; - - while (mCurrentp) - { - if (mCurrentp->mDatap == data) - { - mQueuep = mCurrentp; - return TRUE; - } - mCurrentp = mCurrentp->mNextp; - } - - mCurrentp = mQueuep; - return FALSE; -} - -// NOTE: This next two funtions are only included here -// for those too familiar with the LLLinkedList template class. -// They are depreciated. resetList() is unecessary while -// getCurrentData() is identical to getNextData() and has -// a misleading name. -// -// The recommended way to loop through a list is as follows: -// -// datap = list.getFirstData(); -// while (datap) -// { -// /* do stuff */ -// datap = list.getNextData(); -// } - - // place mCurrentp and mQueuep on first node - template <class DATA_TYPE> - void LLDoubleLinkedList<DATA_TYPE>::resetList() - { - mCurrentp = mHead.mNextp; - mQueuep = mHead.mNextp; - mStateStackDepth = 0; - } - - - // return the data currently pointed to, - // set mCurrentp to that node and bump mQueuep down the list - template <class DATA_TYPE> - DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getCurrentData() - { - if (mQueuep) - { - mCurrentp = mQueuep; - mQueuep = mQueuep->mNextp; - return mCurrentp->mDatap; - } - else - { - return NULL; - } - } - - -// reset the list and return the data currently pointed to, -// set mCurrentp to that node and bump mQueuep down the list -template <class DATA_TYPE> -DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getFirstData() -{ - mQueuep = mHead.mNextp; - mCurrentp = mQueuep; - if (mQueuep) - { - mQueuep = mQueuep->mNextp; - return mCurrentp->mDatap; - } - else - { - return NULL; - } -} - - -// reset the list and return the data at position n, set mCurentp -// to that node and bump mQueuep down the list -// Note: n=0 will behave like getFirstData() -template <class DATA_TYPE> -DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getNthData(U32 n) -{ - mCurrentp = mHead.mNextp; - - if (mCurrentp) - { - for (U32 i=0; i<n; i++) - { - mCurrentp = mCurrentp->mNextp; - if (!mCurrentp) - { - break; - } - } - } - - if (mCurrentp) - { - // bump mQueuep down the list - mQueuep = mCurrentp->mNextp; - return mCurrentp->mDatap; - } - else - { - mQueuep = NULL; - return NULL; - } -} - - -// reset the list and return the last data in it, -// set mCurrentp to that node and bump mQueuep up the list -template <class DATA_TYPE> -DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getLastData() -{ - mQueuep = mTail.mPrevp; - mCurrentp = mQueuep; - if (mQueuep) - { - mQueuep = mQueuep->mPrevp; - return mCurrentp->mDatap; - } - else - { - return NULL; - } -} - - -// return the data in mQueuep, -// set mCurrentp to mQueuep and bump mQueuep down the list -template <class DATA_TYPE> -DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getNextData() -{ - if (mQueuep) - { - mCurrentp = mQueuep; - mQueuep = mQueuep->mNextp; - return mCurrentp->mDatap; - } - else - { - return NULL; - } -} - - -// return the data in mQueuep, -// set mCurrentp to mQueuep and bump mQueuep up the list -template <class DATA_TYPE> -DATA_TYPE* LLDoubleLinkedList<DATA_TYPE>::getPreviousData() -{ - if (mQueuep) - { - mCurrentp = mQueuep; - mQueuep = mQueuep->mPrevp; - return mCurrentp->mDatap; - } - else - { - return NULL; - } -} - - -// remove the Node at mCurrentp -// set mCurrentp to mQueuep, or NULL if (mCurrentp == mQueuep) -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::removeCurrentData() -{ - if (mCurrentp) - { - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // otherwise we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // otherwise we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // remove the node - mCurrentp->removeData(); - delete mCurrentp; - mCount--; - - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - } -} - - -// delete the Node at mCurrentp -// set mCurrentp to mQueuep, or NULL if (mCurrentp == mQueuep) -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::deleteCurrentData() -{ - if (mCurrentp) - { - // remove the node - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // otherwise we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // otherwise we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // remove the LLDoubleLinkedNode - mCurrentp->deleteData(); - delete mCurrentp; - mCount--; - - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - } -} - - -// remove the Node at mCurrentp and insert it into newlist -// set mCurrentp to mQueuep, or NULL if (mCurrentp == mQueuep) -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::moveCurrentData(LLDoubleLinkedList<DATA_TYPE> *newlist) -{ - if (mCurrentp) - { - // remove the node - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // otherwise we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // otherwise we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // move the node to the new list - newlist->addNode(mCurrentp); - - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - } -} - - -// Inserts the node previous to mCurrentp -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::insertNode(LLDoubleLinkedNode<DATA_TYPE> *nodep) -{ - // don't allow pointer to NULL to be passed - if (!nodep) - { - llerror("NULL pointer passed to LLDoubleLinkedList::insertNode()", 0); - } - if (!nodep->mDatap) - { - llerror("NULL data pointer passed to LLDoubleLinkedList::insertNode()", 0); - } - - if (mCurrentp) - { - if (mCurrentp->mPrevp) - { - nodep->mPrevp = mCurrentp->mPrevp; - nodep->mNextp = mCurrentp; - mCurrentp->mPrevp->mNextp = nodep; - mCurrentp->mPrevp = nodep; - } - else // at beginning of list - { - nodep->mPrevp = NULL; - nodep->mNextp = mCurrentp; - mHead.mNextp = nodep; - mCurrentp->mPrevp = nodep; - } - mCurrentp = mQueuep; - } - else // add to front of list - { - addNode(nodep); - } -} - - -// insert the data in front of mCurrentp -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::insertData(DATA_TYPE *data) -{ - if (!data) - { - llerror("NULL data pointer passed to LLDoubleLinkedList::insertNode()", 0); - } - LLDoubleLinkedNode<DATA_TYPE> *node = new LLDoubleLinkedNode<DATA_TYPE>(data); - insertNode(node); - mCount++; -} - - -// if mCurrentp has a previous node then : -// * swaps mCurrentp with its previous -// * set mCurrentp to mQueuep -// otherwise does nothing -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::swapCurrentWithPrevious() -{ - if (mCurrentp) - { - if (mCurrentp->mPrevp) - { - // Pull mCurrentp out of list - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // mCurrentp was at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // Fix mCurrentp's pointers - mCurrentp->mNextp = mCurrentp->mPrevp; - mCurrentp->mPrevp = mCurrentp->mNextp->mPrevp; - mCurrentp->mNextp->mPrevp = mCurrentp; - - if (mCurrentp->mPrevp) - { - // Fix the backward pointer of mCurrentp's new previous - mCurrentp->mPrevp->mNextp = mCurrentp; - } - else // mCurrentp is now at beginning of list - { - mHead.mNextp = mCurrentp; - } - - // Set the list back to the way it was - mCurrentp = mQueuep; - } - } -} - - -// if mCurrentp has a next node then : -// * swaps mCurrentp with its next -// * set mCurrentp to mQueuep -// otherwise does nothing -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::swapCurrentWithNext() -{ - if (mCurrentp) - { - if (mCurrentp->mNextp) - { - // Pull mCurrentp out of list - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // mCurrentp was at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // Fix mCurrentp's pointers - mCurrentp->mPrevp = mCurrentp->mNextp; - mCurrentp->mNextp = mCurrentp->mPrevp->mNextp; - mCurrentp->mPrevp->mNextp = mCurrentp; - - if (mCurrentp->mNextp) - { - // Fix the back pointer of mCurrentp's new next - mCurrentp->mNextp->mPrevp = mCurrentp; - } - else // mCurrentp is now at end of list - { - mTail.mPrevp = mCurrentp; - } - - // Set the list back to the way it was - mCurrentp = mQueuep; - } - } -} - -// move mCurrentp to the front of the list -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::moveCurrentToFront() -{ - if (mCurrentp) - { - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // otherwise we are at beginning of list - { - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - return; - } - - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // otherwise we are at end of list - { - mTail.mPrevp = mCurrentp->mPrevp; - } - - // add mCurrentp to beginning of list - mCurrentp->mNextp = mHead.mNextp; - mHead.mNextp->mPrevp = mCurrentp; // mHead.mNextp MUST be valid, - // or the list had only one node - // and we would have returned already - mCurrentp->mPrevp = NULL; - mHead.mNextp = mCurrentp; - - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - } - -} - -// move mCurrentp to the end of the list -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::moveCurrentToEnd() -{ - if (mCurrentp) - { - // if there is a next one, fix it - if (mCurrentp->mNextp) - { - mCurrentp->mNextp->mPrevp = mCurrentp->mPrevp; - } - else // otherwise we are at end of list and we're done - { - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - return; - } - - // if there is a previous one, fix it - if (mCurrentp->mPrevp) - { - mCurrentp->mPrevp->mNextp = mCurrentp->mNextp; - } - else // otherwise we are at beginning of list - { - mHead.mNextp = mCurrentp->mNextp; - } - - // add mCurrentp to end of list - mCurrentp->mPrevp = mTail.mPrevp; - mTail.mPrevp->mNextp = mCurrentp; // mTail.mPrevp MUST be valid, - // or the list had only one node - // and we would have returned already - mCurrentp->mNextp = NULL; - mTail.mPrevp = mCurrentp; - - // check for redundant pointing - if (mCurrentp == mQueuep) - { - mCurrentp = mQueuep = NULL; - } - else - { - mCurrentp = mQueuep; - } - } -} - - -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::setInsertBefore(BOOL (*insert_before)(DATA_TYPE *first, DATA_TYPE *second) ) -{ - mInsertBefore = insert_before; -} - - -// add data in front of the first node for which mInsertBefore(datap, node->mDatap) returns TRUE -// set mCurrentp to mQueuep -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::addDataSorted(DATA_TYPE *datap) -{ - // don't allow NULL to be passed to addData() - if (!datap) - { - llerror("NULL pointer passed to LLDoubleLinkedList::addDataSorted()", 0); - } - - // has mInsertBefore not been set? - if (!mInsertBefore) - { - addData(datap); - return FALSE; - } - - // is the list empty? - if (!mHead.mNextp) - { - addData(datap); - return TRUE; - } - - // Note: this step has been added so that the behavior of LLDoubleLinkedList - // is as rigorous as the LLLinkedList class about adding duplicate nodes. - // Duplicate nodes can cause a problem when sorting if mInsertBefore(foo, foo) - // returns TRUE. However, if mInsertBefore(foo, foo) returns FALSE, then there - // shouldn't be any reason to exclude duplicate nodes (as we do here). - if (checkData(datap)) - { - return FALSE; - } - - mCurrentp = mHead.mNextp; - while (mCurrentp) - { - // check to see if datap is already in the list - if (datap == mCurrentp->mDatap) - { - return FALSE; - } - else if (mInsertBefore(datap, mCurrentp->mDatap)) - { - insertData(datap); - return TRUE; - } - mCurrentp = mCurrentp->mNextp; - } - - addDataAtEnd(datap); - return TRUE; -} - - -// bubble-sort until sorted and return TRUE if anything was sorted -// leaves mQueuep pointing at last node that was swapped with its mNextp -// -// NOTE: if you find this function looping for really long times, then you -// probably need to check your implementation of mInsertBefore(a,b) and make -// sure it does not return TRUE when (a == b)! -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::bubbleSort() -{ - BOOL b_swapped = FALSE; - U32 count = 0; - while (lazyBubbleSort()) - { - b_swapped = TRUE; - if (count++ > 0x7FFFFFFF) - { - llwarning("LLDoubleLinkedList::bubbleSort() : too many passes...", 1); - llwarning(" make sure the mInsertBefore(a, b) does not return TRUE for a == b", 1); - break; - } - } - return b_swapped; -} - - -// do a single bubble-sort pass and return TRUE if anything was sorted -// leaves mQueuep pointing at last node that was swapped with its mNextp -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::lazyBubbleSort() -{ - // has mInsertBefore been set? - if (!mInsertBefore) - { - return FALSE; - } - - // is list empty? - mCurrentp = mHead.mNextp; - if (!mCurrentp) - { - return FALSE; - } - - BOOL b_swapped = FALSE; - - // the sort will exit after 0x7FFFFFFF nodes or the end of the list, whichever is first - S32 length = 0x7FFFFFFF; - S32 count = 0; - - while (mCurrentp && mCurrentp->mNextp && count<length) - { - if (mInsertBefore(mCurrentp->mNextp->mDatap, mCurrentp->mDatap)) - { - b_swapped = TRUE; - mQueuep = mCurrentp; - swapCurrentWithNext(); // sets mCurrentp to mQueuep - } - count++; - mCurrentp = mCurrentp->mNextp; - } - - return b_swapped; -} - - -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::pushState() -{ - if (mStateStackDepth < LLDOUBLE_LINKED_LIST_STATE_STACK_DEPTH) - { - *(mQueuepStack + mStateStackDepth) = mQueuep; - *(mCurrentpStack + mStateStackDepth) = mCurrentp; - mStateStackDepth++; - return TRUE; - } - return FALSE; -} - - -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::popState() -{ - if (mStateStackDepth > 0) - { - mStateStackDepth--; - mQueuep = *(mQueuepStack + mStateStackDepth); - mCurrentp = *(mCurrentpStack + mStateStackDepth); - return TRUE; - } - return FALSE; -} - - -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::clearStateStack() -{ - mStateStackDepth = 0; -} - -////////////////////////////////////////////////////////////////////////////////////////// -// private members -////////////////////////////////////////////////////////////////////////////////////////// - -// add node to beginning of list -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::addNode(LLDoubleLinkedNode<DATA_TYPE> *nodep) -{ - // add the node to the front of the list - nodep->mPrevp = NULL; - nodep->mNextp = mHead.mNextp; - mHead.mNextp = nodep; - - // if there's something in the list, fix its back pointer - if (nodep->mNextp) - { - nodep->mNextp->mPrevp = nodep; - } - else // otherwise fix the tail node - { - mTail.mPrevp = nodep; - } - - mCurrentp = mQueuep; -} - - -// add node to end of list -// set mCurrentp to mQueuep -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::addNodeAtEnd(LLDoubleLinkedNode<DATA_TYPE> *node) -{ - // add the node to the end of the list - node->mNextp = NULL; - node->mPrevp = mTail.mPrevp; - mTail.mPrevp = node; - - // if there's something in the list, fix its back pointer - if (node->mPrevp) - { - node->mPrevp->mNextp = node; - } - else // otherwise fix the head node - { - mHead.mNextp = node; - } - - mCurrentp = mQueuep; -} - - -// randomly move nodes in the list for DEBUG (or Discordian) purposes -// sets mCurrentp and mQueuep to top of list -template <class DATA_TYPE> -void LLDoubleLinkedList<DATA_TYPE>::scramble() -{ - S32 random_number; - DATA_TYPE *datap = getFirstData(); - while(datap) - { - random_number = ll_rand(5); - - if (0 == random_number) - { - removeCurrentData(); - addData(datap); - } - else if (1 == random_number) - { - removeCurrentData(); - addDataAtEnd(datap); - } - else if (2 == random_number) - { - swapCurrentWithPrevious(); - } - else if (3 == random_number) - { - swapCurrentWithNext(); - } - datap = getNextData(); - } - mQueuep = mHead.mNextp; - mCurrentp = mQueuep; -} - -template <class DATA_TYPE> -BOOL LLDoubleLinkedList<DATA_TYPE>::isEmpty() -{ - return (mCount == 0); -} - - -#endif diff --git a/indra/llcommon/llassoclist.h b/indra/llcommon/llassoclist.h deleted file mode 100644 index 2950504155..0000000000 --- a/indra/llcommon/llassoclist.h +++ /dev/null @@ -1,296 +0,0 @@ -/** - * @file llassoclist.h - * @brief LLAssocList class header file - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLASSOCLIST_H -#define LL_LLASSOCLIST_H - -//------------------------------------------------------------------------ -// LLAssocList is an associative list container class. -// -// The implementation is a single linked list. -// Both index and value objects are stored by value (not reference). -// If pointer values are specified for index and/or value, this -// container does NOT assume ownership of the referenced objects, -// and does NOT delete() them on removal or destruction of the container. -// -// Note that operations are generally not optimized, and may of them -// are O(n) complexity. -//------------------------------------------------------------------------ - -#include <iostream> - -template<class INDEX_TYPE, class VALUE_TYPE> -class LLAssocList -{ -private: - // internal list node type - class Node - { - public: - Node(const INDEX_TYPE &index, const VALUE_TYPE &value, Node *next) - { - mIndex = index; - mValue = value; - mNext = next; - } - ~Node() { } - INDEX_TYPE mIndex; - VALUE_TYPE mValue; - Node *mNext; - }; - - // head of the linked list - Node *mHead; - -public: - // Constructor - LLAssocList() - { - mHead = NULL; - } - - // Destructor - ~LLAssocList() - { - removeAll(); - } - - // Returns TRUE if list is empty. - BOOL isEmpty() - { - return (mHead == NULL); - } - - // Returns the number of items in the list. - U32 length() - { - U32 count = 0; - for ( Node *node = mHead; - node; - node = node->mNext ) - { - count++; - } - return count; - } - - // Removes item with the specified index. - BOOL remove( const INDEX_TYPE &index ) - { - if (!mHead) - return FALSE; - - if (mHead->mIndex == index) - { - Node *node = mHead; - mHead = mHead->mNext; - delete node; - return TRUE; - } - - for ( Node *prev = mHead; - prev->mNext; - prev = prev->mNext ) - { - if (prev->mNext->mIndex == index) - { - Node *node = prev->mNext; - prev->mNext = prev->mNext->mNext; - delete node; - return TRUE; - } - } - return FALSE; - } - - // Removes all items from the list. - void removeAll() - { - while ( mHead ) - { - Node *node = mHead; - mHead = mHead->mNext; - delete node; - } - } - - // Adds a new item to the head of the list, - // removing any existing item with same index. - void addToHead( const INDEX_TYPE &index, const VALUE_TYPE &value ) - { - remove(index); - Node *node = new Node(index, value, mHead); - mHead = node; - } - - // Adds a new item to the end of the list, - // removing any existing item with the same index. - void addToTail( const INDEX_TYPE &index, const VALUE_TYPE &value ) - { - remove(index); - Node *node = new Node(index, value, NULL); - if (!mHead) - { - mHead = node; - return; - } - for ( Node *prev=mHead; - prev; - prev=prev->mNext ) - { - if (!prev->mNext) - { - prev->mNext=node; - return; - } - } - } - - // Sets the value of a specified index. - // If index does not exist, a new value will be added only if - // 'addIfNotFound' is set to TRUE. - // Returns TRUE if successful. - BOOL setValue( const INDEX_TYPE &index, const VALUE_TYPE &value, BOOL addIfNotFound=FALSE ) - { - VALUE_TYPE *valueP = getValue(index); - if (valueP) - { - *valueP = value; - return TRUE; - } - if (!addIfNotFound) - return FALSE; - addToTail(index, value); - return TRUE; - } - - // Sets the ith value in the list. - // A new value will NOT be addded, if the ith value does not exist. - // Returns TRUE if successful. - BOOL setValueAt( U32 i, const VALUE_TYPE &value ) - { - VALUE_TYPE *valueP = getValueAt(i); - if (valueP) - { - *valueP = value; - return TRUE; - } - return FALSE; - } - - // Returns a pointer to the value for the specified index, - // or NULL if no item found. - VALUE_TYPE *getValue( const INDEX_TYPE &index ) - { - for ( Node *node = mHead; - node; - node = node->mNext ) - { - if (node->mIndex == index) - return &node->mValue; - } - return NULL; - } - - // Returns a pointer to the ith value in the list, or - // NULL if i is not valid. - VALUE_TYPE *getValueAt( U32 i ) - { - U32 count = 0; - for ( Node *node = mHead; - node; - node = node->mNext ) - { - if (count == i) - return &node->mValue; - count++; - } - return NULL; - } - - // Returns a pointer to the index for the specified index, - // or NULL if no item found. - INDEX_TYPE *getIndex( const INDEX_TYPE &index ) - { - for ( Node *node = mHead; - node; - node = node->mNext ) - { - if (node->mIndex == index) - return &node->mIndex; - } - return NULL; - } - - // Returns a pointer to the ith index in the list, or - // NULL if i is not valid. - INDEX_TYPE *getIndexAt( U32 i ) - { - U32 count = 0; - for ( Node *node = mHead; - node; - node = node->mNext ) - { - if (count == i) - return &node->mIndex; - count++; - } - return NULL; - } - - // Returns a pointer to the value for the specified index, - // or NULL if no item found. - VALUE_TYPE *operator[](const INDEX_TYPE &index) - { - return getValue(index); - } - - // Returns a pointer to the ith value in the list, or - // NULL if i is not valid. - VALUE_TYPE *operator[](U32 i) - { - return getValueAt(i); - } - - // Prints the list contents to the specified stream. - friend std::ostream &operator<<( std::ostream &os, LLAssocList &map ) - { - os << "{"; - for ( Node *node = map.mHead; - node; - node = node->mNext ) - { - os << "<" << node->mIndex << ", " << node->mValue << ">"; - if (node->mNext) - os << ", "; - } - os << "}"; - - return os; - } -}; - -#endif // LL_LLASSOCLIST_H diff --git a/indra/llcommon/lldarrayptr.h b/indra/llcommon/lldarrayptr.h deleted file mode 100644 index c9a0b204d1..0000000000 --- a/indra/llcommon/lldarrayptr.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file lldarrayptr.h - * @brief Wrapped std::vector for backward compatibility. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ -#ifndef LL_LLDARRAYPTR_H -#define LL_LLDARRAYPTR_H - -#include "lldarray.h" - -template <class Type, int BlockSize = 32> -class LLDynamicArrayPtr : public LLDynamicArray<Type, BlockSize> -{ -}; - -#endif // LL_LLDARRAYPTR_H diff --git a/indra/llcommon/lldeleteutils.h b/indra/llcommon/lldeleteutils.h deleted file mode 100644 index f250dc3028..0000000000 --- a/indra/llcommon/lldeleteutils.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file lldeleteutils.h - * @brief Utility functions to simplify some common pointer-munging idioms. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ -#ifndef LL_DELETE_UTILS_H -#define LL_DELETE_UTILS_H - -// Simple utility functions to eventually replace the common 2-line -// idiom scattered throughout the viewer codebase. Note that where -// possible we would rather be using smart pointers of some sort. - -template <class T> -inline void deleteAndClear(T*& ptr) -{ - delete ptr; - ptr = NULL; -} - -template <class T> -inline void deleteAndClearArray(T*& array_ptr) -{ - delete[] array_ptr; - array_ptr = NULL; -} - -#endif diff --git a/indra/llcommon/lldepthstack.h b/indra/llcommon/lldepthstack.h index d9db54efc7..ac435a30fa 100644 --- a/indra/llcommon/lldepthstack.h +++ b/indra/llcommon/lldepthstack.h @@ -27,17 +27,20 @@ #ifndef LL_LLDEPTHSTACK_H #define LL_LLDEPTHSTACK_H -#include "linked_lists.h" +#include "llstl.h" template <class DATA_TYPE> class LLDepthStack { private: - LLLinkedList<DATA_TYPE> mStack; + std::deque<DATA_TYPE*> mStack; U32 mCurrentDepth; U32 mMaxDepth; public: - LLDepthStack() : mCurrentDepth(0), mMaxDepth(0) {} + LLDepthStack() + : mCurrentDepth(0), mMaxDepth(0) + {} + ~LLDepthStack() {} void setDepth(U32 depth) @@ -54,24 +57,27 @@ public: { if (mCurrentDepth < mMaxDepth) { - mStack.addData(data); + mStack.push_back(data); mCurrentDepth++; } else { // the last item falls off stack and is deleted - mStack.getLastData(); - mStack.deleteCurrentData(); - mStack.addData(data); + if (!mStack.empty()) + { + mStack.pop_front(); + } + mStack.push_back(data); } } DATA_TYPE *pop() { - DATA_TYPE *tempp = mStack.getFirstData(); - if (tempp) + DATA_TYPE *tempp = NULL; + if (!mStack.empty()) { - mStack.removeCurrentData(); + tempp = mStack.back(); + mStack.pop_back(); mCurrentDepth--; } return tempp; @@ -79,20 +85,20 @@ public: DATA_TYPE *check() { - DATA_TYPE *tempp = mStack.getFirstData(); - return tempp; + return mStack.empty() ? NULL : mStack.back(); } void deleteAllData() { mCurrentDepth = 0; - mStack.deleteAllData(); + std::for_each(mStack.begin(), mStack.end(), DeletePointer()); + mStack.clear(); } void removeAllNodes() { mCurrentDepth = 0; - mStack.removeAllNodes(); + mStack.clear(); } }; diff --git a/indra/llcommon/lldlinked.h b/indra/llcommon/lldlinked.h deleted file mode 100644 index 3f7c197be7..0000000000 --- a/indra/llcommon/lldlinked.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file lldlinked.h - * @brief Declaration of the LLDLinked class. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ -#ifndef LL_LLDLINKED_H -#define LL_LLDLINKED_H - -template <class Type> class LLDLinked -{ - LLDLinked* mNextp; - LLDLinked* mPrevp; -public: - - Type* getNext() { return (Type*)mNextp; } - Type* getPrev() { return (Type*)mPrevp; } - Type* getFirst() { return (Type*)mNextp; } - - void init() - { - mNextp = mPrevp = NULL; - } - - void unlink() - { - if (mPrevp) mPrevp->mNextp = mNextp; - if (mNextp) mNextp->mPrevp = mPrevp; - } - - LLDLinked() { mNextp = mPrevp = NULL; } - virtual ~LLDLinked() { unlink(); } - - virtual void deleteAll() - { - Type *curp = getFirst(); - while(curp) - { - Type *nextp = curp->getNext(); - curp->unlink(); - delete curp; - curp = nextp; - } - } - - void relink(Type &after) - { - LLDLinked *afterp = (LLDLinked*)&after; - afterp->mPrevp = this; - mNextp = afterp; - } - - virtual void append(Type& after) - { - LLDLinked *afterp = (LLDLinked*)&after; - afterp->mPrevp = this; - afterp->mNextp = mNextp; - if (mNextp) mNextp->mPrevp = afterp; - mNextp = afterp; - } - - virtual void insert(Type& before) - { - LLDLinked *beforep = (LLDLinked*)&before; - beforep->mNextp = this; - beforep->mPrevp = mPrevp; - if (mPrevp) mPrevp->mNextp = beforep; - mPrevp = beforep; - } - - virtual void put(Type& obj) { append(obj); } -}; - -#endif diff --git a/indra/llcommon/lldqueueptr.h b/indra/llcommon/lldqueueptr.h deleted file mode 100644 index 9fe08191e1..0000000000 --- a/indra/llcommon/lldqueueptr.h +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @file lldqueueptr.h - * @brief LLDynamicQueuePtr declaration - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ -#ifndef LL_LLDQUEUEPTR_H -#define LL_LLDQUEUEPTR_H - -template <class Type> -class LLDynamicQueuePtr -{ -public: - enum - { - OKAY = 0, - FAIL = -1 - }; - - LLDynamicQueuePtr(const S32 size=8); - ~LLDynamicQueuePtr(); - - void init(); - void destroy(); - void reset(); - void reallocate(U32 newsize); - - // ACCESSORS - const Type& get(const S32 index) const; // no bounds checking - Type& get(const S32 index); // no bounds checking - const Type& operator [] (const S32 index) const { return get(index); } - Type& operator [] (const S32 index) { return get(index); } - S32 find(const Type &obj) const; - - S32 count() const { return (mLastObj >= mFirstObj ? mLastObj - mFirstObj : mLastObj + mMaxObj - mFirstObj); } - S32 getMax() const { return mMaxObj; } - S32 getFirst() const { return mFirstObj; } - S32 getLast () const { return mLastObj; } - - // MANIPULATE - S32 push(const Type &obj); // add to end of Queue, returns index from start - S32 pull( Type &obj); // pull from Queue, returns index from start - - S32 remove (S32 index); // remove by index - S32 removeObj(const Type &obj); // remove by object - -protected: - S32 mFirstObj, mLastObj, mMaxObj; - Type* mMemory; - -public: - - void print() - { - /* - Convert this to llinfos if it's intended to be used - djs 08/30/02 - - printf("Printing from %d to %d (of %d): ",mFirstObj, mLastObj, mMaxObj); - - if (mFirstObj <= mLastObj) - { - for (S32 i=mFirstObj;i<mLastObj;i++) - { - printf("%d ",mMemory[i]); - } - } - else - { - for (S32 i=mFirstObj;i<mMaxObj;i++) - { - printf("%d ",mMemory[i]); - } - for (i=0;i<mLastObj;i++) - { - printf("%d ",mMemory[i]); - } - } - printf("\n"); - */ - } - -}; - - -//-------------------------------------------------------- -// LLDynamicQueuePtrPtr implementation -//-------------------------------------------------------- - - -template <class Type> -inline LLDynamicQueuePtr<Type>::LLDynamicQueuePtr(const S32 size) -{ - init(); - reallocate(size); -} - -template <class Type> -inline LLDynamicQueuePtr<Type>::~LLDynamicQueuePtr() -{ - destroy(); -} - -template <class Type> -inline void LLDynamicQueuePtr<Type>::init() -{ - mFirstObj = 0; - mLastObj = 0; - mMaxObj = 0; - mMemory = NULL; -} - -template <class Type> -inline void LLDynamicQueuePtr<Type>::reallocate(U32 newsize) -{ - if (newsize) - { - if (mFirstObj > mLastObj && newsize > mMaxObj) - { - Type* new_memory = new Type[newsize]; - - llassert(new_memory); - - S32 _count = count(); - S32 i, m = 0; - for (i=mFirstObj; i < mMaxObj; i++) - { - new_memory[m++] = mMemory[i]; - } - for (i=0; i <=mLastObj; i++) - { - new_memory[m++] = mMemory[i]; - } - - delete[] mMemory; - mMemory = new_memory; - - mFirstObj = 0; - mLastObj = _count; - } - else - { - Type* new_memory = new Type[newsize]; - - llassert(new_memory); - - S32 i, m = 0; - for (i=0; i < mLastObj; i++) - { - new_memory[m++] = mMemory[i]; - } - delete[] mMemory; - mMemory = new_memory; - } - } - else if (mMemory) - { - delete[] mMemory; - mMemory = NULL; - } - - mMaxObj = newsize; -} - -template <class Type> -inline void LLDynamicQueuePtr<Type>::destroy() -{ - reset(); - delete[] mMemory; - mMemory = NULL; -} - - -template <class Type> -void LLDynamicQueuePtr<Type>::reset() -{ - for (S32 i=0; i < mMaxObj; i++) - { - get(i) = NULL; // unrefs for pointers - } - - mFirstObj = 0; - mLastObj = 0; -} - - -template <class Type> -inline S32 LLDynamicQueuePtr<Type>::find(const Type &obj) const -{ - S32 i; - if (mFirstObj <= mLastObj) - { - for ( i = mFirstObj; i < mLastObj; i++ ) - { - if (mMemory[i] == obj) - { - return i; - } - } - } - else - { - for ( i = mFirstObj; i < mMaxObj; i++ ) - { - if (mMemory[i] == obj) - { - return i; - } - } - for ( i = 0; i < mLastObj; i++ ) - { - if (mMemory[i] == obj) - { - return i; - } - } - } - - return FAIL; -} - -template <class Type> -inline S32 LLDynamicQueuePtr<Type>::remove(S32 i) -{ - if (mFirstObj > mLastObj) - { - if (i >= mFirstObj && i < mMaxObj) - { - while( i > mFirstObj) - { - mMemory[i] = mMemory[i-1]; - i--; - } - mMemory[mFirstObj] = NULL; - mFirstObj++; - if (mFirstObj >= mMaxObj) mFirstObj = 0; - - return count(); - } - else if (i < mLastObj && i >= 0) - { - while(i < mLastObj) - { - mMemory[i] = mMemory[i+1]; - i++; - } - mMemory[mLastObj] = NULL; - mLastObj--; - if (mLastObj < 0) mLastObj = mMaxObj-1; - - return count(); - } - } - else if (i <= mLastObj && i >= mFirstObj) - { - while(i < mLastObj) - { - mMemory[i] = mMemory[i+1]; - i++; - } - mMemory[mLastObj] = NULL; - mLastObj--; - if (mLastObj < 0) mLastObj = mMaxObj-1; - - return count(); - } - - - return FAIL; -} - -template <class Type> -inline S32 LLDynamicQueuePtr<Type>::removeObj(const Type& obj) -{ - S32 ind = find(obj); - if (ind >= 0) - { - return remove(ind); - } - return FAIL; -} - -template <class Type> -inline S32 LLDynamicQueuePtr<Type>::push(const Type &obj) -{ - if (mMaxObj - count() <= 1) - { - reallocate(mMaxObj * 2); - } - - mMemory[mLastObj++] = obj; - - if (mLastObj >= mMaxObj) - { - mLastObj = 0; - } - - return count(); -} - -template <class Type> -inline S32 LLDynamicQueuePtr<Type>::pull(Type &obj) -{ - obj = NULL; - - if (count() < 1) return -1; - - obj = mMemory[mFirstObj]; - mMemory[mFirstObj] = NULL; - - mFirstObj++; - - if (mFirstObj >= mMaxObj) - { - mFirstObj = 0; - } - - return count(); -} - -template <class Type> -inline const Type& LLDynamicQueuePtr<Type>::get(const S32 i) const -{ - return mMemory[i]; -} - -template <class Type> -inline Type& LLDynamicQueuePtr<Type>::get(const S32 i) -{ - return mMemory[i]; -} - - -#endif // LL_LLDQUEUEPTR_H diff --git a/indra/llcommon/llenum.h b/indra/llcommon/llenum.h deleted file mode 100644 index f57b2bc0b5..0000000000 --- a/indra/llcommon/llenum.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file llenum.h - * @author Tom Yedwab - * @brief Utility class for storing enum value <-> string lookup. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLENUM_H -#define LL_LLENUM_H - -class LLEnum -{ -public: - typedef std::pair<const std::string, const U32> enum_t; - enum - { - UNDEFINED = 0xffffffff, - }; - - LLEnum(const enum_t values_array[], const U32 length) - { - for (U32 i=0; i<length; ++i) - { - mEnumMap.insert(values_array[i]); - if (values_array[i].second >= mEnumArray.size()) - { - mEnumArray.resize(values_array[i].second+1); - } - mEnumArray[values_array[i].second] = values_array[i].first; - } - } - - U32 operator[](std::string str) - { - std::map<const std::string, const U32>::iterator itor; - itor = mEnumMap.find(str); - if (itor != mEnumMap.end()) - { - return itor->second; - } - return UNDEFINED; - } - - const std::string operator[](U32 index) - { - if (index < mEnumArray.size()) - { - return mEnumArray[index]; - } - return ""; - } - -private: - std::map<const std::string, const U32> mEnumMap; - std::vector<std::string> mEnumArray; -}; - -#endif // LL_LLENUM_H diff --git a/indra/llcommon/llindexedqueue.h b/indra/llcommon/llindexedqueue.h deleted file mode 100644 index aa2675d87d..0000000000 --- a/indra/llcommon/llindexedqueue.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file llindexedqueue.h - * @brief An indexed FIFO queue, where only one element with each key - * can be in the queue. - * - * $LicenseInfo:firstyear=2003&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLINDEXEDQUEUE_H -#define LL_LLINDEXEDQUEUE_H - -// An indexed FIFO queue, where only one element with each key can be in the queue. -// This is ONLY used in the interest list, you'll probably want to review this code -// carefully if you want to use it elsewhere - Doug - -template <typename Type> -class LLIndexedQueue -{ -protected: - typedef std::deque<Type> type_deque; - type_deque mQueue; - std::set<Type> mKeySet; - -public: - LLIndexedQueue() {} - - // move_if_there is an O(n) operation - bool push_back(const Type &value, bool move_if_there = false) - { - if (mKeySet.find(value) != mKeySet.end()) - { - // Already on the queue - if (move_if_there) - { - // Remove the existing entry. - typename type_deque::iterator it; - for (it = mQueue.begin(); it != mQueue.end(); ++it) - { - if (*it == value) - { - break; - } - } - - // This HAS to succeed, otherwise there's a serious bug in the keyset implementation - // (although this isn't thread safe, at all) - - mQueue.erase(it); - } - else - { - // We're not moving it, leave it alone - return false; - } - } - else - { - // Doesn't exist, add it to the key set - mKeySet.insert(value); - } - - mQueue.push_back(value); - - // We succeeded in adding the new element. - return true; - } - - bool push_front(const Type &value, bool move_if_there = false) - { - if (mKeySet.find(value) != mKeySet.end()) - { - // Already on the queue - if (move_if_there) - { - // Remove the existing entry. - typename type_deque::iterator it; - for (it = mQueue.begin(); it != mQueue.end(); ++it) - { - if (*it == value) - { - break; - } - } - - // This HAS to succeed, otherwise there's a serious bug in the keyset implementation - // (although this isn't thread safe, at all) - - mQueue.erase(it); - } - else - { - // We're not moving it, leave it alone - return false; - } - } - else - { - // Doesn't exist, add it to the key set - mKeySet.insert(value); - } - - mQueue.push_front(value); - return true; - } - - void pop() - { - Type value = mQueue.front(); - mKeySet.erase(value); - mQueue.pop_front(); - } - - Type &front() - { - return mQueue.front(); - } - - S32 size() const - { - return mQueue.size(); - } - - bool empty() const - { - return mQueue.empty(); - } - - void clear() - { - // Clear out all elements on the queue - mQueue.clear(); - mKeySet.clear(); - } -}; - -#endif // LL_LLINDEXEDQUEUE_H diff --git a/indra/llcommon/lllazy.cpp b/indra/llcommon/lllazy.cpp deleted file mode 100644 index 29fa040387..0000000000 --- a/indra/llcommon/lllazy.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file lllazy.cpp - * @author Nat Goodspeed - * @date 2009-01-28 - * @brief Implementation for lllazy. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -// Precompiled header -#include "linden_common.h" -// associated header -#include "lllazy.h" -// STL headers -// std headers -// external library headers -// other Linden headers - -// lllazy.h is presently header-only. This file exists only because our CMake -// test macro ADD_BUILD_TEST requires it. -int dummy = 0; diff --git a/indra/llcommon/lllazy.h b/indra/llcommon/lllazy.h deleted file mode 100644 index 5f3bbce79e..0000000000 --- a/indra/llcommon/lllazy.h +++ /dev/null @@ -1,399 +0,0 @@ -/** - * @file lllazy.h - * @author Nat Goodspeed - * @date 2009-01-22 - * @brief Lazy instantiation of specified type. Useful in conjunction with - * Michael Feathers's "Extract and Override Getter" ("Working - * Effectively with Legacy Code", p. 352). - * - * Quoting his synopsis of steps on p.355: - * - * 1. Identify the object you need a getter for. - * 2. Extract all of the logic needed to create the object into a getter. - * 3. Replace all uses of the object with calls to the getter, and initialize - * the reference that holds the object to null in all constructors. - * 4. Add the first-time logic to the getter so that the object is constructed - * and assigned to the reference whenever the reference is null. - * 5. Subclass the class and override the getter to provide an alternative - * object for testing. - * - * It's the second half of bullet 3 (3b, as it were) that bothers me. I find - * it all too easy to imagine adding pointer initializers to all but one - * constructor... the one not exercised by my tests. That suggested using - * (e.g.) boost::scoped_ptr<MyObject> so you don't have to worry about - * destroying it either. - * - * However, introducing additional machinery allows us to encapsulate bullet 4 - * as well. - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#if ! defined(LL_LLLAZY_H) -#define LL_LLLAZY_H - -#include <boost/function.hpp> -#include <boost/scoped_ptr.hpp> -#include <boost/lambda/construct.hpp> -#include <stdexcept> - -/// LLLazyCommon simply factors out of LLLazy<T> things that don't depend on -/// its template parameter. -class LLLazyCommon -{ -public: - /** - * This exception is thrown if you try to replace an LLLazy<T>'s factory - * (or T* instance) after it already has an instance in hand. Since T - * might well be stateful, we can't know the effect of silently discarding - * and replacing an existing instance, so we disallow it. This facility is - * intended for testing, and in a test scenario we can definitely control - * that. - */ - struct InstanceChange: public std::runtime_error - { - InstanceChange(const std::string& what): std::runtime_error(what) {} - }; - -protected: - /** - * InstanceChange might be appropriate in a couple of different LLLazy<T> - * methods. Factor out the common logic. - */ - template <typename PTR> - static void ensureNoInstance(const PTR& ptr) - { - if (ptr) - { - // Too late: we've already instantiated the lazy object. We don't - // know whether it's stateful or not, so it's not safe to discard - // the existing instance in favor of a replacement. - throw InstanceChange("Too late to replace LLLazy instance"); - } - } -}; - -/** - * LLLazy<T> is useful when you have an outer class Outer that you're trying - * to bring under unit test, that contains a data member difficult to - * instantiate in a test harness. Typically the data member's class Inner has - * many thorny dependencies. Feathers generally advocates "Extract and - * Override Factory Method" (p. 350). But in C++, you can't call a derived - * class override of a virtual method from the derived class constructor, - * which limits applicability of "Extract and Override Factory Method." For - * such cases Feathers presents "Extract and Override Getter" (p. 352). - * - * So we'll assume that your class Outer contains a member like this: - * @code - * Inner mInner; - * @endcode - * - * LLLazy<Inner> can be used to replace this member. You can directly declare: - * @code - * LLLazy<Inner> mInner; - * @endcode - * and change references to mInner accordingly. - * - * (Alternatively, you can add a base class of the form - * <tt>LLLazyBase<Inner></tt>. This is discussed further in the LLLazyBase<T> - * documentation.) - * - * LLLazy<T> binds a <tt>boost::scoped_ptr<T></tt> and a factory functor - * returning T*. You can either bind that functor explicitly or let it default - * to the expression <tt>new T()</tt>. - * - * As long as LLLazy<T> remains unreferenced, its T remains uninstantiated. - * The first time you use get(), <tt>operator*()</tt> or <tt>operator->()</tt> - * it will instantiate its T and thereafter behave like a pointer to it. - * - * Thus, any existing reference to <tt>mInner.member</tt> should be replaced - * with <tt>mInner->member</tt>. Any simple reference to @c mInner should be - * replaced by <tt>*mInner</tt>. - * - * (If the original declaration was a pointer initialized in Outer's - * constructor, e.g. <tt>Inner* mInner</tt>, so much the better. In that case - * you should be able to drop in <tt>LLLazy<Inner></tt> without much change.) - * - * The support for "Extract and Override Getter" lies in the fact that you can - * replace the factory functor -- or provide an explicit T*. Presumably this - * is most useful from a test subclass -- which suggests that your @c mInner - * member should be @c protected. - * - * Note that <tt>boost::lambda::new_ptr<T>()</tt> makes a dandy factory - * functor, for either the set() method or LLLazy<T>'s constructor. If your T - * requires constructor arguments, use an expression more like - * <tt>boost::lambda::bind(boost::lambda::new_ptr<T>(), arg1, arg2, ...)</tt>. - * - * Of course the point of replacing the functor is to substitute a class that, - * though referenced as Inner*, is not an Inner; presumably this is a testing - * subclass of Inner (e.g. TestInner). Thus your test subclass TestOuter for - * the containing class Outer will contain something like this: - * @code - * class TestOuter: public Outer - * { - * public: - * TestOuter() - * { - * // mInner must be 'protected' rather than 'private' - * mInner.set(boost::lambda::new_ptr<TestInner>()); - * } - * ... - * }; - * @endcode - */ -template <typename T> -class LLLazy: public LLLazyCommon -{ -public: - /// Any nullary functor returning T* will work as a Factory - typedef boost::function<T* ()> Factory; - - /// The default LLLazy constructor uses <tt>new T()</tt> as its Factory - LLLazy(): - mFactory(boost::lambda::new_ptr<T>()) - {} - - /// Bind an explicit Factory functor - LLLazy(const Factory& factory): - mFactory(factory) - {} - - /// Reference T, instantiating it if this is the first access - const T& get() const - { - if (! mInstance) - { - // use the bound Factory functor - mInstance.reset(mFactory()); - } - return *mInstance; - } - - /// non-const get() - T& get() - { - return const_cast<T&>(const_cast<const LLLazy<T>*>(this)->get()); - } - - /// operator*() is equivalent to get() - const T& operator*() const { return get(); } - /// operator*() is equivalent to get() - T& operator*() { return get(); } - - /** - * operator->() must return (something resembling) T*. It's tempting to - * return the underlying boost::scoped_ptr<T>, but that would require - * breaking out the lazy-instantiation logic from get() into a common - * private method. Assume the pointer used for operator->() access is very - * short-lived. - */ - const T* operator->() const { return &get(); } - /// non-const operator->() - T* operator->() { return &get(); } - - /// set(Factory). This will throw InstanceChange if mInstance has already - /// been set. - void set(const Factory& factory) - { - ensureNoInstance(mInstance); - mFactory = factory; - } - - /// set(T*). This will throw InstanceChange if mInstance has already been - /// set. - void set(T* instance) - { - ensureNoInstance(mInstance); - mInstance.reset(instance); - } - -private: - Factory mFactory; - // Consider an LLLazy<T> member of a class we're accessing by const - // reference. We want to allow even const methods to touch the LLLazy<T> - // member. Hence the actual pointer must be mutable because such access - // might assign it. - mutable boost::scoped_ptr<T> mInstance; -}; - -#if (! defined(__GNUC__)) || (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) -// Not gcc at all, or a gcc more recent than gcc 3.3 -#define GCC33 0 -#else -#define GCC33 1 -#endif - -/** - * LLLazyBase<T> wraps LLLazy<T>, giving you an alternative way to replace - * <tt>Inner mInner;</tt>. Instead of coding <tt>LLLazy<Inner> mInner</tt>, - * you can add LLLazyBase<Inner> to your Outer class's bases, e.g.: - * @code - * class Outer: public LLLazyBase<Inner> - * { - * ... - * }; - * @endcode - * - * This gives you @c public get() and @c protected set() methods without - * having to make your LLLazy<Inner> member @c protected. The tradeoff is that - * you must access the wrapped LLLazy<Inner> using get() and set() rather than - * with <tt>operator*()</tt> or <tt>operator->()</tt>. - * - * This mechanism can be used for more than one member, but only if they're of - * different types. That is, you can replace: - * @code - * DifficultClass mDifficult; - * AwkwardType mAwkward; - * @endcode - * with: - * @code - * class Outer: public LLLazyBase<DifficultClass>, public LLLazyBase<AwkwardType> - * { - * ... - * }; - * @endcode - * but for a situation like this: - * @code - * DifficultClass mMainDifficult, mAuxDifficult; - * @endcode - * you should directly embed LLLazy<DifficultClass> (q.v.). - * - * For multiple LLLazyBase bases, e.g. the <tt>LLLazyBase<DifficultClass>, - * LLLazyBase<AwkwardType></tt> example above, access the relevant get()/set() - * as (e.g.) <tt>LLLazyBase<DifficultClass>::get()</tt>. (This is why you - * can't have multiple LLLazyBase<T> of the same T.) For a bit of syntactic - * sugar, please see getLazy()/setLazy(). - */ -template <typename T> -class LLLazyBase -{ -public: - /// invoke default LLLazy constructor - LLLazyBase() {} - /// make wrapped LLLazy bind an explicit Factory - LLLazyBase(const typename LLLazy<T>::Factory& factory): - mInstance(factory) - {} - - /// access to LLLazy::get() - T& get() { return *mInstance; } - /// access to LLLazy::get() - const T& get() const { return *mInstance; } - -protected: - // see getLazy()/setLazy() - #if (! GCC33) - template <typename T2, class MYCLASS> friend T2& getLazy(MYCLASS* this_); - template <typename T2, class MYCLASS> friend const T2& getLazy(const MYCLASS* this_); - #else // gcc 3.3 - template <typename T2, class MYCLASS> friend T2& getLazy(const MYCLASS* this_); - #endif // gcc 3.3 - template <typename T2, class MYCLASS> friend void setLazy(MYCLASS* this_, T2* instance); - template <typename T2, class MYCLASS> - friend void setLazy(MYCLASS* this_, const typename LLLazy<T2>::Factory& factory); - - /// access to LLLazy::set(Factory) - void set(const typename LLLazy<T>::Factory& factory) - { - mInstance.set(factory); - } - - /// access to LLLazy::set(T*) - void set(T* instance) - { - mInstance.set(instance); - } - -private: - LLLazy<T> mInstance; -}; - -/** - * @name getLazy()/setLazy() - * Suppose you have something like the following: - * @code - * class Outer: public LLLazyBase<DifficultClass>, public LLLazyBase<AwkwardType> - * { - * ... - * }; - * @endcode - * - * Your methods can reference the @c DifficultClass instance using - * <tt>LLLazyBase<DifficultClass>::get()</tt>, which is admittedly a bit ugly. - * Alternatively, you can write <tt>getLazy<DifficultClass>(this)</tt>, which - * is somewhat more straightforward to read. - * - * Similarly, - * @code - * LLLazyBase<DifficultClass>::set(new TestDifficultClass()); - * @endcode - * could instead be written: - * @code - * setLazy<DifficultClass>(this, new TestDifficultClass()); - * @endcode - * - * @note - * I wanted to provide getLazy() and setLazy() without explicitly passing @c - * this. That would imply making them methods on a base class rather than free - * functions. But if <tt>LLLazyBase<T></tt> derives normally from (say) @c - * LLLazyGrandBase providing those methods, then unqualified getLazy() would - * be ambiguous: you'd have to write <tt>LLLazyBase<T>::getLazy<T>()</tt>, - * which is even uglier than <tt>LLLazyBase<T>::get()</tt>, and therefore - * pointless. You can make the compiler not care which @c LLLazyGrandBase - * instance you're talking about by making @c LLLazyGrandBase a @c virtual - * base class of @c LLLazyBase. But in that case, - * <tt>LLLazyGrandBase::getLazy<T>()</tt> can't access - * <tt>LLLazyBase<T>::get()</tt>! - * - * We want <tt>getLazy<T>()</tt> to access <tt>LLLazyBase<T>::get()</tt> as if - * in the lexical context of some subclass method. Ironically, free functions - * let us do that better than methods on a @c virtual base class -- but that - * implies passing @c this explicitly. So be it. - */ -//@{ -#if (! GCC33) -template <typename T, class MYCLASS> -T& getLazy(MYCLASS* this_) { return this_->LLLazyBase<T>::get(); } -template <typename T, class MYCLASS> -const T& getLazy(const MYCLASS* this_) { return this_->LLLazyBase<T>::get(); } -#else // gcc 3.3 -// For const-correctness, we really should have two getLazy() variants: one -// accepting const MYCLASS* and returning const T&, the other accepting -// non-const MYCLASS* and returning non-const T&. This works fine on the Mac -// (gcc 4.0.1) and Windows (MSVC 8.0), but fails on our Linux 32-bit Debian -// Sarge stations (gcc 3.3.5). Since I really don't know how to beat that aging -// compiler over the head to make it do the right thing, I'm going to have to -// move forward with the wrong thing: a single getLazy() function that accepts -// const MYCLASS* and returns non-const T&. -template <typename T, class MYCLASS> -T& getLazy(const MYCLASS* this_) { return const_cast<MYCLASS*>(this_)->LLLazyBase<T>::get(); } -#endif // gcc 3.3 -template <typename T, class MYCLASS> -void setLazy(MYCLASS* this_, T* instance) { this_->LLLazyBase<T>::set(instance); } -template <typename T, class MYCLASS> -void setLazy(MYCLASS* this_, const typename LLLazy<T>::Factory& factory) -{ - this_->LLLazyBase<T>::set(factory); -} -//@} - -#endif /* ! defined(LL_LLLAZY_H) */ diff --git a/indra/llcommon/lllocalidhashmap.h b/indra/llcommon/lllocalidhashmap.h deleted file mode 100644 index 8f4f91a560..0000000000 --- a/indra/llcommon/lllocalidhashmap.h +++ /dev/null @@ -1,895 +0,0 @@ -/** - * @file lllocalidhashmap.h - * @brief Map specialized for dealing with local ids - * - * $LicenseInfo:firstyear=2003&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLLOCALIDHASHMAP_H -#define LL_LLLOCALIDHASHMAP_H - -#include "stdtypes.h" -#include "llerror.h" - -const S32 MAX_ITERS = 4; -// LocalID hash map - -// -// LLLocalIDHashNode -// - -template <class DATA, int SIZE> -class LLLocalIDHashNode -{ -public: - LLLocalIDHashNode(); - -public: - S32 mCount; - U32 mKey[SIZE]; - DATA mData[SIZE]; - LLLocalIDHashNode<DATA, SIZE> *mNextNodep; -}; - - -// -// LLLocalIDHashNode implementation -// -template <class DATA, int SIZE> -LLLocalIDHashNode<DATA, SIZE>::LLLocalIDHashNode() -{ - mCount = 0; - mNextNodep = NULL; -} - -// -// LLLocalIDHashMapIter -// -template <class DATA_TYPE, int SIZE> -class LLLocalIDHashMap; - -template <class DATA_TYPE, int SIZE> -class LLLocalIDHashMapIter -{ -public: - LLLocalIDHashMapIter(LLLocalIDHashMap<DATA_TYPE, SIZE> *hash_mapp); - ~LLLocalIDHashMapIter(); - - void setMap(LLLocalIDHashMap<DATA_TYPE, SIZE> *hash_mapp); - inline void first(); - inline void next(); - inline DATA_TYPE& current(); // *NOTE: Deprecate? Phoenix 2005-04-15 - inline BOOL done() const; - inline S32 currentBin() const; - inline void setBin(S32 bin); - - DATA_TYPE& operator*() const - { - return mCurHashNodep->mData[mCurHashNodeKey]; - } - DATA_TYPE* operator->() const - { - return &(operator*()); - } - - LLLocalIDHashMap<DATA_TYPE, SIZE> *mHashMapp; - LLLocalIDHashNode<DATA_TYPE, SIZE> *mCurHashNodep; - - S32 mCurHashMapNodeNum; - S32 mCurHashNodeKey; - - DATA_TYPE mNull; - - S32 mIterID; -}; - - - -template <class DATA_TYPE, int SIZE> -class LLLocalIDHashMap -{ -public: - friend class LLLocalIDHashMapIter<DATA_TYPE, SIZE>; - - LLLocalIDHashMap(); // DO NOT use this unless you explicitly setNull, or the data type constructs a "null" - // object by default - // basic constructor including sorter - LLLocalIDHashMap(const DATA_TYPE &null_data); - // Hack, this should really be a const ref, but I'm not doing it that way because the sim - // usually uses pointers. - ~LLLocalIDHashMap(); - - inline DATA_TYPE &get(const U32 local_id); - inline BOOL check(const U32 local_id) const; - inline DATA_TYPE &set(const U32 local_id, const DATA_TYPE data); - inline BOOL remove(const U32 local_id); - void removeAll(); - - void setNull(const DATA_TYPE data) { mNull = data; } - - inline S32 getLength() const; // Warning, NOT O(1!) - - void dumpIter(); - void dumpBin(U32 bin); - -protected: - // Only used by the iterator. - void addIter(LLLocalIDHashMapIter<DATA_TYPE, SIZE> *iter); - void removeIter(LLLocalIDHashMapIter<DATA_TYPE, SIZE> *iter); - - // Remove the item and shift all items afterward down the list, - // fixing up iterators as we go. - BOOL removeWithShift(const U32 local_id); - -protected: - LLLocalIDHashNode<DATA_TYPE, SIZE> mNodes[256]; - - S32 mIterCount; - LLLocalIDHashMapIter<DATA_TYPE, SIZE> *mIters[MAX_ITERS]; - - DATA_TYPE mNull; -}; - - -// -// LLLocalIDHashMap implementation -// - -template <class DATA_TYPE, int SIZE> -LLLocalIDHashMap<DATA_TYPE, SIZE>::LLLocalIDHashMap() -: mIterCount(0), - mNull() -{ - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - mIters[i] = NULL; - } -} - -template <class DATA_TYPE, int SIZE> -LLLocalIDHashMap<DATA_TYPE, SIZE>::LLLocalIDHashMap(const DATA_TYPE &null_data) -: mIterCount(0), - mNull(null_data) -{ - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - mIters[i] = NULL; - } -} - -template <class DATA_TYPE, int SIZE> -LLLocalIDHashMap<DATA_TYPE, SIZE>::~LLLocalIDHashMap() -{ - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - if (mIters[i]) - { - mIters[i]->mHashMapp = NULL; - mIterCount--; - } - } - removeAll(); -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMap<DATA_TYPE, SIZE>::removeAll() -{ - S32 bin; - for (bin = 0; bin < 256; bin++) - { - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[bin]; - - BOOL first = TRUE; - do // First node guaranteed to be there - { - S32 i; - const S32 count = nodep->mCount; - - // Iterate through all members of this node - for (i = 0; i < count; i++) - { - nodep->mData[i] = mNull; - } - - nodep->mCount = 0; - // Done with all objects in this node, go to the next. - - LLLocalIDHashNode<DATA_TYPE, SIZE>* curp = nodep; - nodep = nodep->mNextNodep; - - // Delete the node if it's not the first node - if (first) - { - first = FALSE; - curp->mNextNodep = NULL; - } - else - { - delete curp; - } - } while (nodep); - } -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMap<DATA_TYPE, SIZE>::dumpIter() -{ - std::cout << "Hash map with " << mIterCount << " iterators" << std::endl; - - std::cout << "Hash Map Iterators:" << std::endl; - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - if (mIters[i]) - { - llinfos << i << " " << mIters[i]->mCurHashNodep << " " << mIters[i]->mCurHashNodeKey << llendl; - } - else - { - llinfos << i << "null" << llendl; - } - } -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMap<DATA_TYPE, SIZE>::dumpBin(U32 bin) -{ - std::cout << "Dump bin " << bin << std::endl; - - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[bin]; - S32 node = 0; - do // First node guaranteed to be there. - { - std::cout << "Bin " << bin - << " node " << node - << " count " << nodep->mCount - << " contains " << std::flush; - - S32 i; - for (i = 0; i < nodep->mCount; i++) - { - std::cout << nodep->mData[i] << " " << std::flush; - } - - std::cout << std::endl; - - nodep = nodep->mNextNodep; - node++; - } while (nodep); -} - -template <class DATA_TYPE, int SIZE> -inline S32 LLLocalIDHashMap<DATA_TYPE, SIZE>::getLength() const -{ - S32 count = 0; - S32 bin; - for (bin = 0; bin < 256; bin++) - { - const LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[bin]; - while (nodep) - { - count += nodep->mCount; - nodep = nodep->mNextNodep; - } - } - return count; -} - -template <class DATA_TYPE, int SIZE> -inline DATA_TYPE &LLLocalIDHashMap<DATA_TYPE, SIZE>::get(const U32 local_id) -{ - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[local_id & 0xff]; - - do // First node guaranteed to be there - { - S32 i; - const S32 count = nodep->mCount; - - // Iterate through all members of this node - for (i = 0; i < count; i++) - { - if (nodep->mKey[i] == local_id) - { - // We found it. - return nodep->mData[i]; - } - } - - // Done with all objects in this node, go to the next. - nodep = nodep->mNextNodep; - } while (nodep); - - return mNull; -} - - -template <class DATA_TYPE, int SIZE> -inline BOOL LLLocalIDHashMap<DATA_TYPE, SIZE>::check(const U32 local_id) const -{ - const LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[local_id & 0xff]; - - do // First node guaranteed to be there - { - S32 i; - const S32 count = nodep->mCount; - - // Iterate through all members of this node - for (i = 0; i < count; i++) - { - if (nodep->mKey[i] == local_id) - { - // We found it. - return TRUE; - } - } - - // Done with all objects in this node, go to the next. - nodep = nodep->mNextNodep; - } while (nodep); - - // Didn't find anything - return FALSE; -} - - -template <class DATA_TYPE, int SIZE> -inline DATA_TYPE &LLLocalIDHashMap<DATA_TYPE, SIZE>::set(const U32 local_id, const DATA_TYPE data) -{ - // Set is just like a normal find, except that if we find a match - // we replace it with the input value. - // If we don't find a match, we append to the end of the list. - - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[local_id & 0xff]; - - while (1) - { - const S32 count = nodep->mCount; - - S32 i; - for (i = 0; i < count; i++) - { - if (nodep->mKey[i] == local_id) - { - // We found a match for this key, replace the data with - // the incoming data. - nodep->mData[i] = data; - return nodep->mData[i]; - } - } - if (!nodep->mNextNodep) - { - // We've iterated through all of the keys without finding a match - if (i < SIZE) - { - // There's still some space on this node, append - // the key and data to it. - nodep->mKey[i] = local_id; - nodep->mData[i] = data; - nodep->mCount++; - - return nodep->mData[i]; - } - else - { - // This node is full, append a new node to the end. - nodep->mNextNodep = new LLLocalIDHashNode<DATA_TYPE, SIZE>; - nodep->mNextNodep->mKey[0] = local_id; - nodep->mNextNodep->mData[0] = data; - nodep->mNextNodep->mCount = 1; - - return nodep->mNextNodep->mData[0]; - } - } - - // No match on this node, go to the next - nodep = nodep->mNextNodep; - } -} - - -template <class DATA_TYPE, int SIZE> -inline BOOL LLLocalIDHashMap<DATA_TYPE, SIZE>::remove(const U32 local_id) -{ - // Remove is the trickiest operation. - // What we want to do is swap the last element of the last - // node if we find the one that we want to remove, but we have - // to deal with deleting the node from the tail if it's empty, but - // NOT if it's the only node left. - - const S32 node_index = local_id & 0xff; - - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[node_index]; - - // A modification of the standard search algorithm. - do // First node guaranteed to be there - { - const S32 count = nodep->mCount; - - S32 i; - for (i = 0; i < count; i++) - { - if (nodep->mKey[i] == local_id) - { - // If we're removing the item currently pointed to by one - // or more iterators, we can just swap in the last item - // and back the iterator(s) up by one. - // Otherwise, we need to do a slow and safe shift of all - // items back to one position to fill the hole and fix up - // all iterators we find. - BOOL need_shift = FALSE; - S32 cur_iter; - if (mIterCount) - { - for (cur_iter = 0; cur_iter < MAX_ITERS; cur_iter++) - { - if (mIters[cur_iter]) - { - // We only care if the hash map node is on the one - // that we're working on. If it's before, we've already - // traversed it, if it's after, changing the order doesn't - // matter. - if (mIters[cur_iter]->mCurHashMapNodeNum == node_index) - { - if ((mIters[cur_iter]->mCurHashNodep == nodep) - && (mIters[cur_iter]->mCurHashNodeKey == i)) - { - // it's on the one we're deleting, we'll - // fix the iterator quickly below. - } - else - { - // We're trying to remove an item on this - // iterator's chain that this - // iterator doesn't point to! We need to do - // the slow remove-and-shift-down case. - need_shift = TRUE; - } - } - } - } - } - - // Removing an item that isn't pointed to by all iterators - if (need_shift) - { - return removeWithShift(local_id); - } - - // Fix the iterators that point to this node/i pair, the - // one we're deleting - for (cur_iter = 0; cur_iter < MAX_ITERS; cur_iter++) - { - if (mIters[cur_iter]) - { - // We only care if the hash map node is on the one - // that we're working on. If it's before, we've already - // traversed it, if it's after, changing the order doesn't - // matter. - if (mIters[cur_iter]->mCurHashMapNodeNum == node_index) - { - if ((mIters[cur_iter]->mCurHashNodep == nodep) - && (mIters[cur_iter]->mCurHashNodeKey == i)) - { - // We can handle the case where we're deleting - // the element we're on trivially (sort of). - if (nodep->mCount > 1) - { - // If we're not going to delete this node, - // it's OK. - mIters[cur_iter]->mCurHashNodeKey--; - } - else - { - // We're going to delete this node, because this - // is the last element on it. - - // Find the next node, and then back up one. - mIters[cur_iter]->next(); - mIters[cur_iter]->mCurHashNodeKey--; - } - } - } - } - } - - // We found the node that we want to remove. - // Find the last (and next-to-last) node, and the index of the last - // element. We could conceviably start from the node we're on, - // but that makes it more complicated, this is easier. - - LLLocalIDHashNode<DATA_TYPE, SIZE> *prevp = &mNodes[node_index]; - LLLocalIDHashNode<DATA_TYPE, SIZE> *lastp = prevp; - - // Find the last and next-to-last - while (lastp->mNextNodep) - { - prevp = lastp; - lastp = lastp->mNextNodep; - } - - // First, swap in the last to the current location. - nodep->mKey[i] = lastp->mKey[lastp->mCount - 1]; - nodep->mData[i] = lastp->mData[lastp->mCount - 1]; - - // Now, we delete the entry - lastp->mCount--; - lastp->mData[lastp->mCount] = mNull; - - if (!lastp->mCount) - { - // We deleted the last element! - if (lastp != &mNodes[local_id & 0xff]) - { - // Only blitz the node if it's not the head - // Set the previous node to point to NULL, then - // blitz the empty last node - prevp->mNextNodep = NULL; - delete lastp; - } - } - - return TRUE; - } - } - - // Iterate to the next node, we've scanned all the entries in this one. - nodep = nodep->mNextNodep; - } while (nodep); - - return FALSE; -} - -template <class DATA_TYPE, int SIZE> -BOOL LLLocalIDHashMap<DATA_TYPE, SIZE>::removeWithShift(const U32 local_id) -{ - const S32 node_index = local_id & 0xFF; - LLLocalIDHashNode<DATA_TYPE, SIZE>* nodep = &mNodes[node_index]; - LLLocalIDHashNode<DATA_TYPE, SIZE>* prevp = NULL; - BOOL found = FALSE; - - do // First node guaranteed to be there - { - const S32 count = nodep->mCount; - S32 i; - for (i = 0; i < count; i++) - { - if (nodep->mKey[i] == local_id) - { - // Found the item. Start shifting items from later - // in the list over this item. - found = TRUE; - } - - if (found) - { - // If there is an iterator on this node, we need to - // back it up. - S32 cur_iter; - for (cur_iter = 0; cur_iter <MAX_ITERS; cur_iter++) - { - LLLocalIDHashMapIter<DATA_TYPE, SIZE>* iter; - iter = mIters[cur_iter]; - // If an iterator is on this node,i pair, then back it up. - if (iter - && iter->mCurHashMapNodeNum == node_index - && iter->mCurHashNodep == nodep - && iter->mCurHashNodeKey == i) - { - if (i > 0) - { - // Don't need to move iterator nodep, since - // we're in the same node. - iter->mCurHashNodeKey--; - } - else if (prevp) - { - // need to go the previous node, last item - iter->mCurHashNodep = prevp; - iter->mCurHashNodeKey = prevp->mCount - 1; - } - else - { - // we're on the first item in the list, but - // need to go back anyhow. - - // BUG: If this deletion empties the list, - // iter->done() will be wrong until - // iter->next() is called. - iter->mCurHashNodeKey = -1; - } - } - } - - // Copy data from the next position into this position. - if (i < count-1) - { - // we're not on the last item in the node, - // so we can copy within the node - nodep->mKey[i] = nodep->mKey[i+1]; - nodep->mData[i] = nodep->mData[i+1]; - } - else if (nodep->mNextNodep) - { - // we're on the last item in the node, - // but there's a next node we can copy from - nodep->mKey[i] = nodep->mNextNodep->mKey[0]; - nodep->mData[i] = nodep->mNextNodep->mData[0]; - } - else - { - // We're on the last position in the list. - // No one to copy from. Replace with nothing. - nodep->mKey[i] = 0; - nodep->mData[i] = mNull; - } - } - } - - // Last node in chain, so delete the last node - if (found - && !nodep->mNextNodep) - { - // delete the last item off the last node - nodep->mCount--; - - if (nodep->mCount == 0) - { - // We deleted the last element! - if (nodep != &mNodes[node_index]) - { - // Always have a prevp if we're not the head. - llassert(prevp); - - // Only blitz the node if it's not the head - // Set the previous node to point to NULL, then - // blitz the empty last node - prevp->mNextNodep = NULL; - delete nodep; - nodep = NULL; - } - } - - // Deleted last item in chain, so we're done. - return found; - } - - prevp = nodep; - nodep = nodep->mNextNodep; - } while (nodep); - - return found; -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMap<DATA_TYPE, SIZE>::removeIter(LLLocalIDHashMapIter<DATA_TYPE, SIZE> *iter) -{ - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - if (mIters[i] == iter) - { - mIters[i] = NULL; - mIterCount--; - return; - } - } - llerrs << "Iterator " << iter << " not found for removal in hash map!" << llendl; -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMap<DATA_TYPE, SIZE>::addIter(LLLocalIDHashMapIter<DATA_TYPE, SIZE> *iter) -{ - S32 i; - for (i = 0; i < MAX_ITERS; i++) - { - if (mIters[i] == NULL) - { - mIters[i] = iter; - mIterCount++; - return; - } - } - llerrs << "More than " << MAX_ITERS << " iterating over a map simultaneously!" << llendl; -} - - - -// -// LLLocalIDHashMapIter Implementation -// -template <class DATA_TYPE, int SIZE> -LLLocalIDHashMapIter<DATA_TYPE, SIZE>::LLLocalIDHashMapIter(LLLocalIDHashMap<DATA_TYPE, SIZE> *hash_mapp) -{ - mHashMapp = NULL; - setMap(hash_mapp); -} - -template <class DATA_TYPE, int SIZE> -LLLocalIDHashMapIter<DATA_TYPE, SIZE>::~LLLocalIDHashMapIter() -{ - if (mHashMapp) - { - mHashMapp->removeIter(this); - } -} - -template <class DATA_TYPE, int SIZE> -void LLLocalIDHashMapIter<DATA_TYPE, SIZE>::setMap(LLLocalIDHashMap<DATA_TYPE, SIZE> *hash_mapp) -{ - if (mHashMapp) - { - mHashMapp->removeIter(this); - } - mHashMapp = hash_mapp; - if (mHashMapp) - { - mHashMapp->addIter(this); - } - - mCurHashNodep = NULL; - mCurHashMapNodeNum = -1; - mCurHashNodeKey = 0; -} - -template <class DATA_TYPE, int SIZE> -inline void LLLocalIDHashMapIter<DATA_TYPE, SIZE>::first() -{ - // Iterate through until we find the first non-empty node; - S32 i; - for (i = 0; i < 256; i++) - { - if (mHashMapp->mNodes[i].mCount) - { - - mCurHashNodep = &mHashMapp->mNodes[i]; - mCurHashMapNodeNum = i; - mCurHashNodeKey = 0; - //return mCurHashNodep->mData[0]; - return; - } - } - - // Completely empty! - mCurHashNodep = NULL; - //return mNull; - return; -} - -template <class DATA_TYPE, int SIZE> -inline BOOL LLLocalIDHashMapIter<DATA_TYPE, SIZE>::done() const -{ - return mCurHashNodep ? FALSE : TRUE; -} - -template <class DATA_TYPE, int SIZE> -inline S32 LLLocalIDHashMapIter<DATA_TYPE, SIZE>::currentBin() const -{ - if ( (mCurHashMapNodeNum > 255) - ||(mCurHashMapNodeNum < 0)) - { - return 0; - } - else - { - return mCurHashMapNodeNum; - } -} - -template <class DATA_TYPE, int SIZE> -inline void LLLocalIDHashMapIter<DATA_TYPE, SIZE>::setBin(S32 bin) -{ - // Iterate through until we find the first non-empty node; - S32 i; - bin = llclamp(bin, 0, 255); - for (i = bin; i < 256; i++) - { - if (mHashMapp->mNodes[i].mCount) - { - - mCurHashNodep = &mHashMapp->mNodes[i]; - mCurHashMapNodeNum = i; - mCurHashNodeKey = 0; - return; - } - } - for (i = 0; i < bin; i++) - { - if (mHashMapp->mNodes[i].mCount) - { - - mCurHashNodep = &mHashMapp->mNodes[i]; - mCurHashMapNodeNum = i; - mCurHashNodeKey = 0; - return; - } - } - // Completely empty! - mCurHashNodep = NULL; -} - -template <class DATA_TYPE, int SIZE> -inline DATA_TYPE &LLLocalIDHashMapIter<DATA_TYPE, SIZE>::current() -{ - if (!mCurHashNodep) - { - return mNull; - } - return mCurHashNodep->mData[mCurHashNodeKey]; -} - -template <class DATA_TYPE, int SIZE> -inline void LLLocalIDHashMapIter<DATA_TYPE, SIZE>::next() -{ - // No current entry, this iterator is done - if (!mCurHashNodep) - { - //return mNull; - return; - } - - // Go to the next element - mCurHashNodeKey++; - if (mCurHashNodeKey < mCurHashNodep->mCount) - { - // We're not done with this node, return the current element - //return mCurHashNodep->mData[mCurHashNodeKey]; - return; - } - - // Done with this node, move to the next - mCurHashNodep = mCurHashNodep->mNextNodep; - if (mCurHashNodep) - { - // Return the first element - mCurHashNodeKey = 0; - //return mCurHashNodep->mData[0]; - return; - } - - // Find the next non-empty node (keyed on the first byte) - mCurHashMapNodeNum++; - - S32 i; - for (i = mCurHashMapNodeNum; i < 256; i++) - { - if (mHashMapp->mNodes[i].mCount) - { - // We found one that wasn't empty - mCurHashNodep = &mHashMapp->mNodes[i]; - mCurHashMapNodeNum = i; - mCurHashNodeKey = 0; - //return mCurHashNodep->mData[0]; - return; - } - } - - // OK, we're done, nothing else to iterate - mCurHashNodep = NULL; - mHashMapp->mIterCount--; // Decrement since we're safe to do removes now - //return mNull; - return; -} - -#endif // LL_LLLOCALIDHASHMAP_H diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index f03551045e..c83e55577d 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -166,52 +166,36 @@ protected: }; template<typename Type> -class LLCopyOnWritePointer +class LLCopyOnWritePointer : public LLPointer<Type> { public: typedef LLCopyOnWritePointer<Type> self_t; - + typedef LLPointer<Type> pointer_t; + LLCopyOnWritePointer() {} LLCopyOnWritePointer(Type* ptr) - : mPointer(ptr) + : LLPointer<Type>(ptr) {} LLCopyOnWritePointer(LLPointer<Type>& ptr) - : mPointer(ptr) + : LLPointer<Type>(ptr) {} Type* write() { makeUnique(); - return mPointer.get(); + return pointer_t::mPointer; } void makeUnique() { - if (mPointer.notNull() && mPointer.get()->getNumRefs() > 1) + if (pointer_t::notNull() && pointer_t::mPointer->getNumRefs() > 1) { - mPointer = new Type(*mPointer.get()); + *(pointer_t*)(this) = new Type(*pointer_t::mPointer); } } - - operator BOOL() const { return (BOOL)mPointer; } - operator bool() const { return (bool)mPointer; } - bool operator!() const { return !mPointer; } - bool isNull() const { return mPointer.isNull(); } - bool notNull() const { return mPointer.notNull(); } - - bool operator !=(Type* ptr) const { return (mPointer.get() != ptr); } - bool operator ==(Type* ptr) const { return (mPointer.get() == ptr); } - bool operator ==(const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer == ptr.mPointer); } - bool operator < (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer < ptr.mPointer); } - bool operator > (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer > ptr.mPointer); } - - operator const Type*() const { return mPointer.get(); } - const Type* operator->() const { return mPointer.get(); } -protected: - LLPointer<Type> mPointer; }; #endif diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 956642e97a..4339f203db 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -404,6 +404,7 @@ S32 LLQueuedThread::processNextRequest() QueuedRequest *req; // Get next request from pool lockData(); + while(1) { req = NULL; @@ -468,10 +469,11 @@ S32 LLQueuedThread::processNextRequest() ms_sleep(1); // sleep the thread a little } } + + LLTrace::get_thread_recorder()->pushToMaster(); } S32 pending = getPending(); - return pending; } @@ -500,6 +502,7 @@ void LLQueuedThread::run() if (isQuitting()) { + LLTrace::get_thread_recorder()->pushToMaster(); endThread(); break; } @@ -508,11 +511,9 @@ void LLQueuedThread::run() threadedUpdate(); - int res = processNextRequest(); - - LLTrace::get_thread_recorder()->pushToMaster(); + int pending_work = processNextRequest(); - if (res == 0) + if (pending_work == 0) { mIdleThread = TRUE; ms_sleep(1); diff --git a/indra/llcommon/llregistry.h b/indra/llcommon/llregistry.h index 853c427a13..9bb66d13dd 100644 --- a/indra/llcommon/llregistry.h +++ b/indra/llcommon/llregistry.h @@ -29,7 +29,6 @@ #include <list> -#include <boost/type_traits.hpp> #include "llsingleton.h" #include "llstl.h" @@ -47,12 +46,11 @@ template <typename KEY, typename VALUE, typename COMPARATOR = LLRegistryDefaultC class LLRegistry { public: - typedef LLRegistry<KEY, VALUE, COMPARATOR> registry_t; - typedef typename boost::add_reference<typename boost::add_const<KEY>::type>::type ref_const_key_t; - typedef typename boost::add_reference<typename boost::add_const<VALUE>::type>::type ref_const_value_t; - typedef typename boost::add_reference<VALUE>::type ref_value_t; - typedef typename boost::add_pointer<typename boost::add_const<VALUE>::type>::type ptr_const_value_t; - typedef typename boost::add_pointer<VALUE>::type ptr_value_t; + typedef LLRegistry<KEY, VALUE, COMPARATOR> registry_t; + typedef const KEY& ref_const_key_t; + typedef const VALUE& ref_const_value_t; + typedef const VALUE* ptr_const_value_t; + typedef VALUE* ptr_value_t; class Registrar { diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp index eb8e2c9456..9b49e52377 100644 --- a/indra/llcommon/llsingleton.cpp +++ b/indra/llcommon/llsingleton.cpp @@ -28,5 +28,4 @@ #include "llsingleton.h" -std::map<std::string, void *> * LLSingletonRegistry::sSingletonMap = NULL; diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index f6b0a7194b..b9cb8e3d41 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -30,38 +30,6 @@ #include <typeinfo> #include <boost/noncopyable.hpp> -/// @brief A global registry of all singletons to prevent duplicate allocations -/// across shared library boundaries -class LL_COMMON_API LLSingletonRegistry { - private: - typedef std::map<std::string, void *> TypeMap; - static TypeMap * sSingletonMap; - - static void checkInit() - { - if(sSingletonMap == NULL) - { - sSingletonMap = new TypeMap(); - } - } - - public: - template<typename T> static void * & get() - { - std::string name(typeid(T).name()); - - checkInit(); - - // the first entry of the pair returned by insert will be either the existing - // iterator matching our key, or the newly inserted NULL initialized entry - // see "Insert element" in http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html - TypeMap::iterator result = - sSingletonMap->insert(std::make_pair(name, (void*)NULL)).first; - - return result->second; - } -}; - // LLSingleton implements the getInstance() method part of the Singleton // pattern. It can't make the derived class constructors protected, though, so // you have to do that yourself. @@ -90,7 +58,7 @@ template <typename DERIVED_TYPE> class LLSingleton : private boost::noncopyable { -protected: +private: typedef enum e_init_state { UNINITIALIZED, @@ -99,22 +67,30 @@ protected: INITIALIZED, DELETED } EInitState; + + static DERIVED_TYPE* constructSingleton() + { + return new DERIVED_TYPE(); + } // stores pointer to singleton instance - // and tracks initialization state of singleton - struct SingletonInstanceData + struct SingletonLifetimeManager { - EInitState mInitState; - DERIVED_TYPE* mSingletonInstance; - - SingletonInstanceData() - : mSingletonInstance(NULL), - mInitState(UNINITIALIZED) - {} - - ~SingletonInstanceData() + SingletonLifetimeManager() { - if (mInitState != DELETED) + construct(); + } + + static void construct() + { + sData.mInitState = CONSTRUCTING; + sData.mInstance = constructSingleton(); + sData.mInitState = INITIALIZING; + } + + ~SingletonLifetimeManager() + { + if (sData.mInitState != DELETED) { deleteSingleton(); } @@ -124,9 +100,8 @@ protected: public: virtual ~LLSingleton() { - SingletonInstanceData& data = getSingletonData(); - data.mSingletonInstance = NULL; - data.mInitState = DELETED; + sData.mInstance = NULL; + sData.mInitState = DELETED; } /** @@ -151,42 +126,49 @@ public: */ static void deleteSingleton() { - SingletonInstanceData& data = getSingletonData(); - delete data.mSingletonInstance; - data.mSingletonInstance = NULL; - data.mInitState = DELETED; + delete sData.mInstance; + sData.mInstance = NULL; + sData.mInitState = DELETED; } + static DERIVED_TYPE* getInstance() { - SingletonInstanceData& data = getSingletonData(); + static SingletonLifetimeManager sLifeTimeMgr; - if (data.mInitState == CONSTRUCTING) + switch (sData.mInitState) { + case UNINITIALIZED: + // should never be uninitialized at this point + llassert(false); + return NULL; + case CONSTRUCTING: llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; - } - - if (data.mInitState == DELETED) - { + return NULL; + case INITIALIZING: + // go ahead and flag ourselves as initialized so we can be reentrant during initialization + sData.mInitState = INITIALIZED; + // initialize singleton after constructing it so that it can reference other singletons which in turn depend on it, + // thus breaking cyclic dependencies + sData.mInstance->initSingleton(); + return sData.mInstance; + case INITIALIZED: + return sData.mInstance; + case DELETED: llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; + SingletonLifetimeManager::construct(); + // same as first time construction + sData.mInitState = INITIALIZED; + sData.mInstance->initSingleton(); + return sData.mInstance; } - - if (!data.mSingletonInstance) - { - data.mInitState = CONSTRUCTING; - data.mSingletonInstance = new DERIVED_TYPE(); - data.mInitState = INITIALIZING; - data.mSingletonInstance->initSingleton(); - data.mInitState = INITIALIZED; - } - - return data.mSingletonInstance; + + return NULL; } static DERIVED_TYPE* getIfExists() { - SingletonInstanceData& data = getSingletonData(); - return data.mSingletonInstance; + return sData.mInstance; } // Reference version of getInstance() @@ -200,32 +182,31 @@ public: // Use this to avoid accessing singletons before the can safely be constructed static bool instanceExists() { - return getSingletonData().mInitState == INITIALIZED; + return sData.mInitState == INITIALIZED; } // Has this singleton already been deleted? // Use this to avoid accessing singletons from a static object's destructor static bool destroyed() { - return getSingletonData().mInitState == DELETED; + return sData.mInitState == DELETED; } private: - static SingletonInstanceData& getSingletonData() - { - // this is static to cache the lookup results - static void * & registry = LLSingletonRegistry::get<DERIVED_TYPE>(); - // *TODO - look into making this threadsafe - if(NULL == registry) - { - static SingletonInstanceData data; - registry = &data; - } - - return *static_cast<SingletonInstanceData *>(registry); - } virtual void initSingleton() {} + + struct SingletonData + { + // explicitly has a default constructor so that member variables are zero initialized in BSS + // and only changed by singleton logic, not constructor running during startup + EInitState mInitState; + DERIVED_TYPE* mInstance; + }; + static SingletonData sData; }; +template<typename T> +typename LLSingleton<T>::SingletonData LLSingleton<T>::sData; + #endif diff --git a/indra/llcommon/llsortedvector.h b/indra/llcommon/llsortedvector.h deleted file mode 100644 index 391b82ee44..0000000000 --- a/indra/llcommon/llsortedvector.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @file llsortedvector.h - * @author Nat Goodspeed - * @date 2012-04-08 - * @brief LLSortedVector class wraps a vector that we maintain in sorted - * order so we can perform binary-search lookups. - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Copyright (c) 2012, Linden Research, Inc. - * $/LicenseInfo$ - */ - -#if ! defined(LL_LLSORTEDVECTOR_H) -#define LL_LLSORTEDVECTOR_H - -#include <vector> -#include <algorithm> - -/** - * LLSortedVector contains a std::vector<std::pair> that we keep sorted on the - * first of the pair. This makes insertion somewhat more expensive than simple - * std::vector::push_back(), but allows us to use binary search for lookups. - * It's intended for small aggregates where lookup is far more performance- - * critical than insertion; in such cases a binary search on a small, sorted - * std::vector can be more performant than a std::map lookup. - */ -template <typename KEY, typename VALUE> -class LLSortedVector -{ -public: - typedef LLSortedVector<KEY, VALUE> self; - typedef KEY key_type; - typedef VALUE mapped_type; - typedef std::pair<key_type, mapped_type> value_type; - typedef std::vector<value_type> PairVector; - typedef typename PairVector::iterator iterator; - typedef typename PairVector::const_iterator const_iterator; - - /// Empty - LLSortedVector() {} - - /// Fixed initial size - LLSortedVector(std::size_t size): - mVector(size) - {} - - /// Bulk load - template <typename ITER> - LLSortedVector(ITER begin, ITER end): - mVector(begin, end) - { - // Allow caller to dump in a bunch of (pairs convertible to) - // value_type if desired, but make sure we sort afterwards. - std::sort(mVector.begin(), mVector.end()); - } - - /// insert(key, value) - std::pair<iterator, bool> insert(const key_type& key, const mapped_type& value) - { - return insert(value_type(key, value)); - } - - /// insert(value_type) - std::pair<iterator, bool> insert(const value_type& pair) - { - typedef std::pair<iterator, bool> iterbool; - iterator found = std::lower_bound(mVector.begin(), mVector.end(), pair, - less<value_type>()); - // have to check for end() before it's even valid to dereference - if (found == mVector.end()) - { - std::size_t index(mVector.size()); - mVector.push_back(pair); - // don't forget that push_back() invalidates 'found' - return iterbool(mVector.begin() + index, true); - } - if (found->first == pair.first) - { - return iterbool(found, false); - } - // remember that insert() invalidates 'found' -- save index - std::size_t index(found - mVector.begin()); - mVector.insert(found, pair); - // okay, convert from index back to iterator - return iterbool(mVector.begin() + index, true); - } - - iterator begin() { return mVector.begin(); } - iterator end() { return mVector.end(); } - const_iterator begin() const { return mVector.begin(); } - const_iterator end() const { return mVector.end(); } - - bool empty() const { return mVector.empty(); } - std::size_t size() const { return mVector.size(); } - - /// find - iterator find(const key_type& key) - { - iterator found = std::lower_bound(mVector.begin(), mVector.end(), - value_type(key, mapped_type()), - less<value_type>()); - if (found == mVector.end() || found->first != key) - return mVector.end(); - return found; - } - - const_iterator find(const key_type& key) const - { - return const_cast<self*>(this)->find(key); - } - -private: - // Define our own 'less' comparator so we can specialize without messing - // with std::less. - template <typename T> - struct less: public std::less<T> {}; - - // Specialize 'less' for an LLSortedVector::value_type involving - // std::type_info*. This is one of LLSortedVector's foremost use cases. We - // specialize 'less' rather than just defining a specific comparator - // because LLSortedVector should be usable for other key_types as well. - template <typename T> - struct less< std::pair<std::type_info*, T> >: - public std::binary_function<std::pair<std::type_info*, T>, - std::pair<std::type_info*, T>, - bool> - { - bool operator()(const std::pair<std::type_info*, T>& lhs, - const std::pair<std::type_info*, T>& rhs) const - { - return lhs.first->before(*rhs.first); - } - }; - - // Same as above, but with const std::type_info*. - template <typename T> - struct less< std::pair<const std::type_info*, T> >: - public std::binary_function<std::pair<const std::type_info*, T>, - std::pair<const std::type_info*, T>, - bool> - { - bool operator()(const std::pair<const std::type_info*, T>& lhs, - const std::pair<const std::type_info*, T>& rhs) const - { - return lhs.first->before(*rhs.first); - } - }; - - PairVector mVector; -}; - -#endif /* ! defined(LL_LLSORTEDVECTOR_H) */ diff --git a/indra/llcommon/llstack.h b/indra/llcommon/llstack.h deleted file mode 100644 index 315de6ba2d..0000000000 --- a/indra/llcommon/llstack.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file llstack.h - * @brief LLStack template class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLSTACK_H -#define LL_LLSTACK_H - -#include "linked_lists.h" - -template <class DATA_TYPE> class LLStack -{ -private: - LLLinkedList<DATA_TYPE> mStack; - -public: - LLStack() {} - ~LLStack() {} - - void push(DATA_TYPE *data) { mStack.addData(data); } - DATA_TYPE *pop() { DATA_TYPE *tempp = mStack.getFirstData(); mStack.removeCurrentData(); return tempp; } - void deleteAllData() { mStack.deleteAllData(); } - void removeAllNodes() { mStack.removeAllNodes(); } -}; - -#endif - diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 92323f5fda..f499beca80 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -91,15 +91,15 @@ private: BOOL mPaused; // static function passed to APR thread creation routine - static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap); + static void *APR_THREAD_FUNC staticRun(struct apr_thread_t *apr_threadp, void *datap); protected: std::string mName; class LLCondition* mRunCondition; LLMutex* mDataLock; - apr_thread_t *mAPRThreadp; - apr_pool_t *mAPRPoolp; + apr_thread_t* mAPRThreadp; + apr_pool_t* mAPRPoolp; BOOL mIsLocalPool; EThreadStatus mStatus; U32 mID; @@ -107,7 +107,7 @@ protected: //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao - LLVolatileAPRPool *mLocalAPRFilePoolp ; + LLVolatileAPRPool* mLocalAPRFilePoolp ; void setQuitting(); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2917c217d7..cced6546ba 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -40,37 +40,31 @@ namespace LLTrace /////////////////////////////////////////////////////////////////////// RecordingBuffers::RecordingBuffers() -: mCountsFloat(new AccumulatorBuffer<CountAccumulator<F64> >()), - mMeasurementsFloat(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), - mCounts(new AccumulatorBuffer<CountAccumulator<S64> >()), - mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<S64> >()), - mStackTimers(new AccumulatorBuffer<TimeBlockAccumulator>()), - mMemStats(new AccumulatorBuffer<MemStatAccumulator>()) {} void RecordingBuffers::handOffTo(RecordingBuffers& other) { - other.mCountsFloat.write()->reset(mCountsFloat); - other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); - other.mCounts.write()->reset(mCounts); - other.mMeasurements.write()->reset(mMeasurements); - other.mStackTimers.write()->reset(mStackTimers); - other.mMemStats.write()->reset(mMemStats); + other.mCountsFloat.reset(&mCountsFloat); + other.mMeasurementsFloat.reset(&mMeasurementsFloat); + other.mCounts.reset(&mCounts); + other.mMeasurements.reset(&mMeasurements); + other.mStackTimers.reset(&mStackTimers); + other.mMemStats.reset(&mMemStats); } void RecordingBuffers::makePrimary() { - mCountsFloat.write()->makePrimary(); - mMeasurementsFloat.write()->makePrimary(); - mCounts.write()->makePrimary(); - mMeasurements.write()->makePrimary(); - mStackTimers.write()->makePrimary(); - mMemStats.write()->makePrimary(); + mCountsFloat.makePrimary(); + mMeasurementsFloat.makePrimary(); + mCounts.makePrimary(); + mMeasurements.makePrimary(); + mStackTimers.makePrimary(); + mMemStats.makePrimary(); ThreadRecorder* thread_recorder = get_thread_recorder().get(); - AccumulatorBuffer<TimeBlockAccumulator>& timer_accumulator_buffer = *mStackTimers.write(); + AccumulatorBuffer<TimeBlockAccumulator>& timer_accumulator_buffer = mStackTimers; // update stacktimer parent pointers - for (S32 i = 0, end_i = mStackTimers->size(); i < end_i; i++) + for (S32 i = 0, end_i = mStackTimers.size(); i < end_i; i++) { TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); if (tree_node) @@ -82,46 +76,36 @@ void RecordingBuffers::makePrimary() bool RecordingBuffers::isPrimary() const { - return mCounts->isPrimary(); + return mCounts.isPrimary(); } -void RecordingBuffers::makeUnique() +void RecordingBuffers::append( const RecordingBuffers& other ) { - mCountsFloat.makeUnique(); - mMeasurementsFloat.makeUnique(); - mCounts.makeUnique(); - mMeasurements.makeUnique(); - mStackTimers.makeUnique(); - mMemStats.makeUnique(); + mCountsFloat.addSamples(other.mCountsFloat); + mMeasurementsFloat.addSamples(other.mMeasurementsFloat); + mCounts.addSamples(other.mCounts); + mMeasurements.addSamples(other.mMeasurements); + mMemStats.addSamples(other.mMemStats); + mStackTimers.addSamples(other.mStackTimers); } -void RecordingBuffers::appendBuffers( const RecordingBuffers& other ) +void RecordingBuffers::merge( const RecordingBuffers& other) { - mCountsFloat.write()->addSamples(*other.mCountsFloat); - mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); - mCounts.write()->addSamples(*other.mCounts); - mMeasurements.write()->addSamples(*other.mMeasurements); - mMemStats.write()->addSamples(*other.mMemStats); - mStackTimers.write()->addSamples(*other.mStackTimers); + mCountsFloat.addSamples(other.mCountsFloat); + mMeasurementsFloat.addSamples(other.mMeasurementsFloat); + mCounts.addSamples(other.mCounts); + mMeasurements.addSamples(other.mMeasurements); + mMemStats.addSamples(other.mMemStats); } -void RecordingBuffers::mergeBuffers( const RecordingBuffers& other) +void RecordingBuffers::reset(RecordingBuffers* other) { - mCountsFloat.write()->addSamples(*other.mCountsFloat); - mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); - mCounts.write()->addSamples(*other.mCounts); - mMeasurements.write()->addSamples(*other.mMeasurements); - mMemStats.write()->addSamples(*other.mMemStats); -} - -void RecordingBuffers::resetBuffers(RecordingBuffers* other) -{ - mCountsFloat.write()->reset(other ? other->mCountsFloat : LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > >()); - mMeasurementsFloat.write()->reset(other ? other->mMeasurementsFloat : LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > >()); - mCounts.write()->reset(other ? other->mCounts : LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > >()); - mMeasurements.write()->reset(other ? other->mMeasurements : LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > >()); - mStackTimers.write()->reset(other ? other->mStackTimers : LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> >()); - mMemStats.write()->reset(other ? other->mMemStats : LLCopyOnWritePointer<AccumulatorBuffer<MemStatAccumulator> >()); + mCountsFloat.reset(other ? &other->mCountsFloat : NULL); + mMeasurementsFloat.reset(other ? &other->mMeasurementsFloat : NULL); + mCounts.reset(other ? &other->mCounts : NULL); + mMeasurements.reset(other ? &other->mMeasurements : NULL); + mStackTimers.reset(other ? &other->mStackTimers : NULL); + mMemStats.reset(other ? &other->mMemStats : NULL); } /////////////////////////////////////////////////////////////////////// @@ -130,14 +114,24 @@ void RecordingBuffers::resetBuffers(RecordingBuffers* other) Recording::Recording() : mElapsedSeconds(0) -{} +{ + mBuffers = new RecordingBuffers(); +} Recording::Recording( const Recording& other ) -: RecordingBuffers(other), - mElapsedSeconds(other.mElapsedSeconds), - mSamplingTimer(other.mSamplingTimer) { - LLStopWatchControlsMixin<Recording>::setPlayState(other.getPlayState()); + Recording& mutable_other = const_cast<Recording&>(other); + EPlayState other_play_state = other.getPlayState(); + mutable_other.pause(); + + mBuffers = other.mBuffers; + + LLStopWatchControlsMixin<Recording>::setPlayState(other_play_state); + mutable_other.setPlayState(other_play_state); + + // above call will clear mElapsedSeconds as a side effect, so copy it here + mElapsedSeconds = other.mElapsedSeconds; + mSamplingTimer = other.mSamplingTimer; } @@ -158,7 +152,7 @@ void Recording::update() void Recording::handleReset() { - resetBuffers(); + mBuffers.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -179,44 +173,42 @@ void Recording::handleStop() void Recording::handleSplitTo(Recording& other) { - stop(); - other.restart(); - handOffTo(other); + mBuffers.write()->handOffTo(*other.mBuffers.write()); } void Recording::appendRecording( const Recording& other ) { - appendBuffers(other); + mBuffers.write()->append(*other.mBuffers); mElapsedSeconds += other.mElapsedSeconds; } void Recording::mergeRecording( const Recording& other) { - mergeBuffers(other); + mBuffers.write()->merge(*other.mBuffers); } LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator>& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond(); } U32 Recording::getSum(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const { - return (*mStackTimers)[stat.getIndex()].mCalls; + return mBuffers->mStackTimers[stat.getIndex()].mCalls; } LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mTotalTimeCounter - accumulator.mStartTotalTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); @@ -224,7 +216,7 @@ LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccu LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const { - const TimeBlockAccumulator& accumulator = (*mStackTimers)[stat.getIndex()]; + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return (F64)(accumulator.mSelfTimeCounter) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); @@ -232,45 +224,45 @@ LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccu F32 Recording::getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const { - return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; + return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds; } LLUnit<LLUnits::Bytes, U32> Recording::getSum(const TraceType<MemStatAccumulator>& stat) const { - return (*mMemStats)[stat.getIndex()].mAllocatedCount; + return mBuffers->mMemStats[stat.getIndex()].mAllocatedCount; } LLUnit<LLUnits::Bytes, F32> Recording::getPerSec(const TraceType<MemStatAccumulator>& stat) const { - return (F32)(*mMemStats)[stat.getIndex()].mAllocatedCount / mElapsedSeconds; + return (F32)mBuffers->mMemStats[stat.getIndex()].mAllocatedCount / mElapsedSeconds; } F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const { - return (*mCountsFloat)[stat.getIndex()].getSum(); + return mBuffers->mCountsFloat[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType<CountAccumulator<S64> >& stat ) const { - return (*mCounts)[stat.getIndex()].getSum(); + return mBuffers->mCounts[stat.getIndex()].getSum(); } F64 Recording::getSum( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (F64)(*mMeasurementsFloat)[stat.getIndex()].getSum(); + return (F64)mBuffers->mMeasurementsFloat[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (S64)(*mMeasurements)[stat.getIndex()].getSum(); + return (S64)mBuffers->mMeasurements[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const { - F64 sum = (*mCountsFloat)[stat.getIndex()].getSum(); + F64 sum = mBuffers->mCountsFloat[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -278,7 +270,7 @@ F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const { - S64 sum = (*mCounts)[stat.getIndex()].getSum(); + S64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; @@ -286,72 +278,72 @@ F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const U32 Recording::getSampleCount( const TraceType<CountAccumulator<F64> >& stat ) const { - return (*mCountsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType<CountAccumulator<S64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); } F64 Recording::getMin( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMin(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMin(); } S64 Recording::getMin( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMin(); + return mBuffers->mMeasurements[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMax(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMax(); } S64 Recording::getMax( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMax(); + return mBuffers->mMeasurements[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getMean(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getMean(); } F64 Recording::getMean( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getMean(); + return mBuffers->mMeasurements[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getStandardDeviation(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getStandardDeviation(); } F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getStandardDeviation(); + return mBuffers->mMeasurements[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getLastValue(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getLastValue(); } S64 Recording::getLastValue( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getLastValue(); + return mBuffers->mMeasurements[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurementsFloat[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (*mMeasurements)[stat.getIndex()].getSampleCount(); + return mBuffers->mMeasurements[stat.getIndex()].getSampleCount(); } /////////////////////////////////////////////////////////////////////// @@ -360,152 +352,187 @@ U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& st PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state) : mAutoResize(num_periods == 0), - mCurPeriod(0) + mCurPeriod(0), + mRecordingPeriods(num_periods ? num_periods : 1) { - if (num_periods) - { - mRecordingPeriods.resize(num_periods); - } setPlayState(state); } void PeriodicRecording::nextPeriod() { - EPlayState play_state = getPlayState(); - Recording& old_recording = getCurRecording(); if (mAutoResize) { mRecordingPeriods.push_back(Recording()); } - U32 num_periods = mRecordingPeriods.size(); - mCurPeriod = (num_periods > 0) - ? (mCurPeriod + 1) % num_periods - : mCurPeriod + 1; - old_recording.splitTo(getCurRecording()); - switch(play_state) - { - case STOPPED: - getCurRecording().stop(); - break; - case PAUSED: - getCurRecording().pause(); - break; - case STARTED: - break; - } + Recording& old_recording = getCurRecording(); + + mCurPeriod = (mCurPeriod + 1) % mRecordingPeriods.size(); + old_recording.splitTo(getCurRecording()); } void PeriodicRecording::appendPeriodicRecording( PeriodicRecording& other ) { - if (other.mRecordingPeriods.size() < 2) return; + if (other.mRecordingPeriods.empty()) return; EPlayState play_state = getPlayState(); - pause(); + stop(); EPlayState other_play_state = other.getPlayState(); other.pause(); - if (mAutoResize) - { - // copy everything after current period of other recording to end of buffer - // this will only apply if other recording is using a fixed circular buffer - if (other.mCurPeriod < other.mRecordingPeriods.size() - 1) - { - std::copy( other.mRecordingPeriods.begin() + other.mCurPeriod + 1, - other.mRecordingPeriods.end(), - std::back_inserter(mRecordingPeriods)); - } + U32 other_recording_count = other.mRecordingPeriods.size(); - // copy everything from beginning of other recording's buffer up to, but not including - // current period - std::copy( other.mRecordingPeriods.begin(), - other.mRecordingPeriods.begin() + other.mCurPeriod, - std::back_inserter(mRecordingPeriods)); + Recording& other_oldest_recording = other.mRecordingPeriods[(other.mCurPeriod + 1) % other.mRecordingPeriods.size()]; - mCurPeriod = mRecordingPeriods.size() - 1; + // if I have a recording of any length, then close it off and start a fresh one + if (getCurRecording().getDuration().value()) + { + nextPeriod(); } - else + getCurRecording().appendRecording(other_oldest_recording); + + if (other_recording_count > 1) { - size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() ); - std::vector<Recording>::iterator src_it = other.mRecordingPeriods.begin() - + ( (other.mCurPeriod + 1) // cur period - + (other.mRecordingPeriods.size() - num_to_copy) // minus room for copy - % other.mRecordingPeriods.size()); - std::vector<Recording>::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); - - for(S32 i = 0; i < num_to_copy; i++) + if (mAutoResize) { - *dest_it = *src_it; - - if (++src_it == other.mRecordingPeriods.end()) + for (S32 other_index = (other.mCurPeriod + 2) % other_recording_count; + other_index != other.mCurPeriod; + other_index = (other_index + 1) % other_recording_count) { - src_it = other.mRecordingPeriods.begin(); + llassert(other.mRecordingPeriods[other_index].getDuration() != 0.f + && (mRecordingPeriods.empty() + || other.mRecordingPeriods[other_index].getDuration() != mRecordingPeriods.back().getDuration())); + mRecordingPeriods.push_back(other.mRecordingPeriods[other_index]); } - if (++dest_it == mRecordingPeriods.end()) + mCurPeriod = mRecordingPeriods.size() - 1; + } + else + { + size_t num_to_copy = llmin( mRecordingPeriods.size(), other.mRecordingPeriods.size() - 1); + std::vector<Recording>::iterator src_it = other.mRecordingPeriods.begin() + + ( (other.mCurPeriod + 1 // oldest period + + (other.mRecordingPeriods.size() - num_to_copy)) // minus room for copy + % other.mRecordingPeriods.size()); + std::vector<Recording>::iterator dest_it = mRecordingPeriods.begin() + ((mCurPeriod + 1) % mRecordingPeriods.size()); + + for(S32 i = 0; i < num_to_copy; i++) { - dest_it = mRecordingPeriods.begin(); + *dest_it = *src_it; + + if (++src_it == other.mRecordingPeriods.end()) + { + src_it = other.mRecordingPeriods.begin(); + } + + if (++dest_it == mRecordingPeriods.end()) + { + dest_it = mRecordingPeriods.begin(); + } } - } - mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); + mCurPeriod = (mCurPeriod + num_to_copy) % mRecordingPeriods.size(); + } } - // if copying from periodic recording that wasn't active advance our period to the next available one - // otherwise continue recording on top of the last period of data received from the other recording - if (other_play_state != STARTED) - { - nextPeriod(); - } + nextPeriod(); setPlayState(play_state); other.setPlayState(other_play_state); } +LLUnit<LLUnits::Seconds, F64> PeriodicRecording::getDuration() +{ + LLUnit<LLUnits::Seconds, F64> duration; + size_t num_periods = mRecordingPeriods.size(); + for (size_t i = 1; i <= num_periods; i++) + { + size_t index = (mCurPeriod + num_periods - i) % num_periods; + duration += mRecordingPeriods[index].getDuration(); + } + return duration; +} -void PeriodicRecording::start() +LLTrace::Recording PeriodicRecording::snapshotCurRecording() const { - getCurRecording().start(); + Recording recording_copy(getCurRecording()); + recording_copy.stop(); + return recording_copy; } -void PeriodicRecording::stop() + +Recording& PeriodicRecording::getLastRecording() { - getCurRecording().stop(); + U32 num_periods = mRecordingPeriods.size(); + return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; } -void PeriodicRecording::pause() +const Recording& PeriodicRecording::getLastRecording() const { - getCurRecording().pause(); + return getPrevRecording(1); } -void PeriodicRecording::resume() +Recording& PeriodicRecording::getCurRecording() { - getCurRecording().resume(); + return mRecordingPeriods[mCurPeriod]; } -void PeriodicRecording::restart() +const Recording& PeriodicRecording::getCurRecording() const { - getCurRecording().restart(); + return mRecordingPeriods[mCurPeriod]; } -void PeriodicRecording::reset() +Recording& PeriodicRecording::getPrevRecording( U32 offset ) { - getCurRecording().reset(); + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; } -void PeriodicRecording::splitTo(PeriodicRecording& other) +const Recording& PeriodicRecording::getPrevRecording( U32 offset ) const { - getCurRecording().splitTo(other.getCurRecording()); + U32 num_periods = mRecordingPeriods.size(); + offset = llclamp(offset, 0u, num_periods - 1); + return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; +} + +void PeriodicRecording::handleStart() +{ + getCurRecording().start(); +} + +void PeriodicRecording::handleStop() +{ + getCurRecording().pause(); } -void PeriodicRecording::splitFrom(PeriodicRecording& other) +void PeriodicRecording::handleReset() { - getCurRecording().splitFrom(other.getCurRecording()); + if (mAutoResize) + { + mRecordingPeriods.clear(); + mRecordingPeriods.push_back(Recording()); + } + else + { + for (std::vector<Recording>::iterator it = mRecordingPeriods.begin(), end_it = mRecordingPeriods.end(); + it != end_it; + ++it) + { + it->reset(); + } + } + mCurPeriod = 0; + getCurRecording().setPlayState(getPlayState()); } +void PeriodicRecording::handleSplitTo(PeriodicRecording& other) +{ + getCurRecording().splitTo(other.getCurRecording()); +} /////////////////////////////////////////////////////////////////////// // ExtendableRecording @@ -523,64 +550,43 @@ void ExtendableRecording::extend() mPotentialRecording.setPlayState(getPlayState()); } -void ExtendableRecording::start() +void ExtendableRecording::handleStart() { - LLStopWatchControlsMixin<ExtendableRecording>::start(); mPotentialRecording.start(); } -void ExtendableRecording::stop() +void ExtendableRecording::handleStop() { - LLStopWatchControlsMixin<ExtendableRecording>::stop(); - mPotentialRecording.stop(); -} - -void ExtendableRecording::pause() -{ - LLStopWatchControlsMixin<ExtendableRecording>::pause(); mPotentialRecording.pause(); } -void ExtendableRecording::resume() +void ExtendableRecording::handleReset() { - LLStopWatchControlsMixin<ExtendableRecording>::resume(); - mPotentialRecording.resume(); -} - -void ExtendableRecording::restart() -{ - LLStopWatchControlsMixin<ExtendableRecording>::restart(); - mAcceptedRecording.reset(); - mPotentialRecording.restart(); -} - -void ExtendableRecording::reset() -{ - LLStopWatchControlsMixin<ExtendableRecording>::reset(); mAcceptedRecording.reset(); mPotentialRecording.reset(); } -void ExtendableRecording::splitTo(ExtendableRecording& other) +void ExtendableRecording::handleSplitTo(ExtendableRecording& other) { - LLStopWatchControlsMixin<ExtendableRecording>::splitTo(other); mPotentialRecording.splitTo(other.mPotentialRecording); } -void ExtendableRecording::splitFrom(ExtendableRecording& other) -{ - LLStopWatchControlsMixin<ExtendableRecording>::splitFrom(other); - mPotentialRecording.splitFrom(other.mPotentialRecording); -} /////////////////////////////////////////////////////////////////////// // ExtendablePeriodicRecording /////////////////////////////////////////////////////////////////////// + +ExtendablePeriodicRecording::ExtendablePeriodicRecording() +: mAcceptedRecording(0), + mPotentialRecording(0) +{} + void ExtendablePeriodicRecording::extend() { + llassert(mPotentialRecording.getPlayState() == getPlayState()); // stop recording to get latest data - mPotentialRecording.stop(); + mPotentialRecording.pause(); // push the data back to accepted recording mAcceptedRecording.appendPeriodicRecording(mPotentialRecording); // flush data, so we can start from scratch @@ -589,55 +595,28 @@ void ExtendablePeriodicRecording::extend() mPotentialRecording.setPlayState(getPlayState()); } -void ExtendablePeriodicRecording::start() -{ - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::start(); - mPotentialRecording.start(); -} -void ExtendablePeriodicRecording::stop() +void ExtendablePeriodicRecording::handleStart() { - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::stop(); - mPotentialRecording.stop(); + mPotentialRecording.start(); } -void ExtendablePeriodicRecording::pause() +void ExtendablePeriodicRecording::handleStop() { - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::pause(); mPotentialRecording.pause(); } -void ExtendablePeriodicRecording::resume() +void ExtendablePeriodicRecording::handleReset() { - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::resume(); - mPotentialRecording.resume(); -} - -void ExtendablePeriodicRecording::restart() -{ - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::restart(); - mAcceptedRecording.reset(); - mPotentialRecording.restart(); -} - -void ExtendablePeriodicRecording::reset() -{ - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::reset(); mAcceptedRecording.reset(); mPotentialRecording.reset(); } -void ExtendablePeriodicRecording::splitTo(ExtendablePeriodicRecording& other) +void ExtendablePeriodicRecording::handleSplitTo(ExtendablePeriodicRecording& other) { - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::splitTo(other); mPotentialRecording.splitTo(other.mPotentialRecording); } -void ExtendablePeriodicRecording::splitFrom(ExtendablePeriodicRecording& other) -{ - LLStopWatchControlsMixin<ExtendablePeriodicRecording>::splitFrom(other); - mPotentialRecording.splitFrom(other.mPotentialRecording); -} PeriodicRecording& get_frame_recording() { @@ -675,7 +654,6 @@ void LLStopWatchControlsMixinCommon::stop() case STOPPED: break; case PAUSED: - handleStop(); break; case STARTED: handleStop(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 23b031b49b..b339e72e5c 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -46,12 +46,12 @@ public: STARTED }; - virtual void start(); - virtual void stop(); - virtual void pause(); - virtual void resume(); - virtual void restart(); - virtual void reset(); + void start(); + void stop(); + void pause(); + void resume(); + void restart(); + void reset(); bool isStarted() const { return mPlayState == STARTED; } bool isPaused() const { return mPlayState == PAUSED; } @@ -67,11 +67,11 @@ protected: private: // trigger active behavior (without reset) - virtual void handleStart(){}; + virtual void handleStart() = 0; // stop active behavior - virtual void handleStop(){}; + virtual void handleStop() = 0; // clear accumulated state, can be called while started - virtual void handleReset(){}; + virtual void handleReset() = 0; EPlayState mPlayState; }; @@ -84,7 +84,13 @@ public: typedef LLStopWatchControlsMixin<DERIVED> self_t; virtual void splitTo(DERIVED& other) { + EPlayState play_state = getPlayState(); + stop(); + other.reset(); + handleSplitTo(other); + + other.setPlayState(play_state); } virtual void splitFrom(DERIVED& other) @@ -100,31 +106,28 @@ private: namespace LLTrace { - class RecordingBuffers + struct RecordingBuffers : public LLRefCount { - public: RecordingBuffers(); void handOffTo(RecordingBuffers& other); void makePrimary(); bool isPrimary() const; - void makeUnique(); + void append(const RecordingBuffers& other); + void merge(const RecordingBuffers& other); + void reset(RecordingBuffers* other = NULL); - void appendBuffers(const RecordingBuffers& other); - void mergeBuffers(const RecordingBuffers& other); - void resetBuffers(RecordingBuffers* other = NULL); - - protected: - LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > > mCountsFloat; - LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurementsFloat; - LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > > mCounts; - LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > > mMeasurements; - LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> > mStackTimers; - LLCopyOnWritePointer<AccumulatorBuffer<MemStatAccumulator> > mMemStats; + AccumulatorBuffer<CountAccumulator<F64> > mCountsFloat; + AccumulatorBuffer<MeasurementAccumulator<F64> > mMeasurementsFloat; + AccumulatorBuffer<CountAccumulator<S64> > mCounts; + AccumulatorBuffer<MeasurementAccumulator<S64> > mMeasurements; + AccumulatorBuffer<TimeBlockAccumulator> mStackTimers; + AccumulatorBuffer<MemStatAccumulator> mMemStats; }; - class Recording : public LLStopWatchControlsMixin<Recording>, public RecordingBuffers + class Recording + : public LLStopWatchControlsMixin<Recording> { public: Recording(); @@ -141,6 +144,9 @@ namespace LLTrace // grab latest recorded data void update(); + // ensure that buffers are exclusively owned by this recording + void makeUnique() { mBuffers.makeUnique(); } + // Timer accessors LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimeBlockAccumulator>& stat) const; LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const; @@ -229,7 +235,7 @@ namespace LLTrace LLUnit<LLUnits::Seconds, F64> getDuration() const { return LLUnit<LLUnits::Seconds, F64>(mElapsedSeconds); } - private: + protected: friend class ThreadRecorder; // implementation for LLStopWatchControlsMixin @@ -241,8 +247,9 @@ namespace LLTrace // returns data for current thread class ThreadRecorder* getThreadRecorder(); - LLTimer mSamplingTimer; - F64 mElapsedSeconds; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + LLCopyOnWritePointer<RecordingBuffers> mBuffers; }; class LL_COMMON_API PeriodicRecording @@ -254,49 +261,16 @@ namespace LLTrace void nextPeriod(); U32 getNumPeriods() { return mRecordingPeriods.size(); } - void appendPeriodicRecording(PeriodicRecording& other); - - Recording& getLastRecording() - { - U32 num_periods = mRecordingPeriods.size(); - return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods]; - } - - const Recording& getLastRecording() const - { - return getPrevRecording(1); - } + LLUnit<LLUnits::Seconds, F64> getDuration(); - Recording& getCurRecording() - { - return mRecordingPeriods[mCurPeriod]; - } - - const Recording& getCurRecording() const - { - return mRecordingPeriods[mCurPeriod]; - } - - Recording& getPrevRecording(U32 offset) - { - U32 num_periods = mRecordingPeriods.size(); - offset = llclamp(offset, 0u, num_periods - 1); - return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; - } - - const Recording& getPrevRecording(U32 offset) const - { - U32 num_periods = mRecordingPeriods.size(); - offset = llclamp(offset, 0u, num_periods - 1); - return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods]; - } - - Recording snapshotCurRecording() const - { - Recording recording_copy(getCurRecording()); - recording_copy.stop(); - return recording_copy; - } + void appendPeriodicRecording(PeriodicRecording& other); + Recording& getLastRecording(); + const Recording& getLastRecording() const; + Recording& getCurRecording(); + const Recording& getCurRecording() const; + Recording& getPrevRecording(U32 offset); + const Recording& getPrevRecording(U32 offset) const; + Recording snapshotCurRecording() const; template <typename T> typename T::value_t getPeriodMin(const TraceType<T>& stat, size_t num_periods = U32_MAX) const @@ -400,15 +374,12 @@ namespace LLTrace return mean; } + private: // implementation for LLStopWatchControlsMixin - /*virtual*/ void start(); - /*virtual*/ void stop(); - /*virtual*/ void pause(); - /*virtual*/ void resume(); - /*virtual*/ void restart(); - /*virtual*/ void reset(); - /*virtual*/ void splitTo(PeriodicRecording& other); - /*virtual*/ void splitFrom(PeriodicRecording& other); + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); + /*virtual*/ void handleSplitTo(PeriodicRecording& other); private: std::vector<Recording> mRecordingPeriods; @@ -428,15 +399,15 @@ namespace LLTrace Recording& getAcceptedRecording() { return mAcceptedRecording; } const Recording& getAcceptedRecording() const {return mAcceptedRecording;} + Recording& getPotentialRecording() { return mPotentialRecording; } + const Recording& getPotentialRecording() const { return mPotentialRecording;} + + private: // implementation for LLStopWatchControlsMixin - /*virtual*/ void start(); - /*virtual*/ void stop(); - /*virtual*/ void pause(); - /*virtual*/ void resume(); - /*virtual*/ void restart(); - /*virtual*/ void reset(); - /*virtual*/ void splitTo(ExtendableRecording& other); - /*virtual*/ void splitFrom(ExtendableRecording& other); + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); + /*virtual*/ void handleSplitTo(ExtendableRecording& other); private: Recording mAcceptedRecording; @@ -447,20 +418,21 @@ namespace LLTrace : public LLStopWatchControlsMixin<ExtendablePeriodicRecording> { public: + ExtendablePeriodicRecording(); void extend(); - PeriodicRecording& getAcceptedRecording() { return mAcceptedRecording; } - const PeriodicRecording& getAcceptedRecording() const {return mAcceptedRecording;} + PeriodicRecording& getAcceptedRecording() { return mAcceptedRecording; } + const PeriodicRecording& getAcceptedRecording() const {return mAcceptedRecording;} + + PeriodicRecording& getPotentialRecording() { return mPotentialRecording; } + const PeriodicRecording& getPotentialRecording() const {return mPotentialRecording;} + private: // implementation for LLStopWatchControlsMixin - /*virtual*/ void start(); - /*virtual*/ void stop(); - /*virtual*/ void pause(); - /*virtual*/ void resume(); - /*virtual*/ void restart(); - /*virtual*/ void reset(); - /*virtual*/ void splitTo(ExtendablePeriodicRecording& other); - /*virtual*/ void splitFrom(ExtendablePeriodicRecording& other); + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); + /*virtual*/ void handleSplitTo(ExtendablePeriodicRecording& other); private: PeriodicRecording mAcceptedRecording; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 9bef040cf7..2001b9cd7f 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -118,7 +118,7 @@ ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::update( Record if (next_it != mActiveRecordings.end()) { // ...push our gathered data down to it - (*next_it)->mPartialRecording.appendBuffers((*it)->mPartialRecording); + (*next_it)->mPartialRecording.append((*it)->mPartialRecording); } // copy accumulated measurements into result buffer and clear accumulator (mPartialRecording) @@ -156,7 +156,7 @@ void ThreadRecorder::deactivate( Recording* recording ) ++next_it; if (next_it != mActiveRecordings.end()) { - (*next_it)->mTargetRecording->makePrimary(); + (*next_it)->mTargetRecording->mBuffers.write()->makePrimary(); } delete *it; @@ -171,8 +171,8 @@ ThreadRecorder::ActiveRecording::ActiveRecording( Recording* target ) void ThreadRecorder::ActiveRecording::moveBaselineToTarget() { - mTargetRecording->appendBuffers(mPartialRecording); - mPartialRecording.resetBuffers(); + mTargetRecording->mBuffers.write()->append(mPartialRecording); + mPartialRecording.reset(); } @@ -203,31 +203,31 @@ void SlaveThreadRecorder::pushToMaster() void SlaveThreadRecorder::SharedData::appendFrom( const Recording& source ) { LLMutexLock lock(&mRecordingMutex); - mRecording.appendRecording(source); + appendRecording(source); } void SlaveThreadRecorder::SharedData::appendTo( Recording& sink ) { LLMutexLock lock(&mRecordingMutex); - sink.appendRecording(mRecording); + sink.appendRecording(*this); } void SlaveThreadRecorder::SharedData::mergeFrom( const RecordingBuffers& source ) { LLMutexLock lock(&mRecordingMutex); - mRecording.mergeBuffers(source); + mBuffers.write()->merge(source); } void SlaveThreadRecorder::SharedData::mergeTo( RecordingBuffers& sink ) { LLMutexLock lock(&mRecordingMutex); - sink.mergeBuffers(mRecording); + sink.merge(*mBuffers); } void SlaveThreadRecorder::SharedData::reset() { LLMutexLock lock(&mRecordingMutex); - mRecording.reset(); + Recording::reset(); } diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 3e24303d92..c44bcbd12d 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -106,7 +106,7 @@ namespace LLTrace MasterThreadRecorder* mMaster; - class SharedData + class SharedData : public Recording { public: void appendFrom(const Recording& source); @@ -116,7 +116,6 @@ namespace LLTrace void reset(); private: LLMutex mRecordingMutex; - Recording mRecording; }; SharedData mSharedData; }; diff --git a/indra/llcommon/lltypeinfolookup.h b/indra/llcommon/lltypeinfolookup.h deleted file mode 100644 index 0b6862444e..0000000000 --- a/indra/llcommon/lltypeinfolookup.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file lltypeinfolookup.h - * @author Nat Goodspeed - * @date 2012-04-08 - * @brief Template data structure like std::map<std::type_info*, T> - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Copyright (c) 2012, Linden Research, Inc. - * $/LicenseInfo$ - */ - -#if ! defined(LL_LLTYPEINFOLOOKUP_H) -#define LL_LLTYPEINFOLOOKUP_H - -#include <boost/unordered_map.hpp> -#include <boost/functional/hash.hpp> -#include <boost/optional.hpp> -#include <functional> // std::binary_function -#include <typeinfo> - -/** - * The following helper classes are based on the Boost.Unordered documentation: - * http://www.boost.org/doc/libs/1_45_0/doc/html/unordered/hash_equality.html - */ - -/** - * Compute hash for a string passed as const char* - */ -struct const_char_star_hash: public std::unary_function<const char*, std::size_t> -{ - std::size_t operator()(const char* str) const - { - std::size_t seed = 0; - for ( ; *str; ++str) - { - boost::hash_combine(seed, *str); - } - return seed; - } -}; - -/** - * Compute equality for strings passed as const char* - * - * I (nat) suspect that this is where the default behavior breaks for the - * const char* values returned from std::type_info::name(). If you compare the - * two const char* pointer values, as a naive, unspecialized implementation - * will surely do, they'll compare unequal. - */ -struct const_char_star_equal: public std::binary_function<const char*, const char*, bool> -{ - bool operator()(const char* lhs, const char* rhs) const - { - return strcmp(lhs, rhs) == 0; - } -}; - -/** - * LLTypeInfoLookup is specifically designed for use cases for which you might - * consider std::map<std::type_info*, VALUE>. We have several such data - * structures in the viewer. The trouble with them is that at least on Linux, - * you can't rely on always getting the same std::type_info* for a given type: - * different load modules will produce different std::type_info*. - * LLTypeInfoLookup contains a workaround to address this issue. - * - * The API deliberately diverges from std::map in several respects: - * * It avoids iterators, not only begin()/end() but also as return values - * from insert() and find(). This bypasses transform_iterator overhead. - * * Since we literally use compile-time types as keys, the essential insert() - * and find() methods accept the key type as a @em template parameter, - * accepting and returning value_type as a normal runtime value. This is to - * permit future optimization (e.g. compile-time type hashing) without - * changing the API. - */ -template <typename VALUE> -class LLTypeInfoLookup -{ - // Use this for our underlying implementation: lookup by - // std::type_info::name() string. This is one of the rare cases in which I - // dare use const char* directly, rather than std::string, because I'm - // sure that every value returned by std::type_info::name() is static. - // HOWEVER, specify our own hash + equality functors: naively comparing - // distinct const char* values won't work. - typedef boost::unordered_map<const char*, VALUE, - const_char_star_hash, const_char_star_equal> impl_map_type; - -public: - typedef VALUE value_type; - - LLTypeInfoLookup() {} - - bool empty() const { return mMap.empty(); } - std::size_t size() const { return mMap.size(); } - - template <typename KEY> - bool insert(const value_type& value) - { - // Obtain and store the std::type_info::name() string as the key. - // Return just the bool from std::map::insert()'s return pair. - return mMap.insert(typename impl_map_type::value_type(typeid(KEY).name(), value)).second; - } - - template <typename KEY> - boost::optional<value_type> find() const - { - // Use the std::type_info::name() string as the key. - typename impl_map_type::const_iterator found = mMap.find(typeid(KEY).name()); - if (found == mMap.end()) - return boost::optional<value_type>(); - return found->second; - } - -private: - impl_map_type mMap; -}; - -#endif /* ! defined(LL_LLTYPEINFOLOOKUP_H) */ diff --git a/indra/llcommon/metaclass.cpp b/indra/llcommon/metaclass.cpp deleted file mode 100644 index 5e403511cf..0000000000 --- a/indra/llcommon/metaclass.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file metaclass.cpp - * @author Babbage - * @date 2006-05-15 - * @brief Implementation of LLMetaClass - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#include "linden_common.h" - -#include "metaclass.h" - -#include "metaproperty.h" -#include "reflective.h" - -LLMetaClass::LLMetaClass() -{ -} - -//virtual -LLMetaClass::~LLMetaClass() -{ -} - -const LLMetaProperty* LLMetaClass::findProperty(const std::string& name) const -{ - PropertyIterator iter = mProperties.find(name); - if(iter == mProperties.end()) - { - return NULL; - } - return (*iter).second; -} - -void LLMetaClass::addProperty(const LLMetaProperty* property) -{ - mProperties.insert(std::make_pair(property->getName(), property)); -} - -U32 LLMetaClass::getPropertyCount() const -{ - return mProperties.size(); -} - -LLMetaClass::PropertyIterator LLMetaClass::beginProperties() const -{ - return mProperties.begin(); -} - -LLMetaClass::PropertyIterator LLMetaClass::endProperties() const -{ - return mProperties.end(); -} - -bool LLMetaClass::isInstance(const LLReflective* object) const -{ - // TODO: Babbage: Search through super classes of objects MetaClass. - const LLMetaClass* object_meta_class = &(object->getMetaClass()); - return (object_meta_class == this); -} - diff --git a/indra/llcommon/metaclass.h b/indra/llcommon/metaclass.h deleted file mode 100644 index 626757d58d..0000000000 --- a/indra/llcommon/metaclass.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @file metaclass.h - * @author Babbage - * @date 2006-05-15 - * @brief Reflective meta information describing a class. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_METACLASS_H -#define LL_METACLASS_H - -#include <string> -#include <map> - -#include "stdtypes.h" - -class LLReflective; -class LLMetaProperty; -class LLMetaMethod; -class LL_COMMON_API LLMetaClass -{ -public: - - LLMetaClass(); - virtual ~LLMetaClass(); - - // Create instance of this MetaClass. NULL if class is abstract. - // Gives ownership of returned object. - // virtual LLReflective* create() const = 0; - - // Returns named property or NULL. - const LLMetaProperty* findProperty(const std::string& name) const; - - // Add property to metaclass. Takes ownership of given property. - void addProperty(const LLMetaProperty* property); - - typedef std::map<std::string, const LLMetaProperty*>::const_iterator PropertyIterator; - - U32 getPropertyCount() const; - - PropertyIterator beginProperties() const; - PropertyIterator endProperties() const; - - // Returns named property or NULL. - // const LLMetaMethod* findMethod(const std::string& name) const; - - // Add method to metaclass. Takes ownership of given method. - // void addMethod(const LLMetaMethod* method); - - // Find MetaClass by name. NULL if name is unknown. - // static LLMetaClass* findClass(const std::string& name); - - // True if object is instance of this meta class. - bool isInstance(const LLReflective* object) const; - -private: - - typedef std::map<std::string, const LLMetaProperty*> PropertyMap; - PropertyMap mProperties; -}; - -#endif // LL_METACLASS_H diff --git a/indra/llcommon/metaclasst.h b/indra/llcommon/metaclasst.h deleted file mode 100644 index b9a7ae219d..0000000000 --- a/indra/llcommon/metaclasst.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file metaclasst.h - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_METACLASST_H -#define LL_METACLASST_H - -#include "metaclass.h" - -template<class TObject> -class LLMetaClassT : public LLMetaClass -{ - public: - - virtual ~LLMetaClassT() {;} - - static const LLMetaClassT& instance() - { - static const LLMetaClassT& instance = buildMetaClass(); - return instance; - } - - private: - - static const LLMetaClassT& buildMetaClass() - { - LLMetaClassT& meta_class = *(new LLMetaClassT()); - reflectProperties(meta_class); - return meta_class; - } - - LLMetaClassT() {;} - - static void reflectProperties(LLMetaClass&) - { - } -}; - -#endif // LL_METACLASST_H diff --git a/indra/llcommon/metaproperty.cpp b/indra/llcommon/metaproperty.cpp deleted file mode 100644 index 98d850bf1e..0000000000 --- a/indra/llcommon/metaproperty.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file metaproperty.cpp - * @author Babbage - * @date 2006-05-15 - * @brief Implementation of LLMetaProperty. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#include "linden_common.h" - -#include "metaproperty.h" - -#include "metaclass.h" - -LLMetaProperty::LLMetaProperty(const std::string& name, const LLMetaClass& object_class) : - mName(name), mObjectClass(object_class) -{ -} - -//virtual -LLMetaProperty::~LLMetaProperty() -{ -} - -const LLMetaClass& LLMetaProperty::getObjectMetaClass() const -{ - return mObjectClass; -} - -void LLMetaProperty::checkObjectClass(const LLReflective* object) const -{ - if(! mObjectClass.isInstance(object)) - { - throw "class cast exception"; - } -} diff --git a/indra/llcommon/metaproperty.h b/indra/llcommon/metaproperty.h deleted file mode 100644 index bd5bb1a30f..0000000000 --- a/indra/llcommon/metaproperty.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file metaproperty.h - * @author Babbage - * @date 2006-05-15 - * @brief Reflective meta information describing a property of a class. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_METAPROPERTY_H -#define LL_METAPROPERTY_H - -#include "stdtypes.h" -#include "llsd.h" -#include "reflective.h" - -class LLMetaClass; -class LLReflective; -class LL_COMMON_API LLMetaProperty -{ -public: - LLMetaProperty(const std::string& name, const LLMetaClass& object_class); - virtual ~LLMetaProperty(); - - // Get property name. - const std::string& getName() const {return mName;} - - // Get value of this property. - virtual const LLReflective* get(const LLReflective* object) const = 0; - - // Set value of this property. - // virtual void set(LLReflective* object, const LLReflective* value) = 0; - - // Get value of this property as LLSD. Default returns undefined LLSD. - virtual LLSD getLLSD(const LLReflective* object) const = 0; - - // Get the MetaClass of legal values of this property. - // const LLMetaClass& getValueMetaClass(); - - // Get the meta class that this property is a member of. - const LLMetaClass& getObjectMetaClass() const; - -protected: - - // Check object is instance of object class, throw exception if not. - void checkObjectClass(const LLReflective* object) const; - -private: - - std::string mName; - const LLMetaClass& mObjectClass; -}; - -#endif // LL_METAPROPERTY_H diff --git a/indra/llcommon/metapropertyt.h b/indra/llcommon/metapropertyt.h deleted file mode 100644 index 7a36c161da..0000000000 --- a/indra/llcommon/metapropertyt.h +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @file metapropertyt.h - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_METAPROPERTYT_H -#define LL_METAPROPERTYT_H - -#include "llsd.h" -#include "llstring.h" -#include "metaclasst.h" -#include "metaproperty.h" -#include "reflectivet.h" - -template<class TProperty> -class LLMetaPropertyT : public LLMetaProperty -{ -public: - - virtual ~LLMetaPropertyT() {;} - - // Get value of this property. Gives ownership of returned value. - virtual const LLReflective* get(const LLReflective* object) const - { - checkObjectClass(object); - return getProperty(object); - } - - // Set value of this property. - /*virtual void set(LLReflective* object, const LLReflective* value) - { - // TODO: Babbage: Check types. - ref(object) = static_cast<const LLReflectiveT<TProperty>* >(value)->getValue(); - }*/ - - // Get value of this property as LLSD. - virtual LLSD getLLSD(const LLReflective* object) const - { - return LLSD(); - } - -protected: - - LLMetaPropertyT(const std::string& name, const LLMetaClass& object_class) : LLMetaProperty(name, object_class) {;} - - virtual const TProperty* getProperty(const LLReflective* object) const = 0; -}; - -template <> -inline const LLReflective* LLMetaPropertyT<S32>::get(const LLReflective* object) const -{ - checkObjectClass(object); - return NULL; -} - -template <> -inline const LLReflective* LLMetaPropertyT<std::string>::get(const LLReflective* object) const -{ - checkObjectClass(object); - return NULL; -} - -template <> -inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const -{ - checkObjectClass(object); - return NULL; -} - -template <> -inline const LLReflective* LLMetaPropertyT<bool>::get(const LLReflective* object) const -{ - checkObjectClass(object); - return NULL; -} - -template <> -inline LLSD LLMetaPropertyT<S32>::getLLSD(const LLReflective* object) const -{ - return *(getProperty(object)); -} - -template <> -inline LLSD LLMetaPropertyT<std::string>::getLLSD(const LLReflective* object) const -{ - return *(getProperty(object)); -} - -template <> -inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const -{ - return *(getProperty(object)); -} - -template <> -inline LLSD LLMetaPropertyT<bool>::getLLSD(const LLReflective* object) const -{ - return *(getProperty(object)); -} - -template<class TObject, class TProperty> -class LLMetaPropertyTT : public LLMetaPropertyT<TProperty> -{ -public: - - LLMetaPropertyTT(const std::string& name, const LLMetaClass& object_class, TProperty (TObject::*property)) : - LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;} - -protected: - - // Get void* to property. - virtual const TProperty* getProperty(const LLReflective* object) const - { - const TObject* typed_object = static_cast<const TObject*>(object); - return &(typed_object->*mProperty); - }; - -private: - - TProperty (TObject::*mProperty); -}; - -template<class TObject, class TProperty> -class LLMetaPropertyPtrTT : public LLMetaPropertyT<TProperty> -{ -public: - - LLMetaPropertyPtrTT(const std::string& name, const LLMetaClass& object_class, TProperty* (TObject::*property)) : - LLMetaPropertyT<TProperty>(name, object_class), mProperty(property) {;} - -protected: - - // Get void* to property. - virtual const TProperty* getProperty(const LLReflective* object) const - { - const TObject* typed_object = static_cast<const TObject*>(object); - return typed_object->*mProperty; - }; - -private: - - TProperty* (TObject::*mProperty); -}; - -// Utility function to simplify the registration of members. -template<class TObject, class TProperty> -void reflectProperty(LLMetaClass& meta_class, const std::string& name, TProperty (TObject::*property)) -{ - typedef LLMetaPropertyTT<TObject, TProperty> PropertyType; - const LLMetaProperty* meta_property = new PropertyType(name, meta_class, property); - meta_class.addProperty(meta_property); -} - -// Utility function to simplify the registration of ptr properties. -template<class TObject, class TProperty> -void reflectPtrProperty(LLMetaClass& meta_class, const std::string& name, TProperty* (TObject::*property)) -{ - typedef LLMetaPropertyPtrTT<TObject, TProperty> PropertyType; - const LLMetaProperty* meta_property = new PropertyType(name, meta_class, property); - meta_class.addProperty(meta_property); -} - -#endif // LL_METAPROPERTYT_H diff --git a/indra/llcommon/reflective.cpp b/indra/llcommon/reflective.cpp deleted file mode 100644 index 2cc0e7e1f2..0000000000 --- a/indra/llcommon/reflective.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file reflective.cpp - * @author Babbage - * @date 2006-05-15 - * @brief Implementation of LLReflective. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#include "linden_common.h" - -#include "reflective.h" - -LLReflective::LLReflective() -{ -} - -//virtual -LLReflective::~LLReflective() -{ -} diff --git a/indra/llcommon/reflective.h b/indra/llcommon/reflective.h deleted file mode 100644 index da5c5a2630..0000000000 --- a/indra/llcommon/reflective.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file reflective.h - * @author Babbage - * @date 2006-05-15 - * @brief Interface that must be implemented by all reflective classes. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_REFLECTIVE_H -#define LL_REFLECTIVE_H - -class LLMetaClass; -class LL_COMMON_API LLReflective -{ -public: - LLReflective(); - virtual ~LLReflective(); - - virtual const LLMetaClass& getMetaClass() const = 0; -}; - -#endif // LL_REFLECTIVE_H diff --git a/indra/llcommon/reflectivet.h b/indra/llcommon/reflectivet.h deleted file mode 100644 index 958921f23e..0000000000 --- a/indra/llcommon/reflectivet.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file reflectivet.h - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_REFLECTIVET_H -#define LL_REFLECTIVET_H - -#include "reflective.h" - -template <class T> -class LLReflectiveT : public LLReflective -{ -public: - - LLReflectiveT(const T& value) : mValue(value) {;} - virtual ~LLReflectiveT() {;} - - virtual const LLMetaClass& getMetaClass() const {return LLMetaClassT<LLReflectiveT<T> >::instance();} - - const T& getValue() const {return mValue;} - -private: - - T mValue; -}; - -#endif diff --git a/indra/llcommon/tests/reflection_test.cpp b/indra/llcommon/tests/reflection_test.cpp deleted file mode 100644 index 8980ebb1f1..0000000000 --- a/indra/llcommon/tests/reflection_test.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @file reflection_test.cpp - * @date May 2006 - * @brief Reflection unit tests. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#include "../linden_common.h" -#include "../reflective.h" -#include "../metaclasst.h" -#include "../metapropertyt.h" -#include "../stdtypes.h" - -#include "../test/lltut.h" - -namespace tut -{ - class TestAggregatedData : public LLReflective - { - public: - TestAggregatedData() {;} - virtual const LLMetaClass& getMetaClass() const; - - private: - }; - - class TestReflectionData : public LLReflective - { - public: - TestReflectionData() : mInt(42), mString("foo"), mNullPtr(NULL), mPtr(new TestAggregatedData()), mRef(*(new TestAggregatedData)) {;} - virtual ~TestReflectionData() {delete mPtr;} - virtual const LLMetaClass& getMetaClass() const; - - static U32 getPropertyCount() {return 5;} - - private: - - friend class LLMetaClassT<TestReflectionData>; - S32 mInt; - std::string mString; - TestAggregatedData* mNullPtr; - TestAggregatedData* mPtr; - TestAggregatedData mObj; - TestAggregatedData& mRef; - }; -} - -template <> -void LLMetaClassT<tut::TestReflectionData>::reflectProperties(LLMetaClass& meta_class) -{ - reflectProperty(meta_class, "mInt", &tut::TestReflectionData::mInt); - reflectProperty(meta_class, "mString", &tut::TestReflectionData::mString); - reflectPtrProperty(meta_class, "mNullPtr", &tut::TestReflectionData::mNullPtr); - reflectPtrProperty(meta_class, "mPtr", &tut::TestReflectionData::mPtr); - reflectProperty(meta_class, "mObj", &tut::TestReflectionData::mObj); - //reflectProperty(meta_class, "mRef", &tut::TestReflectionData::mRef); // AARGH! -} - -namespace tut -{ - // virtual - const LLMetaClass& TestReflectionData::getMetaClass() const - { - return LLMetaClassT<TestReflectionData>::instance(); - } - - const LLMetaClass& TestAggregatedData::getMetaClass() const - { - return LLMetaClassT<TestAggregatedData>::instance(); - } -} - -namespace tut -{ - typedef tut::test_group<TestReflectionData> TestReflectionGroup; - typedef TestReflectionGroup::object TestReflectionObject; - TestReflectionGroup gTestReflectionGroup("reflection"); - - template<> template<> - void TestReflectionObject::test<1>() - { - // Check properties can be found. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - const LLMetaProperty* null = NULL; - ensure_not_equals(meta_class.findProperty("mInt"), null); - ensure_not_equals(meta_class.findProperty("mString"), null); - } - - template<> template<> - void TestReflectionObject::test<2>() - { - // Check non-existent property cannot be found. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - const LLMetaProperty* null = NULL; - ensure_equals(meta_class.findProperty("foo"), null); - } - - template<> template<> - void TestReflectionObject::test<3>() - { - // Check integer property has correct value. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - ensure_equals(meta_class.findProperty("mInt")->getLLSD(this).asInteger(), 42); - } - - template<> template<> - void TestReflectionObject::test<4>() - { - // Check string property has correct value. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - ensure_equals(meta_class.findProperty("mString")->getLLSD(this).asString(), std::string("foo")); - } - - template<> template<> - void TestReflectionObject::test<5>() - { - // Check NULL reference property has correct value. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - const LLReflective* null = NULL; - ensure_equals(meta_class.findProperty("mNullPtr")->get(this), null); - } - - template<> template<> - void TestReflectionObject::test<6>() - { - // Check reference property has correct value. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - const LLReflective* null = NULL; - const LLReflective* ref = meta_class.findProperty("mPtr")->get(this); - ensure_not_equals(ref, null); - } - - template<> template<> - void TestReflectionObject::test<7>() - { - // Check reflective property has correct value. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - const LLReflective* null = NULL; - const LLReflective* ref = meta_class.findProperty("mObj")->get(this); - ensure_not_equals(ref, null); - } - - template<> template<> - void TestReflectionObject::test<8>() - { - // Check property count. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - ensure_equals(meta_class.getPropertyCount(), TestReflectionData::getPropertyCount()); - } - - template<> template<> - void TestReflectionObject::test<9>() - { - // Check property iteration. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - U32 count = 0; - LLMetaClass::PropertyIterator iter; - for(iter = meta_class.beginProperties(); iter != meta_class.endProperties(); ++iter) - { - ++count; - } - ensure_equals(count, TestReflectionData::getPropertyCount()); - } - - template<> template<> - void TestReflectionObject::test<10>() - { - // Check meta classes of different types do not compare equal. - const LLMetaClass* reflection_data_meta_class = &(LLMetaClassT<TestReflectionData>::instance()); - const LLMetaClass* aggregated_data_meta_class = &(LLMetaClassT<TestAggregatedData>::instance()); - ensure_not_equals(reflection_data_meta_class, aggregated_data_meta_class); - } - - template<> template<> - void TestReflectionObject::test<11>() - { - // Check class cast checks. - const LLMetaClass& meta_class = LLMetaClassT<TestReflectionData>::instance(); - TestAggregatedData* aggregated_data = new TestAggregatedData(); - LLMetaClass::PropertyIterator iter; - U32 exception_count = 0; - for(iter = meta_class.beginProperties(); iter != meta_class.endProperties(); ++iter) - { - try - { - const LLMetaProperty* property = (*iter).second; - const LLReflective* reflective = property->get(aggregated_data); // Wrong reflective type, should throw exception. - - // useless op to get rid of compiler warning. - reflective = reflective; - } - catch(...) - { - ++exception_count; - } - } - ensure_equals(exception_count, getPropertyCount()); - - } -} diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp index 7e013de11a..55067cde73 100644 --- a/indra/llinventory/llpermissions.cpp +++ b/indra/llinventory/llpermissions.cpp @@ -31,7 +31,6 @@ // library includes #include "message.h" -#include "metapropertyt.h" #include "llsd.h" ///---------------------------------------------------------------------------- @@ -895,21 +894,6 @@ std::ostream& operator<<(std::ostream &s, const LLPermissions &perm) return s; } -template <> -void LLMetaClassT<LLPermissions>::reflectProperties(LLMetaClass& meta_class) -{ - reflectProperty(meta_class, "mCreator", &LLPermissions::mCreator); - reflectProperty(meta_class, "mOwner", &LLPermissions::mOwner); - reflectProperty(meta_class, "mGroup", &LLPermissions::mGroup); - reflectProperty(meta_class, "mIsGroupOwned", &LLPermissions::mIsGroupOwned); -} - -// virtual -const LLMetaClass& LLPermissions::getMetaClass() const -{ - return LLMetaClassT<LLPermissions>::instance(); -} - ///---------------------------------------------------------------------------- /// Class LLAggregatePermissions ///---------------------------------------------------------------------------- diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h index 3ecc922370..89c66f6ebd 100644 --- a/indra/llinventory/llpermissions.h +++ b/indra/llinventory/llpermissions.h @@ -31,7 +31,6 @@ #include "llsd.h" #include "lluuid.h" #include "llxmlnode.h" -#include "reflective.h" #include "llinventorytype.h" // prototypes @@ -83,7 +82,7 @@ template<class T> class LLMetaClassT; // logical consistency. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLPermissions : public LLReflective +class LLPermissions { private: LLUUID mCreator; // null if object created by system @@ -324,9 +323,6 @@ public: friend std::ostream& operator<<(std::ostream &s, const LLPermissions &perm); - // Reflection. - friend class LLMetaClassT<LLPermissions>; - virtual const LLMetaClass& getMetaClass() const; }; // Inlines diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index 1589ea29c1..e94e2282a0 100644 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -50,9 +50,9 @@ #include "lltimer.h" #include "llpacketring.h" #include "llhost.h" -#include "llhttpclient.h" +#include "llcurl.h" #include "llhttpnode.h" -#include "llpacketack.h" +//#include "llpacketack.h" #include "llsingleton.h" #include "message_prehash.h" #include "llstl.h" @@ -158,7 +158,6 @@ const F32 LL_MAX_LOST_TIMEOUT = 5.f; // Maximum amount of time before cons const S32 MAX_MESSAGE_COUNT_NUM = 1024; // Forward declarations -class LLCircuit; class LLVector3; class LLVector4; class LLVector3d; @@ -214,19 +213,19 @@ class LLMessageSystem : public LLMessageSenderInterface public: LLPacketRing mPacketRing; - LLReliablePacketParams mReliablePacketParams; + LLReliablePacketParams mReliablePacketParams; // Set this flag to TRUE when you want *very* verbose logs. - BOOL mVerboseLog; + BOOL mVerboseLog; - F32 mMessageFileVersionNumber; + F32 mMessageFileVersionNumber; typedef std::map<const char *, LLMessageTemplate*> message_template_name_map_t; typedef std::map<U32, LLMessageTemplate*> message_template_number_map_t; private: message_template_name_map_t mMessageTemplates; - message_template_number_map_t mMessageNumbers; + message_template_number_map_t mMessageNumbers; public: S32 mSystemVersionMajor; @@ -235,7 +234,7 @@ public: S32 mSystemVersionServer; U32 mVersionFlags; - BOOL mbProtected; + BOOL mbProtected; U32 mNumberHighFreqMessages; U32 mNumberMediumFreqMessages; @@ -255,11 +254,11 @@ public: U32 mReliablePacketsIn; // total reliable packets in U32 mReliablePacketsOut; // total reliable packets out - U32 mDroppedPackets; // total dropped packets in - U32 mResentPackets; // total resent packets out - U32 mFailedResendPackets; // total resend failure packets out - U32 mOffCircuitPackets; // total # of off-circuit packets rejected - U32 mInvalidOnCircuitPackets; // total # of on-circuit but invalid packets rejected + U32 mDroppedPackets; // total dropped packets in + U32 mResentPackets; // total resent packets out + U32 mFailedResendPackets; // total resend failure packets out + U32 mOffCircuitPackets; // total # of off-circuit packets rejected + U32 mInvalidOnCircuitPackets; // total # of on-circuit but invalid packets rejected S64 mUncompressedBytesIn; // total uncompressed size of compressed packets in S64 mUncompressedBytesOut; // total uncompressed size of compressed packets out @@ -268,14 +267,14 @@ public: S64 mTotalBytesIn; // total size of all uncompressed packets in S64 mTotalBytesOut; // total size of all uncompressed packets out - BOOL mSendReliable; // does the outgoing message require a pos ack? + BOOL mSendReliable; // does the outgoing message require a pos ack? - LLCircuit mCircuitInfo; + LLCircuit mCircuitInfo; F64 mCircuitPrintTime; // used to print circuit debug info every couple minutes F32 mCircuitPrintFreq; // seconds - std::map<U64, U32> mIPPortToCircuitCode; - std::map<U32, U64> mCircuitCodeToIPPort; + std::map<U64, U32> mIPPortToCircuitCode; + std::map<U32, U64> mCircuitCodeToIPPort; U32 mOurCircuitCode; S32 mSendPacketFailureCount; S32 mUnackedListDepth; @@ -494,7 +493,7 @@ public: void (*callback)(void **,S32), void ** callback_data); - LLHTTPClient::ResponderPtr createResponder(const std::string& name); + LLCurl::ResponderPtr createResponder(const std::string& name); S32 sendMessage(const LLHost &host); S32 sendMessage(const U32 circuit); private: diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp index 6f8508ee8c..1c9508214c 100644 --- a/indra/llmessage/net.cpp +++ b/indra/llmessage/net.cpp @@ -26,7 +26,7 @@ #include "linden_common.h" -#include "net.h" +//#include "net.h" // system library includes #include <stdexcept> diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index e4d9de7eb6..e404e01b91 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -29,7 +29,6 @@ set(llprimitive_SOURCE_FILES lltextureentry.cpp lltreeparams.cpp llvolumemessage.cpp - llvolumexml.cpp material_codes.cpp ) @@ -47,7 +46,6 @@ set(llprimitive_HEADER_FILES lltreeparams.h lltree_common.h llvolumemessage.h - llvolumexml.h material_codes.h object_flags.h ) diff --git a/indra/llprimitive/llvolumexml.cpp b/indra/llprimitive/llvolumexml.cpp deleted file mode 100644 index bf2297a029..0000000000 --- a/indra/llprimitive/llvolumexml.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file llvolumexml.cpp - * @brief LLVolumeXml base class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#include "linden_common.h" - -#include "llvolumexml.h" - -//============================================================================ - -// LLVolumeXml is just a wrapper class; all members are static - -//============================================================================ - -LLPointer<LLXMLNode> LLVolumeXml::exportProfileParams(const LLProfileParams* params) -{ - LLPointer<LLXMLNode> ret = new LLXMLNode("profile", FALSE); - - ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType()); - ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin()); - ret->createChild("hollow", FALSE)->setFloatValue(1, ¶ms->getHollow()); - - return ret; -} - - -LLPointer<LLXMLNode> LLVolumeXml::exportPathParams(const LLPathParams* params) -{ - LLPointer<LLXMLNode> ret = new LLXMLNode("path", FALSE); - ret->createChild("curve_type", TRUE)->setByteValue(1, ¶ms->getCurveType()); - ret->createChild("interval", FALSE)->setFloatValue(2, ¶ms->getBegin()); - ret->createChild("scale", FALSE)->setFloatValue(2, params->getScale().mV); - ret->createChild("shear", FALSE)->setFloatValue(2, params->getShear().mV); - ret->createChild("twist_interval", FALSE)->setFloatValue(2, ¶ms->getTwistBegin()); - ret->createChild("radius_offset", FALSE)->setFloatValue(1, ¶ms->getRadiusOffset()); - ret->createChild("taper", FALSE)->setFloatValue(2, params->getTaper().mV); - ret->createChild("revolutions", FALSE)->setFloatValue(1, ¶ms->getRevolutions()); - ret->createChild("skew", FALSE)->setFloatValue(1, ¶ms->getSkew()); - - return ret; -} - - -LLPointer<LLXMLNode> LLVolumeXml::exportVolumeParams(const LLVolumeParams* params) -{ - LLPointer<LLXMLNode> ret = new LLXMLNode("shape", FALSE); - - LLPointer<LLXMLNode> node ; - node = exportPathParams(¶ms->getPathParams()) ; - node->setParent(ret); - node = exportProfileParams(¶ms->getProfileParams()) ; - node->setParent(ret); - - return ret; -} - diff --git a/indra/llprimitive/llvolumexml.h b/indra/llprimitive/llvolumexml.h deleted file mode 100644 index 9d4d989475..0000000000 --- a/indra/llprimitive/llvolumexml.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file llvolumexml.h - * @brief LLVolumeXml base class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * 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. - * - * 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. - * - * 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$ - */ - -#ifndef LL_LLVOLUMEXML_H -#define LL_LLVOLUMEXML_H - -#include "llvolume.h" -#include "llxmlnode.h" - -// wrapper class for some volume/message functions -class LLVolumeXml -{ -public: - static LLPointer<LLXMLNode> exportProfileParams(const LLProfileParams* params); - - static LLPointer<LLXMLNode> exportPathParams(const LLPathParams* params); - - static LLPointer<LLXMLNode> exportVolumeParams(const LLVolumeParams* params); -}; - -#endif // LL_LLVOLUMEXML_H - diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index b5bdba996f..ef48ffa39a 100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -34,13 +34,15 @@ #include "llcontrol.h" #include "lldir.h" #include "llwindow.h" +#include "llxmlnode.h" extern LLControlGroup gSavedSettings; using std::string; using std::map; -bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc); +bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc); +bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node); LLFontDescriptor::LLFontDescriptor(): mStyle(0) @@ -207,7 +209,7 @@ bool LLFontRegistry::parseFontInfo(const std::string& xml_filename) if (root->hasName("fonts")) { // Expect a collection of children consisting of "font" or "font_size" entries - bool init_succ = initFromXML(root); + bool init_succ = init_from_xml(this, root); success = success || init_succ; } } @@ -230,7 +232,7 @@ std::string currentOsName() #endif } -bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) +bool font_desc_init_from_xml(LLXMLNodePtr node, LLFontDescriptor& desc) { if (node->hasName("font")) { @@ -263,14 +265,14 @@ bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) { if (child_name == currentOsName()) { - fontDescInitFromXML(child, desc); + font_desc_init_from_xml(child, desc); } } } return true; } -bool LLFontRegistry::initFromXML(LLXMLNodePtr node) +bool init_from_xml(LLFontRegistry* registry, LLXMLNodePtr node) { LLXMLNodePtr child; @@ -281,17 +283,17 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) if (child->hasName("font")) { LLFontDescriptor desc; - bool font_succ = fontDescInitFromXML(child, desc); + bool font_succ = font_desc_init_from_xml(child, desc); LLFontDescriptor norm_desc = desc.normalize(); if (font_succ) { // if this is the first time we've seen this font name, // create a new template map entry for it. - const LLFontDescriptor *match_desc = getMatchingFontDesc(desc); + const LLFontDescriptor *match_desc = registry->getMatchingFontDesc(desc); if (match_desc == NULL) { // Create a new entry (with no corresponding font). - mFontMap[norm_desc] = NULL; + registry->mFontMap[norm_desc] = NULL; } // otherwise, find the existing entry and combine data. else @@ -306,8 +308,8 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) desc.getFileNames().end()); LLFontDescriptor new_desc = *match_desc; new_desc.getFileNames() = match_file_names; - mFontMap.erase(*match_desc); - mFontMap[new_desc] = NULL; + registry->mFontMap.erase(*match_desc); + registry->mFontMap[new_desc] = NULL; } } } @@ -318,7 +320,7 @@ bool LLFontRegistry::initFromXML(LLXMLNodePtr node) if (child->getAttributeString("name",size_name) && child->getAttributeF32("size",size_value)) { - mFontSizes[size_name] = size_value; + registry->mFontSizes[size_name] = size_value; } } diff --git a/indra/llrender/llfontregistry.h b/indra/llrender/llfontregistry.h index 059248fbbd..177eb6c8a5 100644 --- a/indra/llrender/llfontregistry.h +++ b/indra/llrender/llfontregistry.h @@ -28,7 +28,7 @@ #ifndef LL_LLFONTREGISTRY_H #define LL_LLFONTREGISTRY_H -#include "llxmlnode.h" +#include "llpointer.h" class LLFontGL; @@ -65,6 +65,7 @@ private: class LLFontRegistry { public: + friend bool init_from_xml(LLFontRegistry*, LLPointer<class LLXMLNode>); // create_gl_textures - set to false for test apps with no OpenGL window, // such as llui_libtest LLFontRegistry(bool create_gl_textures); @@ -72,7 +73,6 @@ public: // Load standard font info from XML file(s). bool parseFontInfo(const std::string& xml_filename); - bool initFromXML(LLXMLNodePtr node); // Clear cached glyphs for all fonts. void reset(); @@ -94,6 +94,7 @@ public: const string_vec_t& getUltimateFallbackList() const; private: + LLFontRegistry(const LLFontRegistry& other); // no-copy LLFontGL *createFont(const LLFontDescriptor& desc); typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t; typedef std::map<std::string,F32> font_size_map_t; diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index c025cd7939..0cd5fd938f 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -444,9 +444,9 @@ void LLAccordionCtrlTab::changeOpenClose(bool is_open) } } -void LLAccordionCtrlTab::handleVisibilityChange(BOOL new_visibility) +void LLAccordionCtrlTab::onVisibilityChange(BOOL new_visibility) { - LLUICtrl::handleVisibilityChange(new_visibility); + LLUICtrl::onVisibilityChange(new_visibility); notifyParent(LLSD().with("child_visibility_change", new_visibility)); } diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index dddaa581e6..7a78700e0f 100644 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -158,7 +158,7 @@ public: /** * Raises notifyParent event with "child_visibility_change" = new_visibility */ - void handleVisibilityChange(BOOL new_visibility); + void onVisibilityChange(BOOL new_visibility); // Changes expand/collapse state and triggers expand/collapse callbacks virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index a29ad12d23..7d84b2a392 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -596,7 +596,7 @@ LLControlGroup* LLFloater::getControlGroup() void LLFloater::setVisible( BOOL visible ) { - LLPanel::setVisible(visible); // calls handleVisibilityChange() + LLPanel::setVisible(visible); // calls onVisibilityChange() if( visible && mFirstLook ) { mFirstLook = FALSE; @@ -628,14 +628,14 @@ void LLFloater::setVisible( BOOL visible ) } // virtual -void LLFloater::handleVisibilityChange ( BOOL new_visibility ) +void LLFloater::onVisibilityChange ( BOOL new_visibility ) { if (new_visibility) { if (getHost()) getHost()->setFloaterFlashing(this, FALSE); } - LLPanel::handleVisibilityChange ( new_visibility ); + LLPanel::onVisibilityChange ( new_visibility ); } void LLFloater::openFloater(const LLSD& key) @@ -779,7 +779,7 @@ void LLFloater::closeFloater(bool app_quitting) } else { - setVisible(FALSE); // hide before destroying (so handleVisibilityChange() gets called) + setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called) if (!mReuseInstance) { destroy(); diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index aef63bcf93..939b2ddde3 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -298,7 +298,7 @@ public: virtual BOOL canClose() { return TRUE; } /*virtual*/ void setVisible(BOOL visible); // do not override - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); // do not override + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); // do not override void setFrontmost(BOOL take_focus = TRUE); diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 13888920f9..51cf352645 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -549,13 +549,13 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& return TRUE; } -void LLMenuItemGL::handleVisibilityChange(BOOL new_visibility) +void LLMenuItemGL::onVisibilityChange(BOOL new_visibility) { if (getMenu()) { getMenu()->needsArrange(); } - LLView::handleVisibilityChange(new_visibility); + LLView::onVisibilityChange(new_visibility); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1146,13 +1146,13 @@ void LLMenuItemBranchGL::updateBranchParent(LLView* parentp) } } -void LLMenuItemBranchGL::handleVisibilityChange( BOOL new_visibility ) +void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility ) { if (new_visibility == FALSE && getBranch() && !getBranch()->getTornOff()) { getBranch()->setVisible(FALSE); } - LLMenuItemGL::handleVisibilityChange(new_visibility); + LLMenuItemGL::onVisibilityChange(new_visibility); } BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask ) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 00899020bc..b1d2223588 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -82,7 +82,7 @@ protected: friend class LLUICtrlFactory; public: // LLView overrides - /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); @@ -631,7 +631,7 @@ public: virtual void updateBranchParent( LLView* parentp ); // LLView Functionality - virtual void handleVisibilityChange( BOOL curVisibilityIn ); + virtual void onVisibilityChange( BOOL curVisibilityIn ); virtual void draw(); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index d7534c416d..25a137bb41 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -96,6 +96,7 @@ #include "llfunctorregistry.h" #include "llpointer.h" #include "llinitparam.h" +#include "llinstancetracker.h" #include "llnotificationslistener.h" #include "llnotificationptr.h" @@ -966,7 +967,7 @@ private: bool mIgnoreAllNotifications; - boost::scoped_ptr<LLNotificationsListener> mListener; + boost::scoped_ptr<class LLNotificationsListener> mListener; }; /** diff --git a/indra/llui/llnotificationsutil.cpp b/indra/llui/llnotificationsutil.cpp index cc791c26d1..7b9676f45b 100644 --- a/indra/llui/llnotificationsutil.cpp +++ b/indra/llui/llnotificationsutil.cpp @@ -27,6 +27,7 @@ #include "llnotificationsutil.h" #include "llnotifications.h" +#include "llnotificationslistener.h" #include "llsd.h" #include "llxmlnode.h" // apparently needed to call LLNotifications::instance() diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 188a0fea74..f157d6a923 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -342,9 +342,9 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask ) return handled; } -void LLPanel::handleVisibilityChange ( BOOL new_visibility ) +void LLPanel::onVisibilityChange ( BOOL new_visibility ) { - LLUICtrl::handleVisibilityChange ( new_visibility ); + LLUICtrl::onVisibilityChange ( new_visibility ); if (mVisibleSignal) (*mVisibleSignal)(this, LLSD(new_visibility) ); // Pass BOOL as LLSD } diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index e63b41f97c..ac8583ece9 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -115,7 +115,7 @@ public: /*virtual*/ BOOL isPanel() const; /*virtual*/ void draw(); /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask ); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); // From LLFocusableElement /*virtual*/ void setFocus( BOOL b ); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 680b6ed16d..025b3c4165 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1222,13 +1222,13 @@ void LLTextBase::setReadOnlyColor(const LLColor4 &c) } //virtual -void LLTextBase::handleVisibilityChange( BOOL new_visibility ) +void LLTextBase::onVisibilityChange( BOOL new_visibility ) { if(!new_visibility && mPopupMenu) { mPopupMenu->hide(); } - LLUICtrl::handleVisibilityChange(new_visibility); + LLUICtrl::onVisibilityChange(new_visibility); } //virtual diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 2ce15d891a..bd0c8949dc 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -310,7 +310,7 @@ public: /*virtual*/ BOOL acceptsTextInput() const { return !mReadOnly; } /*virtual*/ void setColor( const LLColor4& c ); virtual void setReadOnlyColor(const LLColor4 &c); - virtual void handleVisibilityChange( BOOL new_visibility ); + virtual void onVisibilityChange( BOOL new_visibility ); /*virtual*/ void setValue(const LLSD& value ); /*virtual*/ LLTextViewModel* getViewModel() const; diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index 00d52fe10d..ccb92ffbb2 100644 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -52,7 +52,7 @@ boost::signals2::connection LLToggleableMenu::setVisibilityChangeCallback(const } // virtual -void LLToggleableMenu::handleVisibilityChange (BOOL curVisibilityIn) +void LLToggleableMenu::onVisibilityChange (BOOL curVisibilityIn) { S32 x,y; LLUI::getMousePositionLocal(LLUI::getRootView(), &x, &y); diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index 4717b0d0ba..47e3b9f824 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -45,7 +45,7 @@ public: boost::signals2::connection setVisibilityChangeCallback( const commit_signal_t::slot_type& cb ); - virtual void handleVisibilityChange (BOOL curVisibilityIn); + virtual void onVisibilityChange (BOOL curVisibilityIn); virtual bool addChild (LLView* view, S32 tab_group = 0); diff --git a/indra/llui/llui.h b/indra/llui/llui.h index dfb9fa60c9..69490d8668 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -31,15 +31,14 @@ #include "llpointer.h" // LLPointer<> #include "llrect.h" -#include "llcontrol.h" #include "llcoord.h" +#include "llcontrol.h" #include "llglslshader.h" #include "llinitparam.h" #include "llregistry.h" #include "lluicolor.h" #include "lluicolortable.h" #include <boost/signals2.hpp> -#include "lllazyvalue.h" #include "llframetimer.h" #include <limits> @@ -59,6 +58,7 @@ class LLWindow; class LLView; class LLHelp; class LLRenderTarget; +class LLControlGroup; // UI colors extern const LLColor4 UI_VERTEX_COLOR; diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h index f07e8fa746..f9c191e65f 100644 --- a/indra/llui/lluiimage.h +++ b/indra/llui/lluiimage.h @@ -30,9 +30,7 @@ #include "v4color.h" #include "llpointer.h" #include "llrefcount.h" -#include "llrefcount.h" #include "llrect.h" -#include <boost/function.hpp> #include <boost/signals2.hpp> #include "llinitparam.h" #include "lltexture.h" diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index ba88396294..23bb3a1f27 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -641,21 +641,21 @@ void LLView::setVisible(BOOL visible) { // tell all children of this view that the visibility may have changed dirtyRect(); - handleVisibilityChange( visible ); + onVisibilityChange( visible ); } updateBoundingRect(); } } // virtual -void LLView::handleVisibilityChange ( BOOL new_visibility ) +void LLView::onVisibilityChange ( BOOL new_visibility ) { BOOST_FOREACH(LLView* viewp, mChildList) { // only views that are themselves visible will have their overall visibility affected by their ancestors if (viewp->getVisible()) { - viewp->handleVisibilityChange ( new_visibility ); + viewp->onVisibilityChange ( new_visibility ); } } } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 88813da3c6..224d75bb85 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -308,7 +308,7 @@ public: virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); - virtual void handleVisibilityChange ( BOOL new_visibility ); + virtual void onVisibilityChange ( BOOL new_visibility ); void pushVisible(BOOL visible) { mLastVisible = mVisible; setVisible(visible); } void popVisible() { setVisible(mLastVisible); } diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 903f10ce10..0291843758 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -338,6 +338,8 @@ LLXSDWriter::LLXSDWriter() registerInspectFunc<LLSD>(boost::bind(&LLXSDWriter::writeAttribute, this, "xs:string", _1, _2, _3, _4)); } +LLXSDWriter::~LLXSDWriter() {} + void LLXSDWriter::writeXSD(const std::string& type_name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace) { Schema schema(xml_namespace); diff --git a/indra/llui/llxuiparser.h b/indra/llui/llxuiparser.h index 8d0276a8ad..e6bb552623 100644 --- a/indra/llui/llxuiparser.h +++ b/indra/llui/llxuiparser.h @@ -29,21 +29,15 @@ #include "llinitparam.h" #include "llregistry.h" -#include "llpointer.h" +#include "llxmlnode.h" #include <boost/function.hpp> #include <iosfwd> #include <stack> #include <set> - - class LLView; - -typedef LLPointer<class LLXMLNode> LLXMLNodePtr; - - // lookup widget type by name class LLWidgetTypeRegistry : public LLRegistrySingleton<std::string, const std::type_info*, LLWidgetTypeRegistry> @@ -59,8 +53,6 @@ class LLChildRegistryRegistry : public LLRegistrySingleton<const std::type_info*, widget_registry_t, LLChildRegistryRegistry> {}; - - class LLXSDWriter : public LLInitParam::Parser { LOG_CLASS(LLXSDWriter); @@ -70,6 +62,7 @@ public: /*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; } LLXSDWriter(); + ~LLXSDWriter(); protected: void writeAttribute(const std::string& type, const Parser::name_stack_t&, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values); @@ -124,6 +117,7 @@ public: } private: + LLXUIParser(const LLXUIParser& other); // no-copy void writeXUIImpl(LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const LLInitParam::predicate_rule_t rules, diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 94a8550938..94f032be67 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -19,7 +19,7 @@ <string> Time before automatically setting AFK (away from keyboard) mode (seconds, 0=never). Valid values are: 0, 120, 300, 600, 1800 -</string> + </string> <key>Persist</key> <integer>1</integer> <key>Type</key> @@ -6848,6 +6848,17 @@ <key>Value</key> <real>6.0</real> </map> + <key>ClothingLoadingDelay</key> + <map> + <key>Comment</key> + <string>Time to wait for avatar appearance to resolve before showing world (seconds)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>10.0</real> + </map> <key>PreferredMaturity</key> <map> <key>Comment</key> @@ -7403,7 +7414,6 @@ <key>Value</key> <integer>1</integer> </map> - <key>OctreeMaxNodeCapacity</key> <map> <key>Comment</key> @@ -9469,6 +9479,28 @@ <key>Value</key> <integer>0</integer> </map> + <key>SceneLoadingMonitorSampleTime</key> + <map> + <key>Comment</key> + <string>Time between screen samples when monitor scene load (seconds)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.25</real> + </map> + <key>SceneLoadingPixelDiffThreshold</key> + <map> + <key>Comment</key> + <string>Amount of pixels changed required to consider the scene as still loading (fraction of pixels on screen)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.0003</real> + </map> <key>ScriptHelpFollowsCursor</key> <map> <key>Comment</key> @@ -14117,5 +14149,27 @@ <key>Value</key> <integer>0</integer> </map> + <key>TeleportArrivalDelay</key> + <map> + <key>Comment</key> + <string>Time to wait before displaying world during teleport (seconds)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>2</real> + </map> + <key>TeleportLocalDelay</key> + <map> + <key>Comment</key> + <string>Delay to prevent teleports after starting an in-sim teleport. (seconds)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>1</real> + </map> </map> </llsd> diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 4e60127ef3..6b996edb76 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1046,14 +1046,6 @@ const LLVector3d &LLAgent::getPositionGlobal() const return mPositionGlobal; } -bool LLAgent::isPositionChanged() const -{ - LLVector3d diff; - diff = mPositionGlobal - mLastPositionGlobal; - - return diff.lengthSquared() > 1.0; -} - //----------------------------------------------------------------------------- // getPositionAgent() //----------------------------------------------------------------------------- @@ -2852,10 +2844,10 @@ BOOL LLAgent::isInGroup(const LLUUID& group_id, BOOL ignore_god_mode /* FALSE */ if (!ignore_god_mode && isGodlike()) return true; - S32 count = mGroups.count(); - for(S32 i = 0; i < count; ++i) + U32 count = mGroups.size(); + for(U32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { return TRUE; } @@ -2872,12 +2864,12 @@ BOOL LLAgent::hasPowerInGroup(const LLUUID& group_id, U64 power) const // GP_NO_POWERS can also mean no power is enough to grant an ability. if (GP_NO_POWERS == power) return FALSE; - S32 count = mGroups.count(); - for(S32 i = 0; i < count; ++i) + U32 count = mGroups.size(); + for(U32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - return (BOOL)((mGroups.get(i).mPowers & power) > 0); + return (BOOL)((mGroups[i].mPowers & power) > 0); } } return FALSE; @@ -2893,12 +2885,12 @@ U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const if (isGodlike()) return GP_ALL_POWERS; - S32 count = mGroups.count(); - for(S32 i = 0; i < count; ++i) + U32 count = mGroups.size(); + for(U32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - return (mGroups.get(i).mPowers); + return (mGroups[i].mPowers); } } @@ -2907,12 +2899,12 @@ U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const BOOL LLAgent::getGroupData(const LLUUID& group_id, LLGroupData& data) const { - S32 count = mGroups.count(); + S32 count = mGroups.size(); for(S32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - data = mGroups.get(i); + data = mGroups[i]; return TRUE; } } @@ -2921,12 +2913,12 @@ BOOL LLAgent::getGroupData(const LLUUID& group_id, LLGroupData& data) const S32 LLAgent::getGroupContribution(const LLUUID& group_id) const { - S32 count = mGroups.count(); + S32 count = mGroups.size(); for(S32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - S32 contribution = mGroups.get(i).mContribution; + S32 contribution = mGroups[i].mContribution; return contribution; } } @@ -2935,12 +2927,12 @@ S32 LLAgent::getGroupContribution(const LLUUID& group_id) const BOOL LLAgent::setGroupContribution(const LLUUID& group_id, S32 contribution) { - S32 count = mGroups.count(); + S32 count = mGroups.size(); for(S32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - mGroups.get(i).mContribution = contribution; + mGroups[i].mContribution = contribution; LLMessageSystem* msg = gMessageSystem; msg->newMessage("SetGroupContribution"); msg->nextBlock("AgentData"); @@ -2958,13 +2950,13 @@ BOOL LLAgent::setGroupContribution(const LLUUID& group_id, S32 contribution) BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile) { - S32 count = mGroups.count(); + S32 count = mGroups.size(); for(S32 i = 0; i < count; ++i) { - if(mGroups.get(i).mID == group_id) + if(mGroups[i].mID == group_id) { - mGroups.get(i).mAcceptNotices = accept_notices; - mGroups.get(i).mListInProfile = list_in_profile; + mGroups[i].mAcceptNotices = accept_notices; + mGroups[i].mListInProfile = list_in_profile; LLMessageSystem* msg = gMessageSystem; msg->newMessage("SetGroupAcceptNotices"); msg->nextBlock("AgentData"); @@ -2984,7 +2976,7 @@ BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOO BOOL LLAgent::canJoinGroups() const { - return mGroups.count() < gMaxAgentGroups; + return (S32)mGroups.size() < gMaxAgentGroups; } LLQuaternion LLAgent::getHeadRotation() diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index a1e899b45d..46dad1dc20 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -34,6 +34,7 @@ #include "llcharacter.h" #include "llcoordframe.h" // for mFrameAgent #include "llvoavatardefines.h" +#include "lldarray.h" #include <boost/function.hpp> #include <boost/shared_ptr.hpp> @@ -251,7 +252,6 @@ public: const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; } void setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; } - bool isPositionChanged() const; private: std::set<U64> mRegionsVisited; // Stat - what distinct regions has the avatar been to? F64 mDistanceTraveled; // Stat - how far has the avatar moved? diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index e441f21f90..49e754a720 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -39,6 +39,7 @@ #include "llinventoryfunctions.h" #include "llinventoryobserver.h" #include "llinventorypanel.h" +#include "lllocaltextureobject.h" #include "llmd5.h" #include "llnotificationsutil.h" #include "lloutfitobserver.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index cb813ea889..cd881208ab 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1203,6 +1203,8 @@ LLFastTimer::DeclareTimer FTM_FRAME("Frame", true); bool LLAppViewer::mainLoop() { + llinfos << "***********************Entering main_loop***********************" << llendflush; + mMainloopTimeout = new LLWatchdogTimeout(); //------------------------------------------- @@ -1528,7 +1530,7 @@ bool LLAppViewer::mainLoop() destroyMainloopTimeout(); - llinfos << "Exiting main_loop" << llendflush; + llinfos << "***********************Exiting main_loop***********************" << llendflush; return true; } @@ -1575,11 +1577,9 @@ bool LLAppViewer::cleanup() LLEventPumps::instance().reset(); //dump scene loading monitor results - if(LLSceneMonitor::getInstance()->hasResults()) + if(LLSceneMonitor::instance().hasResults()) { - std::string file_name = "scene_monitor_results.csv"; - LLSceneMonitor::getInstance()->dumpToFile( - gDirUtilp->getExpandedFilename(LL_PATH_LOGS, file_name)); + LLSceneMonitor::instance().dumpToFile(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "scene_monitor_results.csv")); } if (LLFastTimerView::sAnalyzePerformance) @@ -4264,6 +4264,7 @@ void LLAppViewer::idle() { if (gRenderStartTime.getElapsedTimeF32() > qas) { + llinfos << "Quitting after " << qas << " seconds. See setting \"QuitAfterSeconds\"." << llendl; LLAppViewer::instance()->forceQuit(); } } diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index b539ac38ed..5f5bded3ad 100755 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -37,6 +37,7 @@ #include "lluictrlfactory.h" #include "llagentdata.h" #include "llimfloater.h" +#include "llviewertexture.h" // library includes #include "llavatarnamecache.h" diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 0d55c4429a..c34c09bf87 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -32,13 +32,10 @@ #include "llcallingcard.h" -#include <vector> #include <algorithm> -//#include <iterator> #include "indra_constants.h" -#include "llavatarnamecache.h" -#include "llcachename.h" +//#include "llcachename.h" #include "llstl.h" #include "lltimer.h" #include "lluuid.h" @@ -46,18 +43,13 @@ #include "llagent.h" #include "llavatarnamecache.h" -#include "llbutton.h" #include "llinventoryobserver.h" #include "llinventorymodel.h" #include "llnotifications.h" -#include "llnotificationsutil.h" -#include "llresmgr.h" #include "llslurl.h" #include "llimview.h" #include "llviewercontrol.h" -#include "llviewernetwork.h" #include "llviewerobjectlist.h" -#include "llviewerwindow.h" #include "llvoavatar.h" #include "llavataractions.h" @@ -104,8 +96,6 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, LLAvatarTracker::LLAvatarTracker() : mTrackingData(NULL), mTrackedAgentValid(false), - //mInventory(NULL), - //mInventoryObserver(NULL), mModifyMask(0x0) { } @@ -639,11 +629,11 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg) payload["from_id"] = agent_id; if(LLRelationship::GRANT_MODIFY_OBJECTS & new_rights) { - LLNotificationsUtil::add("GrantedModifyRights",args, payload); + LLNotifications::instance().add("GrantedModifyRights",args, payload); } else { - LLNotificationsUtil::add("RevokedModifyRights",args, payload); + LLNotifications::instance().add("RevokedModifyRights",args, payload); } } (mBuddyInfo[agent_id])->setRightsFrom(new_rights); @@ -728,7 +718,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, if (online) { notification = - LLNotificationsUtil::add("FriendOnline", + LLNotifications::instance().add("FriendOnline", args, payload.with("respond_on_mousedown", TRUE), boost::bind(&LLAvatarActions::startIM, agent_id)); @@ -736,7 +726,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, else { notification = - LLNotificationsUtil::add("FriendOffline", args, payload); + LLNotifications::instance().add("FriendOffline", args, payload); } // If there's an open IM session with this agent, send a notification there too. diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 17f610829d..92b3ee4a26 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -79,7 +79,7 @@ LLTrace::MemStatHandle LLDrawable::sMemStat("LLDrawable"); // static U32 LLDrawable::sNumZombieDrawables = 0; F32 LLDrawable::sCurPixelAngle = 0; -LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList; +LLDynamicArray<LLPointer<LLDrawable>, 32 > LLDrawable::sDeadList; #define FORCE_INVISIBLE_AREA 16.f diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 26796b92d0..e400a8b5f2 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -309,7 +309,7 @@ private: LLVector3 mCurrentScale; static U32 sNumZombieDrawables; - static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList; + static LLDynamicArray<LLPointer<LLDrawable>, 32> sDeadList; } LL_ALIGN_POSTFIX(16); diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 294cecc703..67dbe6de8b 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -421,7 +421,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass) if (pass == 0) { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); + avatarp->renderSkinned(); } else { @@ -1246,7 +1246,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if( !single_avatar || (avatarp == single_avatar) ) { - avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); + avatarp->renderSkinned(); } } diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 15c9e7856f..dda4bc9b3c 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -28,7 +28,6 @@ #define LL_LLFACE_H #include "llstrider.h" - #include "llrender.h" #include "v2math.h" #include "v3math.h" @@ -37,7 +36,6 @@ #include "v4coloru.h" #include "llquaternion.h" #include "xform.h" -#include "lldarrayptr.h" #include "llvertexbuffer.h" #include "llviewertexture.h" #include "lldrawable.h" @@ -47,10 +45,8 @@ class LLFacePool; class LLVolume; class LLViewerTexture; class LLTextureEntry; -class LLVertexProgram; -class LLViewerTexture; -class LLGeometryManager; class LLTextureAtlasSlot; +class LLDrawInfo; const F32 MIN_ALPHA_SIZE = 1024.f; const F32 MIN_TEX_ANIM_SIZE = 512.f; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 45ffe56ac1..b78dd08bf1 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -422,13 +422,6 @@ void LLFastTimerView::draw() mHoverBarIndex = -1; } -F64 LLFastTimerView::getTime(const std::string& name) -{ - //TODO: replace calls to this with use of timer object directly - //llstatic_assert(false, "TODO: implement"); - return 0.0; -} - void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) { //read result back into raw image diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 8b9ad290bc..341adacd65 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -62,7 +62,6 @@ public: virtual void draw(); LLTrace::TimeBlock* getLegendID(S32 y); - F64 getTime(const std::string& name); protected: virtual void onClickCloseBtn(); diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp index 4e10b4fc2c..0fc9150314 100644 --- a/indra/newview/llfloateravatartextures.cpp +++ b/indra/newview/llfloateravatartextures.cpp @@ -36,6 +36,7 @@ #include "lluictrlfactory.h" #include "llviewerobjectlist.h" #include "llvoavatarself.h" +#include "lllocaltextureobject.h" using namespace LLVOAvatarDefines; diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 8223e89b64..c1cea58801 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -202,7 +202,7 @@ public: virtual void draw(); virtual BOOL canClose(); - void onVisibilityChange ( const LLSD& new_visibility ); + void onVisibilityChanged ( const LLSD& new_visibility ); }; @@ -1008,7 +1008,7 @@ BOOL LLFloaterBuyLandUI::canClose() return can_close; } -void LLFloaterBuyLandUI::onVisibilityChange ( const LLSD& new_visibility ) +void LLFloaterBuyLandUI::onVisibilityChanged ( const LLSD& new_visibility ) { if (new_visibility.asBoolean()) { diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index be743d57d2..a2675d6d3e 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -225,7 +225,7 @@ void LLFloaterLand::onOpen(const LLSD& key) refresh(); } -void LLFloaterLand::onVisibilityChange(const LLSD& visible) +void LLFloaterLand::onVisibilityChanged(const LLSD& visible) { if (!visible.asBoolean()) { @@ -255,7 +255,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed) BOOL LLFloaterLand::postBuild() { - setVisibleCallback(boost::bind(&LLFloaterLand::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLFloaterLand::onVisibilityChanged, this, _2)); LLTabContainer* tab = getChild<LLTabContainer>("landtab"); diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 4f1c10274a..dccdfc9acb 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -88,7 +88,7 @@ private: LLFloaterLand(const LLSD& seed); virtual ~LLFloaterLand(); - void onVisibilityChange(const LLSD& visible); + void onVisibilityChanged(const LLSD& visible); protected: diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 6cce013105..34c1127826 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -2865,7 +2865,7 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key) } // virtual -void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility) +void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) { // If hiding (user switched to another tab or closed the floater), // display user's preferred environment. diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index f0499f1903..dd961e21b2 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -402,7 +402,7 @@ public: /*virtual*/ void onOpen(const LLSD& key); // LLView - /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); // LLPanelRegionInfo /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp index 2f9810775b..2bcee69b91 100644 --- a/indra/newview/llgroupiconctrl.cpp +++ b/indra/newview/llgroupiconctrl.cpp @@ -29,17 +29,7 @@ #include "llgroupiconctrl.h" #include "llagent.h" -/* -#include "llavatarconstants.h" -#include "llcallingcard.h" // for LLAvatarTracker -#include "llavataractions.h" -#include "llmenugl.h" -#include "lluictrlfactory.h" - -#include "llcachename.h" -#include "llagentdata.h" -#include "llimfloater.h" -*/ +#include "llviewertexture.h" static LLDefaultChildRegistry::Register<LLGroupIconCtrl> g_i("group_icon"); diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 81eb1d397e..eb83015f4a 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -41,6 +41,7 @@ #include "llui.h" #include "message.h" #include "roles_constants.h" +#include "llhttpclient.h" #include "lltransactiontypes.h" #include "llstatusbar.h" #include "lleconomy.h" @@ -50,6 +51,7 @@ #include "llnotificationsutil.h" #include "lluictrlfactory.h" #include "lltrans.h" +#include "llviewerregion.h" #include <boost/regex.hpp> #if LL_MSVC diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h index 644daa0299..2bbc9c839d 100644 --- a/indra/newview/llhudicon.h +++ b/indra/newview/llhudicon.h @@ -28,7 +28,6 @@ #define LL_LLHUDICON_H #include "llpointer.h" -#include "lldarrayptr.h" #include "llhudobject.h" #include "v4color.h" @@ -42,8 +41,6 @@ #include "lldarray.h" // Renders a 2D icon billboard floating at the location specified. -class LLDrawable; -class LLViewerObject; class LLViewerTexture; class LLHUDIcon : public LLHUDObject diff --git a/indra/newview/llhudmanager.h b/indra/newview/llhudmanager.h index 09e79acbfc..effea8f034 100644 --- a/indra/newview/llhudmanager.h +++ b/indra/newview/llhudmanager.h @@ -30,13 +30,9 @@ // Responsible for managing all HUD elements. #include "llhudobject.h" -#include "lldarrayptr.h" +#include "lldarray.h" -class LLViewerObject; class LLHUDEffect; -//Ventrella 9/16/05 -class LLHUDAnimalControls; -// End Ventrella class LLMessageSystem; class LLHUDManager : public LLSingleton<LLHUDManager> @@ -59,7 +55,7 @@ public: static LLColor4 sChildColor; protected: - LLDynamicArrayPtr<LLPointer<LLHUDEffect> > mHUDEffects; + LLDynamicArray<LLPointer<LLHUDEffect>, 32> mHUDEffects; }; #endif // LL_LLHUDMANAGER_H diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index 63eedcdfea..f27eaba760 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -38,6 +38,7 @@ #include "llchiclet.h" #include "llchicletbar.h" #include "llfloaterreg.h" +#include "llhttpclient.h" #include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container #include "llinventoryfunctions.h" #include "lllayoutstack.h" @@ -49,6 +50,7 @@ #include "lltrans.h" #include "llchathistory.h" #include "llnotifications.h" +#include "llviewerregion.h" #include "llviewerwindow.h" #include "llvoicechannel.h" #include "lltransientfloatermgr.h" @@ -163,7 +165,7 @@ void LLIMFloater::newIMCallback(const LLSD& data){ } } -void LLIMFloater::onVisibilityChange(const LLSD& new_visibility) +void LLIMFloater::onVisibilityChanged(const LLSD& new_visibility) { bool visible = new_visibility.asBoolean(); diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h index f7cd35b5eb..9bdcc113d6 100644 --- a/indra/newview/llimfloater.h +++ b/indra/newview/llimfloater.h @@ -88,7 +88,7 @@ public: // called when docked floater's position has been set by chiclet void setPositioned(bool b) { mPositioned = b; }; - void onVisibilityChange(const LLSD& new_visibility); + void onVisibilityChanged(const LLSD& new_visibility); void processIMTyping(const LLIMInfo* im_info, BOOL typing); void processAgentListUpdates(const LLSD& body); void processSessionUpdate(const LLSD& session_update); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 4000570872..080e1e7ad6 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -63,6 +63,7 @@ #include "lltoolbarview.h" #include "llviewercontrol.h" #include "llviewerparcelmgr.h" +#include "llviewerregion.h" const static std::string ADHOC_NAME_SUFFIX(" Conference"); diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index 7c2cd03d97..3b97ad0901 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -33,13 +33,12 @@ #include "lllogchat.h" #include "llvoicechannel.h" - +#include "lldarray.h" class LLAvatarName; class LLFriendObserver; class LLCallDialogManager; class LLIMSpeakerMgr; - /** * Timeout Timer for outgoing Ad-Hoc/Group IM sessions which being initialized by the server */ diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index 17d0b0ffbb..4f727bbd7d 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -37,6 +37,7 @@ #include "lldateutil.h" #include "llfloaterreporter.h" #include "llfloaterworldmap.h" +#include "llhttpclient.h" #include "llimview.h" #include "llinspect.h" #include "llmutelist.h" @@ -46,6 +47,7 @@ #include "llviewermenu.h" #include "llvoiceclient.h" #include "llviewerobjectlist.h" +#include "llviewerregion.h" #include "lltransientfloatermgr.h" #include "llnotificationsutil.h" diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 949de312be..927ae090c6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -68,6 +68,7 @@ #include "llviewermenu.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" +#include "llviewerregion.h" #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llwearablelist.h" diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp index 34734d57c5..0684734111 100644 --- a/indra/newview/llinventoryicon.cpp +++ b/indra/newview/llinventoryicon.cpp @@ -30,6 +30,7 @@ #include "lldictionary.h" #include "llinventorydefines.h" #include "llui.h" +#include "lluiimage.h" #include "llwearabletype.h" struct IconEntry : public LLDictionaryEntry @@ -47,6 +48,8 @@ public: LLIconDictionary(); }; +typedef LLPointer<LLUIImage> LLUIImagePtr; + LLIconDictionary::LLIconDictionary() { addEntry(LLInventoryIcon::ICONNAME_TEXTURE, new IconEntry("Inv_Texture")); diff --git a/indra/newview/llinventoryicon.h b/indra/newview/llinventoryicon.h index c7e2998a20..cbcddc26a9 100644 --- a/indra/newview/llinventoryicon.h +++ b/indra/newview/llinventoryicon.h @@ -30,7 +30,6 @@ #include "llassettype.h" #include "llinventorytype.h" -#include "lluiimage.h" class LLInventoryIcon { @@ -87,11 +86,11 @@ public: BOOL item_is_multi = FALSE); static const std::string& getIconName(EIconName idx); - static LLUIImagePtr getIcon(LLAssetType::EType asset_type, + static LLPointer<class LLUIImage> getIcon(LLAssetType::EType asset_type, LLInventoryType::EType inventory_type = LLInventoryType::IT_NONE, U32 misc_flag = 0, // different meanings depending on item type BOOL item_is_multi = FALSE); - static LLUIImagePtr getIcon(EIconName idx); + static LLPointer<class LLUIImage> getIcon(EIconName idx); protected: static EIconName assignWearableIcon(U32 misc_flag); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 8382e875b4..88463c4aa9 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -31,7 +31,7 @@ #include "llfoldertype.h" #include "lldarray.h" #include "llframetimer.h" -#include "llhttpclient.h" +#include "llcurl.h" #include "lluuid.h" #include "llpermissionsflags.h" #include "llstring.h" @@ -79,7 +79,7 @@ public: typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t; typedef std::set<LLUUID> changed_items_t; - class fetchInventoryResponder : public LLHTTPClient::Responder + class fetchInventoryResponder : public LLCurl::Responder { public: fetchInventoryResponder(const LLSD& request_sd) : mRequestSD(request_sd) {}; diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 97ba5b634a..ce04629104 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -48,6 +48,7 @@ /* misc headers */ #include "llscrolllistctrl.h" #include "llfilepicker.h" +#include "lllocaltextureobject.h" #include "llviewertexturelist.h" #include "llviewerobjectlist.h" #include "llviewerobject.h" diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h index 7a23c7ef6e..f99fc66f4b 100644 --- a/indra/newview/lllocalbitmaps.h +++ b/indra/newview/lllocalbitmaps.h @@ -33,6 +33,8 @@ #include "llvoavatardefines.h" class LLScrollListCtrl; +class LLImageRaw; +class LLViewerObject; class LLLocalBitmap { diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 99b4707158..baf5a3a839 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -392,7 +392,7 @@ BOOL LLMediaCtrl::postBuild () mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( "menu_media_ctrl.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); - setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChanged, this, _2)); return TRUE; } @@ -422,7 +422,7 @@ BOOL LLMediaCtrl::handleKeyHere( KEY key, MASK mask ) //////////////////////////////////////////////////////////////////////////////// // -void LLMediaCtrl::handleVisibilityChange ( BOOL new_visibility ) +void LLMediaCtrl::onVisibilityChange ( BOOL new_visibility ) { llinfos << "visibility changed to " << (new_visibility?"true":"false") << llendl; if(mMediaSource) @@ -450,7 +450,7 @@ BOOL LLMediaCtrl::handleUnicodeCharHere(llwchar uni_char) //////////////////////////////////////////////////////////////////////////////// // -void LLMediaCtrl::onVisibilityChange ( const LLSD& new_visibility ) +void LLMediaCtrl::onVisibilityChanged ( const LLSD& new_visibility ) { // set state of frequent updates automatically if visibility changes if ( new_visibility.asBoolean() ) diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 7f2a5e1642..db501cdb8c 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -149,7 +149,7 @@ public: // over-rides virtual BOOL handleKeyHere( KEY key, MASK mask); - virtual void handleVisibilityChange ( BOOL new_visibility ); + virtual void onVisibilityChange ( BOOL new_visibility ); virtual BOOL handleUnicodeCharHere(llwchar uni_char); virtual void reshape( S32 width, S32 height, BOOL called_from_parent = TRUE); virtual void draw(); @@ -171,7 +171,7 @@ public: void convertInputCoords(S32& x, S32& y); private: - void onVisibilityChange ( const LLSD& new_visibility ); + void onVisibilityChanged ( const LLSD& new_visibility ); void onPopup(const LLSD& notification, const LLSD& response); const S32 mTextureDepthBytes; diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 6889b98ab1..a86f722db9 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -52,6 +52,7 @@ #include "llfloaterworldmap.h" #include "llviewergenericmessage.h" // send_generic_message #include "llviewerregion.h" +#include "llviewertexture.h" #include "lltrans.h" #include "llscrollcontainer.h" #include "llstatusbar.h" diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 6b9edcb07c..79713ddb12 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -30,6 +30,7 @@ #include "llpanel.h" #include "llwearable.h" #include "lluictrl.h" +#include "lllocaltextureobject.h" #include "llscrollingpanellist.h" #include "llvisualparam.h" #include "lltoolmorph.h" diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index a50d9074f7..74c810ea79 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -202,7 +202,7 @@ void LLPanelNearByMedia::onTopLost() /*virtual*/ -void LLPanelNearByMedia::handleVisibilityChange ( BOOL new_visibility ) +void LLPanelNearByMedia::onVisibilityChange ( BOOL new_visibility ) { if (new_visibility) { diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h index c3634de9b4..a9c1b190cf 100644 --- a/indra/newview/llpanelnearbymedia.h +++ b/indra/newview/llpanelnearbymedia.h @@ -48,7 +48,7 @@ public: /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); /*virtual*/ void onTopLost(); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 36234b9536..26496ec9e2 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -488,7 +488,7 @@ BOOL LLPanelOutfitEdit::postBuild() childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL); childSetCommitCallback("shop_btn_2", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL); - setVisibleCallback(boost::bind(&LLPanelOutfitEdit::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLPanelOutfitEdit::onVisibilityChanged, this, _2)); mWearablesGearMenuBtn = getChild<LLMenuButton>("wearables_gear_menu_btn"); mGearMenuBtn = getChild<LLMenuButton>("gear_menu_btn"); @@ -774,7 +774,7 @@ void LLPanelOutfitEdit::onPlusBtnClicked(void) } } -void LLPanelOutfitEdit::onVisibilityChange(const LLSD &in_visible_chain) +void LLPanelOutfitEdit::onVisibilityChanged(const LLSD &in_visible_chain) { showAddWearablesPanel(false); mWearableItemsList->resetSelection(); diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h index 5d4b8d4644..30870daf40 100644 --- a/indra/newview/llpaneloutfitedit.h +++ b/indra/newview/llpaneloutfitedit.h @@ -145,7 +145,7 @@ public: void updatePlusButton(); void onPlusBtnClicked(void); - void onVisibilityChange(const LLSD &in_visible_chain); + void onVisibilityChanged(const LLSD &in_visible_chain); void applyFolderViewFilter(EFolderViewItemType type); void applyListViewFilter(EListViewItemType type); diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 46c58cd139..76f260cca1 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -38,6 +38,7 @@ class LLFilterEditor; class LLGroupList; class LLMenuButton; class LLTabContainer; +class LLNetMap; class LLPanelPeople : public LLPanel diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp index ce8057eead..b74547a9d7 100644 --- a/indra/newview/llpanelplaceprofile.cpp +++ b/indra/newview/llpanelplaceprofile.cpp @@ -302,9 +302,9 @@ void LLPanelPlaceProfile::processParcelInfo(const LLParcelData& parcel_data) } // virtual -void LLPanelPlaceProfile::handleVisibilityChange(BOOL new_visibility) +void LLPanelPlaceProfile::onVisibilityChange(BOOL new_visibility) { - LLPanel::handleVisibilityChange(new_visibility); + LLPanel::onVisibilityChange(new_visibility); LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance(); if (!parcel_mgr) diff --git a/indra/newview/llpanelplaceprofile.h b/indra/newview/llpanelplaceprofile.h index a33fc12ce4..01adfd4940 100644 --- a/indra/newview/llpanelplaceprofile.h +++ b/indra/newview/llpanelplaceprofile.h @@ -47,7 +47,7 @@ public: /*virtual*/ void processParcelInfo(const LLParcelData& parcel_data); - /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); // Displays information about the currently selected parcel // without sending a request to the server. diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp index 6c2a01fc82..dc18cc6081 100644 --- a/indra/newview/llpanelplaces.cpp +++ b/indra/newview/llpanelplaces.cpp @@ -998,9 +998,9 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible) } // virtual -void LLPanelPlaces::handleVisibilityChange(BOOL new_visibility) +void LLPanelPlaces::onVisibilityChange(BOOL new_visibility) { - LLPanel::handleVisibilityChange(new_visibility); + LLPanel::onVisibilityChange(new_visibility); if (!new_visibility && mPlaceInfoType == AGENT_INFO_TYPE) { diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h index 85bdc2c4e1..b6019ca32e 100644 --- a/indra/newview/llpanelplaces.h +++ b/indra/newview/llpanelplaces.h @@ -102,7 +102,7 @@ private: void togglePickPanel(BOOL visible); void togglePlaceInfoPanel(BOOL visible); - /*virtual*/ void handleVisibilityChange(BOOL new_visibility); + /*virtual*/ void onVisibilityChange(BOOL new_visibility); void updateVerbs(); diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index e2e7006773..435797bf80 100755 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -36,6 +36,7 @@ #include "lltabcontainer.h" #include "llviewercontrol.h" #include "llviewernetwork.h" +#include "llweb.h" static const std::string PANEL_PICKS = "panel_picks"; diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 1830086da2..fa371bd0ca 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -169,7 +169,7 @@ BOOL LLPanelTopInfoBar::postBuild() mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback( boost::bind(&LLPanelTopInfoBar::onAgentParcelChange, this)); - setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChanged, this, _2)); return TRUE; } @@ -186,7 +186,7 @@ void LLPanelTopInfoBar::onNavBarShowParcelPropertiesCtrlChanged() // when panel is shown, all minimized floaters should be shifted downwards to prevent overlapping of // PanelTopInfoBar. See EXT-7951. -void LLPanelTopInfoBar::onVisibilityChange(const LLSD& show) +void LLPanelTopInfoBar::onVisibilityChanged(const LLSD& show) { // this height is used as a vertical offset for ALREADY MINIMIZED floaters // when PanelTopInfoBar visibility changes diff --git a/indra/newview/llpaneltopinfobar.h b/indra/newview/llpaneltopinfobar.h index d58d95be90..f37bd9c048 100644 --- a/indra/newview/llpaneltopinfobar.h +++ b/indra/newview/llpaneltopinfobar.h @@ -57,7 +57,7 @@ public: /** * Called when the top info bar gets shown or hidden */ - void onVisibilityChange(const LLSD& show); + void onVisibilityChanged(const LLSD& show); boost::signals2::connection setResizeCallback( const resize_signal_t::slot_type& cb ); diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp index 6be2ea6481..1782afddd9 100644 --- a/indra/newview/llpanelvoicedevicesettings.cpp +++ b/indra/newview/llpanelvoicedevicesettings.cpp @@ -85,7 +85,7 @@ BOOL LLPanelVoiceDeviceSettings::postBuild() } // virtual -void LLPanelVoiceDeviceSettings::handleVisibilityChange ( BOOL new_visibility ) +void LLPanelVoiceDeviceSettings::onVisibilityChange ( BOOL new_visibility ) { if (new_visibility) { diff --git a/indra/newview/llpanelvoicedevicesettings.h b/indra/newview/llpanelvoicedevicesettings.h index ba3bcad0dc..83464f476a 100644 --- a/indra/newview/llpanelvoicedevicesettings.h +++ b/indra/newview/llpanelvoicedevicesettings.h @@ -44,7 +44,7 @@ public: void initialize(); void cleanup(); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); void setUseTuningMode(bool use) { mUseTuningMode = use; }; diff --git a/indra/newview/llpanelvoiceeffect.cpp b/indra/newview/llpanelvoiceeffect.cpp index 5fec6d967d..59ed53815b 100644 --- a/indra/newview/llpanelvoiceeffect.cpp +++ b/indra/newview/llpanelvoiceeffect.cpp @@ -35,6 +35,7 @@ #include "lltrans.h" #include "lltransientfloatermgr.h" #include "llvoiceclient.h" +#include "llweb.h" static LLRegisterPanelClassWrapper<LLPanelVoiceEffect> t_panel_voice_effect("panel_voice_effect"); diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp index aea7b33d7f..cb00f742cc 100644 --- a/indra/newview/llpanelvolumepulldown.cpp +++ b/indra/newview/llpanelvolumepulldown.cpp @@ -87,7 +87,7 @@ void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask) } /*virtual*/ -void LLPanelVolumePulldown::handleVisibilityChange ( BOOL new_visibility ) +void LLPanelVolumePulldown::onVisibilityChange ( BOOL new_visibility ) { if (new_visibility) { diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h index 0d86e6bd28..b843fab756 100644 --- a/indra/newview/llpanelvolumepulldown.h +++ b/indra/newview/llpanelvolumepulldown.h @@ -42,7 +42,7 @@ class LLPanelVolumePulldown : public LLPanel /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); /*virtual*/ void onTopLost(); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); /*virtual*/ BOOL postBuild(); private: diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index cbb4d5f964..bda603262d 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -253,7 +253,7 @@ void LLPreviewGesture::onUpdateSucceeded() refresh(); } -void LLPreviewGesture::onVisibilityChange ( const LLSD& new_visibility ) +void LLPreviewGesture::onVisibilityChanged ( const LLSD& new_visibility ) { if (new_visibility.asBoolean()) { @@ -333,7 +333,7 @@ LLPreviewGesture::~LLPreviewGesture() BOOL LLPreviewGesture::postBuild() { - setVisibleCallback(boost::bind(&LLPreviewGesture::onVisibilityChange, this, _2)); + setVisibleCallback(boost::bind(&LLPreviewGesture::onVisibilityChanged, this, _2)); LLLineEditor* edit; LLComboBox* combo; diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h index fd4fcf9d8f..7ce5706a0d 100644 --- a/indra/newview/llpreviewgesture.h +++ b/indra/newview/llpreviewgesture.h @@ -102,7 +102,7 @@ protected: // "Sound", "Chat", or "Wait" LLScrollListItem* addStep(const enum EStepType step_type); - void onVisibilityChange ( const LLSD& new_visibility ); + void onVisibilityChanged ( const LLSD& new_visibility ); static std::string getLabel(std::vector<std::string> labels); static void updateLabel(LLScrollListItem* item); diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index c592fd0a38..f744a924f5 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -50,36 +50,30 @@ LLSceneMonitorView* gSceneMonitorView = NULL; //2, (?) disable all sky and water; //3, capture frames periodically, by calling "capture()"; //4, compute pixel differences between two latest captured frames, by calling "compare()", results are stored at mDiff; -//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "queryDiff() -> calcDiffAggregate()"; +//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "calcDiffAggregate()"; //6, use gl occlusion query to fetch the result from GPU, by calling "fetchQueryResult()"; //END. // LLSceneMonitor::LLSceneMonitor() : - mEnabled(FALSE), + mEnabled(false), mDiff(NULL), mDiffResult(0.f), mDiffTolerance(0.1f), - mCurTarget(NULL), - mNeedsUpdateDiff(FALSE), - mHasNewDiff(FALSE), - mHasNewQueryResult(FALSE), - mDebugViewerVisible(FALSE), - mQuitting(FALSE), + mDiffState(WAITING_FOR_NEXT_DIFF), + mDebugViewerVisible(false), mQueryObject(0), - mSamplingTime(1.0f), mDiffPixelRatio(0.5f) { mFrames[0] = NULL; mFrames[1] = NULL; - mRecording = new LLTrace::ExtendableRecording(); - mRecording->start(); + mRecording = new LLTrace::ExtendablePeriodicRecording(); } LLSceneMonitor::~LLSceneMonitor() { - mQuitting = TRUE; + mDiffState = VIEWER_QUITTING; destroyClass(); } @@ -101,7 +95,8 @@ void LLSceneMonitor::reset() mFrames[0] = NULL; mFrames[1] = NULL; mDiff = NULL; - mCurTarget = NULL; + + mRecording->reset(); unfreezeScene(); @@ -173,54 +168,15 @@ void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height) mDitherScaleT = (F32)height / mDitherMatrixWidth; } -void LLSceneMonitor::setDebugViewerVisible(BOOL visible) +void LLSceneMonitor::setDebugViewerVisible(bool visible) { mDebugViewerVisible = visible; } -bool LLSceneMonitor::preCapture() +LLRenderTarget& LLSceneMonitor::getCaptureTarget() { - static LLCachedControl<bool> monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); - static LLFrameTimer timer; - - mCurTarget = NULL; - if (!LLGLSLShader::sNoFixedFunction) - { - return false; - } - - BOOL enabled = (BOOL)monitor_enabled || mDebugViewerVisible; - if(mEnabled != enabled) - { - if(mEnabled) - { - reset(); - unfreezeScene(); - } - else - { - freezeScene(); - } - - mEnabled = enabled; - } - - if(!mEnabled) - { - return false; - } + LLRenderTarget* cur_target = NULL; - if(gAgent.isPositionChanged()) - { - mRecording->reset(); - } - - if(timer.getElapsedTimeF32() < mSamplingTime) - { - return false; - } - timer.reset(); - S32 width = gViewerWindow->getWorldViewWidthRaw(); S32 height = gViewerWindow->getWorldViewHeightRaw(); @@ -232,7 +188,7 @@ bool LLSceneMonitor::preCapture() gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - mCurTarget = mFrames[0]; + cur_target = mFrames[0]; } else if(!mFrames[1]) { @@ -242,21 +198,22 @@ bool LLSceneMonitor::preCapture() gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - mCurTarget = mFrames[1]; + cur_target = mFrames[1]; } else //swap { - mCurTarget = mFrames[0]; + cur_target = mFrames[0]; mFrames[0] = mFrames[1]; - mFrames[1] = mCurTarget; + mFrames[1] = cur_target; } - if(mCurTarget->getWidth() != width || mCurTarget->getHeight() != height) //size changed + if(cur_target->getWidth() != width || cur_target->getHeight() != height) //size changed { - mCurTarget->resize(width, height, GL_RGB); + cur_target->resize(width, height, GL_RGB); } - return true; + // we're promising the target exists + return *cur_target; } void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp) @@ -289,7 +246,7 @@ void LLSceneMonitor::unfreezeScene() //thaw all avatars mAvatarPauseHandles.clear(); - if(mQuitting) + if(mDiffState == VIEWER_QUITTING) { return; //we are quitting viewer. } @@ -308,61 +265,95 @@ void LLSceneMonitor::unfreezeScene() void LLSceneMonitor::capture() { static U32 last_capture_time = 0; + static LLCachedControl<bool> monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled"); + static LLCachedControl<F32> scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); + static LLFrameTimer timer; - if(last_capture_time == gFrameCount) + LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); + if (mEnabled + && (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f + || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)) { - return; + reset(); + freezeScene(); } - last_capture_time = gFrameCount; - - preCapture(); - if(!mCurTarget) + bool enabled = monitor_enabled || mDebugViewerVisible; + if(mEnabled != enabled) { - return; + if(mEnabled) + { + unfreezeScene(); + } + else + { + reset(); + freezeScene(); + } + + mEnabled = enabled; } - - U32 old_FBO = LLRenderTarget::sCurFBO; - gGL.getTexUnit(0)->bind(mCurTarget); - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer. + if(timer.getElapsedTimeF32() > scene_load_sample_time() + && mEnabled + && LLGLSLShader::sNoFixedFunction + && last_capture_time != gFrameCount) + { + mRecording->resume(); + + timer.reset(); + + last_capture_time = gFrameCount; + + LLRenderTarget& cur_target = getCaptureTarget(); + + U32 old_FBO = LLRenderTarget::sCurFBO; + + gGL.getTexUnit(0)->bind(&cur_target); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer. - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, mCurTarget->getWidth(), mCurTarget->getHeight()); //copy the content + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, cur_target.getWidth(), cur_target.getHeight()); //copy the content - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); - mCurTarget = NULL; - mNeedsUpdateDiff = TRUE; + mDiffState = NEED_DIFF; + } } bool LLSceneMonitor::needsUpdate() const { - return mNeedsUpdateDiff; + return mDiffState == NEED_DIFF; } +static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture"); +static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff"); + void LLSceneMonitor::compare() { - if(!mNeedsUpdateDiff) + if(mDiffState != NEED_DIFF) { return; } - mNeedsUpdateDiff = FALSE; if(!mFrames[0] || !mFrames[1]) { return; } if(mFrames[0]->getWidth() != mFrames[1]->getWidth() || mFrames[0]->getHeight() != mFrames[1]->getHeight()) - { - return; //size does not match + { //size does not match + return; } + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + mDiffState = EXECUTE_DIFF; + S32 width = gViewerWindow->getWindowWidthRaw(); S32 height = gViewerWindow->getWindowHeightRaw(); if(!mDiff) { + LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE); mDiff = new LLRenderTarget(); mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true); @@ -370,6 +361,7 @@ void LLSceneMonitor::compare() } else if(mDiff->getWidth() != width || mDiff->getHeight() != height) { + LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE); mDiff->resize(width, height, GL_RGBA); generateDitheringTexture(width, height); } @@ -411,26 +403,18 @@ void LLSceneMonitor::compare() gGL.getTexUnit(2)->disable(); gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); - mHasNewDiff = TRUE; - - //send out the query request. - queryDiff(); -} - -void LLSceneMonitor::queryDiff() -{ - if(mDebugViewerVisible) + if (!mDebugViewerVisible) { - return; + calcDiffAggregate(); } - - calcDiffAggregate(); } //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it. void LLSceneMonitor::calcDiffAggregate() { - if(!mHasNewDiff && !mDebugViewerVisible) + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + + if(mDiffState != EXECUTE_DIFF && !mDebugViewerVisible) { return; } @@ -452,18 +436,17 @@ void LLSceneMonitor::calcDiffAggregate() gOneTextureFilterProgram.bind(); gOneTextureFilterProgram.uniform1f("tolerance", mDiffTolerance); - if(mHasNewDiff) + if(mDiffState == EXECUTE_DIFF) { glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject); } gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff); - if(mHasNewDiff) + if(mDiffState == EXECUTE_DIFF) { glEndQueryARB(GL_SAMPLES_PASSED_ARB); - mHasNewDiff = FALSE; - mHasNewQueryResult = TRUE; + mDiffState = WAIT_ON_RESULT; } gOneTextureFilterProgram.unbind(); @@ -482,67 +465,155 @@ void LLSceneMonitor::calcDiffAggregate() static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference"); void LLSceneMonitor::fetchQueryResult() { - if(!mHasNewQueryResult) - { - return; - } - mHasNewQueryResult = FALSE; + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); - GLuint available = 0; - glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); - if(!available) + if(mDiffState == WAIT_ON_RESULT) { - return; - } + mDiffState = WAITING_FOR_NEXT_DIFF; - GLuint count = 0; - glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); + GLuint available = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); + if(available) + { + GLuint count = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); - mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) - - addMonitorResult(); + mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) + + LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; + sample(sFramePixelDiff, mDiffResult); + + static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); + if(mDiffResult > diff_threshold()) + { + mRecording->extend(); + } + else + { + mRecording->getPotentialRecording().nextPeriod(); + } + } + } } -void LLSceneMonitor::addMonitorResult() +//dump results to a file _scene_xmonitor_results.csv +void LLSceneMonitor::dumpToFile(std::string file_name) { - const F32 diff_threshold = 0.001f; - if(mDiffResult < diff_threshold) + LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; + + std::ofstream os(file_name.c_str()); + + //total scene loading time + os << std::setprecision(4); + + LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording(); + U32 frame_count = scene_load_recording.getNumPeriods(); + + LLUnit<LLUnits::Seconds, F64> frame_time; + + os << "Stat"; + for (S32 frame = 0; frame < frame_count; frame++) { - return; + frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); + os << ", " << frame_time.value(); } + os << std::endl; + + for (LLTrace::CountStatHandle<F64>::instance_iter it = LLTrace::CountStatHandle<F64>::beginInstances(), end_it = LLTrace::CountStatHandle<F64>::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); - mRecording->extend(); - sample(sFramePixelDiff, mDiffResult); + S32 samples = 0; - ll_monitor_result_t result; - result.mTimeStamp = LLImageGL::sLastFrameTime; - result.mDiff = mDiffResult; - mMonitorResults.push_back(result); + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } } -//dump results to a file _scene_monitor_results.csv -void LLSceneMonitor::dumpToFile(std::string file_name) -{ - if(mMonitorResults.empty() || !getRecording()) + for (LLTrace::CountStatHandle<S64>::instance_iter it = LLTrace::CountStatHandle<S64>::beginInstances(), end_it = LLTrace::CountStatHandle<S64>::endInstances(); + it != end_it; + ++it) { - return; //nothing to dump + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } } - std::ofstream os(file_name.c_str()); + for (LLTrace::MeasurementStatHandle<F64>::instance_iter it = LLTrace::MeasurementStatHandle<F64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<F64>::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); - //total scene loading time - os << llformat("Scene Loading time: %.4f seconds\n", (F32)getRecording()->getAcceptedRecording().getDuration().value()); + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } - S32 num_results = mMonitorResults.size(); - for(S32 i = 0; i < num_results; i++) + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::MeasurementStatHandle<S64>::instance_iter it = LLTrace::MeasurementStatHandle<S64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<S64>::endInstances(); + it != end_it; + ++it) { - os << llformat("%.4f %.4f\n", mMonitorResults[i].mTimeStamp, mMonitorResults[i].mDiff); + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } } os.flush(); os.close(); - mMonitorResults.clear(); } //------------------------------------------------------------------------------------------------------------- @@ -563,12 +634,10 @@ void LLSceneMonitorView::onClickCloseBtn() setVisible(false); } -void LLSceneMonitorView::setVisible(BOOL visible) +void LLSceneMonitorView::onVisibilityChange(BOOL visible) { visible = visible && LLGLSLShader::sNoFixedFunction; LLSceneMonitor::getInstance()->setDebugViewerVisible(visible); - - LLView::setVisible(visible); } void LLSceneMonitorView::draw() @@ -582,8 +651,6 @@ void LLSceneMonitorView::draw() F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio(); S32 height = (S32)(target->getHeight() * ratio); S32 width = (S32)(target->getWidth() * ratio); - //S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); - //S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); @@ -608,7 +675,7 @@ void LLSceneMonitorView::draw() LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; - num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime()); + num_str = llformat("Sampling time: %.3f seconds", gSavedSettings.getF32("SceneLoadingMonitorSampleTime")); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h index c897b237b6..3351ed0579 100644 --- a/indra/newview/llscenemonitor.h +++ b/indra/newview/llscenemonitor.h @@ -39,6 +39,7 @@ class LLViewerTexture; class LLSceneMonitor : public LLSingleton<LLSceneMonitor> { + LOG_CLASS(LLSceneMonitor); public: LLSceneMonitor(); ~LLSceneMonitor(); @@ -46,11 +47,10 @@ public: void destroyClass(); void freezeAvatar(LLCharacter* avatarp); - void setDebugViewerVisible(BOOL visible); + void setDebugViewerVisible(bool visible); void capture(); //capture the main frame buffer void compare(); //compare the stored two buffers. - void queryDiff(); void fetchQueryResult(); void calcDiffAggregate(); void setDiffTolerance(F32 tol) {mDiffTolerance = tol;} @@ -58,40 +58,41 @@ public: const LLRenderTarget* getDiffTarget() const {return mDiff;} F32 getDiffTolerance() const {return mDiffTolerance;} F32 getDiffResult() const { return mDiffResult;} - F32 getSamplingTime() const { return mSamplingTime;} F32 getDiffPixelRatio() const { return mDiffPixelRatio;} bool isEnabled()const {return mEnabled;} bool needsUpdate() const; - LLTrace::ExtendableRecording* getRecording() const {return mRecording;} + LLTrace::ExtendablePeriodicRecording* getRecording() const {return mRecording;} void dumpToFile(std::string file_name); - bool hasResults() const { return !mMonitorResults.empty();} + bool hasResults() const { return mRecording->getAcceptedRecording().getDuration() != 0;} private: void freezeScene(); void unfreezeScene(); void reset(); - bool preCapture(); + LLRenderTarget& getCaptureTarget(); void generateDitheringTexture(S32 width, S32 height); - void addMonitorResult(); private: - BOOL mEnabled; - BOOL mNeedsUpdateDiff; - BOOL mHasNewDiff; - BOOL mHasNewQueryResult; - BOOL mDebugViewerVisible; - BOOL mQuitting; + bool mEnabled; + bool mDebugViewerVisible; + + enum EDiffState + { + WAITING_FOR_NEXT_DIFF, + NEED_DIFF, + EXECUTE_DIFF, + WAIT_ON_RESULT, + VIEWER_QUITTING + } mDiffState; LLRenderTarget* mFrames[2]; LLRenderTarget* mDiff; - LLRenderTarget* mCurTarget; GLuint mQueryObject; //used for glQuery F32 mDiffResult; //aggregate results of mDiff. F32 mDiffTolerance; //pixels are filtered out when R+G+B < mDiffTolerance - F32 mSamplingTime; //time interval to capture frames, in seconds F32 mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension LLPointer<LLViewerTexture> mDitheringTexture; @@ -102,15 +103,7 @@ private: std::vector<LLAnimPauseRequest> mAvatarPauseHandles; - LLTrace::ExtendableRecording* mRecording; - - //--------------------------------------- - typedef struct _monitor_result - { - F32 mTimeStamp; - F32 mDiff; - } ll_monitor_result_t; - std::vector<ll_monitor_result_t> mMonitorResults; + LLTrace::ExtendablePeriodicRecording* mRecording; }; class LLSceneMonitorView : public LLFloater @@ -119,7 +112,8 @@ public: LLSceneMonitorView(const LLRect& rect); virtual void draw(); - virtual void setVisible(BOOL visible); + + virtual void onVisibilityChange(BOOL visible); protected: virtual void onClickCloseBtn(); diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index d909a218e3..e0fb09d86d 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -142,7 +142,7 @@ BOOL LLSidepanelAppearance::postBuild() mCurrOutfitPanel = getChild<LLPanel>("panel_currentlook"); - setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChange,this,_2)); + setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChanged,this,_2)); return TRUE; } @@ -181,7 +181,7 @@ void LLSidepanelAppearance::onOpen(const LLSD& key) mOpened = true; } -void LLSidepanelAppearance::onVisibilityChange(const LLSD &new_visibility) +void LLSidepanelAppearance::onVisibilityChanged(const LLSD &new_visibility) { LLSD visibility; visibility["visible"] = new_visibility.asBoolean(); diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h index 6dd3520266..8564827a17 100644 --- a/indra/newview/llsidepanelappearance.h +++ b/indra/newview/llsidepanelappearance.h @@ -67,7 +67,7 @@ public: private: void onFilterEdit(const std::string& search_string); - void onVisibilityChange ( const LLSD& new_visibility ); + void onVisibilityChanged ( const LLSD& new_visibility ); void onOpenOutfitButtonClicked(); void onEditAppearanceButtonClicked(); diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index 986ac14140..191e0abefd 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -162,7 +162,7 @@ BOOL LLSidepanelTaskInfo::postBuild() return TRUE; } -/*virtual*/ void LLSidepanelTaskInfo::handleVisibilityChange ( BOOL visible ) +/*virtual*/ void LLSidepanelTaskInfo::onVisibilityChange ( BOOL visible ) { if (visible) { diff --git a/indra/newview/llsidepaneltaskinfo.h b/indra/newview/llsidepaneltaskinfo.h index 05edcda5ed..a1479ef0e7 100644 --- a/indra/newview/llsidepaneltaskinfo.h +++ b/indra/newview/llsidepaneltaskinfo.h @@ -50,7 +50,7 @@ public: virtual ~LLSidepanelTaskInfo(); /*virtual*/ BOOL postBuild(); - /*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); void setObjectSelection(LLObjectSelectionHandle selection); diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 07d2f1ad6f..5ad8165a72 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -33,7 +33,9 @@ #include "llimview.h" #include "llsdutil.h" #include "lluicolortable.h" +#include "llhttpclient.h" #include "llviewerobjectlist.h" +#include "llviewerregion.h" #include "llvoavatar.h" #include "llworld.h" diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index cf2b491d6c..f748344cc8 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2048,7 +2048,7 @@ bool idle_startup() static LLFrameTimer wearables_timer; const F32 wearables_time = wearables_timer.getElapsedTimeF32(); - const F32 MAX_WEARABLES_TIME = 10.f; + static LLCachedControl<F32> max_wearables_time(gSavedSettings, "ClothingLoadingDelay"); if (!gAgent.isGenderChosen() && isAgentAvatarValid()) { @@ -2068,7 +2068,7 @@ bool idle_startup() display_startup(); - if (wearables_time > MAX_WEARABLES_TIME) + if (wearables_time > max_wearables_time()) { LLNotificationsUtil::add("ClothingLoading"); add(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, 1); @@ -2102,7 +2102,7 @@ bool idle_startup() display_startup(); update_texture_fetch(); display_startup(); - set_startup_status(0.9f + 0.1f * wearables_time / MAX_WEARABLES_TIME, + set_startup_status(0.9f + 0.1f * wearables_time / max_wearables_time(), LLTrans::getString("LoginDownloadingClothing").c_str(), gAgent.mMOTD.c_str()); display_startup(); diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index d6cd881894..1c2bbbed27 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -31,6 +31,7 @@ #include "llagent.h" #include "llimagej2c.h" #include "llimagetga.h" +#include "lllocaltextureobject.h" #include "llnotificationsutil.h" #include "llvfile.h" #include "llvfs.h" diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index a0c12df834..61d879278d 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -42,6 +42,7 @@ #include "llfloaterscriptdebug.h" #include "lltooltip.h" #include "llhudeffecttrail.h" +#include "llhudicon.h" #include "llhudmanager.h" #include "llkeyboard.h" #include "llmediaentry.h" diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 7c604a04bf..0a9153eecb 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -32,6 +32,7 @@ #include "llagentcamera.h" #include "llviewercontrol.h" #include "lldrawable.h" +#include "llhudicon.h" #include "llmanip.h" #include "llmenugl.h" #include "llselectmgr.h" diff --git a/indra/newview/lltoolselect.h b/indra/newview/lltoolselect.h index baa27f6071..74dababe8c 100644 --- a/indra/newview/lltoolselect.h +++ b/indra/newview/lltoolselect.h @@ -34,7 +34,7 @@ class LLObjectSelection; -class LLToolSelect : public LLTool, public LLSingleton<LLToolSelect> +class LLToolSelect : public LLTool { public: LLToolSelect( LLToolComposite* composite ); diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index 5b25d791a9..56eaa13df9 100644 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -38,6 +38,7 @@ #include "llsd.h" #include "llvoavatar.h" #include "lltrace.h" +#include "llinitparam.h" /** * @class LLViewerAssetStats diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index 8d8c401dac..4e97dfb201 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -36,6 +36,7 @@ #include "llviewerwindow.h" #include "llvoiceclient.h" #include "llviewermedia.h" +#include "llviewerregion.h" #include "llprogressview.h" #include "llcallbacklist.h" #include "llstartup.h" diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 1f5bdc8589..45302ebb74 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -57,7 +57,7 @@ LLTrace::CountStatHandle<> LLViewerCamera::sVelocityStat("camera_velocity"); LLTrace::CountStatHandle<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity"); -U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; +LLViewerCamera::eCameraID LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; //glu pick matrix implementation borrowed from Mesa3D glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLint* viewport) diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index d7835d8567..7b2887d725 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -80,7 +80,7 @@ public: NUM_CAMERAS } eCameraID; - static U32 sCurCameraID; + static eCameraID sCurCameraID; LLViewerCamera(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 0889c3ec6c..5974c84596 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -85,9 +85,6 @@ extern bool gShiftFrame; LLPointer<LLViewerTexture> gDisconnectedImagep = NULL; // used to toggle renderer back on after teleport -const F32 TELEPORT_RENDER_DELAY = 20.f; // Max time a teleport is allowed to take before we raise the curtain -const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. -const F32 TELEPORT_LOCAL_DELAY = 1.0f; // Delay to prevent teleports after starting an in-sim teleport. BOOL gTeleportDisplay = FALSE; LLFrameTimer gTeleportDisplayTimer; LLFrameTimer gTeleportArrivalTimer; @@ -373,7 +370,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(FTM_TELEPORT_DISPLAY); LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); - const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. + static LLCachedControl<F32> teleport_arrival_delay(gSavedSettings, "TeleportArrivalDelay"); + static LLCachedControl<F32> teleport_local_delay(gSavedSettings, "TeleportLocalDelay"); S32 attach_count = 0; if (isAgentAvatarValid()) @@ -441,7 +439,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) case LLAgent::TELEPORT_ARRIVING: // Make the user wait while content "pre-caches" { - F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / TELEPORT_ARRIVAL_DELAY); + F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / teleport_arrival_delay()); if( arrival_fraction > 1.f ) { arrival_fraction = 1.f; @@ -458,7 +456,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // Short delay when teleporting in the same sim (progress screen active but not shown - did not // fall-through from TELEPORT_START) { - if( gTeleportDisplayTimer.getElapsedTimeF32() > TELEPORT_LOCAL_DELAY ) + if( gTeleportDisplayTimer.getElapsedTimeF32() > teleport_local_delay() ) { //LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); @@ -805,6 +803,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } + LLSceneMonitor::getInstance()->fetchQueryResult(); + LLGLState::checkStates(); LLGLState::checkClientArrays(); diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 5d1aa870a3..1850ed45d1 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -128,7 +128,6 @@ BOOL LLSkinJoint::setupSkinJoint( LLViewerJoint *joint) //----------------------------------------------------------------------------- BOOL LLViewerJointMesh::sPipelineRender = FALSE; -EAvatarRenderPass LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; U32 LLViewerJointMesh::sClothingMaskImageName = 0; LLColor4 LLViewerJointMesh::sClothingInnerColor; diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index dd5dae1dc1..614d87f2b1 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -37,13 +37,6 @@ class LLFace; class LLCharacter; class LLTexLayerSet; -typedef enum e_avatar_render_pass -{ - AVATAR_RENDER_PASS_SINGLE, - AVATAR_RENDER_PASS_CLOTHING_INNER, - AVATAR_RENDER_PASS_CLOTHING_OUTER -} EAvatarRenderPass; - class LLSkinJoint { public: @@ -84,7 +77,6 @@ public: static BOOL sPipelineRender; //RN: this is here for testing purposes static U32 sClothingMaskImageName; - static EAvatarRenderPass sRenderPass; static LLColor4 sClothingInnerColor; public: diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index ef28c3ad53..50b14183c7 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -39,6 +39,7 @@ #include "llfloaterreg.h" #include "llfontgl.h" #include "llframetimer.h" +#include "llhudicon.h" #include "llinventory.h" #include "llinventorydefines.h" #include "llmaterialtable.h" diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 942eb67823..536106fb1e 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -30,8 +30,7 @@ #include <map> #include "llassetstorage.h" -#include "lldarrayptr.h" -#include "llhudicon.h" +//#include "llhudicon.h" #include "llinventory.h" #include "llrefcount.h" #include "llprimitive.h" @@ -43,34 +42,30 @@ #include "v3math.h" #include "llvertexbuffer.h" #include "llbbox.h" -#include "llbbox.h" class LLAgent; // TODO: Get rid of this. class LLAudioSource; class LLAudioSourceVO; -class LLDataPacker; class LLColor4; -class LLFrameTimer; +class LLDataPacker; +class LLDataPackerBinaryBuffer; class LLDrawable; -class LLHost; class LLHUDText; -class LLWorld; -class LLNameValue; -class LLNetMap; +class LLHost; class LLMessageSystem; +class LLNameValue; class LLPartSysData; -class LLPrimitive; class LLPipeline; class LLTextureEntry; -class LLViewerTexture; +class LLVOAvatar; +class LLVOInventoryListener; class LLViewerInventoryItem; class LLViewerObject; +class LLViewerObjectMedia; class LLViewerPartSourceScript; class LLViewerRegion; -class LLViewerObjectMedia; -class LLVOInventoryListener; -class LLVOAvatar; -class LLDataPackerBinaryBuffer; +class LLViewerTexture; +class LLWorld; typedef enum e_object_update_type { @@ -645,7 +640,7 @@ public: // TODO: Make all this stuff private. JC LLPointer<LLHUDText> mText; - LLPointer<LLHUDIcon> mIcon; + LLPointer<class LLHUDIcon> mIcon; static BOOL sUseSharedDrawables; static LLTrace::MemStatHandle sMemStat; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 4d0d3e8718..6ffd3d8fa4 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -47,6 +47,7 @@ #include "lltooltip.h" #include "llworld.h" #include "llstring.h" +#include "llhudicon.h" #include "llhudnametag.h" #include "lldrawable.h" #include "llflexibleobject.h" @@ -2275,3 +2276,10 @@ bool LLViewerObjectList::OrphanInfo::operator!=(const OrphanInfo &rhs) const } +LLDebugBeacon::~LLDebugBeacon() +{ + if (mHUDObject.notNull()) + { + mHUDObject->markDead(); + } +} diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index a7a4969768..65447156e7 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -237,20 +237,14 @@ protected: class LLDebugBeacon { public: - ~LLDebugBeacon() - { - if (mHUDObject.notNull()) - { - mHUDObject->markDead(); - } - } + ~LLDebugBeacon(); LLVector3 mPositionAgent; std::string mString; LLColor4 mColor; LLColor4 mTextColor; S32 mLineWidth; - LLPointer<LLHUDObject> mHUDObject; + LLPointer<class LLHUDObject> mHUDObject; }; diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 844075089f..d9e1774c6d 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -426,10 +426,7 @@ void LLViewerOctreeEntryData::setVisible() const LLviewerOctreeGroup::~LLviewerOctreeGroup() { - if(LLViewerRegion::sCurRegionp && isVisible()) - { - LLViewerRegion::sCurRegionp->clearVisibleGroup(this); - } + //empty here } LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : @@ -623,7 +620,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo } else { - OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl; + OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << llendl; } unbound(); diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index ed77e4bb7e..1d3533e95c 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -91,9 +91,6 @@ public: void setGroup(LLviewerOctreeGroup* group); void removeData(LLViewerOctreeEntryData* data); - LLViewerOctreeEntryData* getData(U32 data_type)const {return mData[data_type];} - bool hasData(U32 data_type)const {return mData[data_type] != NULL;} - LLViewerOctreeEntryData* getDrawable() const {return mData[LLDRAWABLE];} bool hasDrawable() const {return mData[LLDRAWABLE] != NULL;} LLViewerOctreeEntryData* getVOCacheEntry() const {return mData[LLVOCACHEENTRY];} diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index 27bfcd4343..5c71b4c49e 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -27,7 +27,6 @@ #ifndef LL_LLVIEWERPARTSIM_H #define LL_LLVIEWERPARTSIM_H -#include "lldarrayptr.h" #include "llframetimer.h" #include "llpointer.h" #include "llpartdata.h" @@ -36,7 +35,6 @@ class LLViewerTexture; class LLViewerPart; class LLViewerRegion; -class LLViewerTexture; class LLVOPartGroup; #define LL_MAX_PARTICLE_COUNT 8192 diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h index cafe28356d..137849234d 100644 --- a/indra/newview/llviewerprecompiledheaders.h +++ b/indra/newview/llviewerprecompiledheaders.h @@ -54,11 +54,9 @@ // Library headers from llcommon project: #include "bitpack.h" -#include "lldeleteutils.h" #include "imageids.h" #include "indra_constants.h" #include "llinitparam.h" - #include "llallocator.h" #include "llapp.h" #include "llcriticaldamp.h" @@ -67,11 +65,7 @@ #include "llerror.h" #include "llfasttimer.h" #include "llframetimer.h" -#include "llhash.h" -#include "lllocalidhashmap.h" -#include "llnametable.h" #include "llpointer.h" -#include "llpriqueuemap.h" #include "llprocessor.h" #include "llrefcount.h" #include "llsafehandle.h" diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index a2ff232d02..85da75510b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -86,7 +86,6 @@ const F32 CAP_REQUEST_TIMEOUT = 18; // Even though we gave up on login, keep trying for caps after we are logged in: const S32 MAX_CAP_REQUEST_ATTEMPTS = 30; -LLViewerRegion* LLViewerRegion::sCurRegionp = NULL; BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE; typedef std::map<std::string, std::string> CapabilityMap; @@ -94,28 +93,29 @@ typedef std::map<std::string, std::string> CapabilityMap; class LLViewerRegionImpl { public: LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host) - : mHost(host), - mCompositionp(NULL), - mEventPoll(NULL), - mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS), - mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN), - mSeedCapAttempts(0), - mHttpResponderID(0), - mLastCameraUpdate(0), - mLastCameraOrigin(), - // I'd prefer to set the LLCapabilityListener name to match the region - // name -- it's disappointing that's not available at construction time. - // We could instead store an LLCapabilityListener*, making - // setRegionNameAndZone() replace the instance. Would that pose - // consistency problems? Can we even request a capability before calling - // setRegionNameAndZone()? - // For testability -- the new Michael Feathers paradigm -- - // LLCapabilityListener binds all the globals it expects to need at - // construction time. - mCapabilityListener(host.getString(), gMessageSystem, *region, - gAgent.getID(), gAgent.getSessionID()) - { - } + : mHost(host), + mCompositionp(NULL), + mEventPoll(NULL), + mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS), + mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN), + mSeedCapAttempts(0), + mHttpResponderID(0), + mLastCameraUpdate(0), + mLastCameraOrigin(), + mVOCachePartition(NULL), + mLandp(NULL), + // I'd prefer to set the LLCapabilityListener name to match the region + // name -- it's disappointing that's not available at construction time. + // We could instead store an LLCapabilityListener*, making + // setRegionNameAndZone() replace the instance. Would that pose + // consistency problems? Can we even request a capability before calling + // setRegionNameAndZone()? + // For testability -- the new Michael Feathers paradigm -- + // LLCapabilityListener binds all the globals it expects to need at + // construction time. + mCapabilityListener(host.getString(), gMessageSystem, *region, + gAgent.getID(), gAgent.getSessionID()) + {} void buildCapabilityNames(LLSD& capabilityNames); @@ -142,7 +142,7 @@ public: LLVOCacheEntry::vocache_entry_map_t mCacheMap; //all cached entries LLVOCacheEntry::vocache_entry_set_t mActiveSet; //all active entries; LLVOCacheEntry::vocache_entry_set_t mWaitingSet; //entries waiting for LLDrawable to be generated. - std::set< LLviewerOctreeGroup* > mVisibleGroups; //visible groupa + std::set< LLPointer<LLviewerOctreeGroup> > mVisibleGroups; //visible groupa LLVOCachePartition* mVOCachePartition; LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation. LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation. @@ -439,7 +439,7 @@ void LLViewerRegion::loadObjectCache() // Presume success. If it fails, we don't want to try again. mCacheLoaded = TRUE; - if(LLVOCache::hasInstance()) + if(LLVOCache::instanceExists()) { LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ; if (mImpl->mCacheMap.empty()) @@ -462,7 +462,7 @@ void LLViewerRegion::saveObjectCache() return; } - if(LLVOCache::hasInstance()) + if(LLVOCache::instanceExists()) { const F32 start_time_threshold = 600.0f; //seconds bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file. @@ -755,7 +755,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry if(old_entry) { - old_entry->copyTo(new_entry); + old_entry->moveTo(new_entry); state = old_entry->getState(); in_vo_tree = (state == LLVOCacheEntry::INACTIVE && old_entry->getGroup() != NULL); killCacheEntry(old_entry); @@ -942,18 +942,6 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry) mImpl->mVisibleEntries.insert(entry); } -void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group) -{ - if(mDead) - { - return; - } - - llassert(!group->getOctreeNode() || group->isEmpty()); - - mImpl->mVisibleGroups.erase(group); -} - F32 LLViewerRegion::updateVisibleEntries(F32 max_time) { if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty()) @@ -1024,11 +1012,12 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) #endif //process visible groups - std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin(); + std::set< LLPointer<LLviewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin(); for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter) { - LLviewerOctreeGroup* group = *group_iter; - if(!group->getOctreeNode() || group->isEmpty()) + LLPointer<LLviewerOctreeGroup> group = *group_iter; + if(group->getNumRefs() < 3 || //group to be deleted + !group->getOctreeNode() || group->isEmpty()) //group empty { continue; } @@ -1050,7 +1039,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) } } } - mImpl->mVisibleGroups.clear(); if(needs_update) { @@ -1113,8 +1101,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) return did_update; } - sCurRegionp = this; - //kill invisible objects max_update_time = killInvisibleObjects(max_update_time); @@ -1122,9 +1108,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time) createVisibleObjects(max_update_time); mImpl->mVisibleGroups.clear(); - mImpl->mWaitingList.clear(); - sCurRegionp = NULL; return did_update; } @@ -1135,16 +1119,40 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time) { return max_time; } + if(mImpl->mActiveSet.empty()) + { + return max_time; + } + static LLVOCacheEntry* last_visited_entry = NULL; + + const size_t MAX_UPDATE = 32; std::vector<LLDrawable*> delete_list; - for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin(); - iter != mImpl->mActiveSet.end(); ++iter) - { + S32 update_counter = llmin(MAX_UPDATE, mImpl->mActiveSet.size()); + LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(last_visited_entry); + + for(; update_counter > 0; --update_counter, ++iter) + { + if(iter == mImpl->mActiveSet.end()) + { + iter = mImpl->mActiveSet.begin(); + } + if(!(*iter)->isRecentlyVisible()) { killObject((*iter), delete_list); } } + + if(iter == mImpl->mActiveSet.end()) + { + last_visited_entry = NULL; + } + else + { + last_visited_entry = *iter; + } + for(S32 i = 0; i < delete_list.size(); i++) { gObjectList.killObject(delete_list[i]->getVObj()); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 410c903f18..fefd4209aa 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -224,7 +224,6 @@ public: void addActiveCacheEntry(LLVOCacheEntry* entry); void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep); void killCacheEntry(U32 local_id); //physically delete the cache entry - void clearVisibleGroup(LLviewerOctreeGroup* group); // Like idleUpdate, but forces everything to complete regardless of // how long it takes. @@ -395,7 +394,6 @@ public: LLDynamicArray<U32> mMapAvatars; LLDynamicArray<LLUUID> mMapAvatarIDs; - static LLViewerRegion* sCurRegionp; static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not. private: LLViewerRegionImpl * mImpl; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 13a005dcbf..e8196e9655 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,7 +64,7 @@ namespace LLStatViewer { -LLTrace::CountStatHandle<> FPS("fpsstat"), +LLTrace::CountStatHandle<> FPS("framesrendered"), PACKETS_IN("packetsinstat"), PACKETS_LOST("packetsloststat"), PACKETS_OUT("packetsoutstat"), @@ -322,19 +322,24 @@ void update_statistics() add(LLStatViewer::TOOLBOX_TIME, gFrameIntervalSeconds); } } + + LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); + sample(LLStatViewer::ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); sample(LLStatViewer::DRAW_DISTANCE, (F64)gSavedSettings.getF32("RenderFarClip")); sample(LLStatViewer::CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); - sample(LLStatViewer::FRAME_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Frame"))); - F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle"); - F64 network_secs = gDebugView->mFastTimerView->getTime("Network"); - sample(LLStatViewer::UPDATE_STACKTIME, LLTrace::Seconds(idle_secs - network_secs)); - sample(LLStatViewer::NETWORK_STACKTIME, LLTrace::Seconds(network_secs)); - sample(LLStatViewer::IMAGE_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Update Images"))); - sample(LLStatViewer::REBUILD_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Sort Draw State"))); - sample(LLStatViewer::RENDER_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Geometry"))); + typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t; + + sample(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")).as<LLUnits::Seconds>()); + LLUnit<LLUnits::Seconds, F64> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle")); + LLUnit<LLUnits::Seconds, F64> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network")); + sample(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs); + sample(LLStatViewer::NETWORK_STACKTIME, network_secs); + sample(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Update Images")).as<LLUnits::Seconds>()); + sample(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Sort Draw State")).as<LLUnits::Seconds>()); + sample(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Render Geometry")).as<LLUnits::Seconds>()); LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index e3df71cca2..7ce4a8fc70 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -34,6 +34,7 @@ #include "llui.h" #include <list> #include <set> +#include "lluiimage.h" const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index eb004106c3..53c9003fb4 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -38,6 +38,7 @@ #include "llagent.h" #include "llagentcamera.h" #include "llfloaterreg.h" +#include "llhudicon.h" #include "llmeshrepository.h" #include "llpanellogin.h" #include "llviewerkeyboard.h" diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5a07cdf7c9..1381cf9314 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -55,7 +55,6 @@ #include "lldriverparam.h" #include "lleditingmotion.h" #include "llemote.h" -//#include "llfirstuse.h" #include "llfloatertools.h" #include "llheadrotmotion.h" #include "llhudeffecttrail.h" @@ -80,10 +79,12 @@ #include "lltexlayer.h" #include "lltoolmorph.h" #include "llviewercamera.h" +#include "llviewerjointmesh.h" #include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" +#include "llviewerregion.h" #include "llviewershadermgr.h" #include "llviewerstats.h" #include "llvoavatarself.h" @@ -216,6 +217,24 @@ struct LLTextureMaskData S32 mLastDiscardLevel; }; +// Simple utility functions to eventually replace the common 2-line +// idiom scattered throughout the viewer codebase. Note that where +// possible we would rather be using smart pointers of some sort. + +template <class T> +inline void delete_and_clear(T*& ptr) +{ + delete ptr; + ptr = NULL; +} + +template <class T> +inline void delete_and_clear_array(T*& array_ptr) +{ + delete[] array_ptr; + array_ptr = NULL; +} + /********************************************************************************* ** ** ** Begin private LLVOAvatar Support classes @@ -824,14 +843,14 @@ LLVOAvatar::~LLVOAvatar() mRoot.removeAllChildren(); mJointMap.clear(); - deleteAndClearArray(mSkeleton); - deleteAndClearArray(mCollisionVolumes); + delete_and_clear_array(mSkeleton); + delete_and_clear_array(mCollisionVolumes); mNumJoints = 0; for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - deleteAndClear(mBakedTextureDatas[i].mTexLayerSet); + delete_and_clear(mBakedTextureDatas[i].mTexLayerSet); mBakedTextureDatas[i].mMeshes.clear(); for (morph_list_t::iterator iter2 = mBakedTextureDatas[i].mMaskedMorphs.begin(); @@ -845,9 +864,9 @@ LLVOAvatar::~LLVOAvatar() std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer()); mAttachmentPoints.clear(); - deleteAndClear(mTexSkinColor); - deleteAndClear(mTexHairColor); - deleteAndClear(mTexEyeColor); + delete_and_clear(mTexSkinColor); + delete_and_clear(mTexHairColor); + delete_and_clear(mTexEyeColor); std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer()); mMeshes.clear(); @@ -1234,7 +1253,7 @@ void LLVOAvatar::initClass() // parse avatar_lad.xml if (sAvatarXmlInfo) { //this can happen if a login attempt failed - deleteAndClear(sAvatarXmlInfo); + delete_and_clear(sAvatarXmlInfo); } sAvatarXmlInfo = new LLVOAvatarXmlInfo; if (!sAvatarXmlInfo->parseXmlSkeletonNode(root)) @@ -1278,7 +1297,7 @@ void LLVOAvatar::initClass() void LLVOAvatar::cleanupClass() { - deleteAndClear(sAvatarXmlInfo); + delete_and_clear(sAvatarXmlInfo); sSkeletonXMLTree.cleanup(); sXMLTree.cleanup(); } @@ -4188,7 +4207,7 @@ U32 LLVOAvatar::renderSkinnedAttachments() //----------------------------------------------------------------------------- // renderSkinned() //----------------------------------------------------------------------------- -U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) +U32 LLVOAvatar::renderSkinned() { U32 num_indices = 0; @@ -4324,57 +4343,50 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) //-------------------------------------------------------------------- // render all geometry attached to the skeleton //-------------------------------------------------------------------- - LLViewerJointMesh::sRenderPass = pass; - - if (pass == AVATAR_RENDER_PASS_SINGLE) - { - bool should_alpha_mask = shouldAlphaMask(); - LLGLState test(GL_ALPHA_TEST, should_alpha_mask); + bool should_alpha_mask = shouldAlphaMask(); + LLGLState test(GL_ALPHA_TEST, should_alpha_mask); - if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) - { - gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); - } + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) + { + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); + } - BOOL first_pass = TRUE; - if (!LLDrawPoolAvatar::sSkipOpaque) + BOOL first_pass = TRUE; + if (!LLDrawPoolAvatar::sSkipOpaque) + { + if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) { - if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender) + if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy) { - if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy) - { - num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy); - first_pass = FALSE; - } - } - if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy) - { - num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); - first_pass = FALSE; - } - - if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy) - { - num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); + num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy); first_pass = FALSE; } } - - if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) + if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy) { - gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); + first_pass = FALSE; } - - if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender) + + if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy) { - LLGLState blend(GL_BLEND, !mIsDummy); - LLGLState test(GL_ALPHA_TEST, !mIsDummy); - num_indices += renderTransparent(first_pass); + num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); + first_pass = FALSE; } } - - LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; + + if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) + { + gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); + } + + if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender) + { + LLGLState blend(GL_BLEND, !mIsDummy); + LLGLState test(GL_ALPHA_TEST, !mIsDummy); + num_indices += renderTransparent(first_pass); + } return num_indices; } @@ -5331,7 +5343,7 @@ LLVector3 LLVOAvatar::getPosAgentFromGlobal(const LLVector3d &position) //----------------------------------------------------------------------------- BOOL LLVOAvatar::allocateCharacterJoints( U32 num ) { - deleteAndClearArray(mSkeleton); + delete_and_clear_array(mSkeleton); mNumJoints = 0; mSkeleton = new LLViewerJoint[num]; @@ -5355,7 +5367,7 @@ BOOL LLVOAvatar::allocateCharacterJoints( U32 num ) //----------------------------------------------------------------------------- BOOL LLVOAvatar::allocateCollisionVolumes( U32 num ) { - deleteAndClearArray(mCollisionVolumes); + delete_and_clear_array(mCollisionVolumes); mNumCollisionVolumes = 0; mCollisionVolumes = new LLViewerJointCollisionVolume[num]; @@ -7870,9 +7882,9 @@ LLVOAvatar::LLVOAvatarXmlInfo::~LLVOAvatarXmlInfo() std::for_each(mMeshInfoList.begin(), mMeshInfoList.end(), DeletePointer()); std::for_each(mSkeletalDistortionInfoList.begin(), mSkeletalDistortionInfoList.end(), DeletePointer()); std::for_each(mAttachmentInfoList.begin(), mAttachmentInfoList.end(), DeletePointer()); - deleteAndClear(mTexSkinColorInfo); - deleteAndClear(mTexHairColorInfo); - deleteAndClear(mTexEyeColorInfo); + delete_and_clear(mTexSkinColorInfo); + delete_and_clear(mTexHairColorInfo); + delete_and_clear(mTexEyeColorInfo); std::for_each(mLayerInfoList.begin(), mLayerInfoList.end(), DeletePointer()); std::for_each(mDriverInfoList.begin(), mDriverInfoList.end(), DeletePointer()); std::for_each(mMorphMaskInfoList.begin(), mMorphMaskInfoList.end(), DeletePointer()); @@ -8203,7 +8215,7 @@ BOOL LLVOAvatar::LLVOAvatarXmlInfo::parseXmlColorNodes(LLXmlTreeNode* root) mTexSkinColorInfo = new LLTexGlobalColorInfo; if( !mTexSkinColorInfo->parseXml( color_node ) ) { - deleteAndClear(mTexSkinColorInfo); + delete_and_clear(mTexSkinColorInfo); llwarns << "avatar file: mTexSkinColor->parseXml() failed" << llendl; return FALSE; } @@ -8218,7 +8230,7 @@ BOOL LLVOAvatar::LLVOAvatarXmlInfo::parseXmlColorNodes(LLXmlTreeNode* root) mTexHairColorInfo = new LLTexGlobalColorInfo; if( !mTexHairColorInfo->parseXml( color_node ) ) { - deleteAndClear(mTexHairColorInfo); + delete_and_clear(mTexHairColorInfo); llwarns << "avatar file: mTexHairColor->parseXml() failed" << llendl; return FALSE; } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 1adb680962..87d3e40b8c 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -33,7 +33,7 @@ #include <string> #include <vector> -#include <boost/signals2.hpp> +#include <boost/signals2/trackable.hpp> #include "imageids.h" // IMG_INVISIBLE #include "llchat.h" @@ -69,6 +69,7 @@ class LLHUDEffectSpiral; class LLTexGlobalColor; class LLVOAvatarBoneInfo; class LLVOAvatarSkeletonInfo; +class LLViewerJointMesh; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLVOAvatar @@ -435,7 +436,7 @@ public: bool isVisuallyMuted() const; U32 renderRigid(); - U32 renderSkinned(EAvatarRenderPass pass); + U32 renderSkinned(); F32 getLastSkinTime() { return mLastSkinTime; } U32 renderSkinnedAttachments(); U32 renderTransparent(BOOL first_pass); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 4275552117..69f998f0f3 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -43,6 +43,7 @@ #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llinventoryfunctions.h" +#include "lllocaltextureobject.h" #include "llnotificationsutil.h" #include "llselectmgr.h" #include "lltoolgrab.h" // for needsRenderBeam diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 6261540765..1a6ad90a78 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -170,7 +170,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) LLVOCacheEntry::~LLVOCacheEntry() { mDP.freeBuffer(); - //llassert(mState == INACTIVE); + llassert(mState == INACTIVE); } //virtual @@ -191,7 +191,7 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) LLViewerOctreeEntryData::setOctreeEntry(entry); } -void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) +void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry) { //copy LLViewerOctreeEntry if(mEntry.notNull()) @@ -206,6 +206,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) { new_entry->addChild(getChild(i)); } + mChildrenList.clear(); } void LLVOCacheEntry::setState(U32 state) @@ -494,37 +495,10 @@ const U32 INVALID_TIME = 0 ; const char* object_cache_dirname = "objectcache"; const char* header_filename = "object.cache"; -LLVOCache* LLVOCache::sInstance = NULL; - -//static -LLVOCache* LLVOCache::getInstance() -{ - if(!sInstance) - { - sInstance = new LLVOCache() ; - } - return sInstance ; -} - -//static -BOOL LLVOCache::hasInstance() -{ - return sInstance != NULL ; -} - -//static -void LLVOCache::destroyClass() -{ - if(sInstance) - { - delete sInstance ; - sInstance = NULL ; - } -} LLVOCache::LLVOCache(): - mInitialized(FALSE), - mReadOnly(TRUE), + mInitialized(false), + mReadOnly(true), mNumEntries(0), mCacheSize(1) { @@ -561,7 +535,7 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) llwarns << "Cache already initialized." << llendl; return ; } - mInitialized = TRUE ; + mInitialized = true; setDirNames(location); if (!mReadOnly) @@ -609,7 +583,7 @@ void LLVOCache::removeCache(ELLPath location, bool started) LLFile::rmdir(cache_dir); clearCacheInMemory(); - mInitialized = FALSE ; + mInitialized = false; } void LLVOCache::removeCache() @@ -636,23 +610,23 @@ void LLVOCache::removeCache() void LLVOCache::removeEntry(HeaderEntryInfo* entry) { - llassert_always(mInitialized) ; + llassert_always(mInitialized); if(mReadOnly) { - return ; + return; } if(!entry) { - return ; + return; } - header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry) ; + header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry); if(iter != mHeaderEntryQueue.end()) { - mHandleEntryMap.erase(entry->mHandle) ; - mHeaderEntryQueue.erase(iter) ; - removeFromCache(entry) ; - delete entry ; + mHandleEntryMap.erase(entry->mHandle); + mHeaderEntryQueue.erase(iter); + removeFromCache(entry); + delete entry; mNumEntries = mHandleEntryMap.size() ; } diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 2aec88537c..7409b94d60 100644 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -29,7 +29,6 @@ #include "lluuid.h" #include "lldatapacker.h" -#include "lldlinked.h" #include "lldir.h" #include "llvieweroctree.h" @@ -101,7 +100,7 @@ public: void recordHit(); void recordDupe() { mDupeCount++; } - void copyTo(LLVOCacheEntry* new_entry); //copy variables + void moveTo(LLVOCacheEntry* new_entry); //copy variables /*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry); void setParentID(U32 id) {mParentID = id;} @@ -161,7 +160,7 @@ public: // //Note: LLVOCache is not thread-safe // -class LLVOCache +class LLVOCache : public LLSingleton<LLVOCache> { private: struct HeaderEntryInfo @@ -194,6 +193,7 @@ private: typedef std::set<HeaderEntryInfo*, header_entry_less> header_entry_queue_t; typedef std::map<U64, HeaderEntryInfo*> handle_entry_map_t; private: + friend class LLSingleton<LLVOCache>; LLVOCache() ; public: @@ -206,7 +206,7 @@ public: void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled); void removeEntry(U64 handle) ; - void setReadOnly(BOOL read_only) {mReadOnly = read_only;} + void setReadOnly(bool read_only) {mReadOnly = read_only;} private: void setDirNames(ELLPath location); @@ -222,9 +222,9 @@ private: BOOL updateEntry(const HeaderEntryInfo* entry); private: - BOOL mEnabled; - BOOL mInitialized ; - BOOL mReadOnly ; + bool mEnabled; + bool mInitialized ; + bool mReadOnly ; HeaderMetaInfo mMetaInfo; U32 mCacheSize; U32 mNumEntries; @@ -233,12 +233,6 @@ private: LLVolatileAPRPool* mLocalAPRFilePoolp ; header_entry_queue_t mHeaderEntryQueue; handle_entry_map_t mHandleEntryMap; - - static LLVOCache* sInstance ; -public: - static LLVOCache* getInstance() ; - static BOOL hasInstance() ; - static void destroyClass() ; }; #endif diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index bd12328a6b..0e76a978db 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -28,12 +28,14 @@ #include "llagent.h" #include "llfloaterreg.h" +#include "llhttpclient.h" #include "llimview.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llpanel.h" #include "llrecentpeople.h" #include "llviewercontrol.h" +#include "llviewerregion.h" #include "llvoicechannel.h" diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index c9aeea35a9..1b362545ec 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -34,7 +34,6 @@ class LLVOAvatar; #include "lliosocket.h" #include "v3math.h" #include "llframetimer.h" -#include "llviewerregion.h" #include "llcallingcard.h" // for LLFriendObserver #include "llsecapi.h" #include "llcontrol.h" diff --git a/indra/newview/llvoinventorylistener.h b/indra/newview/llvoinventorylistener.h index bf14d19b01..c50c475478 100644 --- a/indra/newview/llvoinventorylistener.h +++ b/indra/newview/llvoinventorylistener.h @@ -30,7 +30,9 @@ #ifndef LL_LLVOINVENTORYLISTENER_H #define LL_LLVOINVENTORYLISTENER_H -#include "llviewerobject.h" +#include "llinventory.h" + +class LLViewerObject; class LLVOInventoryListener { diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h index a15878368e..21693e85e1 100644 --- a/indra/newview/llvosurfacepatch.h +++ b/indra/newview/llvosurfacepatch.h @@ -33,6 +33,8 @@ class LLSurfacePatch; class LLDrawPool; class LLVector2; +class LLFacePool; +class LLFace; class LLVOSurfacePatch : public LLStaticViewerObject { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d1c1602437..664fee9a37 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -406,7 +406,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, dp->dumpBufferToLog(); llwarns << "Flushing cache files" << llendl; - if(LLVOCache::hasInstance() && getRegion()) + if(LLVOCache::instanceExists() && getRegion()) { LLVOCache::getInstance()->removeEntry(getRegion()->getHandle()) ; } diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h index 3d8c53a755..ce5c882c00 100644 --- a/indra/newview/llwearable.h +++ b/indra/newview/llwearable.h @@ -34,12 +34,12 @@ #include "llassetstorage.h" #include "llwearabletype.h" #include "llfile.h" -#include "lllocaltextureobject.h" class LLViewerInventoryItem; class LLVisualParam; class LLTexGlobalColorInfo; class LLTexGlobalColor; +class LLLocalTextureObject; class LLWearable { diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 9401773886..9603849b10 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -110,7 +110,7 @@ LLWorld::LLWorld() : gGL.getTexUnit(0)->bind(mDefaultWaterTexturep); mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - LLViewerRegion::sVOCacheCullingEnabled = (BOOL)gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled"); + LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled") && gSavedSettings.getBOOL("ObjectCacheEnabled"); } @@ -123,10 +123,7 @@ void LLWorld::destroyClass() LLViewerRegion* region_to_delete = *region_it++; removeRegion(region_to_delete->getHost()); } - if(LLVOCache::hasInstance()) - { - LLVOCache::getInstance()->destroyClass() ; - } + LLVOCache::deleteSingleton(); LLViewerPartSim::getInstance()->destroyClass(); mDefaultWaterTexturep = NULL ; @@ -138,7 +135,7 @@ void LLWorld::destroyClass() //make all visible drawbles invisible. LLDrawable::incrementVisible(); - LLSceneMonitor::getInstance()->destroyClass(); + LLSceneMonitor::deleteSingleton(); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a8156b46ed..a9ecbdcd5f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2252,7 +2252,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& min = LLVector3(X,X,X); max = LLVector3(-X,-X,-X); - U32 saved_camera_id = LLViewerCamera::sCurCameraID; + LLViewerCamera::eCameraID saved_camera_id = LLViewerCamera::sCurCameraID; LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; BOOL res = TRUE; @@ -3233,8 +3233,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } postSort(camera); - - LLSceneMonitor::getInstance()->fetchQueryResult(); } void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) @@ -9437,7 +9435,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowFrustPoints[j].clear(); } - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+j; + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); //restore render matrices glh_set_current_modelview(saved_view); @@ -9821,7 +9819,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //update shadow targets for (U32 i = 0; i < 2; i++) { //for each current shadow - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i; + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); if (mShadowSpotLight[i].notNull() && (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || @@ -9940,7 +9938,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4; + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 36abeca295..720ddf79f5 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -29,8 +29,6 @@ #include "llcamera.h" #include "llerror.h" -#include "lldarrayptr.h" -#include "lldqueueptr.h" #include "lldrawpool.h" #include "llspatialpartition.h" #include "m4math.h" @@ -42,25 +40,13 @@ #include <stack> -#include <stack> - -#include <stack> - class LLViewerTexture; -class LLEdge; class LLFace; class LLViewerObject; -class LLAgent; -class LLDisplayPrimitive; class LLTextureEntry; -class LLRenderFunc; -class LLCubeMap; class LLCullResult; class LLVOAvatar; class LLGLSLShader; -class LLCurlRequest; - -class LLMeshResponder; typedef enum e_avatar_skinning_method { diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index f98fcc349e..0493f487d4 100644 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -38,7 +38,7 @@ name="fps" label="FPS" unit_label="fps" - stat="fpsstat" + stat="framesrendered" bar_min="0" bar_max="60" tick_spacing="6" |