From 88e0c2b00ba3dc2c94326f76a88682d346a295a4 Mon Sep 17 00:00:00 2001 From: phr0z3nt04st Date: Sat, 3 Jul 2010 21:20:36 -0500 Subject: [PATCH] Finnally fixed windows comments --- indra/llimage/llimage.h | 1 - indra/llimage/llimagej2c.cpp | 7 +-- indra/llimage/llimagemetadatareader.cpp | 6 +-- indra/newview/llfloaterexport.cpp | 10 ++-- indra/newview/llviewerimage.cpp | 71 ++++++++++++++++++++++++- 5 files changed, 77 insertions(+), 18 deletions(-) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 00db811c8..325c67807 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -156,7 +156,6 @@ private: public: S16 mMemType; // debug - std::string decodedImageComment; //lol comment decoding haha static BOOL sSizeOverride; }; diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 07e6eb5b6..6c1d67329 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -36,9 +36,7 @@ #include "lldir.h" #include "llimagej2c.h" #include "llmemtype.h" -// -#include "llimagemetadatareader.h" -// + typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)(); typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*); typedef const char* (*EngineInfoLLImageJ2CFunction)(); @@ -299,9 +297,6 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir // Update the raw discard level updateRawDiscardLevel(); mDecoding = TRUE; - // - raw_imagep->decodedImageComment = LLImageMetaDataReader::ExtractEncodedComment(getData(),getDataSize()); - // res = mImpl->decodeImpl(*this, *raw_imagep, decode_time, first_channel, max_channel_count); } diff --git a/indra/llimage/llimagemetadatareader.cpp b/indra/llimage/llimagemetadatareader.cpp index bf2c64c90..bfdd529a0 100644 --- a/indra/llimage/llimagemetadatareader.cpp +++ b/indra/llimage/llimagemetadatareader.cpp @@ -73,10 +73,10 @@ std::vector LLJ2cParser::GetNextComment() //static std::string LLImageMetaDataReader::ExtractEncodedComment(U8* data,int data_size) { - LLJ2cParser* parser = new LLJ2cParser(data,data_size); + LLJ2cParser parser = LLJ2cParser(data,data_size); while(1) { - std::vector comment = parser->GetNextComment(); + std::vector comment = parser.GetNextComment(); if (comment.empty()) break; //exit loop if (comment[1] == 0x00 && comment.size() == 130) { @@ -118,12 +118,10 @@ std::string LLImageMetaDataReader::ExtractEncodedComment(U8* data,int data_size) if(i < 4) break; std::string result(payload.begin()+4,payload.begin()+i); //llinfos << "FOUND COMMENT: " << result << llendl; - delete parser; return result; } } //end of loop - delete parser; return ""; } // diff --git a/indra/newview/llfloaterexport.cpp b/indra/newview/llfloaterexport.cpp index 8042f4c54..f131846a5 100644 --- a/indra/newview/llfloaterexport.cpp +++ b/indra/newview/llfloaterexport.cpp @@ -27,10 +27,11 @@ std::vector LLFloaterExport::instances; class CacheReadResponder : public LLTextureCache::ReadResponder { public: -CacheReadResponder(const LLUUID& id, LLImageFormatted* image,const std::string& filename) -: mFormattedImage(image), mID(id) +CacheReadResponder(const LLUUID& id, const std::string& filename) +: mID(id) { - setImage(image); + mFormattedImage = new LLImageJ2C; + setImage(mFormattedImage); mFilename = filename; } void setData(U8* data, S32 datasize, S32 imagesize, S32 imageformat, BOOL imagelocal) @@ -738,8 +739,7 @@ void LLFloaterExport::onClickSaveAs(void* user_data) LLViewerImage* img = gImageList.getImage(textures.front(), MIPMAP_TRUE, FALSE); img->setBoostLevel(LLViewerImageBoostLevel::BOOST_MAX_LEVEL); - LLImageJ2C * mFormattedImage = new LLImageJ2C; - CacheReadResponder* responder = new CacheReadResponder(textures.front(), mFormattedImage,std::string(path + textures.front().asString() + ".j2c")); + CacheReadResponder* responder = new CacheReadResponder(textures.front(), std::string(path + textures.front().asString() + ".j2c")); LLAppViewer::getTextureCache()->readFromCache(textures.front(),LLWorkerThread::PRIORITY_HIGH,0,999999,responder); textures.pop_front(); } diff --git a/indra/newview/llviewerimage.cpp b/indra/newview/llviewerimage.cpp index 6500351ec..cb825a5fe 100644 --- a/indra/newview/llviewerimage.cpp +++ b/indra/newview/llviewerimage.cpp @@ -61,6 +61,11 @@ #include "llappviewer.h" #include "llface.h" #include "llviewercamera.h" + +// +#include "llimagemetadatareader.h" +#include "lltexturecache.h" +// /////////////////////////////////////////////////////////////////////////////// // statics @@ -96,6 +101,63 @@ BOOL LLViewerImage::sFreezeImageScalingDown = FALSE ; //debug use S32 LLViewerImage::sLLViewerImageCount = 0 ; +// +class CommentCacheReadResponder : public LLTextureCache::ReadResponder +{ +public: +CommentCacheReadResponder(LLPointer image) +: mViewerImage(image) +{ + mID = image->getID(); + mFormattedImage = new LLImageJ2C; + setImage(mFormattedImage); +} +void setData(U8* data, S32 datasize, S32 imagesize, S32 imageformat, BOOL imagelocal) +{ + if(imageformat==IMG_CODEC_TGA && mFormattedImage->getCodec()==IMG_CODEC_J2C) + { + //llwarns<<"Bleh its a tga not saving"<getCodec() == imageformat); + mFormattedImage->appendData(data, datasize); + } + else + { + mFormattedImage = LLImageFormatted::createFromType(imageformat); + mFormattedImage->setData(data,datasize); + } + mImageSize = imagesize; + mImageLocal = imagelocal; +} + +virtual void completed(bool success) +{ + if(success && (mFormattedImage.notNull()) && mImageSize>0 && mViewerImage.notNull()) + { + + //llinfos << "SUCCESS getting texture "<decodedComment = LLImageMetaDataReader::ExtractEncodedComment(mFormattedImage->getData(),mFormattedImage->getDataSize()); + + } + else + { + if(!success) + llwarns << "FAIL NOT SUCCESSFUL getting texture "< mFormattedImage; + LLPointer mViewerImage; + LLUUID mID; +}; +// + // static void LLViewerImage::initClass() { @@ -523,7 +585,7 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; - decodedComment = mRawImage->decodedImageComment; + if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) { llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; @@ -546,7 +608,12 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/) destroyRawImage(); return FALSE; } - + + // + CommentCacheReadResponder* responder = new CommentCacheReadResponder(this); + LLAppViewer::getTextureCache()->readFromCache(getID(),LLWorkerThread::PRIORITY_HIGH,0,999999,responder); + // + res = LLImageGL::createGLTexture(mRawDiscardLevel, mRawImage, usename); }