summaryrefslogtreecommitdiff
path: root/indra/newview/llagentbenefits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagentbenefits.cpp')
-rw-r--r--indra/newview/llagentbenefits.cpp66
1 files changed, 65 insertions, 1 deletions
diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp
index 2d219735a0..0717d92ea7 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,12 +161,55 @@ 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 getTextureUploadCost();
+}
+
+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;
if (asset_type == LLAssetType::AT_TEXTURE)
{
- cost = getTextureUploadCost();
+ cost = getTextureUploadCost();
succ = true;
}
else if (asset_type == LLAssetType::AT_SOUND)