Hotspot elimination.

This commit is contained in:
Shyotl
2019-08-07 21:21:36 -05:00
parent 4091bf9da5
commit 21b1d5b52e
7 changed files with 32 additions and 24 deletions

View File

@@ -1056,15 +1056,15 @@ void LLHUDNameTag::reshape()
F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font)
{ {
std::map<const LLFontGL*, F32>::iterator iter = mFontWidthMap.find(font); if (mFontWidthMap[0].first == font)
if (iter != mFontWidthMap.end())
{ {
return iter->second; return mFontWidthMap[0].second;
} }
else else if (mFontWidthMap[1].first == font)
{ {
return mFontWidthMap[1].second;
}
F32 width = font->getWidthF32(mText.c_str()); F32 width = font->getWidthF32(mText.c_str());
mFontWidthMap[font] = width; mFontWidthMap[mFontWidthMap[0].first != nullptr] = std::make_pair(font, width);
return width; return width;
} }
}

View File

@@ -63,14 +63,14 @@ protected:
{} {}
F32 getWidth(const LLFontGL* font); F32 getWidth(const LLFontGL* font);
const LLWString& getText() const { return mText; } const LLWString& getText() const { return mText; }
void clearFontWidthMap() { mFontWidthMap.clear(); } void clearFontWidthMap() { mFontWidthMap[0].first = nullptr; mFontWidthMap[1].first = nullptr; }
LLColor4 mColor; LLColor4 mColor;
LLFontGL::StyleFlags mStyle; LLFontGL::StyleFlags mStyle;
const LLFontGL* mFont; const LLFontGL* mFont;
private: private:
LLWString mText; LLWString mText;
std::map<const LLFontGL*, F32> mFontWidthMap; std::pair<const LLFontGL*, F32> mFontWidthMap[2];
}; };
public: public:

View File

@@ -674,18 +674,18 @@ void LLHUDText::reshape()
F32 LLHUDText::LLHUDTextSegment::getWidth(const LLFontGL* font) F32 LLHUDText::LLHUDTextSegment::getWidth(const LLFontGL* font)
{ {
std::map<const LLFontGL*, F32>::iterator iter = mFontWidthMap.find(font); if (mFontWidthMap[0].first == font)
if (iter != mFontWidthMap.end())
{ {
return iter->second; return mFontWidthMap[0].second;
} }
else else if (mFontWidthMap[1].first == font)
{ {
return mFontWidthMap[1].second;
}
F32 width = font->getWidthF32(mText.c_str()); F32 width = font->getWidthF32(mText.c_str());
mFontWidthMap[font] = width; mFontWidthMap[mFontWidthMap[0].first != nullptr] = std::make_pair(font, width);
return width; return width;
} }
}
// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f // [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f
void LLHUDText::refreshAllObjectText() void LLHUDText::refreshAllObjectText()

View File

@@ -61,14 +61,14 @@ protected:
{} {}
F32 getWidth(const LLFontGL* font); F32 getWidth(const LLFontGL* font);
const LLWString& getText() const { return mText; } const LLWString& getText() const { return mText; }
void clearFontWidthMap() { mFontWidthMap.clear(); } void clearFontWidthMap() { mFontWidthMap[0].first = nullptr; mFontWidthMap[1].first = nullptr; }
LLColor4 mColor; LLColor4 mColor;
LLFontGL::StyleFlags mStyle; LLFontGL::StyleFlags mStyle;
const LLFontGL* mFont; const LLFontGL* mFont;
private: private:
LLWString mText; LLWString mText;
std::map<const LLFontGL*, F32> mFontWidthMap; std::pair<const LLFontGL*, F32> mFontWidthMap[2];
}; };
public: public:

View File

@@ -1269,6 +1269,7 @@ public:
group->destroyGL(); group->destroyGL();
{OctreeGuard guard(group->getOctreeNode()); {OctreeGuard guard(group->getOctreeNode());
if (!mNoRebuild) // Singu note: No need to iterate if not rebuilding...
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{ {
LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable(); LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();

View File

@@ -326,6 +326,7 @@ void LLViewerTextureList::shutdown()
mCreateTextureList.clear(); mCreateTextureList.clear();
mUUIDMap.clear(); mUUIDMap.clear();
mUUIDDict.clear();
mImageList.clear(); mImageList.clear();
@@ -600,8 +601,8 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id) LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id)
{ {
uuid_map_t::iterator iter = mUUIDMap.find(image_id); auto& iter = mUUIDDict.find(image_id);
if(iter == mUUIDMap.end()) if(iter == mUUIDDict.end())
return NULL; return NULL;
return iter->second; return iter->second;
} }
@@ -648,8 +649,8 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
<< " but doesn't have mInImageList set" << " but doesn't have mInImageList set"
<< " ref count is " << image->getNumRefs() << " ref count is " << image->getNumRefs()
<< LL_ENDL; << LL_ENDL;
uuid_map_t::iterator iter = mUUIDMap.find(image->getID()); auto& iter = mUUIDDict.find(image->getID());
if(iter == mUUIDMap.end()) if(iter == mUUIDDict.end())
{ {
LL_INFOS() << "Image " << image->getID() << " is also not in mUUIDMap!" << LL_ENDL ; LL_INFOS() << "Image " << image->getID() << " is also not in mUUIDMap!" << LL_ENDL ;
} }
@@ -690,7 +691,8 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
sNumImages++; sNumImages++;
addImageToList(new_image); addImageToList(new_image);
mUUIDMap[image_id] = new_image; mUUIDMap.emplace(image_id, new_image);
mUUIDDict.emplace(image_id, new_image);
} }
@@ -703,7 +705,9 @@ void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image)
mCallbackList.erase(image); mCallbackList.erase(image);
} }
llverify(mUUIDMap.erase(image->getID()) == 1); const LLUUID& id = image->getID();
llverify(mUUIDMap.erase(id) == 1);
llverify(mUUIDDict.erase(id) == 1);
sNumImages--; sNumImages--;
removeImageFromList(image); removeImageFromList(image);
} }

View File

@@ -35,6 +35,7 @@
#include "llui.h" #include "llui.h"
#include <list> #include <list>
#include <set> #include <set>
#include <unordered_map>
const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128;
@@ -187,6 +188,8 @@ public:
private: private:
typedef std::map< LLUUID, LLPointer<LLViewerFetchedTexture> > uuid_map_t; typedef std::map< LLUUID, LLPointer<LLViewerFetchedTexture> > uuid_map_t;
uuid_map_t mUUIDMap; uuid_map_t mUUIDMap;
typedef std::unordered_map< LLUUID, LLPointer<LLViewerFetchedTexture>* > uuid_dict_t;
uuid_map_t mUUIDDict;
LLUUID mLastUpdateUUID; LLUUID mLastUpdateUUID;
LLUUID mLastFetchUUID; LLUUID mLastFetchUUID;