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), mWidth(0),
mHeight(0), mHeight(0),
mComponents(0), mComponents(0),
mBadBufferAllocation(false),
mAllowOverSize(false),
mMemType(LLMemType::MTYPE_IMAGEBASE) mMemType(LLMemType::MTYPE_IMAGEBASE)
{ {
mBadBufferAllocation = FALSE ;
} }
// virtual // virtual
@@ -134,8 +135,6 @@ void LLImageBase::sanityCheck()
} }
} }
BOOL LLImageBase::sSizeOverride = FALSE;
// virtual // virtual
void LLImageBase::deleteData() 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; 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; llerrs << "LLImageBase::allocateData: bad size: " << size << llendl;
} }
@@ -220,7 +219,7 @@ U8* LLImageBase::getData()
return mData; return mData;
} }
BOOL LLImageBase::isBufferInvalid() bool LLImageBase::isBufferInvalid()
{ {
return mBadBufferAllocation || mData == NULL ; return mBadBufferAllocation || mData == NULL ;
} }
@@ -1287,7 +1286,7 @@ LLImageFormatted::LLImageFormatted(S8 codec)
mCodec(codec), mCodec(codec),
mDecoding(0), mDecoding(0),
mDecoded(0), mDecoded(0),
mDiscardLevel(0) mDiscardLevel(-1)
{ {
mMemType = LLMemType::MTYPE_IMAGEFORMATTED; mMemType = LLMemType::MTYPE_IMAGEFORMATTED;
} }

View File

@@ -123,14 +123,16 @@ public:
const U8 *getData() const ; const U8 *getData() const ;
U8 *getData() ; U8 *getData() ;
BOOL isBufferInvalid() ; bool isBufferInvalid() ;
void setSize(S32 width, S32 height, S32 ncomponents); void setSize(S32 width, S32 height, S32 ncomponents);
U8* allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 size = -1); // setSize() + allocateData() U8* allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 size = -1); // setSize() + allocateData()
void enableOverSize() {mAllowOverSize = true ;}
void disableOverSize() {mAllowOverSize = false; }
protected: protected:
// special accessor to allow direct setting of mData and mDataSize by LLImageFormatted // 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: public:
static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels); 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. // <= 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 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); static EImageCodec getCodecFromExtension(const std::string& exten);
private: private:
@@ -152,11 +152,10 @@ private:
S8 mComponents; S8 mComponents;
BOOL mBadBufferAllocation ; bool mBadBufferAllocation ;
bool mAllowOverSize ;
public: public:
S16 mMemType; // debug S16 mMemType; // debug
static BOOL sSizeOverride;
}; };
// Raw representation of an image (used for textures, and other uncompressed formats // 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()); mCreationMutex = new LLMutex(getAPRPool());
} }
//virtual
LLImageDecodeThread::~LLImageDecodeThread()
{
delete mCreationMutex ;
}
// MAIN THREAD // MAIN THREAD
// virtual // virtual
S32 LLImageDecodeThread::update(U32 max_time_ms) S32 LLImageDecodeThread::update(U32 max_time_ms)
@@ -54,9 +60,14 @@ S32 LLImageDecodeThread::update(U32 max_time_ms)
{ {
creation_info& info = *iter; creation_info& info = *iter;
ImageRequest* req = new ImageRequest(info.handle, info.image, ImageRequest* req = new ImageRequest(info.handle, info.image,
info.priority, info.discard, info.needs_aux, info.priority, info.discard, info.needs_aux,
info.responder); info.responder);
addRequest(req);
bool res = addRequest(req);
if (!res)
{
llerrs << "request added after LLLFSThread::cleanupClass()" << llendl;
}
} }
mCreationList.clear(); mCreationList.clear();
S32 res = LLQueuedThread::update(max_time_ms); S32 res = LLQueuedThread::update(max_time_ms);

View File

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

View File

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