diff options
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r-- | indra/newview/llviewertexture.cpp | 199 |
1 files changed, 125 insertions, 74 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index ae9db94000..ad993bc056 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -495,6 +495,8 @@ void LLViewerTexture::init(bool firstinit) mNeedsResetMaxVirtualSize = FALSE ; mAdditionalDecodePriority = 0.f ; mParcelMedia = NULL ; + mNumFaces = 0 ; + mFaceList.clear() ; } //virtual @@ -627,13 +629,55 @@ void LLViewerTexture::setKnownDrawSize(S32 width, S32 height) //virtual void LLViewerTexture::addFace(LLFace* facep) { - mFaceList.push_back(facep) ; + if(mNumFaces >= mFaceList.size()) + { + mFaceList.resize(2 * mNumFaces + 1) ; + } + mFaceList[mNumFaces] = facep ; + facep->setIndexInTex(mNumFaces) ; + mNumFaces++ ; + mLastFaceListUpdateTimer.reset() ; } //virtual void LLViewerTexture::removeFace(LLFace* facep) { - mFaceList.remove(facep) ; + if(mNumFaces > 1) + { + S32 index = facep->getIndexInTex() ; + mFaceList[index] = mFaceList[--mNumFaces] ; + mFaceList[index]->setIndexInTex(index) ; + } + else + { + mFaceList.clear() ; + mNumFaces = 0 ; + } + mLastFaceListUpdateTimer.reset() ; +} + +S32 LLViewerTexture::getNumFaces() const +{ + return mNumFaces ; +} + +void LLViewerTexture::reorganizeFaceList() +{ + static const F32 MAX_WAIT_TIME = 20.f; // seconds + static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ; + + if(mNumFaces + MAX_EXTRA_BUFFER_SIZE > mFaceList.size()) + { + return ; + } + + if(mLastFaceListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME) + { + return ; + } + + mLastFaceListUpdateTimer.reset() ; + mFaceList.erase(mFaceList.begin() + mNumFaces, mFaceList.end()); } //virtual @@ -1469,16 +1513,20 @@ F32 LLViewerFetchedTexture::calcDecodePriority() { desired_discard -= 2; } - else if (!isJustBound() && mCachedRawImageReady && !mBoostLevel) + else if (!isJustBound() && mCachedRawImageReady) { - // We haven't rendered this in the last half second, and we have a cached raw image, leave the desired discard as-is - desired_discard = cur_discard; - } - else if (mGLTexturep.notNull() && !mGLTexturep->getBoundRecently() && mBoostLevel == LLViewerTexture::BOOST_NONE) - { - // We haven't rendered this in a while, de-prioritize it - desired_discard += 2; + if(mBoostLevel < BOOST_HIGH) + { + // We haven't rendered this in a while, de-prioritize it + desired_discard += 2; + } + //else + //{ + // // We haven't rendered this in the last half second, and we have a cached raw image, leave the desired discard as-is + // desired_discard = cur_discard; + //} } + S32 ddiscard = cur_discard - desired_discard; ddiscard = llclamp(ddiscard, 0, 4); priority = (ddiscard+1)*100000.f; @@ -1531,23 +1579,28 @@ void LLViewerFetchedTexture::updateVirtualSize() { addTextureStats(0.f, FALSE) ;//reset } - if(mFaceList.size() > 0) + + for(U32 i = 0 ; i < mNumFaces ; i++) { - for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + LLFace* facep = mFaceList[i] ; + if(facep->getDrawable()->isRecentlyVisible()) { - LLFace* facep = *iter ; - if(facep->getDrawable()->isRecentlyVisible()) - { - addTextureStats(facep->getVirtualSize()) ; - setAdditionalDecodePriority(facep->getImportanceToCamera()) ; - } - } + addTextureStats(facep->getVirtualSize()) ; + setAdditionalDecodePriority(facep->getImportanceToCamera()) ; + } } mNeedsResetMaxVirtualSize = TRUE ; + reorganizeFaceList() ; } bool LLViewerFetchedTexture::updateFetch() { + static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled"); + if(textures_decode_disabled) + { + return false ; + } + mFetchState = 0; mFetchPriority = 0; mFetchDeltaTime = 999999.f; @@ -1580,7 +1633,7 @@ bool LLViewerFetchedTexture::updateFetch() S32 desired_discard = getDesiredDiscardLevel(); F32 decode_priority = getDecodePriority(); decode_priority = llmax(decode_priority, 0.0f); - + if (mIsFetching) { // Sets mRawDiscardLevel, mRawImage, mAuxRawImage @@ -1628,9 +1681,9 @@ bool LLViewerFetchedTexture::updateFetch() mComponents = mRawImage->getComponents(); mGLTexturep->setComponents(mComponents) ; - for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + for(U32 i = 0 ; i < mNumFaces ; i++) { - (*iter)->dirtyTexture() ; + mFaceList[i]->dirtyTexture() ; } } mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; @@ -1723,10 +1776,10 @@ bool LLViewerFetchedTexture::updateFetch() { make_request = false; } - else if (!isJustBound() && mCachedRawImageReady) - { - make_request = false; - } + //else if (!isJustBound() && mCachedRawImageReady) + //{ + // make_request = false; + //} else { if (mIsFetching) @@ -1798,12 +1851,12 @@ BOOL LLViewerFetchedTexture::forceFetch() { return false ; } - if(mDesiredSavedRawDiscardLevel < getDiscardLevel()) + //if(mDesiredSavedRawDiscardLevel < getDiscardLevel()) { //no need to force fetching. normal fetching flow will do the work. //return false ; } - if (mNeedsCreateTexture) + //if (mNeedsCreateTexture) { // We may be fetching still (e.g. waiting on write) // but don't check until we've processed the raw data we have @@ -1839,7 +1892,8 @@ BOOL LLViewerFetchedTexture::forceFetch() h = getHeight(0); c = getComponents(); } - fetch_request_created = LLAppViewer::getTextureFetch()->createRequest(mUrl, getID(),getTargetHost(), maxDecodePriority(), + setDecodePriority(maxDecodePriority()) ; + fetch_request_created = LLAppViewer::getTextureFetch()->createRequest(mUrl, getID(),getTargetHost(), getDecodePriority(), w, h, c, desired_discard, needsAux()); if (fetch_request_created) @@ -2362,16 +2416,13 @@ void LLViewerFetchedTexture::resetFaceAtlas() //invalidate all atlas slots for this image. void LLViewerFetchedTexture::invalidateAtlas(BOOL rebuild_geom) { - for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + for(U32 i = 0 ; i < mNumFaces ; i++) { - if(*iter) + LLFace* facep = mFaceList[i] ; + facep->removeAtlas() ; + if(rebuild_geom && facep->getDrawable() && facep->getDrawable()->getSpatialGroup()) { - LLFace* facep = (LLFace*)*iter ; - facep->removeAtlas() ; - if(rebuild_geom && facep->getDrawable() && facep->getDrawable()->getSpatialGroup()) - { - facep->getDrawable()->getSpatialGroup()->setState(LLSpatialGroup::GEOM_DIRTY); - } + facep->getDrawable()->getSpatialGroup()->setState(LLSpatialGroup::GEOM_DIRTY); } } } @@ -2382,7 +2433,7 @@ BOOL LLViewerFetchedTexture::insertToAtlas() { return FALSE ; } - if(mFaceList.size() < 1) + if(getNumFaces() < 1) { return FALSE ; } @@ -2406,12 +2457,10 @@ BOOL LLViewerFetchedTexture::insertToAtlas() //if the atlas slot pointers for some faces are null, process them later. ll_face_list_t waiting_list ; - - for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + for(U32 i = 0 ; i < mNumFaces ; i++) { - if(*iter) { - facep = (LLFace*)*iter ; + facep = mFaceList[i] ; //face can not use atlas. if(!facep->canUseAtlas()) @@ -2723,7 +2772,7 @@ void LLViewerMediaTexture::updateClass() #if 0 //force to play media. - gSavedSettings.setBOOL("AudioSteamingMedia", true) ; + gSavedSettings.setBOOL("AudioStreamingMedia", true) ; gSavedSettings.setBOOL("AudioStreamingVideo", true) ; #endif @@ -2869,9 +2918,10 @@ BOOL LLViewerMediaTexture::findFaces() if(tex) //this media is a parcel media for tex. { const ll_face_list_t* face_list = tex->getFaceList() ; - for(ll_face_list_t::const_iterator iter = face_list->begin(); iter != face_list->end(); ++iter) + U32 end = tex->getNumFaces() ; + for(U32 i = 0 ; i < end ; i++) { - mMediaFaceList.push_back(*iter) ; + mMediaFaceList.push_back((*face_list)[i]) ; } } @@ -2950,7 +3000,7 @@ void LLViewerMediaTexture::removeMediaFromFace(LLFace* facep) switchTexture(facep) ; mIsPlaying = TRUE ; //set the flag back. - if(mFaceList.empty()) //no face referencing to this media + if(getNumFaces() < 1) //no face referencing to this media { stopPlaying() ; } @@ -2962,7 +3012,7 @@ void LLViewerMediaTexture::addFace(LLFace* facep) LLViewerTexture::addFace(facep) ; const LLTextureEntry* te = facep->getTextureEntry() ; - if(te) + if(te && te->getID().notNull()) { LLViewerTexture* tex = gTextureList.findImage(te->getID()) ; if(tex) @@ -2979,7 +3029,10 @@ void LLViewerMediaTexture::addFace(LLFace* facep) return ; } - llerrs << "The face does not have a valid texture before media texture." << llendl ; + if(te && te->getID().notNull()) //should have a texture + { + llerrs << "The face does not have a valid texture before media texture." << llendl ; + } } //virtual @@ -2988,7 +3041,7 @@ void LLViewerMediaTexture::removeFace(LLFace* facep) LLViewerTexture::removeFace(facep) ; const LLTextureEntry* te = facep->getTextureEntry() ; - if(te) + if(te && te->getID().notNull()) { LLViewerTexture* tex = gTextureList.findImage(te->getID()) ; if(tex) @@ -3006,17 +3059,17 @@ void LLViewerMediaTexture::removeFace(LLFace* facep) // //we have some trouble here: the texture of the face is changed. //we need to find the former texture, and remove it from the list to avoid memory leaking. - if(mFaceList.empty()) + if(!mNumFaces) { mTextureList.clear() ; return ; } - S32 end = mFaceList.size() ; + S32 end = getNumFaces() ; std::vector<const LLTextureEntry*> te_list(end) ; S32 i = 0 ; - for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + for(U32 j = 0 ; j < mNumFaces ; j++) { - te_list[i++] = (*iter)->getTextureEntry() ;//all textures are in use. + te_list[i++] = mFaceList[j]->getTextureEntry() ;//all textures are in use. } for(std::list< LLPointer<LLViewerTexture> >::iterator iter = mTextureList.begin(); iter != mTextureList.end(); ++iter) @@ -3049,7 +3102,10 @@ void LLViewerMediaTexture::removeFace(LLFace* facep) } } - llerrs << "mTextureList texture reference number is corrupted." << llendl ; + if(te && te->getID().notNull()) //should have a texture + { + llerrs << "mTextureList texture reference number is corrupted." << llendl ; + } } void LLViewerMediaTexture::stopPlaying() @@ -3085,11 +3141,15 @@ void LLViewerMediaTexture::switchTexture(LLFace* facep) const LLTextureEntry* te = facep->getTextureEntry() ; if(te) { - LLViewerTexture* tex = gTextureList.findImage(te->getID()) ; + LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL ; if(!tex && te->getID() != mID)//try parcel media. { tex = gTextureList.findImage(mID) ; } + if(!tex) + { + tex = LLViewerFetchedTexture::sDefaultImagep ; + } facep->switchTexture(tex) ; } } @@ -3134,16 +3194,9 @@ void LLViewerMediaTexture::setPlaying(BOOL playing) } else //stop playing this media { - if(mFaceList.empty()) + for(U32 i = mNumFaces ; i ; i--) { - return ; - } - - ll_face_list_t::iterator cur ; - for(ll_face_list_t::iterator iter = mFaceList.begin(); iter!= mFaceList.end(); ) - { - cur = iter++ ; - switchTexture(*cur) ; //cur could be removed in this function. + switchTexture(mFaceList[i - 1]) ; //current face could be removed in this function. } } return ; @@ -3165,17 +3218,14 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() if(mIsPlaying) //media is playing { - if(mFaceList.size() > 0) - { - for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) + for(U32 i = 0 ; i < mNumFaces ; i++) + { + LLFace* facep = mFaceList[i] ; + if(facep->getDrawable()->isRecentlyVisible()) { - LLFace* facep = *iter ; - if(facep->getDrawable()->isRecentlyVisible()) - { - addTextureStats(facep->getVirtualSize()) ; - } - } - } + addTextureStats(facep->getVirtualSize()) ; + } + } } else //media is not in playing { @@ -3195,6 +3245,7 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() } mNeedsResetMaxVirtualSize = TRUE ; + reorganizeFaceList() ; return mMaxVirtualSize ; } |