diff options
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r-- | indra/newview/llvoavatar.cpp | 104 |
1 files changed, 92 insertions, 12 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 316588c982..86e07c3126 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 @@ -847,6 +848,7 @@ void LLVOAvatar::markDead() sNumVisibleChatBubbles--; } mVoiceVisualizer->markDead(); + LLLoadedCallbackEntry::cleanUpCallbackList(&mCallbackTextureList, this) ; LLViewerObject::markDead(); } @@ -2227,12 +2229,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); @@ -4138,6 +4142,7 @@ void LLVOAvatar::updateTextures() { render_avatar = isVisible() && !mCulled; } + checkTextureLoading() ; std::vector<BOOL> layer_baked; // GL NOT ACTIVE HERE - *TODO @@ -4178,7 +4183,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); @@ -4194,7 +4199,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 ); } } @@ -4218,13 +4223,65 @@ void LLVOAvatar::addLocalTextureStats( ETextureIndex idx, LLViewerFetchedTexture } +void LLVOAvatar::checkTextureLoading() +{ + static const F32 MAX_INVISIBLE_WAITING_TIME = 30.f ; //seconds + + BOOL pause = !isVisible() ; + if(mLoadedCallbacksPaused == pause) + { + return ; + } + + if(mCallbackTextureList.empty()) + { + mLoadedCallbacksPaused = pause ; + return ; //nothing to check. + } + + if(!pause) + { + mInvisibleTimer.reset() ; + } + 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 satrt 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); + 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) @@ -6144,6 +6201,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); @@ -6214,10 +6280,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 @@ -6677,6 +6745,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); @@ -6690,9 +6768,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 ); } } |