Minor upstream catchup. Added LLImageRaw::duplicate and no_copy parameter to LLImageRaw::LLImageRaw

This commit is contained in:
Shyotl
2013-10-26 16:39:31 -05:00
parent 2a432f73da
commit 7c7c64bde3
4 changed files with 35 additions and 12 deletions

View File

@@ -299,10 +299,15 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
++sRawImageCount;
}
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy)
: LLImageBase(), mCacheEntries(0)
{
if(allocateDataSize(width, height, components) && data)
if(no_copy)
{
setDataAndSize(data, width, height, components);
}
else if(allocateDataSize(width, height, components) && data)
{
memcpy(getData(), data, width*height*components);
}
@@ -762,8 +767,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)

View File

@@ -173,7 +173,7 @@ protected:
public:
LLImageRaw();
LLImageRaw(U16 width, U16 height, S8 components);
LLImageRaw(U8 *data, U16 width, U16 height, S8 components);
LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy = false);
LLImageRaw(LLImageRaw const* src, U16 width, U16 height, U16 crop_offset, bool crop_vertically);
// Construct using createFromFile (used by tools)
//LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false);
@@ -204,6 +204,9 @@ public:
// 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 );

View File

@@ -131,7 +131,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth)
llassert(mFullHeight <= 512);
llassert(mFullWidth <= 512);
if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete())
if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI)
{ //using offscreen render target, just use the bottom left corner
mOrigin.set(0, 0);
}
@@ -218,13 +218,12 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
return TRUE;
}
#if 0 //THIS CAUSES MAINT-1092
bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete();
bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI;
if (use_fbo)
{
gPipeline.mWaterDis.bindTarget();
}
#endif
LLGLSLShader::bindNoShader();
LLVertexBuffer::unbind();
@@ -259,12 +258,10 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
}
}
#if 0 //THIS CAUSES MAINT-1092
if (use_fbo)
{
gPipeline.mWaterDis.flush();
}
#endif
return ret;
}

View File

@@ -1208,7 +1208,12 @@ void LLViewerFetchedTexture::addToCreateTexture()
destroyRawImage();
return ;
}
mRawImage->scale(w >> i, h >> i) ;
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
}
}
@@ -2540,7 +2545,11 @@ void LLViewerFetchedTexture::setCachedRawImage()
mIsRawImageValid = 0;
return;
}
mRawImage->scale(w >> i, h >> i) ;
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
if(mCachedRawImage.notNull())
mCachedRawImage->setInCache(false);