summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
authorDessie Linden <dessie@lindenlab.com>2010-07-02 07:07:23 -0700
committerDessie Linden <dessie@lindenlab.com>2010-07-02 07:07:23 -0700
commit3de5be44adb91d3a7e1ff3ca8b415964a722ce49 (patch)
tree12a993fde38848529cdcdbadbce2d58cc383d7d2 /indra/newview/llvoavatar.cpp
parent4ffcfe0a5fe21dcb49d79851eb43bd5d80623e0d (diff)
parent1417bd3985f339915f259bf5971ef21e47e30163 (diff)
Merged from viewer-release
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r--indra/newview/llvoavatar.cpp105
1 files changed, 93 insertions, 12 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 4be703cfb0..82823f3de2 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -677,7 +677,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mFullyLoaded(FALSE),
mPreviousFullyLoaded(FALSE),
mFullyLoadedInitialized(FALSE),
- mSupportsAlphaLayers(FALSE)
+ mSupportsAlphaLayers(FALSE),
+ mLoadedCallbacksPaused(FALSE)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
//VTResume(); // VTune
@@ -839,6 +840,7 @@ void LLVOAvatar::markDead()
sNumVisibleChatBubbles--;
}
mVoiceVisualizer->markDead();
+ LLLoadedCallbackEntry::cleanUpCallbackList(&mCallbackTextureList, this) ;
LLViewerObject::markDead();
}
@@ -2229,12 +2231,14 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
llinfos << "Warning! Idle on dead avatar" << llendl;
return TRUE;
- }
+ }
if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_AVATAR)))
{
return TRUE;
}
+
+ checkTextureLoading() ;
// force immediate pixel area update on avatars using last frames data (before drawable or camera updates)
setPixelAreaAndAngle(gAgent);
@@ -4093,6 +4097,7 @@ void LLVOAvatar::updateTextures()
{
render_avatar = isVisible() && !mCulled;
}
+ checkTextureLoading() ;
std::vector<BOOL> layer_baked;
// GL NOT ACTIVE HERE - *TODO
@@ -4133,7 +4138,7 @@ void LLVOAvatar::updateTextures()
}
}
}
- if (isIndexBakedTexture((ETextureIndex) texture_index))
+ if (isIndexBakedTexture((ETextureIndex) texture_index) && render_avatar)
{
const S32 boost_level = getAvatarBakedBoostLevel();
imagep = LLViewerTextureManager::staticCastToFetchedTexture(getImage(texture_index,0), TRUE);
@@ -4149,7 +4154,7 @@ void LLVOAvatar::updateTextures()
<< " on host " << getRegion()->getHost() << llendl;
}
- addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level );
+ addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level );
}
}
@@ -4168,13 +4173,66 @@ void LLVOAvatar::addLocalTextureStats( ETextureIndex idx, LLViewerFetchedTexture
}
+void LLVOAvatar::checkTextureLoading()
+{
+ static const F32 MAX_INVISIBLE_WAITING_TIME = 30.f ; //seconds
+
+ BOOL pause = !isVisible() ;
+ if(!pause)
+ {
+ mInvisibleTimer.reset() ;
+ }
+ if(mLoadedCallbacksPaused == pause)
+ {
+ return ;
+ }
+
+ if(mCallbackTextureList.empty()) //when is self or no callbacks. Note: this list for self is always empty.
+ {
+ mLoadedCallbacksPaused = pause ;
+ return ; //nothing to check.
+ }
+
+ if(pause && mInvisibleTimer.getElapsedTimeF32() < MAX_INVISIBLE_WAITING_TIME)
+ {
+ return ;
+ }
+
+ for(LLLoadedCallbackEntry::source_callback_list_t::iterator iter = mCallbackTextureList.begin();
+ iter != mCallbackTextureList.end(); ++iter)
+ {
+ LLViewerFetchedTexture* tex = gTextureList.findImage(*iter) ;
+ if(tex)
+ {
+ if(pause)//pause texture fetching.
+ {
+ tex->pauseLoadedCallbacks(this) ;
+ }
+ else//unpause
+ {
+ static const F32 START_AREA = 100.f ;
+
+ tex->unpauseLoadedCallbacks(this) ;
+ tex->addTextureStats(START_AREA); //jump start the fetching again
+ }
+ }
+ }
+
+ mLoadedCallbacksPaused = pause ;
+ return ;
+}
+
void LLVOAvatar::addBakedTextureStats( LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level)
{
- mMaxPixelArea = llmax(pixel_area, mMaxPixelArea);
- mMinPixelArea = llmin(pixel_area, mMinPixelArea);
+ //if this function is not called for the last 512 frames, the texture pipeline will stop fetching this texture.
+ static const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL = 512 ; //frames
+
imagep->resetTextureStats();
- imagep->setResetMaxVirtualSizeFlag(false) ;
imagep->setCanUseHTTP(false) ; //turn off http fetching for baked textures.
+ imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL);
+
+ mMaxPixelArea = llmax(pixel_area, mMaxPixelArea);
+ mMinPixelArea = llmin(pixel_area, mMinPixelArea);
imagep->addTextureStats(pixel_area / texel_area_ratio);
imagep->setBoostLevel(boost_level);
if(boost_level == LLViewerTexture::BOOST_AVATAR_BAKED_SELF)
@@ -5987,6 +6045,15 @@ void LLVOAvatar::updateMeshTextures()
const BOOL self_customizing = isSelf() && gAgentCamera.cameraCustomizeAvatar(); // During face edit mode, we don't use baked textures
const BOOL other_culled = !isSelf() && mCulled;
+ LLLoadedCallbackEntry::source_callback_list_t* src_callback_list = NULL ;
+ void* callback_src = NULL ;
+ BOOL paused = FALSE;
+ if(!isSelf())
+ {
+ callback_src = this ;
+ src_callback_list = &mCallbackTextureList ;
+ paused = mLoadedCallbacksPaused ;
+ }
std::vector<BOOL> is_layer_baked;
is_layer_baked.resize(mBakedTextureDatas.size(), false);
@@ -6057,10 +6124,12 @@ void LLVOAvatar::updateMeshTextures()
{
mBakedTextureDatas[i].mIsLoaded = FALSE;
if ( (baked_img->getID() != IMG_INVISIBLE) && ((i == BAKED_HEAD) || (i == BAKED_UPPER) || (i == BAKED_LOWER)) )
- {
- baked_img->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
+ {
+ baked_img->setLoadedCallback(onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ),
+ callback_src, src_callback_list, paused);
}
- baked_img->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ) );
+ baked_img->setLoadedCallback(onBakedTextureLoaded, SWITCH_TO_BAKED_DISCARD, FALSE, FALSE, new LLUUID( mID ),
+ callback_src, src_callback_list, paused );
}
}
else if (mBakedTextureDatas[i].mTexLayerSet
@@ -6520,6 +6589,16 @@ void LLVOAvatar::onFirstTEMessageReceived()
{
mFirstTEMessageReceived = TRUE;
+ LLLoadedCallbackEntry::source_callback_list_t* src_callback_list = NULL ;
+ void* callback_src = NULL ;
+ BOOL paused = FALSE ;
+ if(!isSelf())
+ {
+ callback_src = this ;
+ src_callback_list = &mCallbackTextureList ;
+ paused = mLoadedCallbacksPaused ;
+ }
+
for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
{
const BOOL layer_baked = isTextureDefined(mBakedTextureDatas[i].mTextureIndex);
@@ -6533,9 +6612,11 @@ void LLVOAvatar::onFirstTEMessageReceived()
// If we have more than one texture for the other baked layers, we'll want to call this for them too.
if ( (image->getID() != IMG_INVISIBLE) && ((i == BAKED_HEAD) || (i == BAKED_UPPER) || (i == BAKED_LOWER)) )
{
- image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ));
+ image->setLoadedCallback( onBakedTextureMasksLoaded, MORPH_MASK_REQUESTED_DISCARD, TRUE, TRUE, new LLTextureMaskData( mID ),
+ callback_src, src_callback_list, paused);
}
- image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ) );
+ image->setLoadedCallback( onInitialBakedTextureLoaded, MAX_DISCARD_LEVEL, FALSE, FALSE, new LLUUID( mID ),
+ callback_src, src_callback_list, paused );
}
}