summaryrefslogtreecommitdiff
path: root/indra/newview/lltexlayer.cpp
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2010-06-04 14:38:59 +0300
committerVadim Savchuk <vsavchuk@productengine.com>2010-06-04 14:38:59 +0300
commit411a78826d4166bf8d770c1e195a02858dabdab8 (patch)
tree85640dc97b44b4d6b237de62f4b9b4c4a8727dd6 /indra/newview/lltexlayer.cpp
parent15711b29afd293acd23d948a51ea65795335c95f (diff)
parentbe7554c3b624427ccf8543fb0a3187a2d9f7090b (diff)
Merge from default branch
--HG-- branch : product-engine
Diffstat (limited to 'indra/newview/lltexlayer.cpp')
-rw-r--r--indra/newview/lltexlayer.cpp114
1 files changed, 75 insertions, 39 deletions
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index b13f9e3898..1d74a7be8c 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -57,17 +57,52 @@
using namespace LLVOAvatarDefines;
+class LLTexLayerInfo
+{
+ friend class LLTexLayer;
+ friend class LLTexLayerTemplate;
+ friend class LLTexLayerInterface;
+public:
+ LLTexLayerInfo();
+ ~LLTexLayerInfo();
+
+ BOOL parseXml(LLXmlTreeNode* node);
+ BOOL createVisualParams(LLVOAvatar *avatar);
+ BOOL isUserSettable() { return mLocalTexture != -1; }
+ S32 getLocalTexture() const { return mLocalTexture; }
+ BOOL getOnlyAlpha() const { return mUseLocalTextureAlphaOnly; }
+ std::string getName() const { return mName; }
+
+private:
+ std::string mName;
+
+ BOOL mWriteAllChannels; // Don't use masking. Just write RGBA into buffer,
+ LLTexLayerInterface::ERenderPass mRenderPass;
+
+ std::string mGlobalColor;
+ LLColor4 mFixedColor;
+
+ S32 mLocalTexture;
+ std::string mStaticImageFileName;
+ BOOL mStaticImageIsMask;
+ BOOL mUseLocalTextureAlphaOnly; // Ignore RGB channels from the input texture. Use alpha as a mask
+ BOOL mIsVisibilityMask;
+
+ typedef std::vector< std::pair< std::string,BOOL > > morph_name_list_t;
+ morph_name_list_t mMorphNameList;
+ param_color_info_list_t mParamColorInfoList;
+ param_alpha_info_list_t mParamAlphaInfoList;
+};
+
//-----------------------------------------------------------------------------
// LLBakedUploadData()
//-----------------------------------------------------------------------------
LLBakedUploadData::LLBakedUploadData(const LLVOAvatarSelf* avatar,
LLTexLayerSet* layerset,
- const LLUUID& id,
- BOOL highest_lod) :
+ const LLUUID& id) :
mAvatar(avatar),
mTexLayerSet(layerset),
mID(id),
- mHighestLOD(highest_lod),
mStartTime(LLFrameTimer::getTotalTime()) // Record starting time
{
}
@@ -87,7 +122,7 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLTexLayerSet* const owner,
mNeedsUpdate(TRUE),
mNeedsUpload(FALSE),
mUploadPending(FALSE), // Not used for any logic here, just to sync sending of updates
- mDebugNumLowresUploads(0),
+ mNumLowresUploads(0),
mTexLayerSet(owner)
{
LLTexLayerSetBuffer::sGLByteCount += getSize();
@@ -141,12 +176,12 @@ void LLTexLayerSetBuffer::requestUpload()
// If we requested a new upload but haven't even uploaded
// a low res version of our last upload request, then
// keep the timer ticking instead of resetting it.
- if (mNeedsUpload && (mDebugNumLowresUploads == 0))
+ if (mNeedsUpload && (mNumLowresUploads == 0))
{
mNeedsUploadTimer.reset();
}
mNeedsUpload = TRUE;
- mDebugNumLowresUploads = 0;
+ mNumLowresUploads = 0;
mUploadPending = TRUE;
mNeedsUploadTimer.unpause();
}
@@ -289,8 +324,12 @@ BOOL LLTexLayerSetBuffer::isReadyToUpload() const
const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureTimeout");
if (texture_timeout)
{
+ // The timeout period increases exponentially between every lowres upload in order to prevent
+ // spamming the server with frequent uploads.
+ const U32 texture_timeout_threshold = texture_timeout*(1 << mNumLowresUploads);
+
// If we hit our timeout and have textures available at even lower resolution, then upload.
- const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout;
+ const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout_threshold;
const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable();
if (has_lower_lod && is_upload_textures_timeout) return TRUE;
}
@@ -387,14 +426,13 @@ void LLTexLayerSetBuffer::readBackAndUpload()
if( valid )
{
- const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
// baked_upload_data is owned by the responder and deleted after the request completes
LLBakedUploadData* baked_upload_data = new LLBakedUploadData(gAgentAvatarp,
this->mTexLayerSet,
- asset_id,
- highest_lod);
+ asset_id);
mUploadID = asset_id;
-
+ const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
+
// upload the image
std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture");
@@ -431,19 +469,19 @@ void LLTexLayerSetBuffer::readBackAndUpload()
LLNotificationsUtil::add("AvatarRezSelfBakeNotification",args);
llinfos << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << llendl;
}
-
+
if (highest_lod)
{
- // Got the final LOD for the baked texture.
+ // Sending the final LOD for the baked texture.
// All done, pause the upload timer so we know how long it took.
mNeedsUpload = FALSE;
mNeedsUploadTimer.pause();
}
else
{
- // Got a lower level LOD for the baked texture.
+ // Sending a lower level LOD for the baked texture.
// Restart the upload timer.
- mDebugNumLowresUploads++;
+ mNumLowresUploads++;
mNeedsUploadTimer.unpause();
mNeedsUploadTimer.reset();
}
@@ -973,11 +1011,11 @@ void LLTexLayerSet::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_
mAvatar->applyMorphMask(tex_data, width, height, num_components, mBakedTexIndex);
}
-BOOL LLTexLayerSet::isMorphValid()
+BOOL LLTexLayerSet::isMorphValid() const
{
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
+ for(layer_list_t::const_iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
{
- LLTexLayerInterface* layer = *iter;
+ const LLTexLayerInterface* layer = *iter;
if (layer && !layer->isMorphValid())
{
return FALSE;
@@ -1193,7 +1231,6 @@ BOOL LLTexLayerInfo::createVisualParams(LLVOAvatar *avatar)
LLTexLayerInterface::LLTexLayerInterface(LLTexLayerSet* const layer_set):
mTexLayerSet( layer_set ),
mMorphMasksValid( FALSE ),
- mStaticImageInvalid( FALSE ),
mInfo(NULL),
mHasMorph(FALSE)
{
@@ -1307,17 +1344,17 @@ void LLTexLayerInterface::invalidateMorphMasks()
mMorphMasksValid = FALSE;
}
-LLViewerVisualParam* LLTexLayerInterface::getVisualParamPtr(S32 index)
+LLViewerVisualParam* LLTexLayerInterface::getVisualParamPtr(S32 index) const
{
LLViewerVisualParam *result = NULL;
- for (param_color_list_t::iterator color_iter = mParamColorList.begin(); color_iter != mParamColorList.end() && !result; ++color_iter)
+ for (param_color_list_t::const_iterator color_iter = mParamColorList.begin(); color_iter != mParamColorList.end() && !result; ++color_iter)
{
if ((*color_iter)->getID() == index)
{
result = *color_iter;
}
}
- for (param_alpha_list_t::iterator alpha_iter = mParamAlphaList.begin(); alpha_iter != mParamAlphaList.end() && !result; ++alpha_iter)
+ for (param_alpha_list_t::const_iterator alpha_iter = mParamAlphaList.begin(); alpha_iter != mParamAlphaList.end() && !result; ++alpha_iter)
{
if ((*alpha_iter)->getID() == index)
{
@@ -1571,7 +1608,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height)
return success;
}
-U8* LLTexLayer::getAlphaData()
+const U8* LLTexLayer::getAlphaData() const
{
LLCRC alpha_mask_crc;
const LLUUID& uuid = getUUID();
@@ -1587,7 +1624,7 @@ U8* LLTexLayer::getAlphaData()
U32 cache_index = alpha_mask_crc.getCRC();
- alpha_cache_t::iterator iter2 = mAlphaCache.find(cache_index);
+ alpha_cache_t::const_iterator iter2 = mAlphaCache.find(cache_index);
return (iter2 == mAlphaCache.end()) ? 0 : iter2->second;
}
@@ -1810,7 +1847,7 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height)
{
S32 size = width * height;
- U8* alphaData = getAlphaData();
+ const U8* alphaData = getAlphaData();
if (!alphaData && hasAlphaParams())
{
LLColor4 net_color;
@@ -1833,7 +1870,7 @@ void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32
}
}
-/*virtual*/ BOOL LLTexLayer::isInvisibleAlphaMask()
+/*virtual*/ BOOL LLTexLayer::isInvisibleAlphaMask() const
{
if (mLocalTextureObject)
{
@@ -1846,8 +1883,7 @@ void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32
return FALSE;
}
-// private helper function
-LLUUID LLTexLayer::getUUID()
+LLUUID LLTexLayer::getUUID() const
{
LLUUID uuid;
if( getInfo()->mLocalTexture != -1 )
@@ -1906,7 +1942,7 @@ LLTexLayerTemplate::~LLTexLayerTemplate()
return LLTexLayerInterface::setInfo(info, wearable);
}
-U32 LLTexLayerTemplate::updateWearableCache()
+U32 LLTexLayerTemplate::updateWearableCache() const
{
mWearableCache.clear();
@@ -1931,7 +1967,7 @@ U32 LLTexLayerTemplate::updateWearableCache()
}
return added;
}
-LLTexLayer* LLTexLayerTemplate::getLayer(U32 i)
+LLTexLayer* LLTexLayerTemplate::getLayer(U32 i) const
{
if (mWearableCache.size() <= i)
{
@@ -2040,7 +2076,7 @@ LLTexLayer* LLTexLayerTemplate::getLayer(U32 i)
}
}
-/*virtual*/ BOOL LLTexLayerTemplate::isInvisibleAlphaMask()
+/*virtual*/ BOOL LLTexLayerTemplate::isInvisibleAlphaMask() const
{
U32 num_wearables = updateWearableCache();
for (U32 i = 0; i < num_wearables; i++)
@@ -2064,19 +2100,17 @@ LLTexLayer* LLTexLayerTemplate::getLayer(U32 i)
//-----------------------------------------------------------------------------
LLTexLayerInterface* LLTexLayerSet::findLayerByName(const std::string& name)
{
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
+ for (layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
{
LLTexLayerInterface* layer = *iter;
-
if (layer->getName() == name)
{
return layer;
}
}
- for( layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ )
+ for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ )
{
LLTexLayerInterface* layer = *iter;
-
if (layer->getName() == name)
{
return layer;
@@ -2121,7 +2155,7 @@ LLTexLayerStaticImageList::~LLTexLayerStaticImageList()
deleteCachedImages();
}
-void LLTexLayerStaticImageList::dumpByteCount()
+void LLTexLayerStaticImageList::dumpByteCount() const
{
llinfos << "Avatar Static Textures " <<
"KB GL:" << (mGLBytes / 1024) <<
@@ -2241,11 +2275,13 @@ const std::string LLTexLayerSetBuffer::dumpTextureInfo() const
if (!isAgentAvatarValid()) return "";
const BOOL is_high_res = !mNeedsUpload;
- const U32 num_low_res = mDebugNumLowresUploads;
+ const U32 num_low_res = mNumLowresUploads;
const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32();
+ const BOOL is_uploaded = !mUploadPending;
const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet);
- std::string text = llformat("[ HiRes:%d LoRes:%d Timer:%d ] %s",
- is_high_res, num_low_res, upload_time,
+ std::string text = llformat("[ HiRes:%d LoRes:%d Uploaded:%d ] [ Timer:%d ] %s",
+ is_high_res, num_low_res, is_uploaded,
+ upload_time,
local_texture_info.c_str());
return text;
}