From 0377b775d7ef313ddb9a7383848486c874e4c5ff Mon Sep 17 00:00:00 2001 From: chanayane Date: Wed, 10 Jul 2024 00:05:47 +0200 Subject: [PATCH] Raised the 512x512 limitation for uploading snapshots to inventory to 2048x2048 --- indra/newview/llagentbenefits.cpp | 19 +++++++++++++++++++ indra/newview/llagentbenefits.h | 3 +++ indra/newview/llfloatersnapshot.cpp | 5 ++++- indra/newview/llpanelsnapshot.cpp | 12 ++++++++++-- indra/newview/llpanelsnapshotinventory.cpp | 18 +++++++++++++++++- indra/newview/llpanelsnapshotoptions.cpp | 18 +++++++++++++++++- indra/newview/llsnapshotlivepreview.cpp | 10 ++++++++-- 7 files changed, 78 insertions(+), 7 deletions(-) diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp index d09faeb9e0..4c752485d5 100644 --- a/indra/newview/llagentbenefits.cpp +++ b/indra/newview/llagentbenefits.cpp @@ -267,6 +267,25 @@ S32 LLAgentBenefits::getTextureUploadCost(const LLImageBase* tex) const return getTextureUploadCost(); } +// 2048x2048 snapshots upload to inventory +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); + } + else + { + return getTextureUploadCost(); + } + } + return getTextureUploadCost(); +} +// + S32 LLAgentBenefits::get2KTextureUploadCost(S32 area) const { if (m_2k_texture_upload_cost.empty()) diff --git a/indra/newview/llagentbenefits.h b/indra/newview/llagentbenefits.h index ff23241aa9..2e693798bf 100644 --- a/indra/newview/llagentbenefits.h +++ b/indra/newview/llagentbenefits.h @@ -54,6 +54,9 @@ public: S32 getTextureUploadCost() const; S32 getTextureUploadCost(const LLViewerTexture* tex) const; S32 getTextureUploadCost(const LLImageBase* tex) const; + // 2048x2048 snapshots upload to inventory + S32 getTextureUploadCost(S32 w, S32 h) const; + // S32 get2KTextureUploadCost(S32 area) const; bool findUploadCost(LLAssetType::EType& asset_type, S32& cost) const; diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 9d1288bd96..3b7ff6b907 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -58,7 +58,10 @@ 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 +// 2048x2048 snapshots upload to inventory +//const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +const S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048 +// 2048x2048 snapshots upload to inventory static LLDefaultChildRegistry::Register r("snapshot_floater_view"); diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 3664d755bb..495d3b6242 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -41,7 +41,10 @@ #include "llagentbenefits.h" -const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +// 2048x2048 snapshots upload to inventory +//const 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) { @@ -66,7 +69,12 @@ BOOL LLPanelSnapshot::postBuild() LLUICtrl* save_btn = findChild("save_btn"); if (save_btn) { - save_btn->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost())); + // 2048x2048 snapshots upload to inventory + //save_btn->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost())); + S32 w = getTypedPreviewWidth(); + S32 h = getTypedPreviewHeight(); + save_btn->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost(w, h))); + // } // getChild(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onResolutionComboCommit, this, _1)); diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index c2f40d051f..ce130922ed 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -187,7 +187,23 @@ LLPanelSnapshotInventory::~LLPanelSnapshotInventory() void LLPanelSnapshotInventoryBase::onSend() { - S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + // 2048x2048 snapshots upload to inventory + //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) diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index 4c71ed91f8..d744dd3682 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -30,6 +30,7 @@ #include "llsidetraypanelcontainer.h" #include "llfloatersnapshot.h" // FIXME: create a snapshot model +#include "llsnapshotlivepreview.h" // 2048x2048 snapshots upload to inventory #include "llfloaterreg.h" #include "llfloaterflickr.h" // Share to Flickr @@ -92,7 +93,22 @@ void LLPanelSnapshotOptions::onOpen(const LLSD& key) void LLPanelSnapshotOptions::updateUploadCost() { - S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + // 2048x2048 snapshots upload to inventory + //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("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost)); } diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 1228715eb7..dee8f4504d 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -66,7 +66,10 @@ F32 FALL_TIME = 0.6f; S32 BORDER_WIDTH = 6; S32 TOP_PANEL_HEIGHT = 30; -const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +// 2048x2048 snapshots upload to inventory +//const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +const S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048 +// 2048x2048 snapshots upload to inventory std::set LLSnapshotLivePreview::sList; LLPointer LLSnapshotLivePreview::sSaveLocalImage = NULL; @@ -1131,7 +1134,10 @@ 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(); + // 2048x2048 snapshots upload to inventory + //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;