summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp13
-rw-r--r--indra/llimage/llimage.h5
-rw-r--r--indra/llimage/llimageworker.cpp19
-rw-r--r--indra/llimage/llimageworker.h2
4 files changed, 22 insertions, 17 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 031471d1fe..9c0cc8d760 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -584,8 +584,7 @@ static void bilinear_scale(const U8 *src, U32 srcW, U32 srcH, U32 srcCh, U32 src
//---------------------------------------------------------------------------
//static
-std::string LLImage::sLastErrorMessage;
-LLMutex* LLImage::sMutex = NULL;
+thread_local std::string LLImage::sLastThreadErrorMessage;
bool LLImage::sUseNewByteRange = false;
S32 LLImage::sMinimalReverseByteRangePercent = 75;
@@ -594,28 +593,24 @@ void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_
{
sUseNewByteRange = use_new_byte_range;
sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
- sMutex = new LLMutex();
}
//static
void LLImage::cleanupClass()
{
- delete sMutex;
- sMutex = NULL;
}
//static
-const std::string& LLImage::getLastError()
+const std::string& LLImage::getLastThreadError()
{
static const std::string noerr("No Error");
- return sLastErrorMessage.empty() ? noerr : sLastErrorMessage;
+ return sLastThreadErrorMessage.empty() ? noerr : sLastThreadErrorMessage;
}
//static
void LLImage::setLastError(const std::string& message)
{
- LLMutexLock m(sMutex);
- sLastErrorMessage = message;
+ sLastThreadErrorMessage = message;
}
//---------------------------------------------------------------------------
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 8f9e1b3c54..01b6642e1e 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -95,15 +95,14 @@ public:
static void initClass(bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75);
static void cleanupClass();
- static const std::string& getLastError();
+ static const std::string& getLastThreadError();
static void setLastError(const std::string& message);
static bool useNewByteRange() { return sUseNewByteRange; }
static S32 getReverseByteRangePercent() { return sMinimalReverseByteRangePercent; }
protected:
- static LLMutex* sMutex;
- static std::string sLastErrorMessage;
+ static thread_local std::string sLastThreadErrorMessage;
static bool sUseNewByteRange;
static S32 sMinimalReverseByteRangePercent;
};
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index c1ee052997..e09f6a0a13 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -55,6 +55,7 @@ private:
BOOL mDecodedRaw;
BOOL mDecodedAux;
LLPointer<LLImageDecodeThread::Responder> mResponder;
+ std::string mErrorString;
};
@@ -149,8 +150,9 @@ ImageRequest::~ImageRequest()
bool ImageRequest::processRequest()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- const F32 decode_time_slice = 0.f; //disable time slicing
- bool done = true;
+ const F32 decode_time_slice = 0.f; //disable time slicing
+ bool done = true;
+ mErrorString.clear();
if (!mDecodedRaw && mFormattedImage.notNull())
{
// Decode primary channels
@@ -159,10 +161,13 @@ bool ImageRequest::processRequest()
// parse formatted header
if (!mFormattedImage->updateData())
{
+ // Pick up errors from updateData
+ mErrorString = LLImage::getLastThreadError();
return true; // done (failed)
}
if (!(mFormattedImage->getWidth() * mFormattedImage->getHeight() * mFormattedImage->getComponents()))
{
+ mErrorString = "Invalid image size";
return true; // done (failed)
}
if (mDiscardLevel >= 0)
@@ -176,6 +181,9 @@ bool ImageRequest::processRequest()
done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice);
// some decoders are removing data when task is complete and there were errors
mDecodedRaw = done && mDecodedImageRaw->getData();
+
+ // Pick up errors from decoding
+ mErrorString = LLImage::getLastThreadError();
}
if (done && mNeedsAux && !mDecodedAux && mFormattedImage.notNull())
{
@@ -188,7 +196,10 @@ bool ImageRequest::processRequest()
}
done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4);
mDecodedAux = done && mDecodedImageAux->getData();
- }
+
+ // Pick up errors from decoding
+ mErrorString = LLImage::getLastThreadError();
+ }
return done;
}
@@ -199,7 +210,7 @@ void ImageRequest::finishRequest(bool completed)
if (mResponder.notNull())
{
bool success = completed && mDecodedRaw && (!mNeedsAux || mDecodedAux);
- mResponder->completed(success, mDecodedImageRaw, mDecodedImageAux);
+ mResponder->completed(success, mErrorString, mDecodedImageRaw, mDecodedImageAux);
}
// Will automatically be deleted
}
diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h
index ca4c0d93d0..c48c8084ee 100644
--- a/indra/llimage/llimageworker.h
+++ b/indra/llimage/llimageworker.h
@@ -39,7 +39,7 @@ public:
protected:
virtual ~Responder();
public:
- virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0;
+ virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux) = 0;
};
public: