diff options
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r-- | indra/newview/lltexturectrl.cpp | 350 |
1 files changed, 207 insertions, 143 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 62d3fa28bf..32f38de1e4 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" @@ -147,12 +148,12 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( LLUUID image_asset_id, LLUUID default_image_asset_id, LLUUID blank_image_asset_id, - BOOL tentative, - BOOL allow_no_texture, + bool tentative, + bool allow_no_texture, const std::string& label, PermissionMask immediate_filter_perm_mask, PermissionMask dnd_filter_perm_mask, - BOOL can_apply_immediately, + bool can_apply_immediately, LLUIImagePtr fallback_image, EPickInventoryType pick_type) : LLFloater(LLSD()), @@ -167,12 +168,12 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mLabel(label), mTentativeLabel(NULL), mResolutionLabel(NULL), - mActive( TRUE ), + mActive( true ), mFilterEdit(NULL), mImmediateFilterPermMask(immediate_filter_perm_mask), mDnDFilterPermMask(dnd_filter_perm_mask), mContextConeOpacity(0.f), - mSelectedItemPinned( FALSE ), + mSelectedItemPinned( false ), mCanApply(true), mCanPreview(true), mLimitsSet(false), @@ -183,12 +184,12 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mOnFloaterCloseCallback(NULL), mSetImageAssetIDCallback(NULL), mOnUpdateImageStatsCallback(NULL), - mBakeTextureEnabled(FALSE), + mBakeTextureEnabled(false), mInventoryPickType(pick_type) { mCanApplyImmediately = can_apply_immediately; buildFromFile("floater_texture_ctrl.xml"); - setCanMinimize(FALSE); + setCanMinimize(false); } LLFloaterTexturePicker::~LLFloaterTexturePicker() @@ -199,7 +200,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti { if( ((mImageAssetID != image_id) || mTentative) && mActive) { - mNoCopyTextureSelected = FALSE; + mNoCopyTextureSelected = false; mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? mImageAssetID = image_id; @@ -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(); @@ -241,7 +242,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti } if (item_id.isNull()) { - item_id = findItemID(mImageAssetID, FALSE); + item_id = findItemID(mImageAssetID, false); } if (item_id.isNull()) { @@ -253,8 +254,8 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) { // no copy texture - getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); - mNoCopyTextureSelected = TRUE; + getChild<LLUICtrl>("apply_immediate_check")->setValue(false); + mNoCopyTextureSelected = true; } } @@ -272,12 +273,12 @@ 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); } -void LLFloaterTexturePicker::setActive( BOOL active ) +void LLFloaterTexturePicker::setActive( bool active ) { if (!active && getChild<LLUICtrl>("Pipette")->getValue().asBoolean()) { @@ -286,7 +287,7 @@ void LLFloaterTexturePicker::setActive( BOOL active ) mActive = active; } -void LLFloaterTexturePicker::setCanApplyImmediately(BOOL b) +void LLFloaterTexturePicker::setCanApplyImmediately(bool b) { mCanApplyImmediately = b; @@ -414,14 +415,14 @@ bool LLFloaterTexturePicker::updateImageStats() } // virtual -BOOL LLFloaterTexturePicker::handleDragAndDrop( +bool LLFloaterTexturePicker::handleDragAndDrop( S32 x, S32 y, MASK mask, - BOOL drop, + bool drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { - BOOL handled = FALSE; + bool handled = false; bool is_mesh = cargo_type == DAD_MESH; bool is_texture = cargo_type == DAD_TEXTURE; @@ -445,9 +446,9 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop( { LLInventoryItem *item = (LLInventoryItem *)cargo_data; - BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); - BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); - BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, + bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); + bool mod = item->getPermissions().allowModifyBy(gAgent.getID()); + bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); PermissionMask item_perm_mask = 0; @@ -476,13 +477,13 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop( *accept = ACCEPT_NO; } - handled = TRUE; + handled = true; LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << LL_ENDL; return handled; } -BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) +bool LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) { LLFolderView* root_folder = mInventoryPanel->getRootFolder(); @@ -497,23 +498,23 @@ BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) LLFolderViewItem* itemp = mInventoryPanel->getItemByID(gInventory.getRootFolderID()); if (itemp) { - root_folder->setSelection(itemp, FALSE, FALSE); + root_folder->setSelection(itemp, false, false); } } root_folder->scrollToShowSelection(); // move focus to inventory proper - mInventoryPanel->setFocus(TRUE); + mInventoryPanel->setFocus(true); // treat this as a user selection of the first filtered result commitIfImmediateSet(); - return TRUE; + return true; } if (mInventoryPanel->hasFocus() && key == KEY_UP) { - mFilterEdit->focusFirstItem(TRUE); + mFilterEdit->focusFirstItem(true); } } @@ -537,10 +538,12 @@ void LLFloaterTexturePicker::onClose(bool app_quitting) } stopUsingPipette(); sLastPickerMode = mModeSelector->getValue().asInteger(); + // *NOTE: Vertex buffer for sphere preview is still cached + mGLTFPreview = nullptr; } // virtual -BOOL LLFloaterTexturePicker::postBuild() +bool LLFloaterTexturePicker::postBuild() { LLFloater::postBuild(); @@ -593,7 +596,7 @@ BOOL LLFloaterTexturePicker::postBuild() // Disable auto selecting first filtered item because it takes away // selection from the item set by LLTextureCtrl owning this floater. - mInventoryPanel->getRootFolder()->setAutoSelectOverride(TRUE); + mInventoryPanel->getRootFolder()->setAutoSelectOverride(true); // Commented out to scroll to currently selected texture. See EXT-5403. // // store this filter as the default one @@ -607,7 +610,7 @@ BOOL LLFloaterTexturePicker::postBuild() if(!mImageAssetID.isNull() || mInventoryPickType == PICK_MATERIAL) { - mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO); + mInventoryPanel->setSelection(findItemID(mImageAssetID, false), TAKE_FOCUS_NO); } } @@ -619,7 +622,7 @@ BOOL LLFloaterTexturePicker::postBuild() mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this); refreshLocalList(); - mNoCopyTextureSelected = FALSE; + mNoCopyTextureSelected = false; getChild<LLUICtrl>("apply_immediate_check")->setValue(mCanApplyImmediately && gSavedSettings.getBOOL("TextureLivePreview")); childSetCommitCallback("apply_immediate_check", onApplyImmediateCheck, this); @@ -629,14 +632,14 @@ BOOL LLFloaterTexturePicker::postBuild() childSetAction("Cancel", LLFloaterTexturePicker::onBtnCancel,this); childSetAction("Select", LLFloaterTexturePicker::onBtnSelect,this); - mSavedFolderState.setApply(FALSE); + mSavedFolderState.setApply(false); LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1)); getChild<LLComboBox>("l_bake_use_texture_combo_box")->setCommitCallback(onBakeTextureSelect, this); - setBakeTextureEnabled(TRUE); - return TRUE; + setBakeTextureEnabled(true); + return true; } // virtual @@ -655,10 +658,11 @@ void LLFloaterTexturePicker::draw() mPipetteBtn->setEnabled(mActive); mPipetteBtn->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); - //BOOL allow_copy = FALSE; + //bool allow_copy = false; 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; } } @@ -695,7 +716,7 @@ void LLFloaterTexturePicker::draw() if (mTentativeLabel) { - mTentativeLabel->setVisible( FALSE ); + mTentativeLabel->setVisible( false ); } mDefaultBtn->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative); @@ -711,7 +732,7 @@ void LLFloaterTexturePicker::draw() // Border LLRect border = getChildView("preview_widget")->getRect(); - gl_rect_2d( border, LLColor4::black, FALSE ); + gl_rect_2d( border, LLColor4::black, false ); // Interior @@ -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()) { @@ -748,7 +767,7 @@ void LLFloaterTexturePicker::draw() } else { - gl_rect_2d( interior, LLColor4::grey % alpha, TRUE ); + gl_rect_2d( interior, LLColor4::grey % alpha, true ); // Draw X gl_draw_x(interior, LLColor4::black ); @@ -757,7 +776,7 @@ void LLFloaterTexturePicker::draw() // Draw Tentative Label over the image if( mTentative && !mViewModel->isDirty() ) { - mTentativeLabel->setVisible( TRUE ); + mTentativeLabel->setVisible( true ); drawChild(mTentativeLabel); } @@ -773,19 +792,19 @@ void LLFloaterTexturePicker::draw() // After inventory panel filter is applied we have to update // constraint rect for the selected item because of folder view - // AutoSelectOverride set to TRUE. We force PinningSelectedItem - // flag to FALSE state and setting filter "dirty" to update + // AutoSelectOverride set to true. We force PinningSelectedItem + // flag to false state and setting filter "dirty" to update // scroll container to show selected item (see LLFolderView::doIdle()). if (!is_filter_active && !mSelectedItemPinned) { folder_view->setPinningSelectedItem(mSelectedItemPinned); folder_view->getViewModelItem()->dirtyFilter(); - mSelectedItemPinned = TRUE; + mSelectedItemPinned = true; } } } -const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL copyable_only, BOOL ignore_library) +const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library) { if (asset_id.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(); @@ -1019,7 +1038,7 @@ void LLFloaterTexturePicker::onBtnSelect(void* userdata) void LLFloaterTexturePicker::onBtnPipette() { - BOOL pipette_active = getChild<LLUICtrl>("Pipette")->getValue().asBoolean(); + bool pipette_active = getChild<LLUICtrl>("Pipette")->getValue().asBoolean(); pipette_active = !pipette_active; if (pipette_active) { @@ -1031,13 +1050,13 @@ void LLFloaterTexturePicker::onBtnPipette() } } -void LLFloaterTexturePicker::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action) +void LLFloaterTexturePicker::onSelectionChange(const std::deque<LLFolderViewItem*> &items, bool user_action) { if (items.size()) { LLFolderViewItem* first_item = items.front(); LLInventoryItem* itemp = gInventory.getItem(static_cast<LLFolderViewModelItemInventory*>(first_item->getViewModelItem())->getUUID()); - mNoCopyTextureSelected = FALSE; + mNoCopyTextureSelected = false; if (itemp) { if (!mTextureSelectedCallback.empty()) @@ -1046,7 +1065,7 @@ void LLFloaterTexturePicker::onSelectionChange(const std::deque<LLFolderViewItem } if (!itemp->getPermissions().allowCopyBy(gAgent.getID())) { - mNoCopyTextureSelected = TRUE; + mNoCopyTextureSelected = true; } setImageIDFromItem(itemp, false); mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? @@ -1110,7 +1129,7 @@ void LLFloaterTexturePicker::onBtnRemove(void* userdata) LLScrollListItem* list_item = *iter; if (list_item) { - LLSD data = self->mLocalScrollCtrl->getFirstSelected()->getValue(); + LLSD data = list_item->getValue(); LLUUID tracking_id = data["id"]; S32 asset_type = data["type"].asInteger(); @@ -1328,7 +1347,7 @@ void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string ) return; } - mSavedFolderState.setApply(TRUE); + mSavedFolderState.setApply(true); mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState); // add folder with current item to list of previously opened folders LLOpenFoldersWithSelection opener; @@ -1341,7 +1360,7 @@ void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string ) // first letter in search term, save existing folder open state if (!mInventoryPanel->getFilter().isNotDefault()) { - mSavedFolderState.setApply(FALSE); + mSavedFolderState.setApply(false); mInventoryPanel->getRootFolder()->applyFunctorRecursively(mSavedFolderState); } } @@ -1353,19 +1372,19 @@ void LLFloaterTexturePicker::changeMode() { int index = mModeSelector->getValue().asInteger(); - mDefaultBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); - mBlankBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); - mNoneBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); - mFilterEdit->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); - mInventoryPanel->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE); + mDefaultBtn->setVisible(index == PICKER_INVENTORY ? true : false); + mBlankBtn->setVisible(index == PICKER_INVENTORY ? true : false); + mNoneBtn->setVisible(index == PICKER_INVENTORY ? true : false); + mFilterEdit->setVisible(index == PICKER_INVENTORY ? true : false); + mInventoryPanel->setVisible(index == PICKER_INVENTORY ? true : false); - getChild<LLButton>("l_add_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); - getChild<LLButton>("l_rem_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); - getChild<LLButton>("l_upl_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); - getChild<LLScrollListCtrl>("l_name_list")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE); + getChild<LLButton>("l_add_btn")->setVisible(index == PICKER_LOCAL ? true : false); + getChild<LLButton>("l_rem_btn")->setVisible(index == PICKER_LOCAL ? true : false); + getChild<LLButton>("l_upl_btn")->setVisible(index == PICKER_LOCAL ? true : false); + getChild<LLScrollListCtrl>("l_name_list")->setVisible(index == PICKER_LOCAL ? true : false); - getChild<LLComboBox>("l_bake_use_texture_combo_box")->setVisible(index == PICKER_BAKE ? TRUE : FALSE); - getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setVisible(FALSE);// index == 2 ? TRUE : FALSE); + getChild<LLComboBox>("l_bake_use_texture_combo_box")->setVisible(index == PICKER_BAKE ? true : false); + getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setVisible(false);// index == 2 ? true : false); bool pipette_visible = (index == PICKER_INVENTORY) && (mInventoryPickType != PICK_MATERIAL); @@ -1423,7 +1442,7 @@ void LLFloaterTexturePicker::changeMode() val = 10; } - getChild<LLComboBox>("l_bake_use_texture_combo_box")->setSelectedByValue(val, TRUE); + getChild<LLComboBox>("l_bake_use_texture_combo_box")->setSelectedByValue(val, true); } } @@ -1469,14 +1488,14 @@ void LLFloaterTexturePicker::refreshInventoryFilter() mInventoryPanel->setFilterTypes(filter_types); } -void LLFloaterTexturePicker::setLocalTextureEnabled(BOOL enabled) +void LLFloaterTexturePicker::setLocalTextureEnabled(bool enabled) { mModeSelector->setEnabledByValue(1, enabled); } -void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) +void LLFloaterTexturePicker::setBakeTextureEnabled(bool enabled) { - BOOL changed = (enabled != mBakeTextureEnabled); + bool changed = (enabled != mBakeTextureEnabled); mBakeTextureEnabled = enabled; mModeSelector->setEnabledByValue(2, enabled); @@ -1530,7 +1549,7 @@ void LLFloaterTexturePicker::setInventoryPickType(EPickInventoryType type) // refresh selection if (!mImageAssetID.isNull() || mInventoryPickType == PICK_MATERIAL) { - mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO); + mInventoryPanel->setSelection(findItemID(mImageAssetID, false), TAKE_FOCUS_NO); } } @@ -1584,10 +1603,10 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector<std::string>& fi void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) { - LLUUID inventory_item_id = findItemID(te.getID(), TRUE); + LLUUID inventory_item_id = findItemID(te.getID(), true); if (inventory_item_id.notNull()) { - LLToolPipette::getInstance()->setResult(TRUE, ""); + LLToolPipette::getInstance()->setResult(true, ""); if (mInventoryPickType == PICK_MATERIAL) { // tes have no data about material ids @@ -1600,20 +1619,20 @@ void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) setImageID(te.getID()); } - mNoCopyTextureSelected = FALSE; + mNoCopyTextureSelected = false; LLInventoryItem* itemp = gInventory.getItem(inventory_item_id); if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) { // no copy texture - mNoCopyTextureSelected = TRUE; + mNoCopyTextureSelected = true; } commitIfImmediateSet(); } else { - LLToolPipette::getInstance()->setResult(FALSE, LLTrans::getString("InventoryNoTexture")); + LLToolPipette::getInstance()->setResult(false, LLTrans::getString("InventoryNoTexture")); } } @@ -1631,15 +1650,15 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mOnSelectCallback(NULL), mBorderColor( p.border_color() ), mAllowNoTexture( p.allow_no_texture ), - mAllowLocalTexture( TRUE ), + mAllowLocalTexture( true ), mImmediateFilterPermMask( PERM_NONE ), - mCanApplyImmediately( FALSE ), - mNeedsRawImageData( FALSE ), - mValid( TRUE ), - mShowLoadingPlaceholder( TRUE ), + mCanApplyImmediately( false ), + mNeedsRawImageData( false ), + mValid( true ), + 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), @@ -1697,7 +1716,7 @@ LLTextureCtrl::~LLTextureCtrl() closeDependentFloater(); } -void LLTextureCtrl::setShowLoadingPlaceholder(BOOL showLoadingPlaceholder) +void LLTextureCtrl::setShowLoadingPlaceholder(bool showLoadingPlaceholder) { mShowLoadingPlaceholder = showLoadingPlaceholder; } @@ -1707,7 +1726,7 @@ void LLTextureCtrl::setCaption(const std::string& caption) mCaption->setText( caption ); } -void LLTextureCtrl::setCanApplyImmediately(BOOL b) +void LLTextureCtrl::setCanApplyImmediately(bool b) { mCanApplyImmediately = b; LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); @@ -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 ) { @@ -1752,7 +1784,7 @@ void LLTextureCtrl::setVisible( BOOL visible ) LLUICtrl::setVisible( visible ); } -void LLTextureCtrl::setEnabled( BOOL enabled ) +void LLTextureCtrl::setEnabled( bool enabled ) { LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if( floaterp ) @@ -1778,7 +1810,7 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) LLView::setEnabled( enabled ); } -void LLTextureCtrl::setValid(BOOL valid ) +void LLTextureCtrl::setValid(bool valid ) { mValid = valid; if (!valid) @@ -1786,7 +1818,7 @@ void LLTextureCtrl::setValid(BOOL valid ) LLFloaterTexturePicker* pickerp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if (pickerp) { - pickerp->setActive(FALSE); + pickerp->setActive(false); } } } @@ -1804,7 +1836,7 @@ void LLTextureCtrl::setLabel(const std::string& label) mCaption->setText(label); } -void LLTextureCtrl::showPicker(BOOL take_focus) +void LLTextureCtrl::showPicker(bool take_focus) { // show hourglass cursor when loading inventory window // because inventory construction is slooow @@ -1867,7 +1899,7 @@ void LLTextureCtrl::showPicker(BOOL take_focus) if (take_focus) { - floaterp->setFocus(TRUE); + floaterp->setFocus(true); } } @@ -1878,7 +1910,7 @@ void LLTextureCtrl::closeDependentFloater() if( floaterp && floaterp->isInVisibleChain()) { floaterp->setOwner(NULL); - floaterp->setVisible(FALSE); + floaterp->setVisible(false); floaterp->closeFloater(); } } @@ -1897,22 +1929,22 @@ public: } }; -BOOL LLTextureCtrl::handleHover(S32 x, S32 y, MASK mask) +bool LLTextureCtrl::handleHover(S32 x, S32 y, MASK mask) { getWindow()->setCursor(mBorder->parentPointInView(x,y) ? UI_CURSOR_HAND : UI_CURSOR_ARROW); - return TRUE; + return true; } -BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask) +bool LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask) { - BOOL handled = LLUICtrl::handleMouseDown( x, y , mask ); + bool handled = LLUICtrl::handleMouseDown( x, y , mask ); if (!handled && mBorder->parentPointInView(x, y)) { if (!mOpenTexPreview) { - showPicker(FALSE); + showPicker(false); if (mInventoryPickType == PICK_MATERIAL) { //grab materials first... @@ -1928,7 +1960,7 @@ BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask) { LLInventoryModelBackgroundFetch::instance().start(); } - handled = TRUE; + handled = true; } else { @@ -1983,7 +2015,7 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLPickerSource source, co if(floaterp->isDirty() || asset_id.notNull()) // mModelView->setDirty does not work. { - setTentative( FALSE ); + setTentative( false ); switch(source) { @@ -2004,7 +2036,7 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLPickerSource source, co break; case PICKER_UNKNOWN: default: - mImageItemID = floaterp->findItemID(asset_id, FALSE); + mImageItemID = floaterp->findItemID(asset_id, false); mImageAssetID = asset_id; mLocalTrackingID.setNull(); break; @@ -2094,12 +2126,12 @@ void LLTextureCtrl::setInventoryPickType(EPickInventoryType type) } } -BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, EDragAndDropType cargo_type, void *cargo_data, +bool LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, + bool drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) { - BOOL handled = FALSE; + bool handled = false; // this downcast may be invalid - but if the second test below // returns true, then the cast was valid, and we can perform @@ -2135,7 +2167,7 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, // This removes the 'Multiple' overlay, since // there is now only one texture selected. - setTentative( FALSE ); + setTentative( false ); onCommit(); } } @@ -2147,7 +2179,7 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, *accept = ACCEPT_NO; } - handled = TRUE; + handled = true; LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << LL_ENDL; return handled; @@ -2157,53 +2189,75 @@ 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 LLRect border( 0, getRect().getHeight(), getRect().getWidth(), BTN_HEIGHT_SMALL ); - gl_rect_2d( border, mBorderColor.get(), FALSE ); + gl_rect_2d( border, mBorderColor.get(), false ); // Interior LLRect interior = 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()) { @@ -2227,7 +2281,7 @@ void LLTextureCtrl::draw() } else { - gl_rect_2d( interior, LLColor4::grey % alpha, TRUE ); + gl_rect_2d( interior, LLColor4::grey % alpha, true ); // Draw X gl_draw_x( interior, LLColor4::black ); @@ -2240,7 +2294,7 @@ void LLTextureCtrl::draw() // fully loaded. if (mTexturep.notNull() && (!mTexturep->isFullyLoaded()) && - (mShowLoadingPlaceholder == TRUE)) + (mShowLoadingPlaceholder == true)) { U32 v_offset = 25; LLFontGL* font = LLFontGL::getFontSansSerif(); @@ -2286,11 +2340,11 @@ void LLTextureCtrl::draw() LLUICtrl::draw(); } -BOOL LLTextureCtrl::allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type, std::string& tooltip_msg) +bool LLTextureCtrl::allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type, std::string& tooltip_msg) { - BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); - BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); - BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, + bool copy = item->getPermissions().allowCopyBy(gAgent.getID()); + bool mod = item->getPermissions().allowModifyBy(gAgent.getID()); + bool xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); PermissionMask item_perm_mask = 0; @@ -2307,7 +2361,7 @@ BOOL LLTextureCtrl::allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type } else { - return TRUE; + return true; } } else @@ -2318,16 +2372,16 @@ BOOL LLTextureCtrl::allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type { tooltip_msg.assign(LLTrans::getString("TooltipTextureRestrictedDrop")); } - return FALSE; + return false; } } -BOOL LLTextureCtrl::doDrop(LLInventoryItem* item) +bool LLTextureCtrl::doDrop(LLInventoryItem* item) { // call the callback if it exists. if(mDropCallback) { - // if it returns TRUE, we return TRUE, and therefore the + // if it returns true, we return true, and therefore the // commit is called above. return mDropCallback(this, item); } @@ -2338,20 +2392,20 @@ 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); mImageItemID = item->getUUID(); - return TRUE; + return true; } -BOOL LLTextureCtrl::handleUnicodeCharHere(llwchar uni_char) +bool LLTextureCtrl::handleUnicodeCharHere(llwchar uni_char) { if( ' ' == uni_char ) { - showPicker(TRUE); - return TRUE; + showPicker(true); + return true; } return LLUICtrl::handleUnicodeCharHere(uni_char); } @@ -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); + } +} + |