aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llimage
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llimage
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to '')
-rw-r--r--linden/indra/llimage/llimage.cpp27
-rw-r--r--linden/indra/llimage/llimage.h6
-rw-r--r--linden/indra/llimagej2coj/llimagej2coj.cpp12
3 files changed, 29 insertions, 16 deletions
diff --git a/linden/indra/llimage/llimage.cpp b/linden/indra/llimage/llimage.cpp
index bcd9463..3600cce 100644
--- a/linden/indra/llimage/llimage.cpp
+++ b/linden/indra/llimage/llimage.cpp
@@ -43,6 +43,7 @@
43#if JPEG_SUPPORT 43#if JPEG_SUPPORT
44#include "llimagejpeg.h" 44#include "llimagejpeg.h"
45#endif 45#endif
46#include "llimagepng.h"
46#include "llimagedxt.h" 47#include "llimagedxt.h"
47 48
48//--------------------------------------------------------------------------- 49//---------------------------------------------------------------------------
@@ -490,8 +491,8 @@ void LLImageRaw::composite( LLImageRaw* src )
490{ 491{
491 LLImageRaw* dst = this; // Just for clarity. 492 LLImageRaw* dst = this; // Just for clarity.
492 493
493 llassert( (3 == src->getComponents()) || (4 == src->getComponents()) ); 494 llassert(3 == src->getComponents());
494 llassert( (3 == dst->getComponents()) || (4 == dst->getComponents()) ); 495 llassert(3 == dst->getComponents());
495 496
496 if( 3 == dst->getComponents() ) 497 if( 3 == dst->getComponents() )
497 { 498 {
@@ -519,11 +520,6 @@ void LLImageRaw::composite( LLImageRaw* src )
519 } 520 }
520 } 521 }
521 } 522 }
522 else
523 {
524 // 4 == dst->mComponents
525 llassert(0); // not implemented yet.
526 }
527} 523}
528 524
529// Src and dst can be any size. Src has 4 components. Dst has 3 components. 525// Src and dst can be any size. Src has 4 components. Dst has 3 components.
@@ -689,7 +685,7 @@ void LLImageRaw::copyUnscaled(LLImageRaw* src)
689{ 685{
690 LLImageRaw* dst = this; // Just for clarity. 686 LLImageRaw* dst = this; // Just for clarity.
691 687
692 llassert( (3 == src->getComponents()) || (4 == src->getComponents()) ); 688 llassert( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
693 llassert( src->getComponents() == dst->getComponents() ); 689 llassert( src->getComponents() == dst->getComponents() );
694 llassert( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) ); 690 llassert( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) );
695 691
@@ -772,7 +768,7 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
772 LLMemType mt1((LLMemType::EMemType)mMemType); 768 LLMemType mt1((LLMemType::EMemType)mMemType);
773 LLImageRaw* dst = this; // Just for clarity. 769 LLImageRaw* dst = this; // Just for clarity.
774 770
775 llassert( (3 == src->getComponents()) || (4 == src->getComponents()) ); 771 llassert( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
776 llassert( src->getComponents() == dst->getComponents() ); 772 llassert( src->getComponents() == dst->getComponents() );
777 773
778 if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) ) 774 if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) )
@@ -803,7 +799,7 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
803void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) 799void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
804{ 800{
805 LLMemType mt1((LLMemType::EMemType)mMemType); 801 LLMemType mt1((LLMemType::EMemType)mMemType);
806 llassert( (3 == getComponents()) || (4 == getComponents()) ); 802 llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) );
807 803
808 S32 old_width = getWidth(); 804 S32 old_width = getWidth();
809 S32 old_height = getHeight(); 805 S32 old_height = getHeight();
@@ -1093,7 +1089,7 @@ void LLImageRaw::compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S3
1093static struct 1089static struct
1094{ 1090{
1095 const char* exten; 1091 const char* exten;
1096 S8 codec; 1092 EImageCodec codec;
1097} 1093}
1098file_extensions[] = 1094file_extensions[] =
1099{ 1095{
@@ -1128,7 +1124,7 @@ static LLString find_file(LLString &name, S8 *codec)
1128 return LLString(""); 1124 return LLString("");
1129} 1125}
1130 1126
1131static S8 get_codec(const LLString& exten) 1127EImageCodec LLImageBase::getCodecFromExtension(const LLString& exten)
1132{ 1128{
1133 for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) 1129 for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++)
1134 { 1130 {
@@ -1151,7 +1147,7 @@ bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_on
1151 { 1147 {
1152 exten = name.substr(dotidx+1); 1148 exten = name.substr(dotidx+1);
1153 LLString::toLower(exten); 1149 LLString::toLower(exten);
1154 codec = get_codec(exten); 1150 codec = getCodecFromExtension(exten);
1155 } 1151 }
1156 else 1152 else
1157 { 1153 {
@@ -1294,6 +1290,9 @@ LLImageFormatted* LLImageFormatted::createFromType(S8 codec)
1294 case IMG_CODEC_DXT: 1290 case IMG_CODEC_DXT:
1295 image = new LLImageDXT(); 1291 image = new LLImageDXT();
1296 break; 1292 break;
1293 case IMG_CODEC_PNG:
1294 image = new LLImagePNG();
1295 break;
1297 default: 1296 default:
1298 image = NULL; 1297 image = NULL;
1299 break; 1298 break;
@@ -1314,7 +1313,7 @@ LLImageFormatted* LLImageFormatted::createFromExtension(const LLString& instring
1314 { 1313 {
1315 exten = instring; 1314 exten = instring;
1316 } 1315 }
1317 S8 codec = get_codec(exten); 1316 S8 codec = getCodecFromExtension(exten);
1318 return createFromType(codec); 1317 return createFromType(codec);
1319} 1318}
1320//---------------------------------------------------------------------------- 1319//----------------------------------------------------------------------------
diff --git a/linden/indra/llimage/llimage.h b/linden/indra/llimage/llimage.h
index 199dc07..0393d13 100644
--- a/linden/indra/llimage/llimage.h
+++ b/linden/indra/llimage/llimage.h
@@ -60,7 +60,7 @@ class LLImageFormatted;
60class LLImageRaw; 60class LLImageRaw;
61class LLColor4U; 61class LLColor4U;
62 62
63enum 63typedef enum e_image_codec
64{ 64{
65 IMG_CODEC_INVALID = 0, 65 IMG_CODEC_INVALID = 0,
66 IMG_CODEC_RGB = 1, 66 IMG_CODEC_RGB = 1,
@@ -71,7 +71,7 @@ enum
71 IMG_CODEC_DXT = 6, 71 IMG_CODEC_DXT = 6,
72 IMG_CODEC_PNG = 7, 72 IMG_CODEC_PNG = 7,
73 IMG_CODEC_EOF = 8 73 IMG_CODEC_EOF = 8
74}; 74} EImageCodec;
75 75
76//============================================================================ 76//============================================================================
77 77
@@ -125,6 +125,8 @@ public:
125 125
126 static void setSizeOverride(BOOL enabled) { sSizeOverride = enabled; } 126 static void setSizeOverride(BOOL enabled) { sSizeOverride = enabled; }
127 127
128 static EImageCodec getCodecFromExtension(const LLString& exten);
129
128private: 130private:
129 U8 *mData; 131 U8 *mData;
130 S32 mDataSize; 132 S32 mDataSize;
diff --git a/linden/indra/llimagej2coj/llimagej2coj.cpp b/linden/indra/llimagej2coj/llimagej2coj.cpp
index 3ca271c..01868fd 100644
--- a/linden/indra/llimagej2coj/llimagej2coj.cpp
+++ b/linden/indra/llimagej2coj/llimagej2coj.cpp
@@ -158,6 +158,18 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
158 return TRUE; // done 158 return TRUE; // done
159 } 159 }
160 160
161 // sometimes we get bad data out of the cache - check to see if the decode succeeded
162 for (S32 i = 0; i < image->numcomps; i++)
163 {
164 if (image->comps[i].factor != base.getRawDiscardLevel())
165 {
166 // if we didn't get the discard level we're expecting, fail
167 opj_image_destroy(image);
168 base.mDecoding = FALSE;
169 return TRUE;
170 }
171 }
172
161 // Copy image data into our raw image format (instead of the separate channel format 173 // Copy image data into our raw image format (instead of the separate channel format
162 174
163 S32 img_components = image->numcomps; 175 S32 img_components = image->numcomps;