diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 46 | ||||
-rw-r--r-- | indra/newview/llviewermedia.h | 5 |
2 files changed, 39 insertions, 12 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 585ac4f8e9..0aae1a093d 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -245,6 +245,7 @@ public: bool mInitialized; }; static LLViewerMedia::impl_list sViewerMediaImplList; +static LLViewerMedia::impl_id_map sViewerMediaTextureIDMap; static LLTimer sMediaCreateTimer; static const F32 LLVIEWERMEDIA_CREATE_DELAY = 1.0f; static F32 sGlobalVolume = 1.0f; @@ -302,7 +303,7 @@ viewer_media_t LLViewerMedia::newMediaImpl( else { media_impl->unload(); - media_impl->mTextureId = texture_id; + media_impl->setTextureID(texture_id); media_impl->mMediaWidth = media_width; media_impl->mMediaHeight = media_height; media_impl->mMediaAutoScale = media_auto_scale; @@ -417,18 +418,16 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s // static LLViewerMediaImpl* LLViewerMedia::getMediaImplFromTextureID(const LLUUID& texture_id) { - impl_list::iterator iter = sViewerMediaImplList.begin(); - impl_list::iterator end = sViewerMediaImplList.end(); - - for(; iter != end; iter++) + LLViewerMediaImpl* result = NULL; + + // Look up the texture ID in the texture id->impl map. + impl_id_map::iterator iter = sViewerMediaTextureIDMap.find(texture_id); + if(iter != sViewerMediaTextureIDMap.end()) { - LLViewerMediaImpl* media_impl = *iter; - if(media_impl->getMediaTextureID() == texture_id) - { - return media_impl; - } + result = iter->second; } - return NULL; + + return result; } ////////////////////////////////////////////////////////////////////////////////////////// @@ -832,7 +831,6 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, : mMediaSource( NULL ), mMovieImageHasMips(false), - mTextureId(texture_id), mMediaWidth(media_width), mMediaHeight(media_height), mMediaAutoScale(media_auto_scale), @@ -862,6 +860,7 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mProximityDistance(0.0f), mMimeTypeProbe(NULL), mMediaAutoPlay(false), + mInNearbyMediaList(false), mIsUpdated(false) { @@ -873,6 +872,8 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, } add_media_impl(this); + + setTextureID(texture_id); // connect this media_impl to the media texture, creating it if it doesn't exist.0 // This is necessary because we need to be able to use getMaxVirtualSize() even if the media plugin is not loaded. @@ -896,6 +897,7 @@ LLViewerMediaImpl::~LLViewerMediaImpl() LLViewerMediaTexture::removeMediaImplFromTexture(mTextureId) ; + setTextureID(); remove_media_impl(this); } @@ -2427,6 +2429,26 @@ LLVOVolume *LLViewerMediaImpl::getSomeObject() return result; } +void LLViewerMediaImpl::setTextureID(LLUUID id) +{ + if(id != mTextureId) + { + if(mTextureId.notNull()) + { + // Remove this item's entry from the map + sViewerMediaTextureIDMap.erase(mTextureId); + } + + if(id.notNull()) + { + sViewerMediaTextureIDMap.insert(LLViewerMedia::impl_id_map::value_type(id, this)); + } + + mTextureId = id; + } +} + + ////////////////////////////////////////////////////////////////////////////////////////// //static void LLViewerMedia::toggleMusicPlay(void*) diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 713eb2710b..349a66867a 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -79,6 +79,8 @@ class LLViewerMedia typedef std::vector<LLViewerMediaImpl*> impl_list; + typedef std::map<LLUUID, LLViewerMediaImpl*> impl_id_map; + // Special case early init for just web browser component // so we can show login screen. See .cpp file for details. JC @@ -287,6 +289,8 @@ public: LLPluginClassMedia::EPriority getPriority() { return mPriority; }; void setLowPrioritySizeLimit(int size); + + void setTextureID(LLUUID id = LLUUID::null); typedef enum { @@ -348,6 +352,7 @@ public: LLMimeDiscoveryResponder *mMimeTypeProbe; bool mMediaAutoPlay; std::string mMediaEntryURL; + bool mInNearbyMediaList; // used by LLFloaterNearbyMedia::refreshList() for performance reasons private: BOOL mIsUpdated ; |