summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp34
-rw-r--r--indra/llimage/llimage.h31
-rw-r--r--indra/llimage/llimagej2c.cpp4
3 files changed, 31 insertions, 38 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 680fbf548f..9dea876114 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..e5526ba9c0 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>
{
+ LLPARAMSINGLETON(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;
}