summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-12 15:43:34 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-12 15:43:34 +0300
commiteab5beb54cacc2b0dc2cddad4a78634e7468a298 (patch)
tree51f17910f529af57819bcd77f1a7dd9e92f6291e /indra/llimage
parent00e09ddcad8ec2c33ecbcdd0da09bd7819bc3509 (diff)
parentcc8fdf341dbbe6ab940d7b24bcf81cbed252cb69 (diff)
Merge branch 'main' into marchcat/x-merge
# Conflicts: # indra/llimage/llimageworker.cpp # indra/llimage/llimageworker.h # indra/newview/llcontrolavatar.cpp # indra/newview/llfloaterprofiletexture.cpp # indra/newview/lloutfitslist.cpp # indra/newview/lloutfitslist.h # indra/newview/lltexturefetch.cpp
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimagedimensionsinfo.cpp4
-rw-r--r--indra/llimage/llimagedimensionsinfo.h7
-rw-r--r--indra/llimage/llimageworker.cpp31
-rw-r--r--indra/llimage/llimageworker.h4
4 files changed, 32 insertions, 14 deletions
diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp
index 97b543f3b6..9dd69ff132 100644
--- a/indra/llimage/llimagedimensionsinfo.cpp
+++ b/indra/llimage/llimagedimensionsinfo.cpp
@@ -50,6 +50,7 @@ bool LLImageDimensionsInfo::load(const std::string& src_filename,U32 codec)
if (file_size == 0)
{
+ mWarning = "texture_load_empty_file";
setLastError("File is empty",src_filename);
return false;
}
@@ -90,6 +91,7 @@ bool LLImageDimensionsInfo::getImageDimensionsBmp()
if (signature[0] != 'B' || signature[1] != 'M')
{
LL_WARNS() << "Not a BMP" << LL_ENDL;
+ mWarning = "texture_load_format_error";
return false;
}
@@ -140,6 +142,7 @@ bool LLImageDimensionsInfo::getImageDimensionsPng()
if (memcmp(signature, png_magic, PNG_MAGIC_SIZE) != 0)
{
LL_WARNS() << "Not a PNG" << LL_ENDL;
+ mWarning = "texture_load_format_error";
return false;
}
@@ -183,6 +186,7 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg()
if (memcmp(signature, jpeg_magic, JPEG_MAGIC_SIZE) != 0)
{
LL_WARNS() << "Not a JPEG" << LL_ENDL;
+ mWarning = "texture_load_format_error";
return false;
}
fseek(fp, 0, SEEK_SET); // go back to start of the file
diff --git a/indra/llimage/llimagedimensionsinfo.h b/indra/llimage/llimagedimensionsinfo.h
index 8f716c5d02..ade283bb85 100644
--- a/indra/llimage/llimagedimensionsinfo.h
+++ b/indra/llimage/llimagedimensionsinfo.h
@@ -55,6 +55,12 @@ public:
{
return mLastError;
}
+
+ const std::string& getWarningName()
+ {
+ return mWarning;
+ }
+
protected:
void clean()
@@ -129,6 +135,7 @@ protected:
std::string mSrcFilename;
std::string mLastError;
+ std::string mWarning;
U8* mData;
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index e09f6a0a13..06aaeb0e84 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -35,8 +35,10 @@ class ImageRequest
{
public:
ImageRequest(const LLPointer<LLImageFormatted>& image,
- S32 discard, BOOL needs_aux,
- const LLPointer<LLImageDecodeThread::Responder>& responder);
+ S32 discard,
+ BOOL needs_aux,
+ const LLPointer<LLImageDecodeThread::Responder>& responder,
+ U32 request_id);
virtual ~ImageRequest();
/*virtual*/ bool processRequest();
@@ -48,6 +50,7 @@ private:
// input
LLPointer<LLImageFormatted> mFormattedImage;
S32 mDiscardLevel;
+ U32 mRequestId;
BOOL mNeedsAux;
// output
LLPointer<LLImageRaw> mDecodedImageRaw;
@@ -63,6 +66,7 @@ private:
// MAIN THREAD
LLImageDecodeThread::LLImageDecodeThread(bool /*threaded*/)
+ : mDecodeCount(0)
{
mThreadPool.reset(new LL::ThreadPool("ImageDecode", 8));
mThreadPool->start();
@@ -93,9 +97,10 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ U32 decode_id = ++mDecodeCount;
// Instantiate the ImageRequest right in the lambda, why not?
bool posted = mThreadPool->getQueue().post(
- [req = ImageRequest(image, discard, needs_aux, responder)]
+ [req = ImageRequest(image, discard, needs_aux, responder, decode_id)]
() mutable
{
auto done = req.processRequest();
@@ -104,13 +109,10 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(
if (! posted)
{
LL_DEBUGS() << "Tried to start decoding on shutdown" << LL_ENDL;
- // should this return 0?
+ return 0;
}
- // It's important to our consumer (LLTextureFetchWorker) that we return a
- // nonzero handle. It is NOT important that the nonzero handle be unique:
- // nothing is ever done with it except to compare it to zero, or zero it.
- return 17;
+ return decode_id;
}
void LLImageDecodeThread::shutdown()
@@ -124,15 +126,18 @@ LLImageDecodeThread::Responder::~Responder()
//----------------------------------------------------------------------------
-ImageRequest::ImageRequest(const LLPointer<LLImageFormatted>& image,
- S32 discard, BOOL needs_aux,
- const LLPointer<LLImageDecodeThread::Responder>& responder)
+ImageRequest::ImageRequest(const LLPointer<LLImageFormatted>& image,
+ S32 discard,
+ BOOL needs_aux,
+ const LLPointer<LLImageDecodeThread::Responder>& responder,
+ U32 request_id)
: mFormattedImage(image),
mDiscardLevel(discard),
mNeedsAux(needs_aux),
mDecodedRaw(FALSE),
mDecodedAux(FALSE),
- mResponder(responder)
+ mResponder(responder),
+ mRequestId(request_id)
{
}
@@ -210,7 +215,7 @@ void ImageRequest::finishRequest(bool completed)
if (mResponder.notNull())
{
bool success = completed && mDecodedRaw && (!mNeedsAux || mDecodedAux);
- mResponder->completed(success, mErrorString, mDecodedImageRaw, mDecodedImageAux);
+ mResponder->completed(success, mErrorString, mDecodedImageRaw, mDecodedImageAux, mRequestId);
}
// Will automatically be deleted
}
diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h
index c48c8084ee..670b9772f0 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, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux) = 0;
+ virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux, U32 request_id) = 0;
};
public:
@@ -53,6 +53,7 @@ public:
const LLPointer<Responder>& responder);
size_t getPending();
size_t update(F32 max_time_ms);
+ S32 getTotalDecodeCount() { return mDecodeCount; }
void shutdown();
private:
@@ -60,6 +61,7 @@ private:
// LLQueuedThread - instead this is the API by which we submit work to the
// "ImageDecode" ThreadPool.
std::unique_ptr<LL::ThreadPool> mThreadPool;
+ LLAtomicU32 mDecodeCount;
};
#endif