aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltexlayer.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/lltexlayer.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltexlayer.cpp181
1 files changed, 104 insertions, 77 deletions
diff --git a/linden/indra/newview/lltexlayer.cpp b/linden/indra/newview/lltexlayer.cpp
index 0944d4b..eea4acf 100644
--- a/linden/indra/newview/lltexlayer.cpp
+++ b/linden/indra/newview/lltexlayer.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -46,6 +47,7 @@
46#include "llvfile.h" 47#include "llvfile.h"
47#include "llviewerimagelist.h" 48#include "llviewerimagelist.h"
48#include "llviewerimagelist.h" 49#include "llviewerimagelist.h"
50#include "llviewerregion.h"
49#include "llviewerstats.h" 51#include "llviewerstats.h"
50#include "llviewerwindow.h" 52#include "llviewerwindow.h"
51#include "llvoavatar.h" 53#include "llvoavatar.h"
@@ -53,12 +55,11 @@
53#include "pipeline.h" 55#include "pipeline.h"
54#include "v4coloru.h" 56#include "v4coloru.h"
55#include "llrender.h" 57#include "llrender.h"
58#include "llassetuploadresponders.h"
56 59
57//#include "../tools/imdebug/imdebug.h" 60//#include "../tools/imdebug/imdebug.h"
58 61
59 62using namespace LLVOAvatarDefines;
60// SJB: We really always want to use the GL cache;
61// let GL page textures in and out of video RAM instead of trying to do so by hand.
62 63
63// static 64// static
64S32 LLTexLayerSetBuffer::sGLByteCount = 0; 65S32 LLTexLayerSetBuffer::sGLByteCount = 0;
@@ -67,11 +68,12 @@ S32 LLTexLayerSetBuffer::sGLBumpByteCount = 0;
67//----------------------------------------------------------------------------- 68//-----------------------------------------------------------------------------
68// LLBakedUploadData() 69// LLBakedUploadData()
69//----------------------------------------------------------------------------- 70//-----------------------------------------------------------------------------
70LLBakedUploadData::LLBakedUploadData( LLVOAvatar* avatar, LLTexLayerSetBuffer* layerset_buffer ) : 71LLBakedUploadData::LLBakedUploadData( LLVOAvatar* avatar, LLTexLayerSetBuffer* layerset_buffer, const LLUUID & id ) :
71 mAvatar( avatar ), 72 mAvatar( avatar ),
72 mLayerSetBuffer( layerset_buffer ) 73 mLayerSetBuffer( layerset_buffer ),
74 mID(id)
73{ 75{
74 mID.generate(); 76 mStartTime = LLFrameTimer::getTotalTime(); // Record starting time
75 for( S32 i = 0; i < WT_COUNT; i++ ) 77 for( S32 i = 0; i < WT_COUNT; i++ )
76 { 78 {
77 LLWearable* wearable = gAgent.getWearable( (EWearableType)i); 79 LLWearable* wearable = gAgent.getWearable( (EWearableType)i);
@@ -150,10 +152,9 @@ void LLTexLayerSetBuffer::createBumpTexture()
150 152
151 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); 153 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
152 154
153 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 155 gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
154 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
155 156
156 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 157 LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RGBA8, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
157 stop_glerror(); 158 stop_glerror();
158 159
159 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 160 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
@@ -225,7 +226,7 @@ BOOL LLTexLayerSetBuffer::needsRender()
225 BOOL needs_update = gAgent.mNumPendingQueries == 0 && (mNeedsUpdate || upload_now) && !avatar->mAppearanceAnimating; 226 BOOL needs_update = gAgent.mNumPendingQueries == 0 && (mNeedsUpdate || upload_now) && !avatar->mAppearanceAnimating;
226 if (needs_update) 227 if (needs_update)
227 { 228 {
228 BOOL invalid_skirt = avatar->getBakedTE(mTexLayerSet) == LLVOAvatar::TEX_SKIRT_BAKED && !avatar->isWearingWearableType(WT_SKIRT); 229 BOOL invalid_skirt = avatar->getBakedTE(mTexLayerSet) == TEX_SKIRT_BAKED && !avatar->isWearingWearableType(WT_SKIRT);
229 if (invalid_skirt) 230 if (invalid_skirt)
230 { 231 {
231 // we were trying to create a skirt texture 232 // we were trying to create a skirt texture
@@ -397,7 +398,7 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
397 baked_image_data[5*i + 0] = baked_color_data[4*i + 0]; 398 baked_image_data[5*i + 0] = baked_color_data[4*i + 0];
398 baked_image_data[5*i + 1] = baked_color_data[4*i + 1]; 399 baked_image_data[5*i + 1] = baked_color_data[4*i + 1];
399 baked_image_data[5*i + 2] = baked_color_data[4*i + 2]; 400 baked_image_data[5*i + 2] = baked_color_data[4*i + 2];
400 baked_image_data[5*i + 3] = baked_color_data[4*i + 3] < 255 ? baked_color_data[4*i + 3] : baked_bump_data[4*i]; 401 baked_image_data[5*i + 3] = baked_color_data[4*i + 3]; // alpha should be correct for eyelashes.
401 baked_image_data[5*i + 4] = baked_mask_data[i]; 402 baked_image_data[5*i + 4] = baked_mask_data[i];
402 i++; 403 i++;
403 } 404 }
@@ -413,7 +414,7 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
413 baked_image_data[5*i + 0] = baked_color_data[4*i + 0]; 414 baked_image_data[5*i + 0] = baked_color_data[4*i + 0];
414 baked_image_data[5*i + 1] = baked_color_data[4*i + 1]; 415 baked_image_data[5*i + 1] = baked_color_data[4*i + 1];
415 baked_image_data[5*i + 2] = baked_color_data[4*i + 2]; 416 baked_image_data[5*i + 2] = baked_color_data[4*i + 2];
416 baked_image_data[5*i + 3] = baked_bump_data[4*i]; 417 baked_image_data[5*i + 3] = 255; // reserve for alpha
417 baked_image_data[5*i + 4] = baked_mask_data[i]; 418 baked_image_data[5*i + 4] = baked_mask_data[i];
418 i++; 419 i++;
419 } 420 }
@@ -422,7 +423,7 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
422 } 423 }
423 else 424 else
424 { 425 {
425 if (mTexLayerSet->getBodyRegion() == "skirt") 426 if (mTexLayerSet->getBodyRegion() == "skirt" || mTexLayerSet->getBodyRegion() == "hair")
426 { 427 {
427 S32 i = 0; 428 S32 i = 0;
428 for( S32 u = 0; u < mWidth; u++ ) 429 for( S32 u = 0; u < mWidth; u++ )
@@ -447,7 +448,7 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
447 baked_image_data[4*i + 0] = baked_color_data[4*i + 0]; 448 baked_image_data[4*i + 0] = baked_color_data[4*i + 0];
448 baked_image_data[4*i + 1] = baked_color_data[4*i + 1]; 449 baked_image_data[4*i + 1] = baked_color_data[4*i + 1];
449 baked_image_data[4*i + 2] = baked_color_data[4*i + 2]; 450 baked_image_data[4*i + 2] = baked_color_data[4*i + 2];
450 baked_image_data[4*i + 3] = baked_mask_data[i]; 451 baked_image_data[4*i + 3] = 255; // eyes should have no mask - reserve for alpha
451 i++; 452 i++;
452 } 453 }
453 } 454 }
@@ -483,16 +484,34 @@ void LLTexLayerSetBuffer::readBackAndUpload(U8* baked_bump_data)
483 484
484 if( valid ) 485 if( valid )
485 { 486 {
486 LLBakedUploadData* baked_upload_data = new LLBakedUploadData( gAgent.getAvatarObject(), this ); 487 // baked_upload_data is owned by the responder and deleted after the request completes
487 mUploadID = baked_upload_data->mID; 488 LLBakedUploadData* baked_upload_data = new LLBakedUploadData( gAgent.getAvatarObject(), this, asset_id );
488 489 mUploadID = asset_id;
489 gAssetStorage->storeAssetData(tid, 490
490 LLAssetType::AT_TEXTURE, 491 // upload the image
491 LLTexLayerSetBuffer::onTextureUploadComplete, 492 std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture");
492 baked_upload_data, 493
493 TRUE, // temp_file 494 if(!url.empty()
494 FALSE, // is_priority 495 && !LLPipeline::sForceOldBakedUpload) // Toggle the debug setting UploadBakedTexOld to change between the new caps method and old method
495 TRUE); // store_local 496 {
497 llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl;
498
499 LLSD body = LLSD::emptyMap();
500 LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
501 // Responder will call LLTexLayerSetBuffer::onTextureUploadComplete()
502 }
503 else
504 {
505 llinfos << "Baked texture upload via Asset Store." << llendl;
506 // gAssetStorage->storeAssetData(mTransactionID, LLAssetType::AT_IMAGE_JPEG, &uploadCallback, (void *)this, FALSE);
507 gAssetStorage->storeAssetData(tid,
508 LLAssetType::AT_TEXTURE,
509 LLTexLayerSetBuffer::onTextureUploadComplete,
510 baked_upload_data,
511 TRUE, // temp_file
512 TRUE, // is_priority
513 TRUE); // store_local
514 }
496 515
497 mNeedsUpload = FALSE; 516 mNeedsUpload = FALSE;
498 } 517 }
@@ -545,15 +564,10 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, void* user
545 564
546 if( result >= 0 ) 565 if( result >= 0 )
547 { 566 {
548 LLVOAvatar::ETextureIndex baked_te = avatar->getBakedTE( layerset_buffer->mTexLayerSet ); 567 ETextureIndex baked_te = avatar->getBakedTE( layerset_buffer->mTexLayerSet );
549 if( !gAgent.cameraCustomizeAvatar() ) 568 U64 now = LLFrameTimer::getTotalTime(); // Record starting time
550 { 569 llinfos << "Baked texture upload took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl;
551 avatar->setNewBakedTexture( baked_te, uuid ); 570 avatar->setNewBakedTexture( baked_te, uuid );
552 }
553 else
554 {
555 llinfos << "LLTexLayerSetBuffer::onTextureUploadComplete() when in Customize Avatar" << llendl;
556 }
557 } 571 }
558 else 572 else
559 { 573 {
@@ -804,6 +818,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
804 { 818 {
805 LLGLSUIDefault gls_ui; 819 LLGLSUIDefault gls_ui;
806 gGL.getTexUnit(0)->bind(image_gl); 820 gGL.getTexUnit(0)->bind(image_gl);
821 gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE );
807 gl_rect_2d_simple_tex( width, height ); 822 gl_rect_2d_simple_tex( width, height );
808 } 823 }
809 else 824 else
@@ -811,9 +826,10 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
811 success = FALSE; 826 success = FALSE;
812 } 827 }
813 } 828 }
829 gGL.flush();
814 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 830 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
815 831
816 gGL.flush(); 832 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
817 gGL.setColorMask(true, true); 833 gGL.setColorMask(true, true);
818 gGL.setSceneBlendType(LLRender::BT_ALPHA); 834 gGL.setSceneBlendType(LLRender::BT_ALPHA);
819 } 835 }
@@ -899,7 +915,7 @@ void LLTexLayerSet::createComposite()
899 S32 width = mInfo->mWidth; 915 S32 width = mInfo->mWidth;
900 S32 height = mInfo->mHeight; 916 S32 height = mInfo->mHeight;
901 // Composite other avatars at reduced resolution 917 // Composite other avatars at reduced resolution
902 if( !mAvatar->mIsSelf ) 918 if( !mAvatar->isSelf() )
903 { 919 {
904 width /= 2; 920 width /= 2;
905 height /= 2; 921 height /= 2;
@@ -1053,59 +1069,63 @@ BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node)
1053 1069
1054 if( "upper_shirt" == local_texture ) 1070 if( "upper_shirt" == local_texture )
1055 { 1071 {
1056 mLocalTexture = LLVOAvatar::LOCTEX_UPPER_SHIRT; 1072 mLocalTexture = TEX_UPPER_SHIRT;
1057 } 1073 }
1058 else if( "upper_bodypaint" == local_texture ) 1074 else if( "upper_bodypaint" == local_texture )
1059 { 1075 {
1060 mLocalTexture = LLVOAvatar::LOCTEX_UPPER_BODYPAINT; 1076 mLocalTexture = TEX_UPPER_BODYPAINT;
1061 } 1077 }
1062 else if( "lower_pants" == local_texture ) 1078 else if( "lower_pants" == local_texture )
1063 { 1079 {
1064 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_PANTS; 1080 mLocalTexture = TEX_LOWER_PANTS;
1065 } 1081 }
1066 else if( "lower_bodypaint" == local_texture ) 1082 else if( "lower_bodypaint" == local_texture )
1067 { 1083 {
1068 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_BODYPAINT; 1084 mLocalTexture = TEX_LOWER_BODYPAINT;
1069 } 1085 }
1070 else if( "lower_shoes" == local_texture ) 1086 else if( "lower_shoes" == local_texture )
1071 { 1087 {
1072 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_SHOES; 1088 mLocalTexture = TEX_LOWER_SHOES;
1073 } 1089 }
1074 else if( "head_bodypaint" == local_texture ) 1090 else if( "head_bodypaint" == local_texture )
1075 { 1091 {
1076 mLocalTexture = LLVOAvatar::LOCTEX_HEAD_BODYPAINT; 1092 mLocalTexture = TEX_HEAD_BODYPAINT;
1077 } 1093 }
1078 else if( "lower_socks" == local_texture ) 1094 else if( "lower_socks" == local_texture )
1079 { 1095 {
1080 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_SOCKS; 1096 mLocalTexture = TEX_LOWER_SOCKS;
1081 } 1097 }
1082 else if( "upper_jacket" == local_texture ) 1098 else if( "upper_jacket" == local_texture )
1083 { 1099 {
1084 mLocalTexture = LLVOAvatar::LOCTEX_UPPER_JACKET; 1100 mLocalTexture = TEX_UPPER_JACKET;
1085 } 1101 }
1086 else if( "lower_jacket" == local_texture ) 1102 else if( "lower_jacket" == local_texture )
1087 { 1103 {
1088 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_JACKET; 1104 mLocalTexture = TEX_LOWER_JACKET;
1089 } 1105 }
1090 else if( "upper_gloves" == local_texture ) 1106 else if( "upper_gloves" == local_texture )
1091 { 1107 {
1092 mLocalTexture = LLVOAvatar::LOCTEX_UPPER_GLOVES; 1108 mLocalTexture = TEX_UPPER_GLOVES;
1093 } 1109 }
1094 else if( "upper_undershirt" == local_texture ) 1110 else if( "upper_undershirt" == local_texture )
1095 { 1111 {
1096 mLocalTexture = LLVOAvatar::LOCTEX_UPPER_UNDERSHIRT; 1112 mLocalTexture = TEX_UPPER_UNDERSHIRT;
1097 } 1113 }
1098 else if( "lower_underpants" == local_texture ) 1114 else if( "lower_underpants" == local_texture )
1099 { 1115 {
1100 mLocalTexture = LLVOAvatar::LOCTEX_LOWER_UNDERPANTS; 1116 mLocalTexture = TEX_LOWER_UNDERPANTS;
1101 } 1117 }
1102 else if( "eyes_iris" == local_texture ) 1118 else if( "eyes_iris" == local_texture )
1103 { 1119 {
1104 mLocalTexture = LLVOAvatar::LOCTEX_EYES_IRIS; 1120 mLocalTexture = TEX_EYES_IRIS;
1105 } 1121 }
1106 else if( "skirt" == local_texture ) 1122 else if( "skirt" == local_texture )
1107 { 1123 {
1108 mLocalTexture = LLVOAvatar::LOCTEX_SKIRT; 1124 mLocalTexture = TEX_SKIRT;
1125 }
1126 else if( "hair_grain" == local_texture )
1127 {
1128 mLocalTexture = TEX_HAIR;
1109 } 1129 }
1110 else 1130 else
1111 { 1131 {
@@ -1316,6 +1336,12 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height )
1316 LLColor4 net_color; 1336 LLColor4 net_color;
1317 color_specified = findNetColor( &net_color ); 1337 color_specified = findNetColor( &net_color );
1318 1338
1339 if (mTexLayerSet->getAvatar()->mIsDummy)
1340 {
1341 color_specified = true;
1342 net_color = LLVOAvatar::getDummyColor();
1343 }
1344
1319 // If you can't see the layer, don't render it. 1345 // If you can't see the layer, don't render it.
1320 if( is_approx_zero( net_color.mV[VW] ) ) 1346 if( is_approx_zero( net_color.mV[VW] ) )
1321 { 1347 {
@@ -1368,21 +1394,20 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height )
1368 { 1394 {
1369 { 1395 {
1370 LLImageGL* image_gl = NULL; 1396 LLImageGL* image_gl = NULL;
1371 if( mTexLayerSet->getAvatar()->getLocalTextureGL( getInfo()->mLocalTexture, &image_gl ) ) 1397 if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) )
1372 { 1398 {
1373 if( image_gl ) 1399 if( image_gl )
1374 { 1400 {
1375 LLGLDisable alpha_test(getInfo()->mWriteAllChannels ? GL_ALPHA_TEST : 0); 1401 LLGLDisable alpha_test(getInfo()->mWriteAllChannels ? GL_ALPHA_TEST : 0);
1376 1402
1377 BOOL old_clamps = image_gl->getClampS(); 1403 LLTexUnit::eTextureAddressMode old_mode = image_gl->getAddressMode();
1378 BOOL old_clampt = image_gl->getClampT();
1379 1404
1380 gGL.getTexUnit(0)->bind(image_gl); 1405 gGL.getTexUnit(0)->bind(image_gl);
1381 image_gl->setClamp(TRUE, TRUE); 1406 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
1382 1407
1383 gl_rect_2d_simple_tex( width, height ); 1408 gl_rect_2d_simple_tex( width, height );
1384 1409
1385 image_gl->setClamp(old_clamps, old_clampt); 1410 gGL.getTexUnit(0)->setTextureAddressMode(old_mode);
1386 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 1411 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1387 } 1412 }
1388 } 1413 }
@@ -1439,7 +1464,7 @@ BOOL LLTexLayer::render( S32 x, S32 y, S32 width, S32 height )
1439U8* LLTexLayer::getAlphaData() 1464U8* LLTexLayer::getAlphaData()
1440{ 1465{
1441 LLCRC alpha_mask_crc; 1466 LLCRC alpha_mask_crc;
1442 const LLUUID& uuid = mTexLayerSet->getAvatar()->getLocalTextureID(getInfo()->mLocalTexture); 1467 const LLUUID& uuid = mTexLayerSet->getAvatar()->getLocalTextureID((ETextureIndex)getInfo()->mLocalTexture);
1443 alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); 1468 alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES);
1444 1469
1445 for( alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++ ) 1470 for( alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++ )
@@ -1568,20 +1593,20 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4
1568 { 1593 {
1569 { 1594 {
1570 LLImageGL* image_gl = NULL; 1595 LLImageGL* image_gl = NULL;
1571 if( mTexLayerSet->getAvatar()->getLocalTextureGL( getInfo()->mLocalTexture, &image_gl ) ) 1596 if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) )
1572 { 1597 {
1573 if( image_gl && (image_gl->getComponents() == 4) ) 1598 if( image_gl && (image_gl->getComponents() == 4) )
1574 { 1599 {
1575 LLGLSNoAlphaTest gls_no_alpha_test; 1600 LLGLSNoAlphaTest gls_no_alpha_test;
1576 1601
1577 BOOL old_clamps = image_gl->getClampS(); 1602 LLTexUnit::eTextureAddressMode old_mode = image_gl->getAddressMode();
1578 BOOL old_clampt = image_gl->getClampT(); 1603
1579 gGL.getTexUnit(0)->bind(image_gl); 1604 gGL.getTexUnit(0)->bind(image_gl);
1580 image_gl->setClamp(TRUE, TRUE); 1605 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
1581 1606
1582 gl_rect_2d_simple_tex( width, height ); 1607 gl_rect_2d_simple_tex( width, height );
1583 1608
1584 image_gl->setClamp(old_clamps, old_clampt); 1609 gGL.getTexUnit(0)->setTextureAddressMode(old_mode);
1585 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 1610 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1586 } 1611 }
1587 } 1612 }
@@ -1632,7 +1657,7 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4
1632 if (!mMorphMasksValid && !mMaskedMorphs.empty()) 1657 if (!mMorphMasksValid && !mMaskedMorphs.empty())
1633 { 1658 {
1634 LLCRC alpha_mask_crc; 1659 LLCRC alpha_mask_crc;
1635 const LLUUID& uuid = mTexLayerSet->getAvatar()->getLocalTextureID(getInfo()->mLocalTexture); 1660 const LLUUID& uuid = mTexLayerSet->getAvatar()->getLocalTextureID((ETextureIndex)getInfo()->mLocalTexture);
1636 alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES); 1661 alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES);
1637 1662
1638 for( alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++ ) 1663 for( alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++ )
@@ -1653,7 +1678,7 @@ BOOL LLTexLayer::renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4
1653 else 1678 else
1654 { 1679 {
1655 // clear out a slot if we have filled our cache 1680 // clear out a slot if we have filled our cache
1656 S32 max_cache_entries = getTexLayerSet()->getAvatar()->mIsSelf ? 4 : 1; 1681 S32 max_cache_entries = getTexLayerSet()->getAvatar()->isSelf() ? 4 : 1;
1657 while ((S32)mAlphaCache.size() >= max_cache_entries) 1682 while ((S32)mAlphaCache.size() >= max_cache_entries)
1658 { 1683 {
1659 iter2 = mAlphaCache.begin(); // arbitrarily grab the first entry 1684 iter2 = mAlphaCache.begin(); // arbitrarily grab the first entry
@@ -1706,7 +1731,7 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i
1706 format = GL_ALPHA; 1731 format = GL_ALPHA;
1707 } 1732 }
1708 1733
1709 if( (in_width != VOAVATAR_SCRATCH_TEX_WIDTH) || (in_height != VOAVATAR_SCRATCH_TEX_HEIGHT) ) 1734 if( (in_width != SCRATCH_TEX_WIDTH) || (in_height != SCRATCH_TEX_HEIGHT) )
1710 { 1735 {
1711 LLGLSNoAlphaTest gls_no_alpha_test; 1736 LLGLSNoAlphaTest gls_no_alpha_test;
1712 1737
@@ -1718,21 +1743,20 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i
1718 internal_format = GL_ALPHA8; 1743 internal_format = GL_ALPHA8;
1719 } 1744 }
1720 1745
1721 GLuint name = 0; 1746 U32 name = 0;
1722 glGenTextures(1, &name ); 1747 LLImageGL::generateTextures(1, &name );
1723 stop_glerror(); 1748 stop_glerror();
1724 1749
1725 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, name); 1750 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, name);
1726 stop_glerror(); 1751 stop_glerror();
1727 1752
1728 glTexImage2D( 1753 LLImageGL::setManualImage(
1729 GL_TEXTURE_2D, 0, internal_format, 1754 GL_TEXTURE_2D, 0, internal_format,
1730 in_width, in_height, 1755 in_width, in_height,
1731 0, format, GL_UNSIGNED_BYTE, in_data ); 1756 format, GL_UNSIGNED_BYTE, in_data );
1732 stop_glerror(); 1757 stop_glerror();
1733 1758
1734 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 1759 gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
1735 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1736 1760
1737 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); 1761 gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
1738 1762
@@ -1740,7 +1764,7 @@ BOOL LLTexLayer::renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 i
1740 1764
1741 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 1765 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1742 1766
1743 glDeleteTextures(1, &name ); 1767 LLImageGL::deleteTextures(1, &name );
1744 stop_glerror(); 1768 stop_glerror();
1745 } 1769 }
1746 else 1770 else
@@ -1924,8 +1948,13 @@ void LLTexLayerParamAlpha::setWeight(F32 weight, BOOL set_by_user)
1924 LLVOAvatar* avatar = mTexLayer->getTexLayerSet()->getAvatar(); 1948 LLVOAvatar* avatar = mTexLayer->getTexLayerSet()->getAvatar();
1925 if( avatar->getSex() & getSex() ) 1949 if( avatar->getSex() & getSex() )
1926 { 1950 {
1951 if ( gAgent.cameraCustomizeAvatar() )
1952 {
1953 set_by_user = FALSE;
1954 }
1927 avatar->invalidateComposite( mTexLayer->getTexLayerSet(), set_by_user ); 1955 avatar->invalidateComposite( mTexLayer->getTexLayerSet(), set_by_user );
1928 mTexLayer->invalidateMorphMasks(); 1956 mTexLayer->invalidateMorphMasks();
1957 avatar->updateMeshTextures();
1929 } 1958 }
1930 } 1959 }
1931} 1960}
@@ -2015,7 +2044,7 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height )
2015 if( !mCachedProcessedImageGL || 2044 if( !mCachedProcessedImageGL ||
2016 (mCachedProcessedImageGL->getWidth() != image_tga_width) || 2045 (mCachedProcessedImageGL->getWidth() != image_tga_width) ||
2017 (mCachedProcessedImageGL->getHeight() != image_tga_height) || 2046 (mCachedProcessedImageGL->getHeight() != image_tga_height) ||
2018 (weight_changed )) 2047 (weight_changed) )
2019 { 2048 {
2020// llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl; 2049// llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl;
2021 mCachedEffectiveWeight = effective_weight; 2050 mCachedEffectiveWeight = effective_weight;
@@ -2027,7 +2056,6 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height )
2027 // We now have something in one of our caches 2056 // We now have something in one of our caches
2028 LLTexLayerSet::sHasCaches |= mCachedProcessedImageGL ? TRUE : FALSE; 2057 LLTexLayerSet::sHasCaches |= mCachedProcessedImageGL ? TRUE : FALSE;
2029 2058
2030
2031 mCachedProcessedImageGL->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); 2059 mCachedProcessedImageGL->setExplicitFormat( GL_ALPHA8, GL_ALPHA );
2032 } 2060 }
2033 2061
@@ -2046,9 +2074,8 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height )
2046 { 2074 {
2047 mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw); 2075 mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw);
2048 mNeedsCreateTexture = FALSE; 2076 mNeedsCreateTexture = FALSE;
2049
2050 gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); 2077 gGL.getTexUnit(0)->bind(mCachedProcessedImageGL);
2051 mCachedProcessedImageGL->setClamp(TRUE, TRUE); 2078 mCachedProcessedImageGL->setAddressMode(LLTexUnit::TAM_CLAMP);
2052 } 2079 }
2053 2080
2054 LLGLSNoAlphaTest gls_no_alpha_test; 2081 LLGLSNoAlphaTest gls_no_alpha_test;
@@ -2061,7 +2088,7 @@ BOOL LLTexLayerParamAlpha::render( S32 x, S32 y, S32 width, S32 height )
2061 2088
2062 // Don't keep the cache for other people's avatars 2089 // Don't keep the cache for other people's avatars
2063 // (It's not really a "cache" in that case, but the logic is the same) 2090 // (It's not really a "cache" in that case, but the logic is the same)
2064 if( !mTexLayer->getTexLayerSet()->getAvatar()->mIsSelf ) 2091 if( !mTexLayer->getTexLayerSet()->getAvatar()->isSelf() )
2065 { 2092 {
2066 mCachedProcessedImageGL = NULL; 2093 mCachedProcessedImageGL = NULL;
2067 } 2094 }
@@ -2503,7 +2530,7 @@ LLImageGL* LLTexStaticImageList::getImageGL(const std::string& file_name, BOOL i
2503 image_gl->createGLTexture(0, image_raw); 2530 image_gl->createGLTexture(0, image_raw);
2504 2531
2505 gGL.getTexUnit(0)->bind(image_gl); 2532 gGL.getTexUnit(0)->bind(image_gl);
2506 image_gl->setClamp(TRUE, TRUE); 2533 image_gl->setAddressMode(LLTexUnit::TAM_CLAMP);
2507 2534
2508 mStaticImageListGL [ namekey ] = image_gl; 2535 mStaticImageListGL [ namekey ] = image_gl;
2509 mGLBytes += (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents(); 2536 mGLBytes += (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents();