From a207a71066f7943a5cf56085c3dc8bb904d11e42 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 22 Feb 2011 18:21:02 -0600 Subject: [PATCH] V2 llimage merge --- indra/llimage/llimage.cpp | 11 +++++------ indra/llimage/llimage.h | 13 ++++++------- indra/llimage/llimageworker.cpp | 17 ++++++++++++++--- indra/llimage/llimageworker.h | 4 +++- indra/newview/llviewermenufile.cpp | 5 ++--- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index c84fad8e1..6221b2b3d 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -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; } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 325c67807..7d45911bd 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -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 diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index 86d41515e..b9d44c6cb 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -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); diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index fcd3039b6..9a09f81bc 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -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 image; U32 priority; S32 discard; BOOL needs_aux; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 733b0411c..987c15d12 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -587,8 +587,8 @@ class LLFileTakeSnapshotToDisk : public view_listener_t { gViewerWindow->playSnapshotAnimAndSound(); - LLImageBase::setSizeOverride(TRUE); LLPointer 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;