Texture fetch closer to v2.4

This commit is contained in:
Siana Gearz
2011-01-16 01:07:11 +01:00
parent 29c4b08911
commit 4ef86ff190

View File

@@ -944,16 +944,25 @@ bool LLTextureFetchWorker::doWork(S32 param)
return false ; //wait.
}
mFetcher->removeFromNetworkQueue(this, false);
S32 cur_size = 0;
if (mFormattedImage.notNull())
{
cur_size = mFormattedImage->getDataSize(); // amount of data we already have
if (mFormattedImage->getDiscardLevel() == 0)
{
// We already have all the data, just decode it
mLoadedDiscard = mFormattedImage->getDiscardLevel();
mState = DECODE_IMAGE;
return false;
if(cur_size > 0)
{
// We already have all the data, just decode it
mLoadedDiscard = mFormattedImage->getDiscardLevel();
mState = DECODE_IMAGE;
return false;
}
else
{
return true; //abort
}
}
}
mRequestedSize = mDesiredSize;
@@ -1251,15 +1260,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
else
{
setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
if(mDecodedDiscard<=0)
{
return true;
}
else
{
return false;
}
return true;
}
}
@@ -1426,62 +1427,36 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
if (success)
{
// get length of stream:
data_size = buffer->countAfter(channels.in(), NULL);
data_size = buffer->countAfter(channels.in(), NULL);
LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL;
if (data_size > 0)
{
bool clean_data = false;
bool done = false;
if (!partial)
// *TODO: set the formatted image data here directly to avoid the copy
mBuffer = new U8[data_size];
buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
mBufferSize += data_size;
if (data_size < mRequestedSize && mRequestedDiscard == 0)
{
// we got the whole image in one go
done = true;
clean_data = true;
}
else if (data_size < mRequestedSize)
{
// we have the whole image
done = true;
}
else if (data_size == mRequestedSize)
{
if (mRequestedDiscard <= 0)
{
done = true;
}
else
{
// this is the normal case where we get the data we requested,
// but still need to request more data.
}
mHaveAllData = TRUE;
}
else if (data_size > mRequestedSize)
{
// *TODO: This shouldn't be happening any more
llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
done = true;
clean_data = true;
llassert_always(mDecodeHandle == 0);
}
if (clean_data)
{
resetFormattedData(); // discard any previous data we had
llassert(mBufferSize == 0);
}
if (done)
{
mHaveAllData = TRUE;
mRequestedDiscard = 0;
llassert_always(mDecodeHandle == 0);
mFormattedImage = NULL; // discard any previous data we had
mBufferSize = data_size;
}
// *TODO: set the formatted image data here directly to avoid the copy
mBuffer = new U8[data_size];
buffer->readAfter(channels.in(), NULL, mBuffer, data_size);
mBufferSize += data_size;
mRequestedSize = data_size;
}
else
{
// We requested data but received none (and no error),
// so presumably we have all of it
mHaveAllData = TRUE;
}
mRequestedSize = data_size;
}
else
{