summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r--indra/newview/llviewertexture.cpp137
1 files changed, 110 insertions, 27 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index a957367f61..e2b8ff8e80 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -97,6 +97,7 @@ S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size
const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;
const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez;
const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128;
+const S32 DEFAULT_ICON_DIMENTIONS = 32;
S32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256.
S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA;
BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE;
@@ -130,7 +131,7 @@ LLLoadedCallbackEntry::LLLoadedCallbackEntry(loaded_callback_func cb,
{
if(mSourceCallbackList)
{
- mSourceCallbackList->insert(target->getID());
+ mSourceCallbackList->insert(LLTextureKey(target->getID(), (ETexListType)target->getTextureListType()));
}
}
@@ -142,7 +143,7 @@ void LLLoadedCallbackEntry::removeTexture(LLViewerFetchedTexture* tex)
{
if(mSourceCallbackList)
{
- mSourceCallbackList->erase(tex->getID());
+ mSourceCallbackList->erase(LLTextureKey(tex->getID(), (ETexListType)tex->getTextureListType()));
}
}
@@ -169,24 +170,39 @@ LLViewerMediaTexture* LLViewerTextureManager::createMediaTexture(const LLUUID &m
{
return new LLViewerMediaTexture(media_id, usemipmaps, gl_image);
}
-
-LLViewerTexture* LLViewerTextureManager::findTexture(const LLUUID& id)
+
+void LLViewerTextureManager::findFetchedTextures(const LLUUID& id, std::vector<LLViewerFetchedTexture*> &output)
{
- LLViewerTexture* tex;
- //search fetched texture list
- tex = gTextureList.findImage(id);
-
- //search media texture list
- if(!tex)
- {
- tex = LLViewerTextureManager::findMediaTexture(id);
- }
- return tex;
+ return gTextureList.findTexturesByID(id, output);
+}
+
+void LLViewerTextureManager::findTextures(const LLUUID& id, std::vector<LLViewerTexture*> &output)
+{
+ std::vector<LLViewerFetchedTexture*> fetched_output;
+ gTextureList.findTexturesByID(id, fetched_output);
+ std::vector<LLViewerFetchedTexture*>::iterator iter = fetched_output.begin();
+ while (iter != fetched_output.end())
+ {
+ output.push_back(*iter);
+ iter++;
+ }
+
+ //search media texture list
+ if (output.empty())
+ {
+ LLViewerTexture* tex;
+ tex = LLViewerTextureManager::findMediaTexture(id);
+ if (tex)
+ {
+ output.push_back(tex);
+ }
+ }
+
}
-LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID& id)
+LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID& id, S32 tex_type)
{
- return gTextureList.findImage(id);
+ return gTextureList.findImage(id, (ETexListType)tex_type);
}
LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id)
@@ -1178,6 +1194,17 @@ void LLViewerFetchedTexture::loadFromFastCache()
}
else
{
+ if (mBoostLevel == LLGLTexture::BOOST_ICON)
+ {
+ S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
+ S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
+ if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ {
+ // scale oversized icon, no need to give more work to gl
+ mRawImage->scale(expected_width, expected_height);
+ }
+ }
+
mRequestedDiscardLevel = mDesiredDiscardLevel + 1;
mIsRawImageValid = TRUE;
addToCreateTexture();
@@ -1506,6 +1533,17 @@ void LLViewerFetchedTexture::processTextureStats()
{
mDesiredDiscardLevel = 0;
}
+ else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON)
+ {
+ if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
+ {
+ mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
+ }
+ else
+ {
+ mDesiredDiscardLevel = 0;
+ }
+ }
else if(!mFullWidth || !mFullHeight)
{
mDesiredDiscardLevel = llmin(getMaxDiscardLevel(), (S32)mLoadedCallbackDesiredDiscardLevel);
@@ -1936,6 +1974,17 @@ bool LLViewerFetchedTexture::updateFetch()
addToCreateTexture();
}
+ if (mBoostLevel == LLGLTexture::BOOST_ICON)
+ {
+ S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
+ S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
+ if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ {
+ // scale oversized icon, no need to give more work to gl
+ mRawImage->scale(expected_width, expected_height);
+ }
+ }
+
return TRUE;
}
else
@@ -2670,7 +2719,7 @@ LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level)
if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level)
{
- if(mSavedRawDiscardLevel != discard_level)
+ if (mSavedRawDiscardLevel != discard_level && mBoostLevel != BOOST_ICON)
{
mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents());
mRawImage->copy(getSavedRawImage());
@@ -2771,8 +2820,25 @@ void LLViewerFetchedTexture::switchToCachedImage()
void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
{
if(imageraw != mRawImage.get())
- {
- mCachedRawImage = imageraw;
+ {
+ if (mBoostLevel == LLGLTexture::BOOST_ICON)
+ {
+ S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
+ S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
+ if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ {
+ mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
+ mCachedRawImage->copyScaled(imageraw);
+ }
+ else
+ {
+ mCachedRawImage = imageraw;
+ }
+ }
+ else
+ {
+ mCachedRawImage = imageraw;
+ }
mCachedRawDiscardLevel = discard_level;
mCachedRawImageReady = TRUE;
}
@@ -2862,7 +2928,24 @@ void LLViewerFetchedTexture::saveRawImage()
}
mSavedRawDiscardLevel = mRawDiscardLevel;
- mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
+ if (mBoostLevel == LLGLTexture::BOOST_ICON)
+ {
+ S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
+ S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
+ if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ {
+ mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents());
+ mSavedRawImage->copyScaled(mRawImage);
+ }
+ else
+ {
+ mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
+ }
+ }
+ else
+ {
+ mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
+ }
if(mForceToSaveRawImage && mSavedRawDiscardLevel <= mDesiredSavedRawDiscardLevel)
{
@@ -3239,7 +3322,7 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
setCategory(LLGLTexture::MEDIA);
- LLViewerTexture* tex = gTextureList.findImage(mID);
+ LLViewerTexture* tex = gTextureList.findImage(mID, TEX_LIST_DISCARD);
if(tex) //this media is a parcel media for tex.
{
tex->setParcelMedia(this);
@@ -3249,7 +3332,7 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
//virtual
LLViewerMediaTexture::~LLViewerMediaTexture()
{
- LLViewerTexture* tex = gTextureList.findImage(mID);
+ LLViewerTexture* tex = gTextureList.findImage(mID, TEX_LIST_DISCARD);
if(tex) //this media is a parcel media for tex.
{
tex->setParcelMedia(NULL);
@@ -3304,7 +3387,7 @@ BOOL LLViewerMediaTexture::findFaces()
BOOL ret = TRUE;
- LLViewerTexture* tex = gTextureList.findImage(mID);
+ LLViewerTexture* tex = gTextureList.findImage(mID, TEX_LIST_DISCARD);
if(tex) //this media is a parcel media for tex.
{
for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch)
@@ -3413,7 +3496,7 @@ void LLViewerMediaTexture::addFace(U32 ch, LLFace* facep)
const LLTextureEntry* te = facep->getTextureEntry();
if(te && te->getID().notNull())
{
- LLViewerTexture* tex = gTextureList.findImage(te->getID());
+ LLViewerTexture* tex = gTextureList.findImage(te->getID(), TEX_LIST_DISCARD);
if(tex)
{
mTextureList.push_back(tex);//increase the reference number by one for tex to avoid deleting it.
@@ -3442,7 +3525,7 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep)
const LLTextureEntry* te = facep->getTextureEntry();
if(te && te->getID().notNull())
{
- LLViewerTexture* tex = gTextureList.findImage(te->getID());
+ LLViewerTexture* tex = gTextureList.findImage(te->getID(), TEX_LIST_DISCARD);
if(tex)
{
for(std::list< LLPointer<LLViewerTexture> >::iterator iter = mTextureList.begin();
@@ -3551,10 +3634,10 @@ void LLViewerMediaTexture::switchTexture(U32 ch, LLFace* facep)
const LLTextureEntry* te = facep->getTextureEntry();
if(te)
{
- LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL;
+ LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID(), TEX_LIST_DISCARD) : NULL;
if(!tex && te->getID() != mID)//try parcel media.
{
- tex = gTextureList.findImage(mID);
+ tex = gTextureList.findImage(mID, TEX_LIST_DISCARD);
}
if(!tex)
{