From 7706c1771dd0d8b767d69c3e3cdfd8ab6d620d16 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 5 Oct 2023 23:19:24 +0300 Subject: SL-20411 Thumbnail textures should have less of an impact on performance #1 scale thumbnail textures down to 256 when needed. As we do to chat icons. # Conflicts: # indra/newview/llviewertexture.cpp --- indra/newview/llthumbnailctrl.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llthumbnailctrl.cpp') diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 04130fc724..72818cf991 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -57,7 +57,6 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p) , mFallbackImagep(p.fallback_image) , mInteractable(p.interactable()) , mShowLoadingPlaceholder(p.show_loading()) -, mPriority(LLGLTexture::BOOST_PREVIEW) { mLoadingPlaceholderString = LLTrans::getString("texture_loading"); @@ -201,9 +200,8 @@ void LLThumbnailCtrl::setValue(const LLSD& value) if (mImageAssetID.notNull()) { // Should it support baked textures? - mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL); - mTexturep->setBoostLevel(mPriority); mTexturep->forceToSaveRawImage(0); S32 desired_draw_width = mTexturep->getWidth(); -- cgit v1.2.3 From f3b8565d212a29a04082d65fc45ab0aa48af3e64 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 6 Oct 2023 23:27:11 +0300 Subject: SL-20411 Don't load all thumnails at once for large folders #2 --- indra/newview/llthumbnailctrl.cpp | 77 ++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 21 deletions(-) (limited to 'indra/newview/llthumbnailctrl.cpp') diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 72818cf991..78204204af 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -57,6 +57,8 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p) , mFallbackImagep(p.fallback_image) , mInteractable(p.interactable()) , mShowLoadingPlaceholder(p.show_loading()) +, mInited(false) +, mInitImmediately(true) { mLoadingPlaceholderString = LLTrans::getString("texture_loading"); @@ -83,6 +85,10 @@ LLThumbnailCtrl::~LLThumbnailCtrl() void LLThumbnailCtrl::draw() { + if (!mInited) + { + initImage(); + } LLRect draw_rect = getLocalRect(); if (mBorderVisible) @@ -170,11 +176,19 @@ void LLThumbnailCtrl::draw() LLUICtrl::draw(); } +void LLThumbnailCtrl::setVisible(BOOL visible) +{ + if (!visible && mInited) + { + unloadImage(); + } + LLUICtrl::setVisible(visible); +} + void LLThumbnailCtrl::clearTexture() { - mImageAssetID = LLUUID::null; - mTexturep = nullptr; - mImagep = nullptr; + setValue(LLSD()); + mInited = true; // nothing to do } // virtual @@ -190,33 +204,56 @@ void LLThumbnailCtrl::setValue(const LLSD& value) LLUICtrl::setValue(tvalue); - mImageAssetID = LLUUID::null; - mTexturep = nullptr; - mImagep = nullptr; - - if (tvalue.isUUID()) - { + 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 = tvalue.asUUID(); if (mImageAssetID.notNull()) { // Should it support baked textures? mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL); - + mTexturep->forceToSaveRawImage(0); - + 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(mImagep->getImage().get()); - if(texture) + if (texture) { mImageAssetID = texture->getID(); } @@ -224,14 +261,12 @@ void LLThumbnailCtrl::setValue(const LLSD& value) } } -BOOL LLThumbnailCtrl::handleHover(S32 x, S32 y, MASK mask) +void LLThumbnailCtrl::unloadImage() { - if (mInteractable && getEnabled()) - { - getWindow()->setCursor(UI_CURSOR_HAND); - return TRUE; - } - return LLUICtrl::handleHover(x, y, mask); + mImageAssetID = LLUUID::null; + mTexturep = nullptr; + mImagep = nullptr; + mInited = false; } -- cgit v1.2.3 From 53e958a2638705572ed7dbf61369d92b332c4b60 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 14 Nov 2023 20:41:39 +0200 Subject: SL-20411 Fix texture preview images not always loading Likely happened because some textures had 0 height width initially, but this is for UI/preview so request maximum either way. --- indra/newview/llthumbnailctrl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/llthumbnailctrl.cpp') diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index 78204204af..b558c249cb 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -241,9 +241,8 @@ void LLThumbnailCtrl::initImage() mTexturep->forceToSaveRawImage(0); - S32 desired_draw_width = mTexturep->getWidth(); - S32 desired_draw_height = mTexturep->getHeight(); - + S32 desired_draw_width = MAX_IMAGE_SIZE; + S32 desired_draw_height = MAX_IMAGE_SIZE; mTexturep->setKnownDrawSize(desired_draw_width, desired_draw_height); } } -- cgit v1.2.3