aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llimagegl.cpp')
-rw-r--r--linden/indra/llrender/llimagegl.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index c4b90a7..92d8eb4 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -615,18 +615,25 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
615 S32 w = width, h = height; 615 S32 w = width, h = height;
616 const U8* prev_mip_data = 0; 616 const U8* prev_mip_data = 0;
617 const U8* cur_mip_data = 0; 617 const U8* cur_mip_data = 0;
618 S32 prev_mip_size = 0;
619 S32 cur_mip_size = 0;
618 for (int m=0; m<nummips; m++) 620 for (int m=0; m<nummips; m++)
619 { 621 {
620 if (m==0) 622 if (m==0)
621 { 623 {
622 cur_mip_data = data_in; 624 cur_mip_data = data_in;
625 cur_mip_size = width * height * mComponents;
623 } 626 }
624 else 627 else
625 { 628 {
626 S32 bytes = w * h * mComponents; 629 S32 bytes = w * h * mComponents;
630 llassert(prev_mip_data);
631 llassert(prev_mip_size == bytes);
627 U8* new_data = new U8[bytes]; 632 U8* new_data = new U8[bytes];
633 llassert_always(new_data);
628 LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents); 634 LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents);
629 cur_mip_data = new_data; 635 cur_mip_data = new_data;
636 cur_mip_size = bytes;
630 } 637 }
631 llassert(w > 0 && h > 0 && cur_mip_data); 638 llassert(w > 0 && h > 0 && cur_mip_data);
632 { 639 {
@@ -651,12 +658,14 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
651 delete[] prev_mip_data; 658 delete[] prev_mip_data;
652 } 659 }
653 prev_mip_data = cur_mip_data; 660 prev_mip_data = cur_mip_data;
661 prev_mip_size = cur_mip_size;
654 w >>= 1; 662 w >>= 1;
655 h >>= 1; 663 h >>= 1;
656 } 664 }
657 if (prev_mip_data && prev_mip_data != data_in) 665 if (prev_mip_data && prev_mip_data != data_in)
658 { 666 {
659 delete[] prev_mip_data; 667 delete[] prev_mip_data;
668 prev_mip_data = NULL;
660 } 669 }
661 } 670 }
662 } 671 }
@@ -1058,6 +1067,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1058 llerrs << llformat("LLImageGL::readBackRaw: bogus params: %d x %d x %d",width,height,ncomponents) << llendl; 1067 llerrs << llformat("LLImageGL::readBackRaw: bogus params: %d x %d x %d",width,height,ncomponents) << llendl;
1059 } 1068 }
1060 1069
1070 BOOL return_result = TRUE ;
1061 LLGLint is_compressed = 0; 1071 LLGLint is_compressed = 0;
1062 if (compressed_ok) 1072 if (compressed_ok)
1063 { 1073 {
@@ -1073,6 +1083,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1073 { 1083 {
1074 llwarns << "Error happens when reading back the compressed texture image." << llendl ; 1084 llwarns << "Error happens when reading back the compressed texture image." << llendl ;
1075 imageraw->deleteData() ; 1085 imageraw->deleteData() ;
1086 return_result = FALSE ;
1076 } 1087 }
1077 stop_glerror(); 1088 stop_glerror();
1078 } 1089 }
@@ -1084,11 +1095,12 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1084 { 1095 {
1085 llwarns << "Error happens when reading back the texture image." << llendl ; 1096 llwarns << "Error happens when reading back the texture image." << llendl ;
1086 imageraw->deleteData() ; 1097 imageraw->deleteData() ;
1098 return_result = FALSE ;
1087 } 1099 }
1088 stop_glerror(); 1100 stop_glerror();
1089 } 1101 }
1090 1102
1091 return TRUE; 1103 return return_result ;
1092} 1104}
1093 1105
1094void LLImageGL::destroyGLTexture() 1106void LLImageGL::destroyGLTexture()