master
Xiaohong Bao 2009-10-30 21:34:52 -06:00
commit 4e1cde2e39
9 changed files with 131 additions and 34 deletions

View File

@ -61,6 +61,8 @@ public:
//
//interfaces to access LLViewerTexture
//
virtual S8 getType() const = 0 ;
virtual void setKnownDrawSize(S32 width, S32 height) = 0 ;
virtual bool bindDefaultImage(const S32 stage = 0) const = 0 ;
virtual void forceImmediateUpdate() = 0 ;
virtual void setActive() = 0 ;

View File

@ -57,7 +57,9 @@ LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p)
: LLUICtrl(p),
mColor(p.color()),
mImagep(p.image),
mPriority(0)
mPriority(0),
mDrawWidth(0),
mDrawHeight(0)
{
if (mImagep.notNull())
{
@ -100,6 +102,8 @@ void LLIconCtrl::setValue(const LLSD& value )
{
mImagep = LLUI::getUIImage(tvalue.asString(), mPriority);
}
setIconImageDrawSize();
}
std::string LLIconCtrl::getImageName() const
@ -109,3 +113,14 @@ std::string LLIconCtrl::getImageName() const
else
return std::string();
}
void LLIconCtrl::setIconImageDrawSize()
{
if(mImagep.notNull() && mDrawWidth && mDrawHeight)
{
if(mImagep->getImage().notNull())
{
mImagep->getImage()->setKnownDrawSize(mDrawWidth, mDrawHeight) ;
}
}
}

View File

@ -60,6 +60,7 @@ public:
protected:
LLIconCtrl(const Params&);
friend class LLUICtrlFactory;
public:
virtual ~LLIconCtrl();
@ -73,9 +74,16 @@ public:
void setColor(const LLColor4& color) { mColor = color; }
private:
void setIconImageDrawSize() ;
protected:
S32 mPriority;
//the output size of the icon image if set.
S32 mDrawWidth ;
S32 mDrawHeight ;
private:
LLUIColor mColor;
LLPointer<LLUIImage> mImagep;

View File

@ -155,6 +155,8 @@ LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p)
mPriority = LLViewerFetchedTexture::BOOST_ICON;
LLRect rect = p.rect;
mDrawWidth = llmax(32, rect.getWidth()) ;
mDrawHeight = llmax(32, rect.getHeight()) ;
static LLUICachedControl<S32> llavatariconctrl_symbol_hpad("UIAvatariconctrlSymbolHPad", 2);
static LLUICachedControl<S32> llavatariconctrl_symbol_vpad("UIAvatariconctrlSymbolVPad", 2);
@ -193,7 +195,6 @@ LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p)
LLIconCtrl::setValue("default_profile_picture.j2c");
}
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
registrar.add("AvatarIcon.Action", boost::bind(&LLAvatarIconCtrl::onAvatarIconContextMenuItemClicked, this, _2));

View File

@ -278,6 +278,16 @@ void LLFace::setTexture(LLViewerTexture* tex)
}
mTexture = tex ;
//check if this texture is replaced by a parcel media texture.
if(mTexture.notNull() && mTexture->hasParcelMedia())
{
LLViewerMediaTexture* mediap = LLViewerTextureManager::findMediaTexture(mTexture->getID()) ;
if(mediap)
{
mediap->addMediaToFace(this) ;
}
}
}
void LLFace::dirtyTexture()

View File

@ -246,7 +246,7 @@ protected:
//atlas
LLPointer<LLTextureAtlasSlot> mAtlasInfop ;
BOOL mUsingAtlas ;
BOOL mUsingAtlas ;
protected:
static BOOL sSafeRenderSelect;

View File

@ -704,7 +704,7 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
}
if (volume->mLODChanged || volume->mFaceMappingChanged ||
volume->mVolumeChanged)
volume->mVolumeChanged || drawable->isState(LLDrawable::REBUILD_MATERIAL))
{
volume->regenFaces();
volume->mDrawable->setState(LLDrawable::REBUILD_VOLUME);

View File

@ -93,6 +93,7 @@ BOOL LLViewerTexture::sUseTextureAtlas = FALSE ;
const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by
const F32 desired_discard_bias_max = 1.5f; // max number of levels to reduce image quality by
const F64 log_2 = log(2.0);
//----------------------------------------------------------------------------------------------
//namespace: LLViewerTextureAccess
@ -134,7 +135,7 @@ LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id,
return tex ;
}
LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLViewerTexture* tex, BOOL report_error)
LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTexture* tex, BOOL report_error)
{
if(!tex)
{
@ -415,6 +416,7 @@ void LLViewerTexture::init(bool firstinit)
mDontDiscard = FALSE;
mMaxVirtualSize = 0.f;
mNeedsResetMaxVirtualSize = FALSE ;
mHasParcelMedia = FALSE ;
}
//virtual
@ -522,6 +524,12 @@ F32 LLViewerTexture::getMaxVirtualSize()
return mMaxVirtualSize ;
}
//virtual
void LLViewerTexture::setKnownDrawSize(S32 width, S32 height)
{
//nothing here.
}
//virtual
void LLViewerTexture::addFace(LLFace* facep)
{
@ -852,6 +860,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
mKnownDrawWidth = 0;
mKnownDrawHeight = 0;
mKnownDrawSizeChanged = FALSE ;
if (firstinit)
{
@ -1084,10 +1093,17 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
}
// Call with 0,0 to turn this feature off.
//virtual
void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height)
{
mKnownDrawWidth = width;
mKnownDrawHeight = height;
if(mKnownDrawWidth != width || mKnownDrawHeight != height)
{
mKnownDrawWidth = width;
mKnownDrawHeight = height;
mKnownDrawSizeChanged = TRUE ;
mFullyLoaded = FALSE ;
}
addTextureStats((F32)(width * height));
}
@ -1104,13 +1120,26 @@ void LLViewerFetchedTexture::processTextureStats()
mDesiredDiscardLevel = getMaxDiscardLevel() ;
}
else
{
mDesiredDiscardLevel = 0;
if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
{
if(!mKnownDrawWidth || !mKnownDrawHeight || mFullWidth <= mKnownDrawWidth || mFullHeight <= mKnownDrawHeight)
{
mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
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(mKnownDrawSizeChanged)//known draw size is set
{
mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2,
log((F32)mFullHeight / mKnownDrawHeight) / log_2) ;
mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ;
}
mKnownDrawSizeChanged = FALSE ;
if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel))
{
mFullyLoaded = TRUE ;
@ -1121,8 +1150,6 @@ void LLViewerFetchedTexture::processTextureStats()
//texture does not have any data, so we don't know the size of the image, treat it like 32 * 32.
F32 LLViewerFetchedTexture::calcDecodePriorityForUnknownTexture(F32 pixel_priority)
{
static const F64 log_2 = log(2.0);
F32 desired = (F32)(log(32.0/pixel_priority) / log_2);
S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired + 1;
ddiscard = llclamp(ddiscard, 1, 9);
@ -1169,7 +1196,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
// Don't decode anything we don't need
priority = -1.0f;
}
else if (mBoostLevel == LLViewerTexture::BOOST_UI && !have_all_data)
else if ((mBoostLevel == LLViewerTexture::BOOST_UI || mBoostLevel == LLViewerTexture::BOOST_ICON) && !have_all_data)
{
priority = 1.f;
}
@ -2124,19 +2151,20 @@ void LLViewerMediaTexture::updateClass()
for(media_map_t::iterator iter = sMediaMap.begin() ; iter != sMediaMap.end(); )
{
LLViewerMediaTexture* mediap = iter->second;
//
//Note: delay some time to delete the media textures to stop endlessly creating and immediately removing media texture.
//
if(mediap->getNumRefs() == 1 && mediap->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME) //one by sMediaMap
if(mediap->getNumRefs() == 1) //one reference by sMediaMap
{
media_map_t::iterator cur = iter++ ;
sMediaMap.erase(cur) ;
}
else
{
++iter ;
//
//Note: delay some time to delete the media textures to stop endlessly creating and immediately removing media texture.
//
if(mediap->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME)
{
media_map_t::iterator cur = iter++ ;
sMediaMap.erase(cur) ;
continue ;
}
}
++iter ;
}
}
@ -2189,11 +2217,22 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
mIsPlaying = FALSE ;
setMediaImpl() ;
LLViewerTexture* tex = gTextureList.findImage(mID) ;
if(tex) //this media is a parcel media for tex.
{
tex->setParcelMedia(TRUE) ;
mParcelTexture = tex ;
}
}
//virtual
LLViewerMediaTexture::~LLViewerMediaTexture()
{
if(mParcelTexture.notNull())
{
mParcelTexture->setParcelMedia(FALSE) ;
}
}
void LLViewerMediaTexture::reinit(BOOL usemipmaps /* = TRUE */)
@ -2246,10 +2285,19 @@ BOOL LLViewerMediaTexture::findFaces()
BOOL ret = TRUE ;
//for parcel media
LLViewerTexture* tex = gTextureList.findImage(mID) ;
if(tex)
if(mParcelTexture.isNull())
{
const ll_face_list_t* face_list = tex->getFaceList() ;
LLViewerTexture* tex = gTextureList.findImage(mID) ;
if(tex)
{
tex->setParcelMedia(TRUE) ;
mParcelTexture = tex ;
}
}
if(mParcelTexture.notNull())
{
const ll_face_list_t* face_list = mParcelTexture->getFaceList() ;
for(ll_face_list_t::const_iterator iter = face_list->begin(); iter != face_list->end(); ++iter)
{
mMediaFaceList.push_back(*iter) ;
@ -2356,9 +2404,14 @@ void LLViewerMediaTexture::addFace(LLFace* facep)
if(facep->getTexture() && facep->getTexture() != this && facep->getTexture()->getID() == mID)
{
mTextureList.push_back(facep->getTexture()) ; //a parcel media.
if(mParcelTexture.isNull())
{
mParcelTexture = facep->getTexture() ;
mParcelTexture->setParcelMedia(TRUE) ;
}
return ;
}
llerrs << "The face does not have a valid texture before media texture." << llendl ;
}

View File

@ -163,6 +163,7 @@ public:
S32 getFullWidth() const { return mFullWidth; }
S32 getFullHeight() const { return mFullHeight; }
/*virtual*/ void setKnownDrawSize(S32 width, S32 height);
virtual void addFace(LLFace* facep) ;
virtual void removeFace(LLFace* facep) ;
@ -220,6 +221,9 @@ public:
BOOL getDontDiscard() const { return mDontDiscard; }
//-----------------
void setParcelMedia(BOOL has_media) {mHasParcelMedia = has_media;}
BOOL hasParcelMedia() const { return mHasParcelMedia ;}
/*virtual*/ void updateBindStatsForTester() ;
protected:
void cleanup() ;
@ -246,6 +250,8 @@ protected:
LLPointer<LLImageGL> mGLTexturep ;
S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
BOOL mHasParcelMedia ;
protected:
typedef enum
{
@ -357,7 +363,7 @@ public:
// Override the computation of discard levels if we know the exact output
// size of the image. Used for UI textures to not decode, even if we have
// more data.
void setKnownDrawSize(S32 width, S32 height);
/*virtual*/ void setKnownDrawSize(S32 width, S32 height);
void setIsMissingAsset();
/*virtual*/ BOOL isMissingAsset() const { return mIsMissingAsset; }
@ -406,6 +412,8 @@ private:
BOOL mFullyLoaded;
protected:
std::string mLocalFileName;
S32 mOrigWidth;
S32 mOrigHeight;
@ -413,8 +421,7 @@ protected:
// Used for UI textures to not decode, even if we have more data.
S32 mKnownDrawWidth;
S32 mKnownDrawHeight;
std::string mLocalFileName;
BOOL mKnownDrawSizeChanged ;
S8 mDesiredDiscardLevel; // The discard level we'd LIKE to have - if we have it and there's space
S8 mMinDesiredDiscardLevel; // The minimum discard level we'd like to have
@ -545,6 +552,7 @@ private:
LLViewerMediaImpl* mMediaImplp ;
BOOL mIsPlaying ;
U32 mUpdateVirtualSizeTime ;
LLPointer< LLViewerTexture > mParcelTexture ; //the texture replaces this media texure when it is a parcel media texture.
public:
static void updateClass() ;
@ -570,7 +578,7 @@ public:
static LLTexturePipelineTester* sTesterp ;
//returns NULL if tex is not a LLViewerFetchedTexture nor derived from LLViewerFetchedTexture.
static LLViewerFetchedTexture* staticCastToFetchedTexture(LLViewerTexture* tex, BOOL report_error = FALSE) ;
static LLViewerFetchedTexture* staticCastToFetchedTexture(LLTexture* tex, BOOL report_error = FALSE) ;
//
//"find-texture" just check if the texture exists, if yes, return it, otherwise return null.