[FIRE-35292] Fix for textures getting downscaled and compressed (J2C save fix)

Added fix for not reading enough LLImageJ2K data from the cache to save to file.
Issue is caused by hard coded data size of 999,999 used for the amount of data to read from the cache.
Used the LLImageJ2C::calcDataSizeJ2C to properly calculate the amount of data to read from the cache.
meow-7.2.2
minerjr 2025-03-26 12:14:10 -03:00
parent d26bf4cbd2
commit 9ccd8f107c
1 changed files with 9 additions and 1 deletions

View File

@ -505,7 +505,15 @@ void ColladaExportFloater::CacheReadResponder::saveTexturesWorker(void* data)
std::string name = gDirUtilp->getDirName(me->mFilename);
name += gDirUtilp->getDirDelimiter() + me->mTexturesToSave[id];
CacheReadResponder* responder = new CacheReadResponder(id, img, name, img_type);
LLAppViewer::getTextureCache()->readFromCache(id, 0, 999999, responder);
// <FS:minerjr> [FIRE-35292] Fix for textures getting downscaled and compressed
//LLAppViewer::getTextureCache()->readFromCache(id, 0, 999999, responder);
// The above line hard coded the size of data to read from the cached version of the texture as 999999,
// where now we will calcuate the correct value based upon the texture's full width, height and # of components (3=RGB, 4=RGBA) and
// the discard level (0)). There is a choice to change the rate, but we seem to use the value of 1/8 compression level
S32 texture_size = LLImageJ2C::calcDataSizeJ2C(imagep->getFullWidth(), imagep->getFullHeight(), imagep->getComponents(), 0);// , F32 rate) rate = const F32 DEFAULT_COMPRESSION_RATE = 1.f/8.f;
// Use calculated texture_size (from LLTextureFetch::createRequest see "else if (w*h*c > 0)" statement for more info)
LLAppViewer::getTextureCache()->readFromCache(id, 0, texture_size, responder);
// </FS:minerjr> [FIRE-35292]
me->mTexturesToSave.erase(id);
me->updateTitleProgress();
me->mTimer.reset();