V2 llimage merge

This commit is contained in:
Shyotl
2011-02-22 18:21:02 -06:00
parent 97d5e8f154
commit a207a71066
5 changed files with 30 additions and 20 deletions

View File

@@ -93,9 +93,10 @@ LLImageBase::LLImageBase()
mWidth(0),
mHeight(0),
mComponents(0),
mBadBufferAllocation(false),
mAllowOverSize(false),
mMemType(LLMemType::MTYPE_IMAGEBASE)
{
mBadBufferAllocation = FALSE ;
}
// virtual
@@ -134,8 +135,6 @@ void LLImageBase::sanityCheck()
}
}
BOOL LLImageBase::sSizeOverride = FALSE;
// virtual
void LLImageBase::deleteData()
{
@@ -158,7 +157,7 @@ U8* LLImageBase::allocateData(S32 size)
llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl;
}
}
else if (size <= 0 || (size > 4096*4096*16 && sSizeOverride == FALSE))
else if (size <= 0 || (size > 4096*4096*16 && !mAllowOverSize))
{
llerrs << "LLImageBase::allocateData: bad size: " << size << llendl;
}
@@ -220,7 +219,7 @@ U8* LLImageBase::getData()
return mData;
}
BOOL LLImageBase::isBufferInvalid()
bool LLImageBase::isBufferInvalid()
{
return mBadBufferAllocation || mData == NULL ;
}
@@ -1287,7 +1286,7 @@ LLImageFormatted::LLImageFormatted(S8 codec)
mCodec(codec),
mDecoding(0),
mDecoded(0),
mDiscardLevel(0)
mDiscardLevel(-1)
{
mMemType = LLMemType::MTYPE_IMAGEFORMATTED;
}

View File

@@ -123,14 +123,16 @@ public:
const U8 *getData() const ;
U8 *getData() ;
BOOL isBufferInvalid() ;
bool isBufferInvalid() ;
void setSize(S32 width, S32 height, S32 ncomponents);
U8* allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 size = -1); // setSize() + allocateData()
void enableOverSize() {mAllowOverSize = true ;}
void disableOverSize() {mAllowOverSize = false; }
protected:
// special accessor to allow direct setting of mData and mDataSize by LLImageFormatted
void setDataAndSize(U8 *data, S32 size) { mData = data; mDataSize = size; };
void setDataAndSize(U8 *data, S32 size) { mData = data; mDataSize = size; }
public:
static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels);
@@ -139,8 +141,6 @@ public:
// <= 0 priority means that there's no need for more data.
static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent);
static void setSizeOverride(BOOL enabled) { sSizeOverride = enabled; }
static EImageCodec getCodecFromExtension(const std::string& exten);
private:
@@ -152,11 +152,10 @@ private:
S8 mComponents;
BOOL mBadBufferAllocation ;
bool mBadBufferAllocation ;
bool mAllowOverSize ;
public:
S16 mMemType; // debug
static BOOL sSizeOverride;
};
// Raw representation of an image (used for textures, and other uncompressed formats

View File

@@ -44,6 +44,12 @@ LLImageDecodeThread::LLImageDecodeThread(bool threaded)
mCreationMutex = new LLMutex(getAPRPool());
}
//virtual
LLImageDecodeThread::~LLImageDecodeThread()
{
delete mCreationMutex ;
}
// MAIN THREAD
// virtual
S32 LLImageDecodeThread::update(U32 max_time_ms)
@@ -54,9 +60,14 @@ S32 LLImageDecodeThread::update(U32 max_time_ms)
{
creation_info& info = *iter;
ImageRequest* req = new ImageRequest(info.handle, info.image,
info.priority, info.discard, info.needs_aux,
info.responder);
addRequest(req);
info.priority, info.discard, info.needs_aux,
info.responder);
bool res = addRequest(req);
if (!res)
{
llerrs << "request added after LLLFSThread::cleanupClass()" << llendl;
}
}
mCreationList.clear();
S32 res = LLQueuedThread::update(max_time_ms);

View File

@@ -78,6 +78,8 @@ public:
public:
LLImageDecodeThread(bool threaded = true);
virtual ~LLImageDecodeThread();
handle_t decodeImage(LLImageFormatted* image,
U32 priority, S32 discard, BOOL needs_aux,
Responder* responder);
@@ -90,7 +92,7 @@ private:
struct creation_info
{
handle_t handle;
LLImageFormatted* image;
LLPointer<LLImageFormatted> image;
U32 priority;
S32 discard;
BOOL needs_aux;

View File

@@ -587,8 +587,8 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
{
gViewerWindow->playSnapshotAnimAndSound();
LLImageBase::setSizeOverride(TRUE);
LLPointer<LLImageFormatted> formatted;
formatted->enableOverSize();
switch(LLFloaterSnapshot::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat")))
{
case LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG:
@@ -602,12 +602,11 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
break;
default:
llwarns << "Unknown Local Snapshot format" << llendl;
LLImageBase::setSizeOverride(FALSE);
return true;
}
formatted->encode(raw, 0);
LLImageBase::setSizeOverride(FALSE);
formatted->disableOverSize();
gViewerWindow->saveImageNumbered(formatted);
}
return true;