diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-12 08:51:45 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-12 08:51:45 -0400 |
commit | 77ac5e44a6b57e2b33dc3026c7a3bf2aa73d2df3 (patch) | |
tree | 7cba2dcd5d4968519bba931388c5b80adbcc3e41 /indra/newview/llagentbenefits.cpp | |
parent | f95dc89d5e7481f4e02953617ce7a13feb87d27a (diff) | |
parent | e92689063bdbe34907348a12f1db39bc81132783 (diff) |
Merge 'release/luau-scripting' of secondlife/viewer into lua-login
Diffstat (limited to 'indra/newview/llagentbenefits.cpp')
-rw-r--r-- | indra/newview/llagentbenefits.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp index c2a1589682..e9f00f6556 100644 --- a/indra/newview/llagentbenefits.cpp +++ b/indra/newview/llagentbenefits.cpp @@ -25,6 +25,7 @@ #include "llviewerprecompiledheaders.h" #include "llagentbenefits.h" +#include "llviewertexture.h" LLAgentBenefits::LLAgentBenefits(): m_initalized(false), @@ -95,6 +96,26 @@ bool LLAgentBenefits::init(const LLSD& benefits_sd) return false; } + if (benefits_sd.has("large_texture_upload_cost")) + { + LLSD large_texture_cost = benefits_sd.get("large_texture_upload_cost"); + if (large_texture_cost.isArray()) + { + LLSD::array_const_iterator end = large_texture_cost.endArray(); + LLSD::array_const_iterator it = large_texture_cost.beginArray(); + for (; it != end; ++it) + { + m_2k_texture_upload_cost.push_back(it->asInteger()); + } + std::sort(m_2k_texture_upload_cost.begin(), m_2k_texture_upload_cost.end()); + } + } + + if (m_2k_texture_upload_cost.empty()) + { + m_2k_texture_upload_cost.push_back(m_texture_upload_cost); + } + // FIXME PREMIUM - either use this field or get rid of it m_initalized = true; return true; @@ -140,6 +161,49 @@ S32 LLAgentBenefits::getTextureUploadCost() const return m_texture_upload_cost; } +S32 LLAgentBenefits::getTextureUploadCost(const LLViewerTexture* tex) const +{ + if (tex) + { + S32 area = tex->getFullHeight() * tex->getFullWidth(); + if (area >= MIN_2K_TEXTURE_AREA) + { + return get2KTextureUploadCost(area); + } + else + { + return getTextureUploadCost(); + } + } + return 0; +} + +S32 LLAgentBenefits::getTextureUploadCost(const LLImageBase* tex) const +{ + if (tex) + { + S32 area = tex->getHeight() * tex->getWidth(); + 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()) + { + return m_texture_upload_cost; + } + return m_2k_texture_upload_cost[0]; +} + bool LLAgentBenefits::findUploadCost(LLAssetType::EType& asset_type, S32& cost) const { bool succ = false; |