summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-04-02 13:14:12 -0400
committerLoren Shih <seraph@lindenlab.com>2010-04-02 13:14:12 -0400
commitfd04b26d3465bc48644cd71bea728c5dcfb7c231 (patch)
treee8b2cb54166dab2cb4be60cb437a99c5e0507515 /indra
parent873de2daae04a63c796661ff6d4db6aa912041bf (diff)
parent36987904d4568b5398122b3e09bea305bc49edc6 (diff)
automated merge
Diffstat (limited to 'indra')
-rw-r--r--indra/llimage/llimage.cpp30
-rw-r--r--indra/llimage/llimage.h14
-rw-r--r--indra/newview/lltexturecache.cpp11
-rw-r--r--indra/newview/llviewermedia.cpp8
-rw-r--r--indra/newview/llviewermenufile.cpp5
5 files changed, 46 insertions, 22 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 7d0de18c7c..0874f574c5 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -93,9 +93,10 @@ LLImageBase::LLImageBase()
mWidth(0),
mHeight(0),
mComponents(0),
+ mBadBufferAllocation(false),
+ mAllowOverSize(false),
mMemType(LLMemType::MTYPE_IMAGEBASE)
{
- mBadBufferAllocation = FALSE ;
}
// virtual
@@ -134,8 +135,6 @@ void LLImageBase::sanityCheck()
}
}
-BOOL LLImageBase::sSizeOverride = FALSE;
-
// virtual
void LLImageBase::deleteData()
{
@@ -157,23 +156,32 @@ U8* LLImageBase::allocateData(S32 size)
llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl;
}
}
- if (size < 1 || (size > 4096*4096*16 && sSizeOverride == FALSE))
+
+ //make this function thread-safe.
+ static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB
+ if (size < 1 || size > MAX_BUFFER_SIZE)
{
llinfos << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << llendl ;
+ if(mAllowOverSize)
+ {
+ llinfos << "Oversize: " << size << llendl ;
+ }
+ else
+ {
llerrs << "LLImageBase::allocateData: bad size: " << size << llendl;
}
-
+ }
if (!mData || size != mDataSize)
{
deleteData(); // virtual
- mBadBufferAllocation = FALSE ;
+ mBadBufferAllocation = false ;
mData = new U8[size];
if (!mData)
{
llwarns << "allocate image data: " << size << llendl;
size = 0 ;
mWidth = mHeight = 0 ;
- mBadBufferAllocation = TRUE ;
+ mBadBufferAllocation = true ;
}
mDataSize = size;
}
@@ -222,7 +230,7 @@ U8* LLImageBase::getData()
return mData;
}
-BOOL LLImageBase::isBufferInvalid()
+bool LLImageBase::isBufferInvalid()
{
return mBadBufferAllocation || mData == NULL ;
}
@@ -258,7 +266,11 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
: LLImageBase()
{
mMemType = LLMemType::MTYPE_IMAGERAW;
- llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
+ //llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
+ if(S32(width) * S32(height) * S32(components) > MAX_IMAGE_DATA_SIZE)
+ {
+ llwarns << "over size: width: " << (S32)width << " height: " << (S32)height << " components: " << (S32)components << llendl ;
+ }
allocateDataSize(width, height, components);
++sRawImageCount;
}
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 686f583886..10444e7f89 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -48,7 +48,7 @@ const S32 MAX_IMAGE_SIZE = (1<<MAX_IMAGE_MIP); // 2048
const S32 MIN_IMAGE_AREA = MIN_IMAGE_SIZE * MIN_IMAGE_SIZE;
const S32 MAX_IMAGE_AREA = MAX_IMAGE_SIZE * MAX_IMAGE_SIZE;
const S32 MAX_IMAGE_COMPONENTS = 8;
-const S32 MAX_IMAGE_DATA_SIZE = MAX_IMAGE_AREA * MAX_IMAGE_COMPONENTS;
+const S32 MAX_IMAGE_DATA_SIZE = MAX_IMAGE_AREA * MAX_IMAGE_COMPONENTS; //2048 * 2048 * 8 = 16 MB
// Note! These CANNOT be changed without modifying simulator code
// *TODO: change both to 1024 when SIM texture fetching is deprecated
@@ -124,10 +124,12 @@ public:
const U8 *getData() const ;
U8 *getData() ;
- BOOL isBufferInvalid() ;
+ bool isBufferInvalid() ;
void setSize(S32 width, S32 height, S32 ncomponents);
U8* allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 size = -1); // setSize() + allocateData()
+ void enableOverSize() {mAllowOverSize = true ;}
+ void disableOverSize() {mAllowOverSize = false; }
protected:
// special accessor to allow direct setting of mData and mDataSize by LLImageFormatted
@@ -140,8 +142,6 @@ public:
// <= 0 priority means that there's no need for more data.
static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent);
- static void setSizeOverride(BOOL enabled) { sSizeOverride = enabled; }
-
static EImageCodec getCodecFromExtension(const std::string& exten);
private:
@@ -153,12 +153,10 @@ private:
S8 mComponents;
- BOOL mBadBufferAllocation ;
-
+ bool mBadBufferAllocation ;
+ bool mAllowOverSize ;
public:
LLMemType::DeclareMemType& mMemType; // debug
-
- static BOOL sSizeOverride;
};
// Raw representation of an image (used for textures, and other uncompressed formats
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 08bc8220d9..651070a2ea 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -1108,7 +1108,16 @@ S32 LLTextureCache::openAndReadEntry(const LLUUID& id, Entry& entry, bool create
{
readEntryFromHeaderImmediately(idx, entry) ;
}
- llassert_always(entry.mImageSize > entry.mBodySize);
+ if(entry.mImageSize <= entry.mBodySize)//it happens on 64-bit systems, do not know why
+ {
+ llwarns << "corrupted entry: " << id << " entry image size: " << entry.mImageSize << " entry body size: " << entry.mBodySize << llendl ;
+
+ //erase this entry and the cached texture from the cache.
+ std::string tex_filename = getTextureFileName(id);
+ removeEntry(idx, entry, tex_filename) ;
+ mUpdatedEntryMap.erase(idx) ;
+ idx = -1 ;
+ }
}
return idx;
}
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index e0cbddafae..170eb7ae86 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -2968,7 +2968,13 @@ void LLViewerMediaImpl::calculateInterest()
if(!mObjectList.empty())
{
// Just use the first object in the list. We could go through the list and find the closest object, but this should work well enough.
- LLVector3d global_delta = gAgent.getPositionGlobal() - (*mObjectList.begin())->getPositionGlobal();
+ std::list< LLVOVolume* >::iterator iter = mObjectList.begin() ;
+ LLVOVolume* objp = *iter ;
+ llassert_always(objp != NULL) ;
+
+ LLVector3d obj_global = objp->getPositionGlobal() ;
+ LLVector3d agent_global = gAgent.getPositionGlobal() ;
+ LLVector3d global_delta = agent_global - obj_global ;
mProximityDistance = global_delta.magVecSquared(); // use distance-squared because it's cheaper and sorts the same.
}
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index c575656b24..c415d89e9c 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -410,7 +410,6 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
{
gViewerWindow->playSnapshotAnimAndSound();
- LLImageBase::setSizeOverride(TRUE);
LLPointer<LLImageFormatted> formatted;
switch(LLFloaterSnapshot::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat")))
{
@@ -425,12 +424,12 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
break;
default:
llwarns << "Unknown Local Snapshot format" << llendl;
- LLImageBase::setSizeOverride(FALSE);
return true;
}
+ formatted->enableOverSize() ;
formatted->encode(raw, 0);
- LLImageBase::setSizeOverride(FALSE);
+ formatted->disableOverSize() ;
gViewerWindow->saveImageNumbered(formatted);
}
return true;