diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 00:39:07 +0200 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 00:39:07 +0200 |
commit | 84f3b2865fe3ec2a3dfb0a96ed0389381cebeed5 (patch) | |
tree | 1490249690bb3c7c0509e8ad73e2b7f7748d9dba /indra/llimage | |
parent | 6ec37fac60c0288e576b72b91b16d74b37dbc32d (diff) | |
parent | 78bdf57ad6610b34389226bf941ba736ca0c2225 (diff) |
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/llimage')
-rw-r--r-- | indra/llimage/llimage.cpp | 34 | ||||
-rw-r--r-- | indra/llimage/llimage.h | 31 | ||||
-rw-r--r-- | indra/llimage/llimagej2c.cpp | 4 |
3 files changed, 31 insertions, 38 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index aed8943439..7a0c8cd8f5 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -583,39 +583,29 @@ static void bilinear_scale(const U8 *src, U32 srcW, U32 srcH, U32 srcCh, U32 src // LLImage //--------------------------------------------------------------------------- -//static -std::string LLImage::sLastErrorMessage; -LLMutex* LLImage::sMutex = NULL; -bool LLImage::sUseNewByteRange = false; -S32 LLImage::sMinimalReverseByteRangePercent = 75; - -//static -void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) +LLImage::LLImage(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) { - sUseNewByteRange = use_new_byte_range; - sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent; - sMutex = new LLMutex(); + mMutex = new LLMutex(); + mUseNewByteRange = use_new_byte_range; + mMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent; } -//static -void LLImage::cleanupClass() +LLImage::~LLImage() { - delete sMutex; - sMutex = NULL; + delete mMutex; + mMutex = NULL; } -//static -const std::string& LLImage::getLastError() +const std::string& LLImage::getLastErrorMessage() { static const std::string noerr("No Error"); - return sLastErrorMessage.empty() ? noerr : sLastErrorMessage; + return mLastErrorMessage.empty() ? noerr : mLastErrorMessage; } -//static -void LLImage::setLastError(const std::string& message) +void LLImage::setLastErrorMessage(const std::string& message) { - LLMutexLock m(sMutex); - sLastErrorMessage = message; + LLMutexLock m(mMutex); + mLastErrorMessage = message; } //--------------------------------------------------------------------------- diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 8ec49d3f0f..9f8d061293 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -30,6 +30,7 @@ #include "lluuid.h" #include "llstring.h" #include "llpointer.h" +#include "llsingleton.h" #include "lltrace.h" const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 @@ -88,23 +89,25 @@ typedef enum e_image_codec //============================================================================ // library initialization class -class LLImage +class LLImage : public LLParamSingleton<LLImage> { + LLSINGLETON(LLImage, bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75); + ~LLImage(); 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 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 bool sUseNewByteRange; - static S32 sMinimalReverseByteRangePercent; + const std::string& getLastErrorMessage(); + static const std::string& getLastError() { return getInstance()->getLastErrorMessage(); }; + void setLastErrorMessage(const std::string& message); + static void setLastError(const std::string& message) { getInstance()->setLastErrorMessage(message); } + + bool useNewByteRange() { return mUseNewByteRange; } + S32 getReverseByteRangePercent() { return mMinimalReverseByteRangePercent; } + +private: + LLMutex* mMutex; + std::string mLastErrorMessage; + bool mUseNewByteRange; + S32 mMinimalReverseByteRangePercent; }; //============================================================================ diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 4bff21610f..71cab0554d 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -281,7 +281,7 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r S32 bytes; S32 new_bytes = (S32) (sqrt((F32)(w*h))*(F32)(comp)*rate*1000.f/layer_factor); S32 old_bytes = (S32)((F32)(w*h*comp)*rate); - bytes = (LLImage::useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes); + bytes = (LLImage::getInstance()->useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes); bytes = llmax(bytes, calcHeaderSizeJ2C()); return bytes; } @@ -322,7 +322,7 @@ S32 LLImageJ2C::calcDiscardLevelBytes(S32 bytes) { S32 bytes_needed = calcDataSize(discard_level); // Use TextureReverseByteRange percent (see settings.xml) of the optimal size to qualify as correct rendering for the given discard level - if (bytes >= (bytes_needed*LLImage::getReverseByteRangePercent()/100)) + if (bytes >= (bytes_needed*LLImage::getInstance()->getReverseByteRangePercent()/100)) { break; } |