Skip to content
Snippets Groups Projects
Commit d3b9f446 authored by Xiaohong Bao's avatar Xiaohong Bao
Browse files

fix for MAINT-2147: crash in LLTextureCache::writeToFastCache on OSX

parent 1d44f4d8
Branches
Tags
No related merge requests found
......@@ -666,8 +666,17 @@ void LLImageRaw::fill( const LLColor4U& color )
}
}
LLPointer<LLImageRaw> LLImageRaw::duplicate()
{
if(getNumRefs() < 2)
{
return this; //nobody else refences to this image, no need to duplicate.
}
//make a duplicate
LLPointer<LLImageRaw> dup = new LLImageRaw(getData(), getWidth(), getHeight(), getComponents());
return dup;
}
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
void LLImageRaw::copy(LLImageRaw* src)
......
......@@ -30,6 +30,7 @@
#include "lluuid.h"
#include "llstring.h"
#include "llthread.h"
#include "llpointer.h"
const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2
const S32 MAX_IMAGE_MIP = 11; // 2048x2048
......@@ -214,6 +215,9 @@ class LLImageRaw : public LLImageBase
// Copy operations
//duplicate this raw image if refCount > 1.
LLPointer<LLImageRaw> duplicate();
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
void copy( LLImageRaw* src );
......
......@@ -1912,9 +1912,9 @@ bool LLTextureCache::writeToFastCache(S32 id, LLPointer<LLImageRaw> raw, S32 dis
h >>= i;
if(w * h *c > 0) //valid
{
LLPointer<LLImageRaw> newraw = new LLImageRaw(raw->getData(), raw->getWidth(), raw->getHeight(), raw->getComponents());
newraw->scale(w, h) ;
raw = newraw;
//make a duplicate to keep the original raw image untouched.
raw = raw->duplicate();
raw->scale(w, h) ;
discardlevel += i ;
}
......
......@@ -1531,11 +1531,16 @@ void LLViewerFetchedTexture::addToCreateTexture()
destroyRawImage();
return ;
}
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
}
}
}
#endif
mNeedsCreateTexture = TRUE;
gTextureList.mCreateTextureList.insert(this);
......@@ -2899,8 +2904,12 @@ void LLViewerFetchedTexture::setCachedRawImage()
--i ;
}
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
mCachedRawImage = mRawImage ;
mRawDiscardLevel += i ;
mCachedRawDiscardLevel = mRawDiscardLevel ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment