summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-04-17 02:49:18 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-04-18 23:00:43 +0300
commit3758618949684641fc94b5c9478d9002706213cc (patch)
treea80a43b67241d5b783cf1e10f98855ac4d558d5a /indra/newview
parent21947778baaca205615a71a97ac8f563c998fdd3 (diff)
viewer#1260 Fix thumbnail preview being blury
1. Switched 'inspect' to thumbnails to minimalize differences 2. Reporting larger area to bump priority 3. Change scaling behavior. Old mechanics worked fine for icons that were scaled down from large images to ~32, but for thumbnails it can result in 256 image scaling down to ~200 before being scaled up to UI's scale (scale factor), causing extra loss of quality.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinspecttexture.cpp41
-rw-r--r--indra/newview/llthumbnailctrl.cpp12
-rw-r--r--indra/newview/llviewertexture.cpp30
3 files changed, 34 insertions, 49 deletions
diff --git a/indra/newview/llinspecttexture.cpp b/indra/newview/llinspecttexture.cpp
index da4e3c0949..a8c638aa68 100644
--- a/indra/newview/llinspecttexture.cpp
+++ b/indra/newview/llinspecttexture.cpp
@@ -112,7 +112,6 @@ public:
protected:
LLPointer<LLViewerFetchedTexture> m_Image;
- S32 mImageBoostLevel = LLGLTexture::BOOST_NONE;
std::string mLoadingText;
};
@@ -125,11 +124,7 @@ LLTexturePreviewView::LLTexturePreviewView(const LLView::Params& p)
LLTexturePreviewView::~LLTexturePreviewView()
{
- if (m_Image)
- {
- m_Image->setBoostLevel(mImageBoostLevel);
- m_Image = nullptr;
- }
+ m_Image = nullptr;
}
void LLTexturePreviewView::draw()
@@ -150,33 +145,33 @@ void LLTexturePreviewView::draw()
bool isLoading = (!m_Image->isFullyLoaded()) && (m_Image->getDiscardLevel() > 0);
if (isLoading)
LLFontGL::getFontSansSerif()->renderUTF8(mLoadingText, 0, llfloor(rctClient.mLeft + 3), llfloor(rctClient.mTop - 25), LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW);
- m_Image->addTextureStats((isLoading) ? MAX_IMAGE_AREA : (F32)(rctClient.getWidth() * rctClient.getHeight()));
+
+ m_Image->setKnownDrawSize(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE);
}
}
void LLTexturePreviewView::setImageFromAssetId(const LLUUID& idAsset)
{
- m_Image = LLViewerTextureManager::getFetchedTexture(idAsset, FTT_DEFAULT, MIPMAP_TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
- if (m_Image)
- {
- mImageBoostLevel = m_Image->getBoostLevel();
- m_Image->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
- m_Image->forceToSaveRawImage(0);
- if ( (!m_Image->isFullyLoaded()) && (!m_Image->hasFetcher()) )
- {
- if (m_Image->isInFastCacheList())
- {
- m_Image->loadFromFastCache();
- }
- gTextureList.forceImmediateUpdate(m_Image);
- }
- }
+ m_Image = LLViewerTextureManager::getFetchedTexture(idAsset, FTT_DEFAULT, MIPMAP_TRUE, LLGLTexture::BOOST_THUMBNAIL);
+ if (m_Image)
+ {
+ m_Image->forceToSaveRawImage(0);
+ m_Image->setKnownDrawSize(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE);
+ if ((!m_Image->isFullyLoaded()) && (!m_Image->hasFetcher()))
+ {
+ if (m_Image->isInFastCacheList())
+ {
+ m_Image->loadFromFastCache();
+ }
+ gTextureList.forceImmediateUpdate(m_Image);
+ }
+ }
}
void LLTexturePreviewView::setImageFromItemId(const LLUUID& idItem)
{
const LLViewerInventoryItem* pItem = gInventory.getItem(idItem);
- setImageFromAssetId( (pItem) ? pItem->getAssetUUID() : LLUUID::null );
+ setImageFromAssetId( (pItem) ? pItem->getAssetUUID() : LLUUID::null);
}
// ============================================================================
diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp
index b558c249cb..1cabb62f77 100644
--- a/indra/newview/llthumbnailctrl.cpp
+++ b/indra/newview/llthumbnailctrl.cpp
@@ -110,8 +110,10 @@ void LLThumbnailCtrl::draw()
}
gl_draw_scaled_image( draw_rect.mLeft, draw_rect.mBottom, draw_rect.getWidth(), draw_rect.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha);
-
- mTexturep->setKnownDrawSize(draw_rect.getWidth(), draw_rect.getHeight());
+
+ // Thumbnails are usually 256x256 or smaller, either report that or
+ // some high value to get image with higher priority
+ mTexturep->setKnownDrawSize(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE);
}
else if( mImagep.notNull() )
{
@@ -238,12 +240,8 @@ void LLThumbnailCtrl::initImage()
{
// Should it support baked textures?
mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL);
-
mTexturep->forceToSaveRawImage(0);
-
- S32 desired_draw_width = MAX_IMAGE_SIZE;
- S32 desired_draw_height = MAX_IMAGE_SIZE;
- mTexturep->setKnownDrawSize(desired_draw_width, desired_draw_height);
+ mTexturep->setKnownDrawSize(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE);
}
}
else if (tvalue.isString())
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 04ef441a69..648bdf7bee 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1193,12 +1193,11 @@ void LLViewerFetchedTexture::loadFromFastCache()
if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
- if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
+ if (mRawImage && (mRawImage->getWidth() > DEFAULT_THUMBNAIL_DIMENSIONS || mRawImage->getHeight() > DEFAULT_THUMBNAIL_DIMENSIONS))
{
- // scale oversized icon, no need to give more work to gl
- mRawImage->scale(expected_width, expected_height);
+ // Scale oversized thumbnail
+ // thumbnails aren't supposed to go over DEFAULT_THUMBNAIL_DIMENSIONS
+ mRawImage->scale(DEFAULT_THUMBNAIL_DIMENSIONS, DEFAULT_THUMBNAIL_DIMENSIONS);
}
}
@@ -1941,13 +1940,10 @@ bool LLViewerFetchedTexture::updateFetch()
if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
- if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
+ if (mRawImage && (mRawImage->getWidth() > DEFAULT_THUMBNAIL_DIMENSIONS || mRawImage->getHeight() > DEFAULT_THUMBNAIL_DIMENSIONS))
{
- // scale oversized icon, no need to give more work to gl
- // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy
- mRawImage = mRawImage->scaled(expected_width, expected_height);
+ // Scale oversized thumbnail
+ mRawImage = mRawImage->scaled(DEFAULT_THUMBNAIL_DIMENSIONS, DEFAULT_THUMBNAIL_DIMENSIONS);
}
}
@@ -2797,11 +2793,9 @@ void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* im
}
else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
- if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ if (mRawImage->getWidth() > DEFAULT_THUMBNAIL_DIMENSIONS || mRawImage->getHeight() > DEFAULT_THUMBNAIL_DIMENSIONS)
{
- mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
+ mCachedRawImage = new LLImageRaw(DEFAULT_THUMBNAIL_DIMENSIONS, DEFAULT_THUMBNAIL_DIMENSIONS, imageraw->getComponents());
mCachedRawImage->copyScaled(imageraw);
}
else
@@ -2919,11 +2913,9 @@ void LLViewerFetchedTexture::saveRawImage()
}
else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
- S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
- S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
- if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
+ if (mRawImage->getWidth() > DEFAULT_THUMBNAIL_DIMENSIONS || mRawImage->getHeight() > DEFAULT_THUMBNAIL_DIMENSIONS)
{
- mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents());
+ mSavedRawImage = new LLImageRaw(DEFAULT_THUMBNAIL_DIMENSIONS, DEFAULT_THUMBNAIL_DIMENSIONS, mRawImage->getComponents());
mSavedRawImage->copyScaled(mRawImage);
}
else