diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2009-07-10 22:02:26 +0000 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2009-07-10 22:02:26 +0000 |
commit | 77f56a3f3db72b2938eadb0868fc7be975dabafa (patch) | |
tree | eb220e9890d0208969746a3e86fecf84b19e436b /indra/newview/llviewermedia.cpp | |
parent | e4dc104e3296319476bb0d6c327d6a326c967976 (diff) |
merge QAR-1579: texture-cleanup-1.
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 222 |
1 files changed, 67 insertions, 155 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 5d1cb824a2..bfc258506f 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -40,12 +40,12 @@ #include "llmimetypes.h" #include "llviewercontrol.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewerparcelmedia.h" #include "llviewerparcelmgr.h" #include "llviewerwindow.h" #include "llversionviewer.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llevent.h" // LLSimpleListener #include "llmediamanager.h" @@ -59,58 +59,58 @@ class LLViewerMediaImpl : public LLMediaObserver { - public: - LLViewerMediaImpl() - : mMediaSource( NULL ), - mMovieImageID(), - mMovieImageHasMips(false) - { } - - void destroyMediaSource(); - - void play(const std::string& media_url, - const std::string& mime_type, - const LLUUID& placeholder_texture_id, - S32 media_width, S32 media_height, U8 media_auto_scale, - U8 media_loop); - - void stop(); - void pause(); - void start(); - void seek(F32 time); - void setVolume(F32 volume); - LLMediaBase::EStatus getStatus(); - - /*virtual*/ void onMediaSizeChange(const EventType& event_in); - /*virtual*/ void onMediaContentsChange(const EventType& event_in); - - void updateMovieImage(const LLUUID& image_id, BOOL active); - void updateImagesMediaStreams(); - LLUUID getMediaTextureID(); - - // Internally set our desired browser user agent string, including - // the Second Life version and skin name. Used because we can - // switch skins without restarting the app. - static void updateBrowserUserAgent(); - - // Callback for when the SkinCurrent control is changed to - // switch the user agent string to indicate the new skin. - static bool handleSkinCurrentChanged(const LLSD& newvalue); - - public: - - // a single media url with some data and an impl. - LLMediaBase* mMediaSource; - LLUUID mMovieImageID; - bool mMovieImageHasMips; - std::string mMediaURL; - std::string mMimeType; - private: - void initializePlaceholderImage(LLViewerImage *placeholder_image, LLMediaBase *media_source); +public: + LLViewerMediaImpl() + : mMediaSource( NULL ), + mMovieImageID(), + mMovieImageHasMips(false) + { } + + void destroyMediaSource(); + + void play(const std::string& media_url, + const std::string& mime_type, + const LLUUID& placeholder_texture_id, + S32 media_width, S32 media_height, U8 media_auto_scale, + U8 media_loop); + + void stop(); + void pause(); + void start(); + void seek(F32 time); + void setVolume(F32 volume); + LLMediaBase::EStatus getStatus(); + + /*virtual*/ void onMediaSizeChange(const EventType& event_in); + /*virtual*/ void onMediaContentsChange(const EventType& event_in); + + void restoreMovieImage(); + void updateImagesMediaStreams(); + LLUUID getMediaTextureID(); + + // Internally set our desired browser user agent string, including + // the Second Life version and skin name. Used because we can + // switch skins without restarting the app. + static void updateBrowserUserAgent(); + + // Callback for when the SkinCurrent control is changed to + // switch the user agent string to indicate the new skin. + static bool handleSkinCurrentChanged(const LLSD& newvalue); + +public: + + // a single media url with some data and an impl. + LLMediaBase* mMediaSource; + LLUUID mMovieImageID; + bool mMovieImageHasMips; + std::string mMediaURL; + std::string mMimeType; + +private: + void initializePlaceholderImage(LLViewerMediaTexture *placeholder_image, LLMediaBase *media_source); }; static LLViewerMediaImpl sViewerMediaImpl; - ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::destroyMediaSource() @@ -118,12 +118,11 @@ void LLViewerMediaImpl::destroyMediaSource() LLMediaManager* mgr = LLMediaManager::getInstance(); if ( mMediaSource ) { - bool was_playing = LLViewerMedia::isMediaPlaying(); mMediaSource->remObserver(this); mgr->destroySource( mMediaSource ); // Restore the texture - updateMovieImage(LLUUID::null, was_playing); + restoreMovieImage(); } mMediaSource = NULL; @@ -229,49 +228,36 @@ LLMediaBase::EStatus LLViewerMediaImpl::getStatus() } ////////////////////////////////////////////////////////////////////////////////////////// -// static -void LLViewerMediaImpl::updateMovieImage(const LLUUID& uuid, BOOL active) +void LLViewerMediaImpl::restoreMovieImage() { // IF the media image hasn't changed, do nothing - if (mMovieImageID == uuid) + if (mMovieImageID.isNull()) { return; } - // If we have changed media uuid, restore the old one - if (!mMovieImageID.isNull()) - { - LLViewerImage* oldImage = LLViewerImage::getImage( mMovieImageID ); - if (oldImage) - { - oldImage->reinit(mMovieImageHasMips); - oldImage->mIsMediaTexture = FALSE; - } - mMovieImageID.setNull(); - } - // If the movie is playing, set the new media image - if (active && !uuid.isNull()) + + //restore the movie image to the old one + LLViewerMediaTexture* media = LLViewerTextureManager::findMediaTexture( mMovieImageID ) ; + if (media) { - LLViewerImage* viewerImage = LLViewerImage::getImage( uuid ); - if( viewerImage ) + if(media->getOldTexture())//set back to the old texture if it exists { - mMovieImageID = uuid; - // Can't use mipmaps for movies because they don't update the full image - mMovieImageHasMips = viewerImage->getUseMipMaps(); - viewerImage->reinit(FALSE); - viewerImage->mIsMediaTexture = TRUE; + media->switchToTexture(media->getOldTexture()) ; + media->setPlaying(FALSE) ; } + media->reinit(mMovieImageHasMips); } + mMovieImageID.setNull(); } ////////////////////////////////////////////////////////////////////////////////////////// -// static void LLViewerMediaImpl::updateImagesMediaStreams() { LLMediaManager::updateClass(); } -void LLViewerMediaImpl::initializePlaceholderImage(LLViewerImage *placeholder_image, LLMediaBase *media_source) +void LLViewerMediaImpl::initializePlaceholderImage(LLViewerMediaTexture *placeholder_image, LLMediaBase *media_source) { int media_width = media_source->getMediaWidth(); int media_height = media_source->getMediaHeight(); @@ -308,19 +294,14 @@ void LLViewerMediaImpl::initializePlaceholderImage(LLViewerImage *placeholder_im // placeholder_image->setExplicitFormat() placeholder_image->setUseMipMaps(FALSE); - - // MEDIAOPT: set this dynamically on play/stop - placeholder_image->mIsMediaTexture = true; } - - // virtual void LLViewerMediaImpl::onMediaContentsChange(const EventType& event_in) { LLMediaBase* media_source = event_in.getSubject(); - LLViewerImage* placeholder_image = gImageList.getImage( mMovieImageID ); - if ((placeholder_image) && (placeholder_image->getHasGLTexture())) + LLViewerMediaTexture* placeholder_image = LLViewerTextureManager::getMediaTexture( mMovieImageID ) ; + if (placeholder_image && placeholder_image->hasValidGLTexture()) { if (placeholder_image->getUseMipMaps()) { @@ -345,7 +326,7 @@ void LLViewerMediaImpl::onMediaContentsChange(const EventType& event_in) void LLViewerMediaImpl::onMediaSizeChange(const EventType& event_in) { LLMediaBase* media_source = event_in.getSubject(); - LLViewerImage* placeholder_image = gImageList.getImage( mMovieImageID ); + LLViewerMediaTexture* placeholder_image = LLViewerTextureManager::getMediaTexture( mMovieImageID ) ; if (placeholder_image) { initializePlaceholderImage(placeholder_image, media_source); @@ -356,75 +337,6 @@ void LLViewerMediaImpl::onMediaSizeChange(const EventType& event_in) } } - - // Get the image we're using - - /* - // update media stream if required - LLMediaEngine* media_engine = LLMediaEngine::getInstance(); - if (media_engine) - { - if ( media_engine->update() ) - { - LLUUID media_uuid = media_engine->getImageUUID(); - updateMovieImage(media_uuid, TRUE); - if (!media_uuid.isNull()) - { - LLViewerImage* viewerImage = getImage( media_uuid ); - if( viewerImage ) - { - LLMediaBase* renderer = media_engine->getMediaRenderer(); - if ((renderer->getTextureWidth() != viewerImage->getWidth()) || - (renderer->getTextureHeight() != viewerImage->getHeight()) || - (renderer->getTextureDepth() != viewerImage->getComponents()) || - (viewerImage->getHasGLTexture() == FALSE)) - { - // destroy existing GL image - viewerImage->destroyGLTexture(); - - // set new size - viewerImage->setSize( renderer->getTextureWidth(), - renderer->getTextureHeight(), - renderer->getTextureDepth() ); - - LLPointer<LLImageRaw> raw = new LLImageRaw(renderer->getTextureWidth(), - renderer->getTextureHeight(), - renderer->getTextureDepth()); - raw->clear(0x7f,0x7f,0x7f,0xff); - viewerImage->createGLTexture(0, raw); - } - - // Set the explicit format the instance wants - viewerImage->setExplicitFormat(renderer->getTextureFormatInternal(), - renderer->getTextureFormatPrimary(), - renderer->getTextureFormatType(), - renderer->getTextureFormatSwapBytes()); - // This should be redundant, but just in case: - viewerImage->setUseMipMaps(FALSE); - - LLImageRaw* rawImage = media_engine->getImageRaw(); - if ( rawImage ) - { - viewerImage->setSubImage(rawImage, 0, 0, - renderer->getMediaWidth(), - renderer->getMediaHeight()); - } - } - else - { - llwarns << "MediaEngine update unable to get viewer image for GL texture" << llendl; - } - } - } - else - { - LLUUID media_uuid = media_engine->getImageUUID(); - updateMovieImage(media_uuid, FALSE); - } - } - */ - - LLUUID LLViewerMediaImpl::getMediaTextureID() { return mMovieImageID; |