diff options
Diffstat (limited to 'indra/newview/llthumbnailctrl.cpp')
-rw-r--r-- | indra/newview/llthumbnailctrl.cpp | 84 |
1 files changed, 26 insertions, 58 deletions
diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index b558c249cb..04130fc724 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -57,8 +57,7 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p) , mFallbackImagep(p.fallback_image) , mInteractable(p.interactable()) , mShowLoadingPlaceholder(p.show_loading()) -, mInited(false) -, mInitImmediately(true) +, mPriority(LLGLTexture::BOOST_PREVIEW) { mLoadingPlaceholderString = LLTrans::getString("texture_loading"); @@ -85,10 +84,6 @@ LLThumbnailCtrl::~LLThumbnailCtrl() void LLThumbnailCtrl::draw() { - if (!mInited) - { - initImage(); - } LLRect draw_rect = getLocalRect(); if (mBorderVisible) @@ -176,19 +171,11 @@ void LLThumbnailCtrl::draw() LLUICtrl::draw(); } -void LLThumbnailCtrl::setVisible(BOOL visible) -{ - if (!visible && mInited) - { - unloadImage(); - } - LLUICtrl::setVisible(visible); -} - void LLThumbnailCtrl::clearTexture() { - setValue(LLSD()); - mInited = true; // nothing to do + mImageAssetID = LLUUID::null; + mTexturep = nullptr; + mImagep = nullptr; } // virtual @@ -204,55 +191,34 @@ void LLThumbnailCtrl::setValue(const LLSD& value) LLUICtrl::setValue(tvalue); - unloadImage(); - - if (mInitImmediately) - { - initImage(); - } -} - -BOOL LLThumbnailCtrl::handleHover(S32 x, S32 y, MASK mask) -{ - if (mInteractable && getEnabled()) - { - getWindow()->setCursor(UI_CURSOR_HAND); - return TRUE; - } - return LLUICtrl::handleHover(x, y, mask); -} - -void LLThumbnailCtrl::initImage() -{ - if (mInited) - { - return; - } - mInited = true; - LLSD tvalue = getValue(); - - if (tvalue.isUUID()) - { + mImageAssetID = LLUUID::null; + mTexturep = nullptr; + mImagep = nullptr; + + if (tvalue.isUUID()) + { mImageAssetID = tvalue.asUUID(); if (mImageAssetID.notNull()) { // Should it support baked textures? - mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL); - + mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + + mTexturep->setBoostLevel(mPriority); mTexturep->forceToSaveRawImage(0); - - S32 desired_draw_width = MAX_IMAGE_SIZE; - S32 desired_draw_height = MAX_IMAGE_SIZE; + + S32 desired_draw_width = mTexturep->getWidth(); + S32 desired_draw_height = mTexturep->getHeight(); + mTexturep->setKnownDrawSize(desired_draw_width, desired_draw_height); } - } + } else if (tvalue.isString()) { mImagep = LLUI::getUIImage(tvalue.asString(), LLGLTexture::BOOST_UI); if (mImagep) { LLViewerFetchedTexture* texture = dynamic_cast<LLViewerFetchedTexture*>(mImagep->getImage().get()); - if (texture) + if(texture) { mImageAssetID = texture->getID(); } @@ -260,12 +226,14 @@ void LLThumbnailCtrl::initImage() } } -void LLThumbnailCtrl::unloadImage() +BOOL LLThumbnailCtrl::handleHover(S32 x, S32 y, MASK mask) { - mImageAssetID = LLUUID::null; - mTexturep = nullptr; - mImagep = nullptr; - mInited = false; + if (mInteractable && getEnabled()) + { + getWindow()->setCursor(UI_CURSOR_HAND); + return TRUE; + } + return LLUICtrl::handleHover(x, y, mask); } |