summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturectrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r--indra/newview/lltexturectrl.cpp130
1 files changed, 97 insertions, 33 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index fd7d8bcc6c..b35cd882db 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -72,6 +72,7 @@
#include "llradiogroup.h"
#include "llfloaterreg.h"
+#include "llgltfmaterialpreviewmgr.h"
#include "lllocalbitmaps.h"
#include "lllocalgltfmaterials.h"
#include "llerror.h"
@@ -229,7 +230,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti
LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID());
if (mInventoryPickType == PICK_MATERIAL
- && mImageAssetID == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID
+ && mImageAssetID == BLANK_MATERIAL_ASSET_ID
&& itemp && itemp->getAssetUUID().isNull())
{
item_id = inv_view->getUUID();
@@ -272,7 +273,7 @@ void LLFloaterTexturePicker::setImageIDFromItem(const LLInventoryItem* itemp, bo
if (mInventoryPickType == PICK_MATERIAL && asset_id.isNull())
{
// If an inventory item has a null asset, consider it a valid blank material(gltf)
- asset_id = LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID;
+ asset_id = BLANK_MATERIAL_ASSET_ID;
}
setImageID(asset_id, set_selection);
}
@@ -537,6 +538,8 @@ void LLFloaterTexturePicker::onClose(bool app_quitting)
}
stopUsingPipette();
sLastPickerMode = mModeSelector->getValue().asInteger();
+ // *NOTE: Vertex buffer for sphere preview is still cached
+ mGLTFPreview = nullptr;
}
// virtual
@@ -659,6 +662,7 @@ void LLFloaterTexturePicker::draw()
if( mOwner )
{
mTexturep = NULL;
+ LLPointer<LLFetchedGLTFMaterial> old_material = mGLTFMaterial;
mGLTFMaterial = NULL;
if (mImageAssetID.notNull())
{
@@ -666,10 +670,27 @@ void LLFloaterTexturePicker::draw()
{
mGLTFMaterial = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mImageAssetID);
llassert(mGLTFMaterial == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(gGLTFMaterialList.getMaterial(mImageAssetID)) != nullptr);
+ if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (old_material.get() != mGLTFMaterial.get())))
+ {
+ // Only update the preview if needed, since gGLTFMaterialPreviewMgr does not cache the preview.
+ if (mGLTFMaterial.isNull())
+ {
+ mGLTFPreview = nullptr;
+ }
+ else
+ {
+ mGLTFPreview = gGLTFMaterialPreviewMgr.getPreview(mGLTFMaterial);
+ }
+ }
+ if (mGLTFPreview)
+ {
+ mGLTFPreview->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
+ }
}
else
{
LLPointer<LLViewerFetchedTexture> texture = NULL;
+ mGLTFPreview = nullptr;
if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID))
{
@@ -679,7 +700,7 @@ void LLFloaterTexturePicker::draw()
if (obj)
{
LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(mImageAssetID);
- texture = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL;
+ texture = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL;
}
}
@@ -720,27 +741,25 @@ void LLFloaterTexturePicker::draw()
// If the floater is focused, don't apply its alpha to the texture (STORM-677).
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
- LLViewerTexture* texture = nullptr;
+ LLViewerTexture* preview;
if (mGLTFMaterial)
{
- texture = mGLTFMaterial->getUITexture();
+ preview = mGLTFPreview.get();
}
else
{
- texture = mTexturep.get();
+ preview = mTexturep.get();
}
- if( texture )
+ if( preview )
{
- if( texture->getComponents() == 4 )
+ preview->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
+ if( preview->getComponents() == 4 )
{
gl_rect_2d_checkerboard( interior, alpha );
}
- gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), texture, UI_VERTEX_COLOR % alpha );
-
- // Pump the priority
- texture->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
+ gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), preview, UI_VERTEX_COLOR % alpha );
}
else if (!mFallbackImage.isNull())
{
@@ -794,7 +813,7 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, bool co
}
LLUUID loockup_id = asset_id;
- if (mInventoryPickType == PICK_MATERIAL && loockup_id == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID)
+ if (mInventoryPickType == PICK_MATERIAL && loockup_id == BLANK_MATERIAL_ASSET_ID)
{
// default asset id means we are looking for an inventory item with a default asset UUID (null)
loockup_id = LLUUID::null;
@@ -889,7 +908,7 @@ void LLFloaterTexturePicker::commitCallback(LLTextureCtrl::ETexturePickOp op)
LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID());
if (mInventoryPickType == PICK_MATERIAL
- && mImageAssetID == LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID
+ && mImageAssetID == BLANK_MATERIAL_ASSET_ID
&& itemp && itemp->getAssetUUID().isNull())
{
inventory_id = inv_view->getUUID();
@@ -1639,7 +1658,7 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
mShowLoadingPlaceholder( true ),
mOpenTexPreview(false),
mBakeTextureEnabled(true),
- mInventoryPickType(PICK_TEXTURE),
+ mInventoryPickType(p.pick_type),
mImageAssetID(p.image_id),
mDefaultImageAssetID(p.default_image_id),
mDefaultImageName(p.default_image_name),
@@ -1743,7 +1762,20 @@ void LLTextureCtrl::setFilterPermissionMasks(PermissionMask mask)
setDnDFilterPermMask(mask);
}
-void LLTextureCtrl::setVisible( bool visible )
+void LLTextureCtrl::onVisibilityChange(bool new_visibility)
+{
+ if (!new_visibility)
+ {
+ // *NOTE: Vertex buffer for sphere preview is still cached
+ mGLTFPreview = nullptr;
+ }
+ else
+ {
+ llassert(!mGLTFPreview);
+ }
+}
+
+void LLTextureCtrl::setVisible(bool visible )
{
if( !visible )
{
@@ -2157,48 +2189,70 @@ void LLTextureCtrl::draw()
{
mBorder->setKeyboardFocusHighlight(hasFocus());
+ LLPointer<LLViewerTexture> preview = NULL;
+
if (!mValid)
{
mTexturep = NULL;
+ mGLTFMaterial = NULL;
+ mGLTFPreview = NULL;
}
else if (!mImageAssetID.isNull())
{
- LLPointer<LLViewerFetchedTexture> texture = NULL;
-
if (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(mImageAssetID))
{
LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
if (obj)
{
LLViewerTexture* viewerTexture = obj->getBakedTextureForMagicId(mImageAssetID);
- texture = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL;
+ mTexturep = viewerTexture ? dynamic_cast<LLViewerFetchedTexture*>(viewerTexture) : NULL;
+ mGLTFMaterial = NULL;
+ mGLTFPreview = NULL;
+
+ preview = mTexturep;
}
}
- if (texture.isNull())
+ if (preview.isNull())
{
+ LLPointer<LLFetchedGLTFMaterial> old_material = mGLTFMaterial;
+ mGLTFMaterial = NULL;
+ mTexturep = NULL;
if (mInventoryPickType == PICK_MATERIAL)
{
- LLPointer<LLFetchedGLTFMaterial> material = gGLTFMaterialList.getMaterial(mImageAssetID);
- if (material)
+ mGLTFMaterial = gGLTFMaterialList.getMaterial(mImageAssetID);
+ if (mGLTFPreview.isNull() || mGLTFMaterial.isNull() || (old_material.notNull() && (old_material.get() != mGLTFMaterial.get())))
+ {
+ // Only update the preview if needed, since gGLTFMaterialPreviewMgr does not cache the preview.
+ if (mGLTFMaterial.isNull())
+ {
+ mGLTFPreview = nullptr;
+ }
+ else
+ {
+ mGLTFPreview = gGLTFMaterialPreviewMgr.getPreview(mGLTFMaterial);
+ }
+ }
+ if (mGLTFPreview)
{
- texture = material->getUITexture();
+ mGLTFPreview->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
}
+
+ preview = mGLTFPreview;
}
else
{
- texture = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
- texture->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
- texture->forceToSaveRawImage(0);
+ preview = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
+ preview->setBoostLevel(LLGLTexture::BOOST_PREVIEW);
}
}
-
- mTexturep = texture;
}
else//mImageAssetID == LLUUID::null
{
mTexturep = NULL;
+ mGLTFMaterial = NULL;
+ mGLTFPreview = NULL;
}
// Border
@@ -2211,15 +2265,15 @@ void LLTextureCtrl::draw()
// If we're in a focused floater, don't apply the floater's alpha to the texture (STORM-677).
const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
- if( mTexturep )
+ if( preview )
{
- if( mTexturep->getComponents() == 4 )
+ if( preview->getComponents() == 4 )
{
gl_rect_2d_checkerboard( interior, alpha );
}
- gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), mTexturep, UI_VERTEX_COLOR % alpha);
- mTexturep->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
+ gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), preview, UI_VERTEX_COLOR % alpha);
+ preview->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
}
else if (!mFallbackImage.isNull())
{
@@ -2338,7 +2392,7 @@ bool LLTextureCtrl::doDrop(LLInventoryItem* item)
if (mInventoryPickType == PICK_MATERIAL && asset_id.isNull())
{
// If an inventory material has a null asset, consider it a valid blank material(gltf)
- asset_id = LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID;
+ asset_id = BLANK_MATERIAL_ASSET_ID;
}
setImageAssetID(asset_id);
@@ -2366,6 +2420,16 @@ LLSD LLTextureCtrl::getValue() const
return LLSD(getImageAssetID());
}
+namespace LLInitParam
+{
+ void TypeValues<EPickInventoryType>::declareValues()
+ {
+ declare("texture_material", PICK_TEXTURE_MATERIAL);
+ declare("texture", PICK_TEXTURE);
+ declare("material", PICK_MATERIAL);
+ }
+}
+