summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2012-09-20 04:29:17 +0000
committerDon Kjer <don@lindenlab.com>2012-09-20 04:29:17 +0000
commit7153d1db11c00245a379fa9601f092020152ea73 (patch)
tree816eb5f9d965379ebc2a4c4b030c2f9f97549726 /indra/newview
parent7b75bd089834a84ab5062c96870edeee6fa22861 (diff)
Partial rewrite of llifstream and llofstream (Windows implementation pending). Moved more functionality from llviewerwearable to llwearable
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llagent.h1
-rw-r--r--indra/newview/lllocalbitmaps.h4
-rw-r--r--indra/newview/lltoolmorph.cpp1
-rw-r--r--indra/newview/llviewertexlayer.h1
-rw-r--r--indra/newview/llviewerwearable.cpp184
-rw-r--r--indra/newview/llviewerwearable.h16
-rw-r--r--indra/newview/llwearablelist.cpp8
7 files changed, 20 insertions, 195 deletions
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index f784262e90..ae5efb2287 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -34,6 +34,7 @@
#include "llcharacter.h"
#include "llcoordframe.h" // for mFrameAgent
#include "llavatarappearancedefines.h"
+#include "llpermissionsflags.h"
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h
index ca12fe2045..580b6dfa7e 100644
--- a/indra/newview/lllocalbitmaps.h
+++ b/indra/newview/lllocalbitmaps.h
@@ -28,9 +28,11 @@
#ifndef LL_LOCALBITMAPS_H
#define LL_LOCALBITMAPS_H
+#include "llavatarappearancedefines.h"
#include "lleventtimer.h"
+#include "llimage.h"
+#include "llpointer.h"
#include "llwearabletype.h"
-#include "llavatarappearancedefines.h"
class LLScrollListCtrl;
class LLViewerObject;
diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp
index 0d5daf129f..148e5a015b 100644
--- a/indra/newview/lltoolmorph.cpp
+++ b/indra/newview/lltoolmorph.cpp
@@ -34,6 +34,7 @@
#include "llaudioengine.h"
#include "llviewercontrol.h"
#include "llfontgl.h"
+#include "llwearable.h"
#include "sound_ids.h"
#include "v3math.h"
#include "v3color.h"
diff --git a/indra/newview/llviewertexlayer.h b/indra/newview/llviewertexlayer.h
index 95c339a5b0..9df9474eff 100644
--- a/indra/newview/llviewertexlayer.h
+++ b/indra/newview/llviewertexlayer.h
@@ -28,6 +28,7 @@
#define LL_VIEWER_TEXLAYER_H
#include "lldynamictexture.h"
+#include "llextendedstatus.h"
#include "lltexlayer.h"
class LLVOAvatarSelf;
diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp
index e9fa92e8be..162c20837a 100644
--- a/indra/newview/llviewerwearable.cpp
+++ b/indra/newview/llviewerwearable.cpp
@@ -90,13 +90,13 @@ LLViewerWearable::~LLViewerWearable()
}
// virtual
-LLWearable::EImportResult LLViewerWearable::importFile( LLFILE* file, LLAvatarAppearance* avatarp )
+LLWearable::EImportResult LLViewerWearable::importStream( std::istream& input_stream, LLAvatarAppearance* avatarp )
{
// suppress texlayerset updates while wearables are being imported. Layersets will be updated
// when the wearables are "worn", not loaded. Note state will be restored when this object is destroyed.
LLOverrideBakedTextureUpdate stop_bakes(false);
- LLWearable::EImportResult result = LLWearable::importFile(file, avatarp);
+ LLWearable::EImportResult result = LLWearable::importStream(input_stream, avatarp);
if (LLWearable::FAILURE == result) return result;
if (LLWearable::BAD_HEADER == result)
{
@@ -129,9 +129,6 @@ LLWearable::EImportResult LLViewerWearable::importFile( LLFILE* file, LLAvatarAp
}
}
- // copy all saved param values to working params
- revertValues();
-
return result;
}
@@ -296,8 +293,8 @@ void LLViewerWearable::setTexturesToDefaults()
}
-//static
-const LLUUID LLViewerWearable::getDefaultTextureImageID(ETextureIndex index)
+// virtual
+LLUUID LLViewerWearable::getDefaultTextureImageID(ETextureIndex index) const
{
const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = LLAvatarAppearanceDictionary::getInstance()->getTexture(index);
const std::string &default_image_name = texture_dict->mDefaultImageName;
@@ -475,103 +472,9 @@ void LLViewerWearable::setItemID(const LLUUID& item_id)
mItemID = item_id;
}
-
-LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index)
-{
- te_map_t::iterator iter = mTEMap.find(index);
- if( iter != mTEMap.end() )
- {
- LLLocalTextureObject* lto = iter->second;
- return lto;
- }
- return NULL;
-}
-
-const LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index) const
-{
- te_map_t::const_iterator iter = mTEMap.find(index);
- if( iter != mTEMap.end() )
- {
- const LLLocalTextureObject* lto = iter->second;
- return lto;
- }
- return NULL;
-}
-
-std::vector<LLLocalTextureObject*> LLViewerWearable::getLocalTextureListSeq()
-{
- std::vector<LLLocalTextureObject*> result;
-
- for(te_map_t::const_iterator iter = mTEMap.begin();
- iter != mTEMap.end(); iter++)
- {
- LLLocalTextureObject* lto = iter->second;
- result.push_back(lto);
- }
-
- return result;
-}
-
-void LLViewerWearable::setLocalTextureObject(S32 index, LLLocalTextureObject &lto)
-{
- if( mTEMap.find(index) != mTEMap.end() )
- {
- mTEMap.erase(index);
- }
- mTEMap[index] = new LLLocalTextureObject(lto);
-}
-
-void LLViewerWearable::setVisualParams()
-{
- for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++)
- {
- S32 id = iter->first;
- LLVisualParam *wearable_param = iter->second;
- F32 value = wearable_param->getWeight();
- gAgentAvatarp->setVisualParamWeight(id, value, FALSE);
- }
-}
-
void LLViewerWearable::revertValues()
{
- //update saved settings so wearable is no longer dirty
- // non-driver params first
- for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
- {
- S32 id = iter->first;
- F32 value = iter->second;
- LLVisualParam *param = getVisualParam(id);
- if(param && !dynamic_cast<LLDriverParam*>(param) )
- {
- setVisualParamWeight(id, value, TRUE);
- }
- }
-
- //then driver params
- for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
- {
- S32 id = iter->first;
- F32 value = iter->second;
- LLVisualParam *param = getVisualParam(id);
- if(param && dynamic_cast<LLDriverParam*>(param) )
- {
- setVisualParamWeight(id, value, TRUE);
- }
- }
-
- // make sure that saved values are sane
- for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
- {
- S32 id = iter->first;
- LLVisualParam *param = getVisualParam(id);
- if( param )
- {
- mSavedVisualParamMap[id] = param->getWeight();
- }
- }
-
- syncImages(mSavedTEMap, mTEMap);
-
+ LLWearable::revertValues();
LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLFloaterSidePanelContainer::getPanel("appearance"));
if( panel )
@@ -582,19 +485,7 @@ void LLViewerWearable::revertValues()
void LLViewerWearable::saveValues()
{
- //update saved settings so wearable is no longer dirty
- mSavedVisualParamMap.clear();
- for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); ++iter)
- {
- S32 id = iter->first;
- LLVisualParam *wearable_param = iter->second;
- F32 value = wearable_param->getWeight();
- mSavedVisualParamMap[id] = value;
- }
-
- // Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed)
- syncImages(mTEMap, mSavedTEMap);
-
+ LLWearable::saveValues();
LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLFloaterSidePanelContainer::getPanel("appearance"));
if( panel )
@@ -603,69 +494,6 @@ void LLViewerWearable::saveValues()
}
}
-void LLViewerWearable::syncImages(te_map_t &src, te_map_t &dst)
-{
- // Deep copy of src (copies only those tes that are current, filling in defaults where needed)
- for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
- {
- if (LLAvatarAppearanceDictionary::getTEWearableType((ETextureIndex) te) == mType)
- {
- te_map_t::const_iterator iter = src.find(te);
- LLUUID image_id;
- LLViewerFetchedTexture *image = NULL;
- LLLocalTextureObject *lto = NULL;
- if(iter != src.end())
- {
- // there's a Local Texture Object in the source image map. Use this to populate the values to store in the destination image map.
- lto = iter->second;
- image = dynamic_cast<LLViewerFetchedTexture*> (lto->getImage());
- image_id = lto->getID();
- }
- else
- {
- // there is no Local Texture Object in the source image map. Get defaults values for populating the destination image map.
- image_id = getDefaultTextureImageID((ETextureIndex) te);
- image = LLViewerTextureManager::getFetchedTexture( image_id );
- }
-
- if( dst.find(te) != dst.end() )
- {
- // there's already an entry in the destination map for the texture. Just update its values.
- dst[te]->setImage(image);
- dst[te]->setID(image_id);
- }
- else
- {
- // no entry found in the destination map, we need to create a new Local Texture Object
- dst[te] = new LLLocalTextureObject(image, image_id);
- }
-
- if( lto )
- {
- // If we pulled values from a Local Texture Object in the source map, make sure the proper flags are set in the new (or updated) entry in the destination map.
- dst[te]->setBakedReady(lto->getBakedReady());
- dst[te]->setDiscard(lto->getDiscard());
- }
- }
- }
-}
-
-void LLViewerWearable::destroyTextures()
-{
- for( te_map_t::iterator iter = mTEMap.begin(); iter != mTEMap.end(); ++iter )
- {
- LLLocalTextureObject *lto = iter->second;
- delete lto;
- }
- mTEMap.clear();
- for( te_map_t::iterator iter = mSavedTEMap.begin(); iter != mSavedTEMap.end(); ++iter )
- {
- LLLocalTextureObject *lto = iter->second;
- delete lto;
- }
- mSavedTEMap.clear();
-}
-
// virtual
void LLViewerWearable::setUpdated() const
{
diff --git a/indra/newview/llviewerwearable.h b/indra/newview/llviewerwearable.h
index d8412b1c65..65566f23a5 100644
--- a/indra/newview/llviewerwearable.h
+++ b/indra/newview/llviewerwearable.h
@@ -64,12 +64,12 @@ public:
void removeFromAvatar( BOOL upload_bake ) { LLViewerWearable::removeFromAvatar( mType, upload_bake ); }
static void removeFromAvatar( LLWearableType::EType type, BOOL upload_bake );
- /*virtual*/ EImportResult importFile(LLFILE* file, LLAvatarAppearance* avatarp);
+ /*virtual*/ EImportResult importStream( std::istream& input_stream, LLAvatarAppearance* avatarp );
void setParamsToDefaults();
void setTexturesToDefaults();
- static const LLUUID getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index);
+ /*virtual*/ LLUUID getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index) const;
void saveNewAsset() const;
@@ -79,14 +79,8 @@ public:
friend std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w);
- /*virtual*/ LLLocalTextureObject* getLocalTextureObject(S32 index);
- const LLLocalTextureObject* getLocalTextureObject(S32 index) const;
- std::vector<LLLocalTextureObject*> getLocalTextureListSeq();
- void setLocalTextureObject(S32 index, LLLocalTextureObject &lto);
- void setVisualParams();
-
- void revertValues();
- void saveValues();
+ /*virtual*/ void revertValues();
+ /*virtual*/ void saveValues();
// Something happened that requires the wearable's label to be updated (e.g. worn/unworn).
/*virtual*/void setUpdated() const;
@@ -99,8 +93,6 @@ public:
/*virtual*/void addToBakedTextureHash(LLMD5& hash) const;
protected:
- void syncImages(te_map_t &src, te_map_t &dst);
- void destroyTextures();
LLAssetID mAssetID;
LLTransactionID mTransactionID;
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 50beaaec3f..3dfacd70f3 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -112,15 +112,16 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
else if (status >= 0)
{
// read the file
- LLFILE* fp = LLFile::fopen(std::string(filename), "rb"); /*Flawfinder: ignore*/
- if( !fp )
+ llifstream ifs(filename, llifstream::binary);
+ if( !ifs.is_open() )
{
LL_WARNS("Wearable") << "Bad Wearable Asset: unable to open file: '" << filename << "'" << LL_ENDL;
}
else
{
wearable = new LLViewerWearable(uuid);
- LLWearable::EImportResult result = wearable->importFile( fp, avatarp );
+ LLWearable::EImportResult result = wearable->importStream(
+ ifs, avatarp );
if (LLWearable::SUCCESS != result)
{
if (wearable->getType() == LLWearableType::WT_COUNT)
@@ -131,7 +132,6 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
wearable = NULL;
}
- fclose( fp );
if(filename)
{
LLFile::remove(std::string(filename));