Raised the 512x512 limitation for uploading snapshots to inventory to 2048x2048 (#2025)

master
Ayane 2024-07-17 01:47:22 +02:00 committed by GitHub
parent b05ab692ba
commit bd0baebb6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 48 additions and 7 deletions

View File

@ -195,6 +195,19 @@ S32 LLAgentBenefits::getTextureUploadCost(const LLImageBase* tex) const
return getTextureUploadCost();
}
S32 LLAgentBenefits::getTextureUploadCost(S32 w, S32 h) const
{
if (w > 0 && h > 0)
{
S32 area = w * h;
if (area >= MIN_2K_TEXTURE_AREA)
{
return get2KTextureUploadCost(area);
}
}
return getTextureUploadCost();
}
S32 LLAgentBenefits::get2KTextureUploadCost(S32 area) const
{
if (m_2k_texture_upload_cost.empty())

View File

@ -54,6 +54,7 @@ public:
S32 getTextureUploadCost() const;
S32 getTextureUploadCost(const LLViewerTexture* tex) const;
S32 getTextureUploadCost(const LLImageBase* tex) const;
S32 getTextureUploadCost(S32 w, S32 h) const;
S32 get2KTextureUploadCost(S32 area) const;
bool findUploadCost(LLAssetType::EType& asset_type, S32& cost) const;

View File

@ -51,7 +51,7 @@ LLSnapshotFloaterView* gSnapshotFloaterView = NULL;
const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f;
const S32 MAX_POSTCARD_DATASIZE = 1572864; // 1.5 megabyte, similar to simulator limit
const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512
const S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048
static LLDefaultChildRegistry::Register<LLSnapshotFloaterView> r("snapshot_floater_view");

View File

@ -41,7 +41,7 @@
#include "llagentbenefits.h"
constexpr S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512
const S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048
S32 power_of_two(S32 sz, S32 upper)
{
@ -61,7 +61,9 @@ LLPanelSnapshot::LLPanelSnapshot()
// virtual
bool LLPanelSnapshot::postBuild()
{
getChild<LLUICtrl>("save_btn")->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost()));
S32 w = getTypedPreviewWidth();
S32 h = getTypedPreviewHeight();
getChild<LLUICtrl>("save_btn")->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost(w, h)));
getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onResolutionComboCommit, this, _1));
if (!getWidthSpinnerName().empty())
{

View File

@ -155,7 +155,19 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl)
void LLPanelSnapshotInventoryBase::onSend()
{
S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
S32 w = 0;
S32 h = 0;
if( mSnapshotFloater )
{
LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView();
if( preview )
{
preview->getSize(w, h);
}
}
S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
if (can_afford_transaction(expected_upload_cost))
{
if (mSnapshotFloater)

View File

@ -30,6 +30,7 @@
#include "llsidetraypanelcontainer.h"
#include "llfloatersnapshot.h" // FIXME: create a snapshot model
#include "llsnapshotlivepreview.h"
#include "llfloaterreg.h"
#include "llagentbenefits.h"
@ -89,7 +90,19 @@ void LLPanelSnapshotOptions::onOpen(const LLSD& key)
void LLPanelSnapshotOptions::updateUploadCost()
{
S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
S32 w = 0;
S32 h = 0;
if( mSnapshotFloater )
{
LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView();
if( preview )
{
preview->getSize(w, h);
}
}
S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h);
getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost));
}

View File

@ -65,7 +65,7 @@ constexpr F32 FALL_TIME = 0.6f;
constexpr S32 BORDER_WIDTH = 6;
constexpr S32 TOP_PANEL_HEIGHT = 30;
constexpr S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512
const S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048
std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList;
LLPointer<LLImageFormatted> LLSnapshotLivePreview::sSaveLocalImage = NULL;
@ -1024,7 +1024,7 @@ void LLSnapshotLivePreview::saveTexture(bool outfit_snapshot, std::string name)
LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL);
std::string who_took_it;
LLAgentUI::buildFullname(who_took_it);
S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(scaled->getWidth(), scaled->getHeight());
std::string res_name = outfit_snapshot ? name : "Snapshot : " + pos_string;
std::string res_desc = outfit_snapshot ? "" : "Taken by " + who_took_it + " at " + pos_string;
LLFolderType::EType folder_type = outfit_snapshot ? LLFolderType::FT_NONE : LLFolderType::FT_SNAPSHOT_CATEGORY;