diff options
Diffstat (limited to 'indra/newview')
157 files changed, 5920 insertions, 1217 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9510dcd9cc..1fddf7043d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -386,9 +386,7 @@ set(viewer_SOURCE_FILES llviewerdisplay.cpp llviewerfloaterreg.cpp llviewergenericmessage.cpp - llviewergesture.cpp - llviewerimage.cpp - llviewerimagelist.cpp + llviewergesture.cpp llviewerinventory.cpp llviewerjointattachment.cpp llviewerjoint.cpp @@ -416,7 +414,9 @@ set(viewer_SOURCE_FILES llviewershadermgr.cpp llviewerstats.cpp llviewertexteditor.cpp + llviewertexture.cpp llviewertextureanim.cpp + llviewertexturelist.cpp llviewerthrottle.cpp llviewervisualparam.cpp llviewerwindow.cpp @@ -815,9 +815,7 @@ set(viewer_HEADER_FILES llviewerdisplay.h llviewerfloaterreg.h llviewergenericmessage.h - llviewergesture.h - llviewerimage.h - llviewerimagelist.h + llviewergesture.h llviewerinventory.h llviewerjoint.h llviewerjointattachment.h @@ -843,7 +841,9 @@ set(viewer_HEADER_FILES llviewershadermgr.h llviewerstats.h llviewertexteditor.h + llviewertexture.h llviewertextureanim.h + llviewertexturelist.h llviewerthrottle.h llviewervisualparam.h llviewerwindow.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c9b27e9802..51b6fc81cd 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -42,7 +42,7 @@ #include "lltexteditor.h" #include "llalertdialog.h" #include "llerrorcontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llgroupmgr.h" #include "llagent.h" #include "llagentwearables.h" @@ -1440,10 +1440,10 @@ bool LLAppViewer::cleanup() LLMetricPerformanceTester::cleanClass() ; //Note: - //LLViewerMedia::cleanupClass() has to be put before gImageList.shutdown() + //LLViewerMedia::cleanupClass() has to be put before gTextureList.shutdown() //because some new image might be generated during cleaning up media. --bao LLViewerMedia::cleanupClass(); - gImageList.shutdown(); // shutdown again in case a callback added something + gTextureList.shutdown(); // shutdown again in case a callback added something LLUIImageList::getInstance()->cleanUp(); // This should eventually be done in LLAppViewer diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp index 531e6d709a..31c2d93c05 100644 --- a/indra/newview/llcolorswatch.cpp +++ b/indra/newview/llcolorswatch.cpp @@ -48,7 +48,7 @@ #include "lltextbox.h" #include "llfloatercolorpicker.h" #include "llviewborder.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llfocusmgr.h" static LLDefaultChildRegistry::Register<LLColorSwatchCtrl> r("color_swatch"); @@ -227,7 +227,7 @@ void LLColorSwatchCtrl::draw() { if (!mFallbackImageName.empty()) { - LLPointer<LLViewerImage> fallback_image = gImageList.getImageFromFile(mFallbackImageName); + LLPointer<LLViewerTexture> fallback_image = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); if( fallback_image->getComponents() == 4 ) { gl_rect_2d_checkerboard( interior ); diff --git a/indra/newview/llcolorswatch.h b/indra/newview/llcolorswatch.h index db771df6b3..e3e267f831 100644 --- a/indra/newview/llcolorswatch.h +++ b/indra/newview/llcolorswatch.h @@ -36,7 +36,7 @@ #include "lluictrl.h" #include "v4color.h" #include "llfloater.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "lltextbox.h" // @@ -45,7 +45,7 @@ class LLColor4; class LLTextBox; class LLFloaterColorPicker; -class LLViewerImage; +class LLViewerTexture; class LLColorSwatchCtrl : public LLUICtrl diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 9f4afc9f17..d8bd32382f 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -229,7 +229,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) return count; } -LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerImage *texturep) +LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { LLMemType mt(LLMemType::MTYPE_DRAWABLE); @@ -253,7 +253,7 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerImage *texturep) return face; } -LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerImage *texturep) +LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) { LLMemType mt(LLMemType::MTYPE_DRAWABLE); @@ -275,7 +275,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerImage *texturep) } -void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerImage *texturep) +void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { if (newFaces == (S32)mFaces.size()) { @@ -298,7 +298,7 @@ void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerImag llassert_always(mFaces.size() == newFaces); } -void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewerImage *texturep) +void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { if (newFaces <= (S32)mFaces.size() && newFaces >= (S32)mFaces.size()/2) { @@ -673,7 +673,7 @@ BOOL LLDrawable::updateMoveDamped() return done_moving; } -void LLDrawable::updateDistance(LLCamera& camera) +void LLDrawable::updateDistance(LLCamera& camera, bool force_update) { //switch LOD with the spatial group to avoid artifacts //LLSpatialGroup* sg = getSpatialGroup(); @@ -695,7 +695,7 @@ void LLDrawable::updateDistance(LLCamera& camera) for (S32 i = 0; i < getNumFaces(); i++) { LLFace* facep = getFace(i); - if (facep->getPoolType() == LLDrawPool::POOL_ALPHA) + if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA) { LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f; LLVector3 v = (facep->mCenterLocal-camera.getOrigin()); @@ -736,11 +736,7 @@ void LLDrawable::updateTexture() if (getVOVolume()) { - if (!isActive()) - { - //gPipeline.markMoved(this); - } - else + if (isActive()) { if (isRoot()) { @@ -1273,7 +1269,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* } } -void LLSpatialBridge::updateDistance(LLCamera& camera_in) +void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) { if (mDrawable == NULL) { @@ -1283,7 +1279,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in) LLCamera camera = transformCamera(camera_in); - mDrawable->updateDistance(camera); + mDrawable->updateDistance(camera, force_update); if (mDrawable->getVObj()) { @@ -1300,7 +1296,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in) if (!drawable->isAvatar()) { - drawable->updateDistance(camera); + drawable->updateDistance(camera, force_update); } } } diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index f3ef0753e7..940e1fc968 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -58,7 +58,7 @@ class LLSpatialGroup; class LLSpatialBridge; class LLSpatialPartition; class LLVOVolume; -class LLViewerImage; +class LLViewerTexture; // Can have multiple silhouettes for each object const U32 SILHOUETTE_HIGHLIGHT = 0; @@ -125,11 +125,11 @@ public: inline S32 getNumFaces() const; //void removeFace(const S32 i); // SJB: Avoid using this, it's slow - LLFace* addFace(LLFacePool *poolp, LLViewerImage *texturep); - LLFace* addFace(const LLTextureEntry *te, LLViewerImage *texturep); + LLFace* addFace(LLFacePool *poolp, LLViewerTexture *texturep); + LLFace* addFace(const LLTextureEntry *te, LLViewerTexture *texturep); void deleteFaces(S32 offset, S32 count); - void setNumFaces(const S32 numFaces, LLFacePool *poolp, LLViewerImage *texturep); - void setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerImage *texturep); + void setNumFaces(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); + void setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep); void mergeFaces(LLDrawable* src); void init(); diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 9f05ce3c46..3a064a4e7d 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -60,7 +60,7 @@ S32 LLDrawPool::sNumDrawPools = 0; //============================= // Draw Pool Implementation //============================= -LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerImage *tex0) +LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) { LLDrawPool *poolp = NULL; switch (type) @@ -129,7 +129,7 @@ LLDrawPool::~LLDrawPool() } -LLViewerImage *LLDrawPool::getDebugTexture() +LLViewerTexture *LLDrawPool::getDebugTexture() { return NULL; } @@ -244,7 +244,7 @@ void LLFacePool::destroy() } } -void LLFacePool::dirtyTextures(const std::set<LLViewerImage*>& textures) +void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures) { } @@ -279,7 +279,7 @@ S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage) iter != face_list.end(); iter++) { LLFace *facep = *iter; - gGL.getTexUnit(stage)->bind(facep->getTexture()); + gGL.getTexUnit(stage)->bind(facep->getTexture()) ; gGL.getTexUnit(0)->activate(); res += facep->renderIndexed(); } @@ -295,13 +295,6 @@ void LLFacePool::drawLoop() } } -void LLFacePool::renderFaceSelected(LLFace *facep, - LLImageGL *image, - const LLColor4 &color, - const S32 index_offset, const S32 index_count) -{ -} - void LLFacePool::enqueue(LLFace* facep) { mDrawFace.push_back(facep); @@ -330,7 +323,7 @@ void LLFacePool::resetDrawOrders() mDrawFace.resize(0); } -LLViewerImage *LLFacePool::getTexture() +LLViewerTexture *LLFacePool::getTexture() { return NULL; } @@ -481,7 +474,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) { if (params.mTexture.notNull()) { - gGL.getTexUnit(0)->bind(params.mTexture.get()); + gGL.getTexUnit(0)->bind(params.mTexture) ; if (params.mTextureMatrix) { glMatrixMode(GL_TEXTURE); diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 87c3ccaffe..966de41df3 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -39,8 +39,8 @@ #include "llvertexbuffer.h" class LLFace; -class LLImageGL; -class LLViewerImage; +class LLViewerTexture; +class LLViewerFetchedTexture; class LLSpatialGroup; class LLDrawInfo; @@ -77,7 +77,7 @@ public: S32 getId() const { return mId; } U32 getType() const { return mType; } - virtual LLViewerImage *getDebugTexture(); + virtual LLViewerTexture *getDebugTexture(); virtual void beginRenderPass( S32 pass ); virtual void endRenderPass( S32 pass ); virtual S32 getNumPasses(); @@ -103,9 +103,9 @@ public: virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; } - static LLDrawPool* createPool(const U32 type, LLViewerImage *tex0 = NULL); + static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL); virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool. - virtual LLViewerImage* getTexture() = 0; + virtual LLViewerTexture* getTexture() = 0; virtual BOOL isFacePool() { return FALSE; } virtual void resetDrawOrders() = 0; @@ -139,8 +139,8 @@ public: LLRenderPass(const U32 type); virtual ~LLRenderPass(); /*virtual*/ LLDrawPool* instancePool(); - /*virtual*/ LLViewerImage* getDebugTexture() { return NULL; } - LLViewerImage* getTexture() { return NULL; } + /*virtual*/ LLViewerTexture* getDebugTexture() { return NULL; } + LLViewerTexture* getTexture() { return NULL; } BOOL isDead() { return FALSE; } void resetDrawOrders() { } @@ -169,11 +169,9 @@ public: virtual void renderForSelect() = 0; BOOL isDead() { return mReferences.empty(); } - virtual void renderFaceSelected(LLFace *facep, LLImageGL *image, const LLColor4 &color, - const S32 index_offset = 0, const S32 index_count = 0); - - virtual LLViewerImage *getTexture(); - virtual void dirtyTextures(const std::set<LLViewerImage*>& textures); + + virtual LLViewerTexture *getTexture(); + virtual void dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures); virtual void enqueue(LLFace *face); virtual BOOL addFace(LLFace *face); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 7e470bd01f..267f83f295 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -46,7 +46,7 @@ #include "lldrawable.h" #include "llface.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" // For debugging +#include "llviewertexturelist.h" // For debugging #include "llviewerobjectlist.h" // For debugging #include "llviewerwindow.h" #include "pipeline.h" @@ -218,8 +218,8 @@ void LLDrawPoolAlpha::render(S32 pass) } gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); - LLViewerImage::sSmokeImagep->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(0)->bind(LLViewerImage::sSmokeImagep.get()); + LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); + gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep) ; renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); } @@ -294,7 +294,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask) if (params.mTexture.notNull()) { gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->bind(params.mTexture.get()); + gGL.getTexUnit(0)->bind(params.mTexture) ; params.mTexture->addTextureStats(params.mVSize); if (params.mTextureMatrix) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 51f4bbac5c..b15cd0b0dc 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -633,7 +633,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (pass==1 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0)) { // debug code to draw a sphere in place of avatar - gGL.getTexUnit(0)->bind(LLViewerImage::sWhiteImagep.get()); + gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); gGL.setColorMask(true, true); LLVector3 pos = avatarp->getPositionAgent(); gGL.color4f(1.0f, 1.0f, 1.0f, 0.7f); @@ -819,7 +819,7 @@ void LLDrawPoolAvatar::renderForSelect() //----------------------------------------------------------------------------- // getDebugTexture() //----------------------------------------------------------------------------- -LLViewerImage *LLDrawPoolAvatar::getDebugTexture() +LLViewerTexture *LLDrawPoolAvatar::getDebugTexture() { if (mReferences.empty()) { diff --git a/indra/newview/lldrawpoolavatar.h b/indra/newview/lldrawpoolavatar.h index 1e2630e1fb..6a2b7fc218 100644 --- a/indra/newview/lldrawpoolavatar.h +++ b/indra/newview/lldrawpoolavatar.h @@ -105,7 +105,7 @@ public: void endDeferredRigid(); void endDeferredSkinned(); - /*virtual*/ LLViewerImage *getDebugTexture(); + /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display void renderAvatars(LLVOAvatar *single_avatar, S32 pass = -1); // renders only one avatar if single_avatar is not null. diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index ed6e55b7bc..971949e885 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -37,7 +37,6 @@ #include "llstl.h" #include "llviewercontrol.h" #include "lldir.h" -#include "llimagegl.h" #include "m3math.h" #include "m4math.h" #include "v4math.h" @@ -51,7 +50,7 @@ #include "llsky.h" #include "lltextureentry.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "pipeline.h" #include "llspatialpartition.h" #include "llviewershadermgr.h" @@ -143,9 +142,10 @@ void LLStandardBumpmap::restoreGL() // llinfos << "Loading bumpmap: " << bump_image_id << " from viewerart" << llendl; gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mLabel = label; gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage = - gImageList.getImage(LLUUID(bump_image_id), + LLViewerTextureManager::getFetchedTexture(LLUUID(bump_image_id), TRUE, FALSE, + LLViewerTexture::LOD_TEXTURE, 0, 0); gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage->setLoadedCallback(LLBumpImageList::onSourceStandardLoaded, 0, TRUE, FALSE, NULL ); @@ -569,22 +569,23 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL // static BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params, S32 channel) { - LLImageGL* bump = NULL; + LLViewerTexture* bump = NULL; U8 bump_code = params.mBump; - LLViewerImage* tex = params.mTexture; + LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(params.mTexture) ; + if(!tex) + { + //if the texture is not a fetched texture + return FALSE; + } switch( bump_code ) { - case BE_NO_BUMP: - bump = NULL; + case BE_NO_BUMP: break; case BE_BRIGHTNESS: case BE_DARKNESS: - if( tex ) - { - bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code ); - } + bump = gBumpImageList.getBrightnessDarknessImage( tex, bump_code ); break; default: @@ -812,7 +813,7 @@ LLBumpImageList::~LLBumpImageList() void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size) { bump &= TEM_BUMP_MASK; - LLViewerImage* bump_image = gStandardBumpmapList[bump].mImage; + LLViewerFetchedTexture* bump_image = gStandardBumpmapList[bump].mImage; if( bump_image ) { bump_image->addTextureStats(virtual_size); @@ -826,11 +827,11 @@ void LLBumpImageList::updateImages() for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); ) { bump_image_map_t::iterator curiter = iter++; - LLImageGL* image = curiter->second; + LLViewerTexture* image = curiter->second; if( image ) { BOOL destroy = TRUE; - if( image->getHasGLTexture()) + if( image->hasValidGLTexture()) { if( image->getBoundRecently() ) { @@ -853,11 +854,11 @@ void LLBumpImageList::updateImages() for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); ) { bump_image_map_t::iterator curiter = iter++; - LLImageGL* image = curiter->second; + LLViewerTexture* image = curiter->second; if( image ) { BOOL destroy = TRUE; - if( image->getHasGLTexture()) + if( image->hasValidGLTexture()) { if( image->getBoundRecently() ) { @@ -881,16 +882,16 @@ void LLBumpImageList::updateImages() // Note: the caller SHOULD NOT keep the pointer that this function returns. It may be updated as more data arrives. -LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image, U8 bump_code ) +LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code ) { llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) ); - LLImageGL* bump = NULL; + LLViewerTexture* bump = NULL; const F32 BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD = 1000; - if( src_image->mMaxVirtualSize > BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD ) + if( src_image->getMaxVirtualSize() > BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD ) { bump_image_map_t* entries_list = NULL; - void (*callback_func)( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL; + void (*callback_func)( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL; switch( bump_code ) { @@ -917,14 +918,8 @@ LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image, LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,1); raw->clear(0x77, 0x77, 0x77, 0xFF); - //------------------------------ - bump = new LLImageGL( raw, TRUE); - //immediately assign bump to a global smart pointer in case some local smart pointer - //accidently releases it. - (*entries_list)[src_image->getID()] = bump; - //------------------------------ - - bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA); + (*entries_list)[src_image->getID()] = LLViewerTextureManager::getLocalTexture( raw.get(), TRUE); + (*entries_list)[src_image->getID()]->setExplicitFormat(GL_ALPHA8, GL_ALPHA); // Note: this may create an LLImageGL immediately src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()) ); @@ -940,7 +935,7 @@ LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image, // static -void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) +void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) { LLUUID* source_asset_id = (LLUUID*)userdata; LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_BRIGHTNESS ); @@ -951,7 +946,7 @@ void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerImage *src } // static -void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) +void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) { LLUUID* source_asset_id = (LLUUID*)userdata; LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_DARKNESS ); @@ -961,7 +956,7 @@ void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerImage *src_v } } -void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerImage* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) { if (success && LLPipeline::sRenderDeferred) { @@ -1028,7 +1023,7 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr } // static -void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code ) +void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code ) { if( success ) { @@ -1147,7 +1142,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLIma //--------------------------------------------------- //immediately assign bump to a global smart pointer in case some local smart pointer //accidently releases it. - LLPointer<LLImageGL> bump = new LLImageGL( TRUE); + LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE); if (!LLPipeline::sRenderDeferred) { @@ -1220,7 +1215,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) { if (params.mTexture.notNull()) { - gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get()); + gGL.getTexUnit(diffuse_channel)->bind(params.mTexture) ; params.mTexture->addTextureStats(params.mVSize); } else diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 34c1e9c29f..bf940cf1e4 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -41,6 +41,7 @@ class LLImageRaw; class LLSpatialGroup; class LLDrawInfo; +class LLViewerFetchedTexture; class LLDrawPoolBump : public LLRenderPass { @@ -110,7 +111,7 @@ public: LLStandardBumpmap( const std::string& label ) : mLabel(label) {} std::string mLabel; - LLPointer<LLViewerImage> mImage; + LLPointer<LLViewerFetchedTexture> mImage; static U32 sStandardBumpmapCount; // Number of valid values in gStandardBumpmapList[] @@ -140,21 +141,20 @@ public: void updateImages(); - LLImageGL* getBrightnessDarknessImage(LLViewerImage* src_image, U8 bump_code); -// LLImageGL* getTestImage(); + LLViewerTexture* getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code); void addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size); - static void onSourceBrightnessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); - static void onSourceDarknessLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); - static void onSourceStandardLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); + static void onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); + static void onSourceDarknessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); + static void onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); static void generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image); private: - static void onSourceLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump ); + static void onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump ); private: - typedef std::map<LLUUID, LLPointer<LLImageGL> > bump_image_map_t; + typedef std::map<LLUUID, LLPointer<LLViewerTexture> > bump_image_map_t; bump_image_map_t mBrightnessEntries; bump_image_map_t mDarknessEntries; }; diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index a9e0948ecf..8428be194f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -41,7 +41,7 @@ #include "llface.h" #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llvosky.h" #include "llworld.h" // To get water height diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 2c644b0fd5..a01c9026c8 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -49,7 +49,7 @@ #include "llviewerparceloverlay.h" #include "llvosurfacepatch.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" // To get alpha gradients +#include "llviewertexturelist.h" // To get alpha gradients #include "llworld.h" #include "pipeline.h" #include "llviewershadermgr.h" @@ -62,28 +62,32 @@ S32 LLDrawPoolTerrain::sDetailMode = 1; F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE; static LLGLSLShader* sShader = NULL; -LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) : +LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerTexture *texturep) : LLFacePool(POOL_TERRAIN), mTexturep(texturep) { // Hack! sDetailScale = 1.f/gSavedSettings.getF32("RenderTerrainScale"); sDetailMode = gSavedSettings.getS32("RenderTerrainDetail"); - mAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient.tga", - TRUE, TRUE, GL_ALPHA8, GL_ALPHA, + mAlphaRampImagep = LLViewerTextureManager::getFetchedTextureFromFile("alpha_gradient.tga", + TRUE, TRUE, + LLViewerTexture::FETCHED_TEXTURE, + GL_ALPHA8, GL_ALPHA, LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); - gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); + gGL.getTexUnit(0)->bind(mAlphaRampImagep); mAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); - m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", - TRUE, TRUE, GL_ALPHA8, GL_ALPHA, + m2DAlphaRampImagep = LLViewerTextureManager::getFetchedTextureFromFile("alpha_gradient_2d.j2c", + TRUE, TRUE, + LLViewerTexture::FETCHED_TEXTURE, + GL_ALPHA8, GL_ALPHA, LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); - gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep); m2DAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); - mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN); + mTexturep->setBoostLevel(LLViewerTexture::BOOST_TERRAIN); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -170,7 +174,7 @@ void LLDrawPoolTerrain::render(S32 pass) LLVLComposition *compp = regionp->getComposition(); for (S32 i = 0; i < 4; i++) { - compp->mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN); + compp->mDetailTextures[i]->setBoostLevel(LLViewerTexture::BOOST_TERRAIN); compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area } @@ -289,10 +293,10 @@ void LLDrawPoolTerrain::renderFullShader() // Hack! Get the region that this draw pool is rendering from! LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); LLVLComposition *compp = regionp->getComposition(); - LLViewerImage *detail_texture0p = compp->mDetailTextures[0]; - LLViewerImage *detail_texture1p = compp->mDetailTextures[1]; - LLViewerImage *detail_texture2p = compp->mDetailTextures[2]; - LLViewerImage *detail_texture3p = compp->mDetailTextures[3]; + LLViewerTexture *detail_texture0p = compp->mDetailTextures[0]; + LLViewerTexture *detail_texture1p = compp->mDetailTextures[1]; + LLViewerTexture *detail_texture2p = compp->mDetailTextures[2]; + LLViewerTexture *detail_texture3p = compp->mDetailTextures[3]; LLVector3d region_origin_global = gAgent.getRegion()->getOriginGlobal(); F32 offset_x = (F32)fmod(region_origin_global.mdV[VX], 1.0/(F64)sDetailScale)*sDetailScale; @@ -363,7 +367,7 @@ void LLDrawPoolTerrain::renderFullShader() // Alpha Ramp // S32 alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); - gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep); // GL_BLEND disabled by default drawLoop(); @@ -429,10 +433,10 @@ void LLDrawPoolTerrain::renderFull4TU() // Hack! Get the region that this draw pool is rendering from! LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); LLVLComposition *compp = regionp->getComposition(); - LLViewerImage *detail_texture0p = compp->mDetailTextures[0]; - LLViewerImage *detail_texture1p = compp->mDetailTextures[1]; - LLViewerImage *detail_texture2p = compp->mDetailTextures[2]; - LLViewerImage *detail_texture3p = compp->mDetailTextures[3]; + LLViewerTexture *detail_texture0p = compp->mDetailTextures[0]; + LLViewerTexture *detail_texture1p = compp->mDetailTextures[1]; + LLViewerTexture *detail_texture2p = compp->mDetailTextures[2]; + LLViewerTexture *detail_texture3p = compp->mDetailTextures[3]; LLVector3d region_origin_global = gAgent.getRegion()->getOriginGlobal(); F32 offset_x = (F32)fmod(region_origin_global.mdV[VX], 1.0/(F64)sDetailScale)*sDetailScale; @@ -527,7 +531,7 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 1: Generate alpha ramp for detail2/detail3 transition // - gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(1)->bind(m2DAlphaRampImagep); gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->activate(); @@ -559,7 +563,7 @@ void LLDrawPoolTerrain::renderFull4TU() // // Stage 3: Generate alpha ramp for detail1/detail2 transition // - gGL.getTexUnit(3)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(3)->bind(m2DAlphaRampImagep); gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(3)->activate(); @@ -630,10 +634,10 @@ void LLDrawPoolTerrain::renderFull2TU() // Hack! Get the region that this draw pool is rendering from! LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); LLVLComposition *compp = regionp->getComposition(); - LLViewerImage *detail_texture0p = compp->mDetailTextures[0]; - LLViewerImage *detail_texture1p = compp->mDetailTextures[1]; - LLViewerImage *detail_texture2p = compp->mDetailTextures[2]; - LLViewerImage *detail_texture3p = compp->mDetailTextures[3]; + LLViewerTexture *detail_texture0p = compp->mDetailTextures[0]; + LLViewerTexture *detail_texture1p = compp->mDetailTextures[1]; + LLViewerTexture *detail_texture2p = compp->mDetailTextures[2]; + LLViewerTexture *detail_texture3p = compp->mDetailTextures[3]; LLVector3d region_origin_global = gAgent.getRegion()->getOriginGlobal(); F32 offset_x = (F32)fmod(region_origin_global.mdV[VX], 1.0/(F64)sDetailScale)*sDetailScale; @@ -671,7 +675,7 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 0: Generate alpha ramp for detail0/detail1 transition // - gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); @@ -709,7 +713,7 @@ void LLDrawPoolTerrain::renderFull2TU() // // Stage 0: Generate alpha ramp for detail1/detail2 transition // - gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep); // Set the texture matrix glMatrixMode(GL_TEXTURE); @@ -749,7 +753,7 @@ void LLDrawPoolTerrain::renderFull2TU() // Stage 0: Generate alpha ramp for detail2/detail3 transition // gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); + gGL.getTexUnit(0)->bind(m2DAlphaRampImagep); // Set the texture matrix glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -822,7 +826,7 @@ void LLDrawPoolTerrain::renderSimple() gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->bind(mTexturep.get()); + gGL.getTexUnit(0)->bind(mTexturep); LLVector3 origin_agent = mDrawFace[0]->getDrawable()->getVObj()->getRegion()->getOriginAgent(); F32 tscale = 1.f/256.f; @@ -872,7 +876,7 @@ void LLDrawPoolTerrain::renderOwnership() LLSurface *surfacep = surface_patchp->getSurface(); LLViewerRegion *regionp = surfacep->getRegion(); LLViewerParcelOverlay *overlayp = regionp->getParcelOverlay(); - LLImageGL *texturep = overlayp->getTexture(); + LLViewerTexture *texturep = overlayp->getTexture(); gGL.getTexUnit(0)->bind(texturep); @@ -920,9 +924,10 @@ void LLDrawPoolTerrain::renderForSelect() } } -void LLDrawPoolTerrain::dirtyTextures(const std::set<LLViewerImage*>& textures) +void LLDrawPoolTerrain::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures) { - if (textures.find(mTexturep) != textures.end()) + LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(mTexturep) ; + if (tex && textures.find(tex) != textures.end()) { for (std::vector<LLFace*>::iterator iter = mReferences.begin(); iter != mReferences.end(); iter++) @@ -933,12 +938,12 @@ void LLDrawPoolTerrain::dirtyTextures(const std::set<LLViewerImage*>& textures) } } -LLViewerImage *LLDrawPoolTerrain::getTexture() +LLViewerTexture *LLDrawPoolTerrain::getTexture() { return mTexturep; } -LLViewerImage *LLDrawPoolTerrain::getDebugTexture() +LLViewerTexture *LLDrawPoolTerrain::getDebugTexture() { return mTexturep; } diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h index 19d09e2feb..2e2a36d533 100644 --- a/indra/newview/lldrawpoolterrain.h +++ b/indra/newview/lldrawpoolterrain.h @@ -37,7 +37,7 @@ class LLDrawPoolTerrain : public LLFacePool { - LLPointer<LLViewerImage> mTexturep; + LLPointer<LLViewerTexture> mTexturep; public: enum { @@ -53,7 +53,7 @@ public: virtual U32 getVertexDataMask(); static S32 getDetailMode(); - LLDrawPoolTerrain(LLViewerImage *texturep); + LLDrawPoolTerrain(LLViewerTexture *texturep); virtual ~LLDrawPoolTerrain(); /*virtual*/ LLDrawPool *instancePool(); @@ -73,14 +73,14 @@ public: /*virtual*/ void beginRenderPass( S32 pass ); /*virtual*/ void endRenderPass( S32 pass ); /*virtual*/ void renderForSelect(); - /*virtual*/ void dirtyTextures(const std::set<LLViewerImage*>& textures); - /*virtual*/ LLViewerImage *getTexture(); - /*virtual*/ LLViewerImage *getDebugTexture(); + /*virtual*/ void dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures); + /*virtual*/ LLViewerTexture *getTexture(); + /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display - LLPointer<LLViewerImage> mAlphaRampImagep; - LLPointer<LLViewerImage> m2DAlphaRampImagep; - LLPointer<LLViewerImage> mAlphaNoiseImagep; + LLPointer<LLViewerTexture> mAlphaRampImagep; + LLPointer<LLViewerTexture> m2DAlphaRampImagep; + LLPointer<LLViewerTexture> mAlphaNoiseImagep; static S32 sDetailMode; static F32 sDetailScale; // meters per texture diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 22634d96b0..f572e2cb44 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -47,11 +47,11 @@ S32 LLDrawPoolTree::sDiffTex = 0; static LLGLSLShader* shader = NULL; -LLDrawPoolTree::LLDrawPoolTree(LLViewerImage *texturep) : +LLDrawPoolTree::LLDrawPoolTree(LLViewerTexture *texturep) : LLFacePool(POOL_TREE), mTexturep(texturep) { - gGL.getTexUnit(0)->bind(mTexturep.get()); + gGL.getTexUnit(0)->bind(mTexturep); mTexturep->setAddressMode(LLTexUnit::TAM_WRAP); } @@ -246,7 +246,7 @@ void LLDrawPoolTree::renderTree(BOOL selecting) LLGLState normalize(GL_NORMALIZE, TRUE); // Bind the texture for this tree. - gGL.getTexUnit(sDiffTex)->bind(mTexturep.get()); + gGL.getTexUnit(sDiffTex)->bind(mTexturep); U32 indices_drawn = 0; @@ -376,12 +376,12 @@ BOOL LLDrawPoolTree::verify() const return TRUE; } -LLViewerImage *LLDrawPoolTree::getTexture() +LLViewerTexture *LLDrawPoolTree::getTexture() { return mTexturep; } -LLViewerImage *LLDrawPoolTree::getDebugTexture() +LLViewerTexture *LLDrawPoolTree::getDebugTexture() { return mTexturep; } diff --git a/indra/newview/lldrawpooltree.h b/indra/newview/lldrawpooltree.h index 80c4fdfffe..bc7711d4e8 100644 --- a/indra/newview/lldrawpooltree.h +++ b/indra/newview/lldrawpooltree.h @@ -37,7 +37,7 @@ class LLDrawPoolTree : public LLFacePool { - LLPointer<LLViewerImage> mTexturep; + LLPointer<LLViewerTexture> mTexturep; public: enum { @@ -48,7 +48,7 @@ public: virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } - LLDrawPoolTree(LLViewerImage *texturep); + LLDrawPoolTree(LLViewerTexture *texturep); /*virtual*/ LLDrawPool *instancePool(); @@ -70,8 +70,8 @@ public: /*virtual*/ S32 getNumPasses() { return 1; } /*virtual*/ void renderForSelect(); /*virtual*/ BOOL verify() const; - /*virtual*/ LLViewerImage *getTexture(); - /*virtual*/ LLViewerImage *getDebugTexture(); + /*virtual*/ LLViewerTexture *getTexture(); + /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display static S32 sDiffTex; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4a593ac4f8..16623ca2b6 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -45,7 +45,7 @@ #include "lldrawable.h" #include "llface.h" #include "llsky.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llvosky.h" #include "llvowater.h" @@ -69,17 +69,17 @@ LLVector3 LLDrawPoolWater::sLightDir; LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER) { - mHBTex[0] = gImageList.getImage(gSunTextureID, TRUE, TRUE); - gGL.getTexUnit(0)->bind(mHBTex[0].get()); + mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, TRUE); + gGL.getTexUnit(0)->bind(mHBTex[0]) ; mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP); - mHBTex[1] = gImageList.getImage(gMoonTextureID, TRUE, TRUE); - gGL.getTexUnit(0)->bind(mHBTex[1].get()); + mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, TRUE); + gGL.getTexUnit(0)->bind(mHBTex[1]); mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP); - mWaterImagep = gImageList.getImage(WATER_TEST); + mWaterImagep = LLViewerTextureManager::getFetchedTexture(WATER_TEST); mWaterImagep->setNoDelete() ; - mWaterNormp = gImageList.getImage(DEFAULT_WATER_NORMAL); + mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL); mWaterNormp->setNoDelete() ; restoreGL(); @@ -184,7 +184,7 @@ void LLDrawPoolWater::render(S32 pass) mWaterImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bind(mWaterImagep.get()); + gGL.getTexUnit(1)->bind(mWaterImagep) ; LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis(); F32 up_dot = camera_up * LLVector3::z_axis; @@ -329,7 +329,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face) LLGLSNoFog noFog; - gGL.getTexUnit(0)->bind(mHBTex[dr].get()); + gGL.getTexUnit(0)->bind(mHBTex[dr]); LLOverrideFaceColor override(this, face->getFaceColor().mV); face->renderIndexed(); @@ -419,11 +419,11 @@ void LLDrawPoolWater::shade() // change mWaterNormp if needed if (mWaterNormp->getID() != param_mgr->getNormalMapID()) { - mWaterNormp = gImageList.getImage(param_mgr->getNormalMapID()); + mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID()); } mWaterNormp->addTextureStats(1024.f*1024.f); - gGL.getTexUnit(bumpTex)->bind(mWaterNormp.get()); + gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; if (gSavedSettings.getBOOL("RenderWaterMipNormal")) { mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); @@ -587,20 +587,9 @@ void LLDrawPoolWater::renderForSelect() return; } - -void LLDrawPoolWater::renderFaceSelected(LLFace *facep, - LLImageGL *image, - const LLColor4 &color, - const S32 index_offset, const S32 index_count) -{ - // Can't select water - return; -} - - -LLViewerImage *LLDrawPoolWater::getDebugTexture() +LLViewerTexture *LLDrawPoolWater::getDebugTexture() { - return LLViewerImage::sSmokeImagep; + return LLViewerFetchedTexture::sSmokeImagep; } LLColor3 LLDrawPoolWater::getDebugColor() const diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h index 6351041140..e28ac1cfab 100644 --- a/indra/newview/lldrawpoolwater.h +++ b/indra/newview/lldrawpoolwater.h @@ -43,9 +43,9 @@ class LLWaterSurface; class LLDrawPoolWater: public LLFacePool { protected: - LLPointer<LLViewerImage> mHBTex[2]; - LLPointer<LLViewerImage> mWaterImagep; - LLPointer<LLViewerImage> mWaterNormp; + LLPointer<LLViewerTexture> mHBTex[2]; + LLPointer<LLViewerTexture> mWaterImagep; + LLPointer<LLViewerTexture> mWaterNormp; const LLWaterSurface *mWaterSurface; public: @@ -78,12 +78,10 @@ public: /*virtual*/ S32 getNumPasses(); /*virtual*/ void render(S32 pass = 0); - /*virtual*/ void renderFaceSelected(LLFace *facep, LLImageGL *image, const LLColor4 &color, - const S32 index_offset = 0, const S32 index_count = 0); /*virtual*/ void prerender(); /*virtual*/ void renderForSelect(); - /*virtual*/ LLViewerImage *getDebugTexture(); + /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ LLColor3 getDebugColor() const; // For AGP debug display void renderReflection(LLFace* face); diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 6ff65c7ed0..917b6fafbc 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -47,7 +47,7 @@ #include "llface.h" #include "llrender.h" -LLPointer<LLImageGL> LLDrawPoolWLSky::sCloudNoiseTexture = NULL; +LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL; LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL; @@ -71,7 +71,7 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) : cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f); - LLImageGL::create(sCloudNoiseTexture, sCloudNoiseRawImage, TRUE); + sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); LLWLParamManager::instance()->propagateParameters(); } @@ -83,7 +83,7 @@ LLDrawPoolWLSky::~LLDrawPoolWLSky() sCloudNoiseRawImage = NULL; } -LLViewerImage *LLDrawPoolWLSky::getDebugTexture() +LLViewerTexture *LLDrawPoolWLSky::getDebugTexture() { return NULL; } @@ -224,7 +224,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN]; if (gSky.mVOSkyp->getSun().getDraw() && face->getGeomCount()) { - LLImageGL * tex = face->getTexture(); + LLViewerTexture * tex = face->getTexture(); gGL.getTexUnit(0)->bind(tex); LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); LLFacePool::LLOverrideFaceColor color_override(this, color); @@ -239,8 +239,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() // *NOTE: even though we already bound this texture above for the // stars register combiners, we bind again here for defensive reasons, // since LLImageGL::bind detects that it's a noop, and optimizes it out. - LLImageGL * tex = face->getTexture(); - gGL.getTexUnit(0)->bind(tex); + gGL.getTexUnit(0)->bind(face->getTexture()); LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; if (a > 0.f) @@ -280,9 +279,8 @@ void LLDrawPoolWLSky::render(S32 pass) // *NOTE: have to bind a texture here since register combiners blending in // renderStars() requires something to be bound and we might as well only - // bind the moon's texture once. - LLImageGL * tex = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(); - gGL.getTexUnit(0)->bind(tex); + // bind the moon's texture once. + gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); renderHeavenlyBodies(); @@ -306,7 +304,7 @@ LLDrawPoolWLSky *LLDrawPoolWLSky::instancePool() return new LLDrawPoolWLSky(); } -LLViewerImage* LLDrawPoolWLSky::getTexture() +LLViewerTexture* LLDrawPoolWLSky::getTexture() { return NULL; } @@ -324,5 +322,5 @@ void LLDrawPoolWLSky::cleanupGL() //static void LLDrawPoolWLSky::restoreGL() { - LLImageGL::create(sCloudNoiseTexture, sCloudNoiseRawImage, TRUE); + sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE); } diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index c7a1f3fe27..7ff760ac39 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -55,7 +55,7 @@ public: /*virtual*/ void endPostDeferredPass(S32 pass) { endRenderPass(pass); } /*virtual*/ void renderPostDeferred(S32 pass) { render(pass); } - /*virtual*/ LLViewerImage *getDebugTexture(); + /*virtual*/ LLViewerTexture *getDebugTexture(); /*virtual*/ void beginRenderPass( S32 pass ); /*virtual*/ void endRenderPass( S32 pass ); /*virtual*/ S32 getNumPasses() { return 1; } @@ -65,11 +65,11 @@ public: /*virtual*/ BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! /*virtual*/ S32 getVertexShaderLevel() const { return mVertexShaderLevel; } - //static LLDrawPool* createPool(const U32 type, LLViewerImage *tex0 = NULL); + //static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL); // Create an empty new instance of the pool. /*virtual*/ LLDrawPoolWLSky *instancePool(); ///< covariant override - /*virtual*/ LLViewerImage* getTexture(); + /*virtual*/ LLViewerTexture* getTexture(); /*virtual*/ BOOL isFacePool() { return FALSE; } /*virtual*/ void resetDrawOrders(); @@ -83,7 +83,7 @@ private: void renderHeavenlyBodies(); private: - static LLPointer<LLImageGL> sCloudNoiseTexture; + static LLPointer<LLViewerTexture> sCloudNoiseTexture; static LLPointer<LLImageRaw> sCloudNoiseRawImage; }; diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index 1953c29068..0bb5edf3f9 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -1,6 +1,6 @@ /** * @file lldynamictexture.cpp - * @brief Implementation of LLDynamicTexture class + * @brief Implementation of LLViewerDynamicTexture class * * $LicenseInfo:firstyear=2001&license=viewergpl$ * @@ -42,24 +42,20 @@ #include "llviewerwindow.h" #include "llviewercamera.h" #include "llviewercontrol.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llvertexbuffer.h" #include "llviewerdisplay.h" #include "llrender.h" // static -LLDynamicTexture::instance_list_t LLDynamicTexture::sInstances[ LLDynamicTexture::ORDER_COUNT ]; -S32 LLDynamicTexture::sNumRenders = 0; +LLViewerDynamicTexture::instance_list_t LLViewerDynamicTexture::sInstances[ LLViewerDynamicTexture::ORDER_COUNT ]; +S32 LLViewerDynamicTexture::sNumRenders = 0; //----------------------------------------------------------------------------- -// LLDynamicTexture() +// LLViewerDynamicTexture() //----------------------------------------------------------------------------- -LLDynamicTexture::LLDynamicTexture(S32 width, S32 height, S32 components, EOrder order, BOOL clamp) : - mWidth(width), - mHeight(height), - mComponents(components), - mTexture(NULL), - mLastBindTime(0), +LLViewerDynamicTexture::LLViewerDynamicTexture(S32 width, S32 height, S32 components, EOrder order, BOOL clamp) : + LLViewerTexture(width, height, components, FALSE), mClamp(clamp) { llassert((1 <= components) && (components <= 4)); @@ -67,64 +63,56 @@ LLDynamicTexture::LLDynamicTexture(S32 width, S32 height, S32 components, EOrder generateGLTexture(); llassert( 0 <= order && order < ORDER_COUNT ); - LLDynamicTexture::sInstances[ order ].insert(this); + LLViewerDynamicTexture::sInstances[ order ].insert(this); } //----------------------------------------------------------------------------- -// LLDynamicTexture() +// LLViewerDynamicTexture() //----------------------------------------------------------------------------- -LLDynamicTexture::~LLDynamicTexture() +LLViewerDynamicTexture::~LLViewerDynamicTexture() { - releaseGLTexture(); for( S32 order = 0; order < ORDER_COUNT; order++ ) { - LLDynamicTexture::sInstances[order].erase(this); // will fail in all but one case. + LLViewerDynamicTexture::sInstances[order].erase(this); // will fail in all but one case. } } -//----------------------------------------------------------------------------- -// releaseGLTexture() -//----------------------------------------------------------------------------- -void LLDynamicTexture::releaseGLTexture() +//virtual +S8 LLViewerDynamicTexture::getType() const { - if (mTexture.notNull()) - { -// llinfos << "RELEASING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; - mTexture = NULL; - } + return LLViewerTexture::DYNAMIC_TEXTURE ; } //----------------------------------------------------------------------------- // generateGLTexture() //----------------------------------------------------------------------------- -void LLDynamicTexture::generateGLTexture() +void LLViewerDynamicTexture::generateGLTexture() { + LLViewerTexture::generateGLTexture() ; generateGLTexture(-1, 0, 0, FALSE); } -void LLDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes) +void LLViewerDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes) { if (mComponents < 1 || mComponents > 4) { llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl; } - releaseGLTexture(); - LLPointer<LLImageRaw> raw_image = new LLImageRaw(mWidth, mHeight, mComponents); - mTexture = new LLViewerImage(mWidth, mHeight, mComponents, FALSE); + + LLPointer<LLImageRaw> raw_image = new LLImageRaw(mFullWidth, mFullHeight, mComponents); if (internal_format >= 0) { - mTexture->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); + setExplicitFormat(internal_format, primary_format, type_format, swap_bytes); } -// llinfos << "ALLOCATING " << (mWidth*mHeight*mComponents)/1024 << "K" << llendl; - mTexture->createGLTexture(0, raw_image); - mTexture->setAddressMode((mClamp) ? LLTexUnit::TAM_CLAMP : LLTexUnit::TAM_WRAP); - mTexture->setGLTextureCreated(false); + createGLTexture(0, raw_image); + setAddressMode((mClamp) ? LLTexUnit::TAM_CLAMP : LLTexUnit::TAM_WRAP); + mGLTexturep->setGLTextureCreated(false); } //----------------------------------------------------------------------------- // render() //----------------------------------------------------------------------------- -BOOL LLDynamicTexture::render() +BOOL LLViewerDynamicTexture::render() { return FALSE; } @@ -132,13 +120,13 @@ BOOL LLDynamicTexture::render() //----------------------------------------------------------------------------- // preRender() //----------------------------------------------------------------------------- -void LLDynamicTexture::preRender(BOOL clear_depth) +void LLViewerDynamicTexture::preRender(BOOL clear_depth) { { // force rendering to on-screen portion of frame buffer LLCoordScreen window_pos; gViewerWindow->getWindow()->getPosition( &window_pos ); - mOrigin.set(0, gViewerWindow->getWindowDisplayHeight() - mHeight); // top left corner + mOrigin.set(0, gViewerWindow->getWindowDisplayHeight() - mFullHeight); // top left corner if (window_pos.mX < 0) { @@ -159,7 +147,7 @@ void LLDynamicTexture::preRender(BOOL clear_depth) mCamera.setView(LLViewerCamera::getInstance()->getView()); mCamera.setNear(LLViewerCamera::getInstance()->getNear()); - glViewport(mOrigin.mX, mOrigin.mY, mWidth, mHeight); + glViewport(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight); if (clear_depth) { glClear(GL_DEPTH_BUFFER_BIT); @@ -169,12 +157,16 @@ void LLDynamicTexture::preRender(BOOL clear_depth) //----------------------------------------------------------------------------- // postRender() //----------------------------------------------------------------------------- -void LLDynamicTexture::postRender(BOOL success) +void LLViewerDynamicTexture::postRender(BOOL success) { { if (success) { - success = mTexture->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, mWidth, mHeight); + if(mGLTexturep.isNull()) + { + generateGLTexture() ; + } + success = mGLTexturep->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight); } } @@ -194,7 +186,7 @@ void LLDynamicTexture::postRender(BOOL success) // updateDynamicTextures() // Calls update on each dynamic texture. Calls each group in order: "first," then "middle," then "last." //----------------------------------------------------------------------------- -BOOL LLDynamicTexture::updateAllInstances() +BOOL LLViewerDynamicTexture::updateAllInstances() { sNumRenders = 0; if (gGLManager.mIsDisabled) @@ -206,10 +198,10 @@ BOOL LLDynamicTexture::updateAllInstances() BOOL ret = FALSE ; for( S32 order = 0; order < ORDER_COUNT; order++ ) { - for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin(); - iter != LLDynamicTexture::sInstances[order].end(); ++iter) + for (instance_list_t::iterator iter = LLViewerDynamicTexture::sInstances[order].begin(); + iter != LLViewerDynamicTexture::sInstances[order].end(); ++iter) { - LLDynamicTexture *dynamicTexture = *iter; + LLViewerDynamicTexture *dynamicTexture = *iter; if (dynamicTexture->needsRender()) { glClear(GL_DEPTH_BUFFER_BIT); @@ -236,30 +228,18 @@ BOOL LLDynamicTexture::updateAllInstances() return ret; } -//virtual -void LLDynamicTexture::restoreGLTexture() -{ - generateGLTexture() ; -} - -//virtual -void LLDynamicTexture::destroyGLTexture() -{ - releaseGLTexture() ; -} - //----------------------------------------------------------------------------- // static // destroyGL() //----------------------------------------------------------------------------- -void LLDynamicTexture::destroyGL() +void LLViewerDynamicTexture::destroyGL() { for( S32 order = 0; order < ORDER_COUNT; order++ ) { - for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin(); - iter != LLDynamicTexture::sInstances[order].end(); ++iter) + for (instance_list_t::iterator iter = LLViewerDynamicTexture::sInstances[order].begin(); + iter != LLViewerDynamicTexture::sInstances[order].end(); ++iter) { - LLDynamicTexture *dynamicTexture = *iter; + LLViewerDynamicTexture *dynamicTexture = *iter; dynamicTexture->destroyGLTexture() ; } } @@ -269,7 +249,7 @@ void LLDynamicTexture::destroyGL() // static // restoreGL() //----------------------------------------------------------------------------- -void LLDynamicTexture::restoreGL() +void LLViewerDynamicTexture::restoreGL() { if (gGLManager.mIsDisabled) { @@ -278,10 +258,10 @@ void LLDynamicTexture::restoreGL() for( S32 order = 0; order < ORDER_COUNT; order++ ) { - for (instance_list_t::iterator iter = LLDynamicTexture::sInstances[order].begin(); - iter != LLDynamicTexture::sInstances[order].end(); ++iter) + for (instance_list_t::iterator iter = LLViewerDynamicTexture::sInstances[order].begin(); + iter != LLViewerDynamicTexture::sInstances[order].end(); ++iter) { - LLDynamicTexture *dynamicTexture = *iter; + LLViewerDynamicTexture *dynamicTexture = *iter; dynamicTexture->restoreGLTexture() ; } } diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h index 22e5a4819d..c5fc83f9bb 100644 --- a/indra/newview/lldynamictexture.h +++ b/indra/newview/lldynamictexture.h @@ -1,6 +1,6 @@ /** * @file lldynamictexture.h - * @brief Implementation of LLDynamicTexture class + * @brief Implementation of LLViewerDynamicTexture class * * $LicenseInfo:firstyear=2002&license=viewergpl$ * @@ -36,59 +36,51 @@ #include "llcamera.h" #include "llgl.h" #include "llcoord.h" -#include "llimagegl.h" +#include "llviewertexture.h" -class LLDynamicTexture +class LLViewerDynamicTexture : public LLViewerTexture { +protected: + /*virtual*/ ~LLViewerDynamicTexture(); + public: enum EOrder { ORDER_FIRST = 0, ORDER_MIDDLE = 1, ORDER_LAST = 2, ORDER_RESET = 3, ORDER_COUNT = 4 }; - LLDynamicTexture(S32 width, + LLViewerDynamicTexture(S32 width, S32 height, S32 components, // = 4, EOrder order, // = ORDER_MIDDLE, BOOL clamp); - virtual ~LLDynamicTexture(); + + /*virtual*/ S8 getType() const ; S32 getOriginX() { return mOrigin.mX; } S32 getOriginY() { return mOrigin.mY; } - S32 getWidth() { return mWidth; } - S32 getHeight() { return mHeight; } - S32 getComponents() { return mComponents; } - S32 getSize() { return mWidth * mHeight * mComponents; } + + S32 getSize() { return mFullWidth * mFullHeight * mComponents; } virtual BOOL needsRender() { return TRUE; } virtual void preRender(BOOL clear_depth = TRUE); virtual BOOL render(); virtual void postRender(BOOL success); - virtual void restoreGLTexture() ; - virtual void destroyGLTexture() ; - - LLImageGL* getTexture(void) const { return mTexture; } + virtual void restoreGLTexture() {} + virtual void destroyGLTexture() {} static BOOL updateAllInstances(); - - static void destroyGL(); - static void restoreGL(); - + static void destroyGL() ; + static void restoreGL() ; protected: - void releaseGLTexture(); void generateGLTexture(); void generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes = FALSE); protected: - S32 mWidth; - S32 mHeight; - S32 mComponents; - LLPointer<LLImageGL> mTexture; - F32 mLastBindTime; BOOL mClamp; LLCoordGL mOrigin; - LLCamera mCamera; - typedef std::set<LLDynamicTexture*> instance_list_t; - static instance_list_t sInstances[ LLDynamicTexture::ORDER_COUNT ]; + + typedef std::set<LLViewerDynamicTexture*> instance_list_t; + static instance_list_t sInstances[ LLViewerDynamicTexture::ORDER_COUNT ]; static S32 sNumRenders; }; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 3dfe6a2820..bef9e40c49 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -47,7 +47,7 @@ #include "lllightconstants.h" #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llvosky.h" #include "llvovolume.h" #include "pipeline.h" @@ -179,6 +179,10 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) void LLFace::destroy() { + if(mTexture.notNull()) + { + mTexture->removeFace(this) ; + } if (mDrawPoolp) { mDrawPoolp->removeFace(this); @@ -217,7 +221,7 @@ void LLFace::setWorldMatrix(const LLMatrix4 &mat) llerrs << "Faces on this drawable are not independently modifiable\n" << llendl; } -void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) +void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep) { LLMemType mt1(LLMemType::MTYPE_DRAWABLE); @@ -247,9 +251,28 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) } mDrawPoolp = new_pool; } - mTexture = texturep; + setTexture(texturep) ; } +void LLFace::setTexture(LLViewerTexture* tex) +{ + if(mTexture == tex) + { + return ; + } + + if(mTexture.notNull()) + { + mTexture->removeFace(this) ; + } + + mTexture = tex ; + + if(mTexture.notNull()) + { + mTexture->addFace(this) ; + } +} void LLFace::setTEOffset(const S32 te_offset) { @@ -422,7 +445,7 @@ void LLFace::renderForSelect(U32 data_mask) } } -void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) +void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) { if(mDrawablep.isNull() || mVertexBuffer.isNull() || mDrawablep->getSpatialGroup() == NULL || mDrawablep->getSpatialGroup()->isState(LLSpatialGroup::GEOM_DIRTY)) @@ -463,8 +486,8 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color) /* removed in lieu of raycast uv detection void LLFace::renderSelectedUV() { - LLViewerImage* red_blue_imagep = gImageList.getImageFromFile("uv_test1.j2c", TRUE, TRUE); - LLViewerImage* green_imagep = gImageList.getImageFromFile("uv_test2.tga", TRUE, TRUE); + LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, TRUE); + LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, TRUE); LLGLSUVSelect object_select; @@ -998,7 +1021,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, break; case BE_BRIGHTNESS: case BE_DARKNESS: - if( mTexture.notNull() && mTexture->getHasGLTexture()) + if( mTexture.notNull() && mTexture->hasValidGLTexture()) { // Offset by approximately one texel S32 cur_discard = mTexture->getDiscardLevel(); @@ -1150,6 +1173,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, BOOL LLFace::verify(const U32* indices_array) const { BOOL ok = TRUE; + + if( mVertexBuffer.isNull() ) + { + if( mGeomCount ) + { + // This happens before teleports as faces are torn down. + // Stop the crash in DEV-31893 with a null pointer check, + // but present this info. + // To clean up the log, the geometry could be cleared, or the + // face could otherwise be marked for no ::verify. + llinfos << "Face with no vertex buffer and " << mGeomCount << " mGeomCount" << llendl; + } + return TRUE; + } + // First, check whether the face data fits within the pool's range. if ((mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts()) { diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 8332eec19c..e0728fe15e 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -45,15 +45,15 @@ #include "xform.h" #include "lldarrayptr.h" #include "llvertexbuffer.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "lldrawable.h" class LLFacePool; class LLVolume; -class LLViewerImage; +class LLViewerTexture; class LLTextureEntry; class LLVertexProgram; -class LLViewerImage; +class LLViewerTexture; class LLGeometryManager; const F32 MIN_ALPHA_SIZE = 1024.f; @@ -86,8 +86,8 @@ public: U16 getGeomCount() const { return mGeomCount; } // vertex count for this face U16 getGeomIndex() const { return mGeomIndex; } // index into draw pool U16 getGeomStart() const { return mGeomIndex; } // index into draw pool - LLViewerImage* getTexture() const { return mTexture; } - void setTexture(LLViewerImage* tex) { mTexture = tex; } + LLViewerTexture* getTexture() const { return mTexture; } + void setTexture(LLViewerTexture* tex) ; LLXformMatrix* getXform() const { return mXform; } BOOL hasGeometry() const { return mGeomCount > 0; } LLVector3 getPositionAgent() const; @@ -119,10 +119,10 @@ public: LLVertexBuffer* getVertexBuffer() const { return mVertexBuffer; } void setPoolType(U32 type) { mPoolType = type; } S32 getTEOffset() { return mTEOffset; } - LLViewerImage* getTexture() { return mTexture; } + LLViewerTexture* getTexture() { return mTexture; } void setViewerObject(LLViewerObject* object); - void setPool(LLFacePool *pool, LLViewerImage *texturep); + void setPool(LLFacePool *pool, LLViewerTexture *texturep); void setDrawable(LLDrawable *drawable); void setTEOffset(const S32 te_offset); @@ -171,7 +171,7 @@ public: void renderSelectedUV(); void renderForSelect(U32 data_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); - void renderSelected(LLImageGL *image, const LLColor4 &color); + void renderSelected(LLViewerTexture *image, const LLColor4 &color); F32 getKey() const { return mDistance; } @@ -222,7 +222,7 @@ protected: U32 mLastIndicesIndex; LLXformMatrix* mXform; - LLPointer<LLViewerImage> mTexture; + LLPointer<LLViewerTexture> mTexture; LLPointer<LLDrawable> mDrawablep; LLPointer<LLViewerObject> mVObjp; S32 mTEOffset; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index b373dd2241..f22114d3c8 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -44,7 +44,7 @@ #include "llsdserialize.h" #include "llappviewer.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llui.h" #include "llviewercontrol.h" #include "llstat.h" diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index b8e2840fe6..2a8365b3f0 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -47,7 +47,7 @@ #include "llviewercontrol.h" #include "llworld.h" #include "lldrawpoolterrain.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llwindow.h" #include "llui.h" #include "llcontrol.h" diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 8f2c6d538b..bafb69a835 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -39,11 +39,10 @@ #include "llglheaders.h" #include "llrendersphere.h" #include "llviewerobject.h" -#include "llimagegl.h" #include "llagent.h" #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewercontrol.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index 12c4932293..a1d9fed567 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -325,7 +325,6 @@ BOOL LLFloaterAnimPreview::postBuild() } else { - delete mAnimPreview; mAnimPreview = NULL; mMotionID.setNull(); childSetValue("bad_animation_text", getString("failed_to_initialize")); @@ -367,7 +366,6 @@ BOOL LLFloaterAnimPreview::postBuild() //----------------------------------------------------------------------------- LLFloaterAnimPreview::~LLFloaterAnimPreview() { - delete mAnimPreview; mAnimPreview = NULL; setEnabled(FALSE); @@ -387,7 +385,7 @@ void LLFloaterAnimPreview::draw() { gGL.color3f(1.f, 1.f, 1.f); - gGL.getTexUnit(0)->bind(mAnimPreview->getTexture()); + gGL.getTexUnit(0)->bind(mAnimPreview); gGL.begin( LLRender::QUADS ); { @@ -1017,7 +1015,7 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata) //----------------------------------------------------------------------------- // LLPreviewAnimation //----------------------------------------------------------------------------- -LLPreviewAnimation::LLPreviewAnimation(S32 width, S32 height) : LLDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) +LLPreviewAnimation::LLPreviewAnimation(S32 width, S32 height) : LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) { mNeedsUpdate = TRUE; mCameraDistance = PREVIEW_CAMERA_DISTANCE; @@ -1063,7 +1061,7 @@ BOOL LLPreviewAnimation::render() glMatrixMode(GL_PROJECTION); gGL.pushMatrix(); glLoadIdentity(); - glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); + glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); @@ -1073,7 +1071,7 @@ BOOL LLPreviewAnimation::render() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); - gl_rect_2d_simple( mWidth, mHeight ); + gl_rect_2d_simple( mFullWidth, mFullHeight ); glMatrixMode(GL_PROJECTION); gGL.popMatrix(); @@ -1095,7 +1093,7 @@ BOOL LLPreviewAnimation::render() target_pos + (mCameraOffset * av_rot) ); // point of interest LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); mCameraRelPos = LLViewerCamera::getInstance()->getOrigin() - avatarp->mHeadp->getWorldPosition(); diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h index 2f228c3ecd..7031e9a716 100644 --- a/indra/newview/llfloateranimpreview.h +++ b/indra/newview/llfloateranimpreview.h @@ -41,12 +41,14 @@ class LLVOAvatar; class LLViewerJointMesh; -class LLPreviewAnimation : public LLDynamicTexture +class LLPreviewAnimation : public LLViewerDynamicTexture { -public: - LLPreviewAnimation(S32 width, S32 height); +protected: virtual ~LLPreviewAnimation(); +public: + LLPreviewAnimation(S32 width, S32 height); + BOOL render(); void requestUpdate(); void rotate(F32 yaw_radians, F32 pitch_radians); @@ -114,7 +116,7 @@ protected: void draw(); void resetMotion(); - LLPreviewAnimation* mAnimPreview; + LLPointer< LLPreviewAnimation > mAnimPreview; S32 mLastMouseX; S32 mLastMouseY; LLButton* mPlayButton; diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp index f5d950a9a5..da2a4d9d93 100644 --- a/indra/newview/llfloaterauction.cpp +++ b/indra/newview/llfloaterauction.cpp @@ -47,7 +47,7 @@ #include "llcombobox.h" #include "llnotify.h" #include "llsavedsettingsglue.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "lluictrlfactory.h" @@ -186,7 +186,7 @@ void LLFloaterAuction::onClickSnapshot(void* data) tga->encode(raw); LLVFile::writeFile(tga->getData(), tga->getDataSize(), gVFS, self->mImageID, LLAssetType::AT_IMAGE_TGA); - raw->biasedScaleToPowerOfTwo(LLViewerImage::MAX_IMAGE_SIZE_DEFAULT); + raw->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT); llinfos << "Writing J2C..." << llendl; @@ -194,7 +194,7 @@ void LLFloaterAuction::onClickSnapshot(void* data) j2c->encode(raw, 0.0f); LLVFile::writeFile(j2c->getData(), j2c->getDataSize(), gVFS, self->mImageID, LLAssetType::AT_TEXTURE); - self->mImage = new LLImageGL((LLImageRaw*)raw, FALSE); + self->mImage = LLViewerTextureManager::getLocalTexture((LLImageRaw*)raw, FALSE); gGL.getTexUnit(0)->bind(self->mImage); self->mImage->setAddressMode(LLTexUnit::TAM_CLAMP); } diff --git a/indra/newview/llfloaterauction.h b/indra/newview/llfloaterauction.h index ebb1a0d1ae..86de0ae966 100644 --- a/indra/newview/llfloaterauction.h +++ b/indra/newview/llfloaterauction.h @@ -37,7 +37,7 @@ #include "llfloater.h" #include "lluuid.h" #include "llpointer.h" -#include "llviewerimage.h" +#include "llviewertexture.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLFloaterAuction @@ -69,7 +69,7 @@ private: private: LLTransactionID mTransactionID; LLAssetID mImageID; - LLPointer<LLImageGL> mImage; + LLPointer<LLViewerTexture> mImage; LLSafeHandle<LLParcelSelection> mParcelp; S32 mParcelID; LLHost mParcelHost; diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index edc96715cd..c140518759 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -56,7 +56,6 @@ #include "llpointer.h" #include "llimage.h" #include "llmousehandler.h" -#include "llimagegl.h" #include "llglheaders.h" #include "llcheckboxctrl.h" #include "lltextbox.h" @@ -161,7 +160,7 @@ void LLFloaterColorPicker::createUI () * ( bits + x + y * linesize + 2 ) = ( U8 )( bVal * 255.0f ); } } - mRGBImage = new LLImageGL ( (LLImageRaw*)raw, FALSE ); + mRGBImage = LLViewerTextureManager::getLocalTexture( (LLImageRaw*)raw, FALSE ); gGL.getTexUnit(0)->bind(mRGBImage); mRGBImage->setAddressMode(LLTexUnit::TAM_CLAMP); diff --git a/indra/newview/llfloatercolorpicker.h b/indra/newview/llfloatercolorpicker.h index 16f456b5bf..a16cde7f10 100644 --- a/indra/newview/llfloatercolorpicker.h +++ b/indra/newview/llfloatercolorpicker.h @@ -175,7 +175,7 @@ class LLFloaterColorPicker const S32 mPaletteRegionHeight; // image used to compose color grid - LLPointer<LLImageGL> mRGBImage; + LLPointer<LLViewerTexture> mRGBImage; // current swatch in use LLColorSwatchCtrl* mSwatch; diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 9999b58e5b..5a4de579c2 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -56,7 +56,7 @@ #include "lltrans.h" #include "lluictrlfactory.h" #include "llviewergesture.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerinventory.h" #include "llvoavatar.h" #include "llviewercontrol.h" diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index 38915ebff9..ef1d43f2f6 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -38,7 +38,7 @@ #include "llfloaterpreference.h" #include "llviewerwindow.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llfeaturemanager.h" #include "llstartup.h" #include "pipeline.h" @@ -47,7 +47,6 @@ #include "llradiogroup.h" #include "lluictrlfactory.h" #include "llwindow.h" -#include "llimagegl.h" LLFloaterHardwareSettings* LLFloaterHardwareSettings::sHardwareSettings = NULL; @@ -91,8 +90,8 @@ void LLFloaterHardwareSettings::refresh() void LLFloaterHardwareSettings::refreshEnabledState() { - S32 min_tex_mem = LLViewerImageList::getMinVideoRamSetting(); - S32 max_tex_mem = LLViewerImageList::getMaxVideoRamSetting(); + S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); + S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(); childSetMinValue("GrapicsCardTextureMemory", min_tex_mem); childSetMaxValue("GrapicsCardTextureMemory", max_tex_mem); diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index faa4f0ec99..26b969224e 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -56,7 +56,7 @@ #include "llvoavatar.h" #include "pipeline.h" #include "lluictrlfactory.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llstring.h" //static @@ -142,9 +142,6 @@ LLFloaterImagePreview::~LLFloaterImagePreview() clearAllPreviewTextures(); mRawImagep = NULL; - delete mAvatarPreview; - delete mSculptedPreview; - mImagep = NULL ; } @@ -252,7 +249,7 @@ void LLFloaterImagePreview::draw() } else { - mImagep = new LLImageGL(mRawImagep, FALSE) ; + mImagep = LLViewerTextureManager::getLocalTexture(mRawImagep.get(), FALSE) ; gGL.getTexUnit(0)->unbind(mImagep->getTarget()) ; gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); @@ -294,11 +291,11 @@ void LLFloaterImagePreview::draw() if (selected == 9) { - gGL.getTexUnit(0)->bind(mSculptedPreview->getTexture()); + gGL.getTexUnit(0)->bind(mSculptedPreview); } else { - gGL.getTexUnit(0)->bind(mAvatarPreview->getTexture()); + gGL.getTexUnit(0)->bind(mAvatarPreview); } gGL.begin( LLRender::QUADS ); @@ -606,7 +603,7 @@ void LLFloaterImagePreview::onMouseCaptureLostImagePreview(LLMouseHandler* handl //----------------------------------------------------------------------------- // LLImagePreviewAvatar //----------------------------------------------------------------------------- -LLImagePreviewAvatar::LLImagePreviewAvatar(S32 width, S32 height) : LLDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) +LLImagePreviewAvatar::LLImagePreviewAvatar(S32 width, S32 height) : LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) { mNeedsUpdate = TRUE; mTargetJoint = NULL; @@ -697,7 +694,7 @@ BOOL LLImagePreviewAvatar::render() glMatrixMode(GL_PROJECTION); gGL.pushMatrix(); glLoadIdentity(); - glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); + glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); @@ -706,7 +703,7 @@ BOOL LLImagePreviewAvatar::render() LLGLSUIDefault def; gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); - gl_rect_2d_simple( mWidth, mHeight ); + gl_rect_2d_simple( mFullWidth, mFullHeight ); glMatrixMode(GL_PROJECTION); gGL.popMatrix(); @@ -728,9 +725,9 @@ BOOL LLImagePreviewAvatar::render() stop_glerror(); - LLViewerCamera::getInstance()->setAspect((F32)mWidth / mHeight); + LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / mFullHeight); LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); LLVertexBuffer::unbind(); avatarp->updateLOD(); @@ -788,7 +785,7 @@ void LLImagePreviewAvatar::pan(F32 right, F32 up) // LLImagePreviewSculpted //----------------------------------------------------------------------------- -LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) +LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -871,7 +868,7 @@ BOOL LLImagePreviewSculpted::render() glMatrixMode(GL_PROJECTION); gGL.pushMatrix(); glLoadIdentity(); - glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); + glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); @@ -879,7 +876,7 @@ BOOL LLImagePreviewSculpted::render() gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); - gl_rect_2d_simple( mWidth, mHeight ); + gl_rect_2d_simple( mFullWidth, mFullHeight ); glMatrixMode(GL_PROJECTION); gGL.popMatrix(); @@ -902,9 +899,9 @@ BOOL LLImagePreviewSculpted::render() stop_glerror(); - LLViewerCamera::getInstance()->setAspect((F32) mWidth / mHeight); + LLViewerCamera::getInstance()->setAspect((F32) mFullWidth / mFullHeight); LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); const LLVolumeFace &vf = mVolume->getVolumeFace(0); U32 num_indices = vf.mIndices.size(); diff --git a/indra/newview/llfloaterimagepreview.h b/indra/newview/llfloaterimagepreview.h index 6a4de3d3cc..e2781b8231 100644 --- a/indra/newview/llfloaterimagepreview.h +++ b/indra/newview/llfloaterimagepreview.h @@ -44,12 +44,14 @@ class LLVOAvatar; class LLTextBox; class LLVertexBuffer; -class LLImagePreviewSculpted : public LLDynamicTexture +class LLImagePreviewSculpted : public LLViewerDynamicTexture { - public: - LLImagePreviewSculpted(S32 width, S32 height); +protected: virtual ~LLImagePreviewSculpted(); + public: + LLImagePreviewSculpted(S32 width, S32 height); + void setPreviewTarget(LLImageRaw *imagep, F32 distance); void setTexture(U32 name) { mTextureName = name; } @@ -73,12 +75,14 @@ class LLImagePreviewSculpted : public LLDynamicTexture }; -class LLImagePreviewAvatar : public LLDynamicTexture +class LLImagePreviewAvatar : public LLViewerDynamicTexture { -public: - LLImagePreviewAvatar(S32 width, S32 height); +protected: virtual ~LLImagePreviewAvatar(); +public: + LLImagePreviewAvatar(S32 width, S32 height); + void setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male); void setTexture(U32 name) { mTextureName = name; } void clearPreviewTexture(const std::string& mesh_name); @@ -127,13 +131,13 @@ protected: bool loadImage(const std::string& filename); LLPointer<LLImageRaw> mRawImagep; - LLImagePreviewAvatar* mAvatarPreview; - LLImagePreviewSculpted* mSculptedPreview; + LLPointer<LLImagePreviewAvatar> mAvatarPreview; + LLPointer<LLImagePreviewSculpted> mSculptedPreview; S32 mLastMouseX; S32 mLastMouseY; LLRect mPreviewRect; LLRectf mPreviewImageRect; - LLPointer<LLImageGL> mImagep ; + LLPointer<LLViewerTexture> mImagep ; static S32 sUploadAmount; }; diff --git a/indra/newview/llfloaterinventory.cpp b/indra/newview/llfloaterinventory.cpp index 0dd1d6adcd..634126202f 100644 --- a/indra/newview/llfloaterinventory.cpp +++ b/indra/newview/llfloaterinventory.cpp @@ -77,7 +77,6 @@ #include "lltabcontainer.h" #include "lltooldraganddrop.h" #include "lluictrlfactory.h" -#include "llviewerimagelist.h" #include "llviewerinventory.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp index 262102b820..da6dceb149 100644 --- a/indra/newview/llfloaterlagmeter.cpp +++ b/indra/newview/llfloaterlagmeter.cpp @@ -36,7 +36,7 @@ #include "lluictrlfactory.h" #include "llviewerstats.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewercontrol.h" #include "llappviewer.h" @@ -185,7 +185,7 @@ void LLFloaterLagMeter::determineClient() { mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) ); } - else if((BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes)) > LLViewerImage::sMaxBoundTextureMemInMegaBytes) + else if((BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes)) > LLViewerTexture::sMaxBoundTextureMemInMegaBytes) { mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) ); } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 039873691d..f7e5eaadd3 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -68,7 +68,7 @@ #include "lltexturectrl.h" #include "lluiconstants.h" #include "lluictrlfactory.h" -#include "llviewerimagelist.h" // LLUIImageList +#include "llviewertexturelist.h" // LLUIImageList #include "llviewermessage.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index ee49da3f05..c04eae2c68 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -39,6 +39,7 @@ #include "llfloater.h" #include "llpointer.h" // LLPointer<> +//#include "llviewertexturelist.h" #include "llsafehandle.h" typedef std::set<LLUUID, lluuid_less> uuid_list_t; diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp index 4a68e3092e..696531c208 100644 --- a/indra/newview/llfloaterpostcard.cpp +++ b/indra/newview/llfloaterpostcard.cpp @@ -61,7 +61,7 @@ #include "llimagej2c.h" #include "llvfile.h" #include "llvfs.h" - +#include "llviewertexture.h" #include "llassetuploadresponders.h" #include <boost/regex.hpp> //boost.regex lib @@ -77,7 +77,7 @@ LLFloaterPostcard::instance_list_t LLFloaterPostcard::sInstances; /// Class LLFloaterPostcard ///---------------------------------------------------------------------------- -LLFloaterPostcard::LLFloaterPostcard(LLImageJPEG* jpeg, LLImageGL *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global) +LLFloaterPostcard::LLFloaterPostcard(LLImageJPEG* jpeg, LLViewerTexture *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global) : LLFloater(), mJPEGImage(jpeg), mViewerImage(img), @@ -130,7 +130,7 @@ BOOL LLFloaterPostcard::postBuild() // static -LLFloaterPostcard* LLFloaterPostcard::showFromSnapshot(LLImageJPEG *jpeg, LLImageGL *img, const LLVector2 &image_scale, const LLVector3d& pos_taken_global) +LLFloaterPostcard* LLFloaterPostcard::showFromSnapshot(LLImageJPEG *jpeg, LLViewerTexture *img, const LLVector2 &image_scale, const LLVector3d& pos_taken_global) { // Take the images from the caller // It's now our job to clean them up @@ -181,7 +181,7 @@ void LLFloaterPostcard::draw() rect.mBottom, rect.getWidth(), rect.getHeight(), - mViewerImage, + mViewerImage.get(), LLColor4::white); } glMatrixMode(GL_TEXTURE); diff --git a/indra/newview/llfloaterpostcard.h b/indra/newview/llfloaterpostcard.h index 5abb97e15f..98910f85f9 100644 --- a/indra/newview/llfloaterpostcard.h +++ b/indra/newview/llfloaterpostcard.h @@ -41,20 +41,20 @@ class LLTextEditor; class LLLineEditor; class LLButton; -class LLImageGL; +class LLViewerTexture; class LLImageJPEG; class LLFloaterPostcard : public LLFloater { public: - LLFloaterPostcard(LLImageJPEG* jpeg, LLImageGL *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global); + LLFloaterPostcard(LLImageJPEG* jpeg, LLViewerTexture *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global); virtual ~LLFloaterPostcard(); virtual BOOL postBuild(); virtual void draw(); - static LLFloaterPostcard* showFromSnapshot(LLImageJPEG *jpeg, LLImageGL *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global); + static LLFloaterPostcard* showFromSnapshot(LLImageJPEG *jpeg, LLViewerTexture *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global); static void onClickCancel(void* data); static void onClickSend(void* data); @@ -73,7 +73,7 @@ public: protected: LLPointer<LLImageJPEG> mJPEGImage; - LLPointer<LLImageGL> mViewerImage; + LLPointer<LLViewerTexture> mViewerImage; LLTransactionID mTransactionID; LLAssetID mAssetID; LLVector2 mImageScale; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 53b88d9f57..f6a50057bc 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -91,13 +91,8 @@ #include "llspinctrl.h" #include "llstartup.h" #include "lltextbox.h" - #include "llui.h" - -#include "llviewerimage.h" -#include "llviewerimagelist.h" #include "llviewerobjectlist.h" - #include "llvoavatar.h" #include "llvovolume.h" #include "llwindow.h" diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 99c1414461..009902b453 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -76,8 +76,8 @@ #include "llviewercontrol.h" #include "lluictrlfactory.h" #include "llviewerinventory.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llviewerstats.h" #include "llviewertexteditor.h" @@ -1144,11 +1144,11 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() if (!texture_ctrl) continue; LLUUID image_asset_id = texture_ctrl->getImageAssetID(); - LLViewerImage* img = gImageList.getImage(image_asset_id); + LLViewerTexture* img = LLViewerTextureManager::getFetchedTexture(image_asset_id); S32 components = img->getComponents(); // Must ask for highest resolution version's width. JC - S32 width = img->getWidth(0); - S32 height = img->getHeight(0); + S32 width = img->getFullWidth(); + S32 height = img->getFullHeight(); //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl; diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 513a6a06b1..8c96734057 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -73,7 +73,7 @@ #include "lltoolmgr.h" #include "llresourcedata.h" // for LLResourceData #include "llviewerwindow.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llworldmap.h" #include "llfilepicker.h" #include "llfloateravatarpicker.h" @@ -825,7 +825,7 @@ void LLFloaterReporter::takeScreenshot() llwarns << "Unable to take screenshot" << llendl; return; } - LLPointer<LLImageJ2C> upload_data = LLViewerImageList::convertToUploadFile(raw); + LLPointer<LLImageJ2C> upload_data = LLViewerTextureList::convertToUploadFile(raw); // create a resource data mResourceDatap->mInventoryType = LLInventoryType::IT_NONE; @@ -855,10 +855,10 @@ void LLFloaterReporter::takeScreenshot() mResourceDatap->mAssetInfo.mType); // store in the image list so it doesn't try to fetch from the server - LLPointer<LLViewerImage> image_in_list = new LLViewerImage(mResourceDatap->mAssetInfo.mUuid, TRUE); + LLPointer<LLViewerFetchedTexture> image_in_list = + LLViewerTextureManager::getFetchedTexture(mResourceDatap->mAssetInfo.mUuid, TRUE, FALSE, LLViewerTexture::FETCHED_TEXTURE); image_in_list->createGLTexture(0, raw); - gImageList.addImage(image_in_list); - + // the texture picker then uses that texture LLTexturePicker* texture = getChild<LLTextureCtrl>("screenshot"); if (texture) diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h index da1dda9c78..52bea736bf 100644 --- a/indra/newview/llfloaterreporter.h +++ b/indra/newview/llfloaterreporter.h @@ -39,7 +39,7 @@ #include "v3math.h" class LLMessageSystem; -class LLViewerImage; +class LLViewerTexture; class LLInventoryItem; class LLViewerObject; class LLAgent; diff --git a/indra/newview/llfloaterscriptdebug.cpp b/indra/newview/llfloaterscriptdebug.cpp index b2bb343681..6cca4927a9 100644 --- a/indra/newview/llfloaterscriptdebug.cpp +++ b/indra/newview/llfloaterscriptdebug.cpp @@ -45,7 +45,7 @@ #include "llviewertexteditor.h" #include "llviewercontrol.h" #include "llviewerobjectlist.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" // // Statics @@ -131,7 +131,7 @@ void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std: if (objectp) { - objectp->setIcon(gImageList.getImageFromFile("script_error.j2c", TRUE, TRUE)); + objectp->setIcon(LLViewerTextureManager::getFetchedTextureFromFile("script_error.j2c", TRUE, TRUE)); floater_label = llformat("%s(%.2f, %.2f)", user_name.c_str(), objectp->getPositionRegion().mV[VX], objectp->getPositionRegion().mV[VY]); } else diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index fef0474062..38d8420c96 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -140,12 +140,12 @@ public: LLFloaterSnapshot::ESnapshotFormat getSnapshotFormat() const { return mSnapshotFormat; } BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } BOOL isSnapshotActive() { return mSnapshotActive; } - LLImageGL* getThumbnailImage() const { return mThumbnailImage ; } + LLViewerTexture* getThumbnailImage() const { return mThumbnailImage ; } S32 getThumbnailWidth() const { return mThumbnailWidth ; } S32 getThumbnailHeight() const { return mThumbnailHeight ; } BOOL getThumbnailLock() const { return mThumbnailUpdateLock ; } BOOL getThumbnailUpToDate() const { return mThumbnailUpToDate ;} - LLImageGL* getCurrentImage(); + LLViewerTexture* getCurrentImage(); F32 getImageAspect(); F32 getAspect() ; LLRect getImageRect(); @@ -170,7 +170,7 @@ public: private: LLColor4 mColor; - LLPointer<LLImageGL> mViewerImage[2]; //used to represent the scene when the frame is frozen. + LLPointer<LLViewerTexture> mViewerImage[2]; //used to represent the scene when the frame is frozen. LLRect mImageRect[2]; S32 mWidth[2]; S32 mHeight[2]; @@ -178,7 +178,7 @@ private: S32 mMaxImageSize ; //thumbnail image - LLPointer<LLImageGL> mThumbnailImage ; + LLPointer<LLViewerTexture> mThumbnailImage ; S32 mThumbnailWidth ; S32 mThumbnailHeight ; LLRect mPreviewRect ; @@ -278,7 +278,7 @@ void LLSnapshotLivePreview::setMaxImageSize(S32 size) } } -LLImageGL* LLSnapshotLivePreview::getCurrentImage() +LLViewerTexture* LLSnapshotLivePreview::getCurrentImage() { return mViewerImage[mCurImageIndex]; } @@ -723,7 +723,7 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) if(raw) { - mThumbnailImage = new LLImageGL(raw, FALSE); + mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mThumbnailUpToDate = TRUE ; } @@ -871,8 +871,8 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) scaled->expandToPowerOfTwo(1024, FALSE); } - previewp->mViewerImage[previewp->mCurImageIndex] = new LLImageGL(scaled, FALSE); - LLPointer<LLImageGL> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex]; + previewp->mViewerImage[previewp->mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE); + LLPointer<LLViewerTexture> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex]; gGL.getTexUnit(0)->bind(curr_preview_image); if (previewp->getSnapshotType() != SNAPSHOT_TEXTURE) { diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index d0a82f283c..6ef011f1de 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -47,8 +47,8 @@ #include "lltooldraganddrop.h" #include "lltrans.h" #include "llui.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewerjointattachment.h" #include "llviewermenu.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index e8f0c4130e..d944a4fa18 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -55,7 +55,7 @@ #include "stdenums.h" #include "llfontgl.h" #include "lleditmenuhandler.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "lldepthstack.h" #include "lltooldraganddrop.h" // JAMESDEBUG - move this up diff --git a/indra/newview/llhudeffect.cpp b/indra/newview/llhudeffect.cpp index c1d46f98d4..bfd62805a1 100644 --- a/indra/newview/llhudeffect.cpp +++ b/indra/newview/llhudeffect.cpp @@ -38,7 +38,6 @@ #include "llgl.h" #include "llagent.h" #include "llrendersphere.h" -#include "llimagegl.h" #include "llviewerobjectlist.h" #include "lldrawable.h" diff --git a/indra/newview/llhudeffectbeam.cpp b/indra/newview/llhudeffectbeam.cpp index 6cb3bef751..43a8dd1d81 100644 --- a/indra/newview/llhudeffectbeam.cpp +++ b/indra/newview/llhudeffectbeam.cpp @@ -43,7 +43,6 @@ #include "llgl.h" #include "llglheaders.h" #include "llhudrender.h" -#include "llimagegl.h" #include "llrendersphere.h" #include "llviewercamera.h" #include "llvoavatar.h" diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp index 0ade6810ba..786491211d 100644 --- a/indra/newview/llhudeffecttrail.cpp +++ b/indra/newview/llhudeffecttrail.cpp @@ -35,14 +35,13 @@ #include "llhudeffecttrail.h" #include "llviewercontrol.h" -#include "llimagegl.h" #include "message.h" #include "llagent.h" #include "llbox.h" #include "lldrawable.h" #include "llhudrender.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobjectlist.h" #include "llviewerpartsim.h" #include "llviewerpartsource.h" diff --git a/indra/newview/llhudicon.cpp b/indra/newview/llhudicon.cpp index 3535fe185c..eda1d3fc55 100644 --- a/indra/newview/llhudicon.cpp +++ b/indra/newview/llhudicon.cpp @@ -40,7 +40,7 @@ #include "llviewerobject.h" #include "lldrawable.h" #include "llviewercamera.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewerwindow.h" //----------------------------------------------------------------------------- @@ -144,7 +144,7 @@ void LLHUDIcon::renderIcon(BOOL for_select) alpha_factor *= clamp_rescale(time_elapsed, MAX_VISIBLE_TIME - FADE_OUT_TIME, MAX_VISIBLE_TIME, 1.f, 0.f); } - F32 image_aspect = (F32)mImagep->mFullWidth / (F32)mImagep->mFullHeight; + F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight() ; LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * x_pixel_vec; LLVector3 y_scale = (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * y_pixel_vec; @@ -164,7 +164,7 @@ void LLHUDIcon::renderIcon(BOOL for_select) LLColor4 icon_color = LLColor4::white; icon_color.mV[VALPHA] = alpha_factor; gGL.color4fv(icon_color.mV); - gGL.getTexUnit(0)->bind(mImagep.get()); + gGL.getTexUnit(0)->bind(mImagep); } gGL.begin(LLRender::QUADS); @@ -181,7 +181,7 @@ void LLHUDIcon::renderIcon(BOOL for_select) gGL.end(); } -void LLHUDIcon::setImage(LLViewerImage* imagep) +void LLHUDIcon::setImage(LLViewerTexture* imagep) { mImagep = imagep; mImagep->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -260,7 +260,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en return FALSE; } - F32 image_aspect = (F32)mImagep->mFullWidth / (F32)mImagep->mFullHeight; + F32 image_aspect = (F32)mImagep->getFullWidth() / (F32)mImagep->getFullHeight() ; LLVector3 x_scale = image_aspect * (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * x_pixel_vec; LLVector3 y_scale = (F32)gViewerWindow->getWindowHeight() * mScale * scale_factor * y_pixel_vec; diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h index 2c1c549521..770e3bbcd0 100644 --- a/indra/newview/llhudicon.h +++ b/indra/newview/llhudicon.h @@ -61,7 +61,7 @@ public: /*virtual*/ void markDead(); /*virtual*/ F32 getDistance() const { return mDistance; } - void setImage(LLViewerImage* imagep); + void setImage(LLViewerTexture* imagep); void setScale(F32 fraction_of_fov); void restartLifeTimer() { mLifeTimer.reset(); } @@ -88,7 +88,7 @@ protected: void renderIcon(BOOL for_select); // common render code private: - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerTexture> mImagep; LLFrameTimer mAnimTimer; LLFrameTimer mLifeTimer; F32 mDistance; diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index fe65a12c47..4c8c1b5f7f 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -40,7 +40,6 @@ #include "v3math.h" #include "llquaternion.h" #include "llfontgl.h" -#include "llimagegl.h" #include "llglheaders.h" #include "llviewerwindow.h" diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index abb3acd974..953d99c7ac 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -45,10 +45,9 @@ #include "llfontgl.h" #include "llglheaders.h" #include "llhudrender.h" -#include "llimagegl.h" #include "llui.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobject.h" #include "llvovolume.h" #include "llviewerwindow.h" diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 9d1b24ae11..d4c40689ce 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -75,7 +75,7 @@ #include "llscrollcontainer.h" #include "llimview.h" #include "lltooldraganddrop.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerinventory.h" #include "llviewerobjectlist.h" #include "llviewerwindow.h" diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index d63eebfcac..efc03b3d88 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -42,8 +42,8 @@ // Project includes #include "llui.h" #include "llagent.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llmoveview.h" @@ -552,7 +552,7 @@ void LLJoystickCameraRotate::draw() } // Draws image rotated by multiples of 90 degrees -void LLJoystickCameraRotate::drawRotatedImage( LLImageGL* image, S32 rotations ) +void LLJoystickCameraRotate::drawRotatedImage( LLTexture* image, S32 rotations ) { S32 width = image->getWidth(); S32 height = image->getHeight(); diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index d0f63803ea..8caef30fa4 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -35,7 +35,7 @@ #include "llbutton.h" #include "llcoord.h" -#include "llviewerimage.h" +#include "llviewertexture.h" typedef enum e_joystick_quadrant { @@ -150,7 +150,7 @@ public: protected: F32 getOrbitRate(); virtual void updateSlop(); - void drawRotatedImage( LLImageGL* image, S32 rotations ); + void drawRotatedImage( LLTexture* image, S32 rotations ); protected: BOOL mInLeft; diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 062e781d49..3d1d6cad74 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -40,7 +40,7 @@ #include "llrender.h" #include "llprimitive.h" #include "llview.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llagent.h" #include "llviewercontrol.h" diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 3a1ffd6546..cc2531d139 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -78,7 +78,7 @@ const F32 PLANE_TICK_SIZE = 0.4f; const F32 MANIPULATOR_SCALE_HALF_LIFE = 0.07f; const F32 SNAP_ARROW_SCALE = 0.7f; -static LLPointer<LLImageGL> sGridTex = NULL ; +static LLPointer<LLViewerTexture> sGridTex = NULL ; const LLManip::EManipPart MANIPULATOR_IDS[9] = { @@ -154,7 +154,7 @@ void LLManipTranslate::restoreGL() U32 mip = 0; destroyGL() ; - sGridTex = new LLImageGL() ; + sGridTex = LLViewerTextureManager::getLocalTexture() ; if(!sGridTex->createGLTexture()) { sGridTex = NULL ; diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 510933a331..7b0b0c2fb7 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -51,6 +51,9 @@ #include "llsurface.h" #include "llviewercamera.h" #include "llviewercontrol.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" +#include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llworld.h" @@ -664,7 +667,7 @@ void LLNetMap::createObjectImage() mObjectRawImagep = new LLImageRaw(img_size, img_size, 4); U8* data = mObjectRawImagep->getData(); memset( data, 0, img_size * img_size * 4 ); - mObjectImagep = new LLImageGL( mObjectRawImagep, FALSE); + mObjectImagep = LLViewerTextureManager::getLocalTexture( mObjectRawImagep.get(), FALSE); setScale(mScale); } mUpdateNow = TRUE; diff --git a/indra/newview/llnetmap.h b/indra/newview/llnetmap.h index cebc4af165..a673ea3f57 100644 --- a/indra/newview/llnetmap.h +++ b/indra/newview/llnetmap.h @@ -39,11 +39,11 @@ #include "v3dmath.h" #include "v4color.h" #include "llimage.h" -#include "llimagegl.h" class LLColor4U; class LLCoordGL; class LLTextBox; +class LLViewerTexture ; class LLNetMap : public LLUICtrl { @@ -106,7 +106,7 @@ private: BOOL mUpdateNow; LLVector3d mObjectImageCenterGlobal; LLPointer<LLImageRaw> mObjectRawImagep; - LLPointer<LLImageGL> mObjectImagep; + LLPointer<LLViewerTexture> mObjectImagep; LLUUID mClosestAgentToCursor; LLUUID mClosestAgentAtLastRightClick; diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp index 2ccd729e0a..d03e39280f 100644 --- a/indra/newview/lloverlaybar.cpp +++ b/indra/newview/lloverlaybar.cpp @@ -49,7 +49,7 @@ #include "lltextbox.h" #include "llui.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerjoystick.h" #include "llviewermedia.h" #include "llviewermenu.h" // handle_reset_view() diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 2ff22416ec..e9e71644b1 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -411,7 +411,7 @@ void LLPanelFace::getState() { LLUUID get(LLViewerObject* object, S32 te) { - LLViewerImage* image = object->getTEImage(te); + LLViewerTexture* image = object->getTEImage(te); return image ? image->getID() : LLUUID::null; } } func; diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 9e537be425..365f07e4b6 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -49,7 +49,7 @@ #include "lltabcontainer.h" #include "lltextbox.h" #include "lltexteditor.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llfocusmgr.h" diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 75df49e5e3..9beecf75eb 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -57,7 +57,7 @@ #include "lluiconstants.h" #include "llurlsimstring.h" #include "llviewerbuild.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" // for handle_preferences() #include "llviewernetwork.h" #include "llviewerwindow.h" // to link into child list @@ -362,7 +362,7 @@ LLPanelLogin::~LLPanelLogin() gResponsePtr->setParent( 0 ); //// We know we're done with the image, so be rid of it. - //gImageList.deleteImage( mLogoImage ); + //gTextureList.deleteImage( mLogoImage ); } // virtual diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index d6ecb42255..9122e49a06 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -46,8 +46,8 @@ #include "lltextbox.h" #include "lltextureview.h" #include "llui.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "lluictrlfactory.h" #include "llviewerwindow.h" #include "lllineeditor.h" @@ -205,7 +205,7 @@ void LLPreviewTexture::draw() LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); - F32 data_progress = mImage->mDownloadProgress; + F32 data_progress = mImage->getDownloadProgress() ; // Draw the progress bar. const S32 BAR_HEIGHT = 12; @@ -295,7 +295,7 @@ void LLPreviewTexture::onFocusReceived() // static void LLPreviewTexture::onFileLoadedForSave(BOOL success, - LLViewerImage *src_vi, + LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, @@ -357,8 +357,8 @@ void LLPreviewTexture::updateDimensions() mUpdateDimensions = FALSE; - S32 image_height = llmax(1, mImage->getHeight(0)); - S32 image_width = llmax(1, mImage->getWidth(0)); + S32 image_height = llmax(1, mImage->getFullHeight()); + S32 image_width = llmax(1, mImage->getFullWidth()); // Attempt to make the image 1:1 on screen. // If that fails, cut width by half. S32 client_width = image_width; @@ -379,8 +379,8 @@ void LLPreviewTexture::updateDimensions() S32 view_height = client_height + vert_pad; // set text on dimensions display (should be moved out of here and into a callback of some sort) - childSetTextArg("dimensions", "[WIDTH]", llformat("%d", mImage->mFullWidth)); - childSetTextArg("dimensions", "[HEIGHT]", llformat("%d", mImage->mFullHeight)); + childSetTextArg("dimensions", "[WIDTH]", llformat("%d", mImage->getFullWidth())); + childSetTextArg("dimensions", "[HEIGHT]", llformat("%d", mImage->getFullHeight())); // add space for dimensions S32 info_height = 0; @@ -464,15 +464,15 @@ void LLPreviewTexture::updateDimensions() void LLPreviewTexture::loadAsset() { - mImage = gImageList.getImage(mImageID, MIPMAP_TRUE, FALSE); - mImage->setBoostLevel(LLViewerImage::BOOST_PREVIEW); + mImage = LLViewerTextureManager::getFetchedTexture(mImageID, MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); + mImage->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); mAssetStatus = PREVIEW_ASSET_LOADING; updateDimensions(); } LLPreview::EAssetStatus LLPreviewTexture::getAssetStatus() { - if (mImage.notNull() && (mImage->mFullWidth * mImage->mFullHeight > 0)) + if (mImage.notNull() && (mImage->getFullWidth() * mImage->getFullHeight() > 0)) { mAssetStatus = PREVIEW_ASSET_LOADED; } diff --git a/indra/newview/llpreviewtexture.h b/indra/newview/llpreviewtexture.h index 45b173e7bf..9ace304fa6 100644 --- a/indra/newview/llpreviewtexture.h +++ b/indra/newview/llpreviewtexture.h @@ -36,7 +36,7 @@ #include "llpreview.h" #include "llbutton.h" #include "llframetimer.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLImageRaw; @@ -60,7 +60,7 @@ public: static void saveToFile(void* userdata); static void onFileLoadedForSave( BOOL success, - LLViewerImage *src_vi, + LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, @@ -75,7 +75,7 @@ protected: private: void updateDimensions(); LLUUID mImageID; - LLPointer<LLViewerImage> mImage; + LLPointer<LLViewerFetchedTexture> mImage; BOOL mLoadingFullImage; std::string mSaveFileName; LLFrameTimer mSavedFileTimer; diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index 38d617e468..f70cfc59ec 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -40,7 +40,6 @@ #include "llrender.h" #include "llui.h" #include "llfontgl.h" -#include "llimagegl.h" #include "lltimer.h" #include "lltextbox.h" #include "llglheaders.h" @@ -51,7 +50,7 @@ #include "llprogressbar.h" #include "llstartup.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llappviewer.h" #include "llweb.h" @@ -147,10 +146,10 @@ void LLProgressView::draw() // Paint bitmap if we've got one glPushMatrix(); - if (gStartImageGL) + if (gStartTexture) { LLGLSUIDefault gls_ui; - gGL.getTexUnit(0)->bind(gStartImageGL); + gGL.getTexUnit(0)->bind(gStartTexture.get()); gGL.color4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f); F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; S32 width = getRect().getWidth(); @@ -186,7 +185,7 @@ void LLProgressView::draw() { gFocusMgr.removeTopCtrlWithoutCallback(this); LLPanel::setVisible(FALSE); - gStartImageGL = NULL; + gStartTexture = NULL; } return; } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index b3b850441c..c24b3f0d04 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -74,7 +74,7 @@ #include "llui.h" #include "llviewercamera.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -1425,7 +1425,7 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) // Texture picker defaults aren't inventory items // * Don't need to worry about permissions for them // * Can just apply the texture and be done with it. - objectp->setTEImage(te, gImageList.getImage(mImageID, TRUE, FALSE)); + objectp->setTEImage(te, LLViewerTextureManager::getFetchedTexture(mImageID, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE)); } return true; } @@ -1581,7 +1581,7 @@ BOOL LLSelectMgr::selectionRevertTextures() } else { - object->setTEImage(te, gImageList.getImage(id)); + object->setTEImage(te, LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE)); } } } @@ -4544,7 +4544,7 @@ void LLSelectMgr::updateSilhouettes() if (!mSilhouetteImagep) { - mSilhouetteImagep = gImageList.getImageFromFile("silhouette.j2c", TRUE, TRUE); + mSilhouetteImagep = LLViewerTextureManager::getFetchedTextureFromFile("silhouette.j2c", TRUE, TRUE); } mHighlightedObjects->cleanupNodes(); @@ -4814,7 +4814,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) return; } - gGL.getTexUnit(0)->bind(mSilhouetteImagep.get()); + gGL.getTexUnit(0)->bind(mSilhouetteImagep); LLGLSPipelineSelection gls_select; gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.f); LLGLEnable blend(GL_BLEND); diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 992cc1e906..cfc2b702fc 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -54,7 +54,7 @@ #include "boost/iterator/filter_iterator.hpp" class LLMessageSystem; -class LLViewerImage; +class LLViewerTexture; class LLViewerObject; class LLColor4; class LLVector3; @@ -690,7 +690,7 @@ private: static bool confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle); private: - LLPointer<LLViewerImage> mSilhouetteImagep; + LLPointer<LLViewerTexture> mSilhouetteImagep; LLObjectSelectionHandle mSelectedObjects; LLObjectSelectionHandle mHoverObjects; LLObjectSelectionHandle mHighlightedObjects; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f8b824732f..435d010de3 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2356,7 +2356,7 @@ void renderTexturePriority(LLDrawable* drawable) LLGLDisable blend(GL_BLEND); - //LLViewerImage* imagep = facep->getTexture(); + //LLViewerTexture* imagep = facep->getTexture(); //if (imagep) { @@ -2386,7 +2386,7 @@ void renderTexturePriority(LLDrawable* drawable) /*S32 boost = imagep->getBoostLevel(); if (boost) { - F32 t = (F32) boost / (F32) (LLViewerImage::BOOST_MAX_LEVEL-1); + F32 t = (F32) boost / (F32) (LLViewerTexture::BOOST_MAX_LEVEL-1); LLVector4 col = lerp(boost_cold, boost_hot, t); LLGLEnable blend_on(GL_BLEND); gGL.blendFunc(GL_SRC_ALPHA, GL_ONE); @@ -2896,7 +2896,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, con } LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, - LLViewerImage* texture, LLVertexBuffer* buffer, + LLViewerTexture* texture, LLVertexBuffer* buffer, BOOL fullbright, U8 bump, BOOL particle, F32 part_size) : mVertexBuffer(buffer), diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 8aec5c8377..13ab35402c 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -67,12 +67,12 @@ protected: public: LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, - LLViewerImage* image, LLVertexBuffer* buffer, + LLViewerTexture* image, LLVertexBuffer* buffer, BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0); LLPointer<LLVertexBuffer> mVertexBuffer; - LLPointer<LLViewerImage> mTexture; + LLPointer<LLViewerTexture> mTexture; LLColor4U mGlowColor; S32 mDebugColor; const LLMatrix4* mTextureMatrix; @@ -164,7 +164,7 @@ public: typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t; typedef std::map<U32, drawmap_elem_t > draw_map_t; typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t; - typedef std::map<LLPointer<LLViewerImage>, buffer_list_t> buffer_texture_map_t; + typedef std::map<LLPointer<LLViewerTexture>, buffer_list_t> buffer_texture_map_t; typedef std::map<U32, buffer_texture_map_t> buffer_map_t; typedef LLOctreeListener<LLDrawable> BaseType; diff --git a/indra/newview/llsprite.cpp b/indra/newview/llsprite.cpp index 893ed22297..dce4e9d144 100644 --- a/indra/newview/llsprite.cpp +++ b/indra/newview/llsprite.cpp @@ -48,7 +48,7 @@ #include "lldrawable.h" #include "llface.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" LLVector3 LLSprite::sCameraUp(0.0f,0.0f,1.0f); LLVector3 LLSprite::sCameraRight(1.0f,0.0f,0.0f); diff --git a/indra/newview/llsprite.h b/indra/newview/llsprite.h index 28f4ec5d03..eefe2a2386 100644 --- a/indra/newview/llsprite.h +++ b/indra/newview/llsprite.h @@ -40,7 +40,7 @@ #include "v4color.h" #include "lluuid.h" #include "llgl.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLViewerCamera; @@ -82,7 +82,7 @@ public: public: LLUUID mImageID; - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerTexture> mImagep; private: F32 mWidth; F32 mHeight; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index f78703f58d..e6a2ab4ace 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -152,7 +152,7 @@ #include "llviewerdisplay.h" #include "llviewergenericmessage.h" #include "llviewergesture.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewermedia.h" #include "llviewermenu.h" #include "llviewermessage.h" @@ -216,7 +216,7 @@ extern S32 gStartImageHeight; // local globals // -LLPointer<LLImageGL> gStartImageGL; +LLPointer<LLViewerTexture> gStartTexture; static LLHost gAgentSimHost; static BOOL gSkipOptionalUpdate = FALSE; @@ -305,7 +305,7 @@ void update_texture_fetch() LLAppViewer::getTextureCache()->update(1); // unpauses the texture cache thread LLAppViewer::getImageDecodeThread()->update(1); // unpauses the image thread LLAppViewer::getTextureFetch()->update(1); // unpauses the texture fetch thread - gImageList.updateImages(0.10f); + gTextureList.updateImages(0.10f); } static std::vector<std::string> sAuthUris; @@ -382,7 +382,7 @@ bool idle_startup() else { // Update images? - gImageList.updateImages(0.01f); + gTextureList.updateImages(0.01f); } if ( STATE_FIRST == LLStartUp::getStartupState() ) @@ -1618,7 +1618,7 @@ bool idle_startup() // // Initialize classes w/graphics stuff. // - gImageList.doPrefetchImages(); + gTextureList.doPrefetchImages(); LLSurface::initClasses(); LLFace::initClass(); @@ -1832,7 +1832,7 @@ bool idle_startup() F32 frac = (F32)i / (F32)DECODE_TIME_SEC; set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages"), gAgent.mMOTD); display_startup(); - gImageList.decodeAllImages(1.f); + gTextureList.decodeAllImages(1.f); } LLStartUp::setStartupState( STATE_WORLD_WAIT ); @@ -2991,8 +2991,8 @@ void use_circuit_callback(void**, S32 result) void register_viewer_callbacks(LLMessageSystem* msg) { msg->setHandlerFuncFast(_PREHASH_LayerData, process_layer_data ); - msg->setHandlerFuncFast(_PREHASH_ImageData, LLViewerImageList::receiveImageHeader ); - msg->setHandlerFuncFast(_PREHASH_ImagePacket, LLViewerImageList::receiveImagePacket ); + msg->setHandlerFuncFast(_PREHASH_ImageData, LLViewerTextureList::receiveImageHeader ); + msg->setHandlerFuncFast(_PREHASH_ImagePacket, LLViewerTextureList::receiveImagePacket ); msg->setHandlerFuncFast(_PREHASH_ObjectUpdate, process_object_update ); msg->setHandlerFunc("ObjectUpdateCompressed", process_compressed_object_update ); msg->setHandlerFunc("ObjectUpdateCached", process_cached_object_update ); @@ -3123,7 +3123,7 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFunc("TeleportFailed", process_teleport_failed, NULL); msg->setHandlerFunc("TeleportLocal", process_teleport_local, NULL); - msg->setHandlerFunc("ImageNotInDatabase", LLViewerImageList::processImageNotInDatabase, NULL); + msg->setHandlerFunc("ImageNotInDatabase", LLViewerTextureList::processImageNotInDatabase, NULL); msg->setHandlerFuncFast(_PREHASH_GroupMembersReply, LLGroupMgr::processGroupMembersReply); @@ -3254,9 +3254,9 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name, // Loads a bitmap to display during load void init_start_screen(S32 location_id) { - if (gStartImageGL.notNull()) + if (gStartTexture.notNull()) { - gStartImageGL = NULL; + gStartTexture = NULL; LL_INFOS("AppInit") << "re-initializing start screen" << LL_ENDL; } @@ -3288,7 +3288,6 @@ void init_start_screen(S32 location_id) return; } - gStartImageGL = new LLImageGL(FALSE); gStartImageWidth = start_image_bmp->getWidth(); gStartImageHeight = start_image_bmp->getHeight(); @@ -3296,12 +3295,12 @@ void init_start_screen(S32 location_id) if (!start_image_bmp->decode(raw, 0.0f)) { LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL; - gStartImageGL = NULL; + gStartTexture = NULL; return; } raw->expandToPowerOfTwo(); - gStartImageGL->createGLTexture(0, raw); + gStartTexture = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE) ; } @@ -3309,7 +3308,7 @@ void init_start_screen(S32 location_id) void release_start_screen() { LL_DEBUGS("AppInit") << "Releasing bitmap..." << LL_ENDL; - gStartImageGL = NULL; + gStartTexture = NULL; } diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index 93701800e9..4532c5e586 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -33,7 +33,7 @@ #ifndef LL_LLSTARTUP_H #define LL_LLSTARTUP_H -#include "llimagegl.h" +class LLViewerTexture ; // functions bool idle_startup(); @@ -74,7 +74,7 @@ typedef enum { // exported symbols extern bool gAgentMovementCompleted; -extern LLPointer<LLImageGL> gStartImageGL; +extern LLPointer<LLViewerTexture> gStartTexture; extern std::string gInitialOutfit; extern std::string gInitialOutfitGender; // "male" or "female" diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 27a08e7d7b..de3d80f044 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -36,7 +36,7 @@ #include "llrender.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llpatchvertexarray.h" #include "patch_dct.h" #include "patch_code.h" @@ -47,7 +47,7 @@ #include "llappviewer.h" #include "llworld.h" #include "llviewercontrol.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llsurfacepatch.h" #include "llvosurfacepatch.h" #include "llvowater.h" @@ -137,12 +137,10 @@ LLSurface::~LLSurface() // Don't enable this until we blitz the draw pool for it as well. -- djs if (mSTexturep) { - gImageList.deleteImage(mSTexturep); mSTexturep = NULL; } if (mWaterTexturep) { - gImageList.deleteImage(mWaterTexturep); mWaterTexturep = NULL; } } @@ -214,18 +212,18 @@ void LLSurface::create(const S32 grids_per_edge, createPatchData(); } -LLViewerImage* LLSurface::getSTexture() +LLViewerTexture* LLSurface::getSTexture() { - if (mSTexturep.notNull() && !mSTexturep->getHasGLTexture()) + if (mSTexturep.notNull() && !mSTexturep->hasValidGLTexture()) { createSTexture(); } return mSTexturep; } -LLViewerImage* LLSurface::getWaterTexture() +LLViewerTexture* LLSurface::getWaterTexture() { - if (mWaterTexturep.notNull() && !mWaterTexturep->getHasGLTexture()) + if (mWaterTexturep.notNull() && !mWaterTexturep->hasValidGLTexture()) { createWaterTexture(); } @@ -249,11 +247,10 @@ void LLSurface::createSTexture() } } - mSTexturep = new LLViewerImage(raw, FALSE); + mSTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mSTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mSTexturep.get()); - mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - gImageList.addImage(mSTexturep); + gGL.getTexUnit(0)->bind(mSTexturep); + mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); } } @@ -274,11 +271,10 @@ void LLSurface::createWaterTexture() *(default_texture + (i*sTextureSize/2 + j)*4 + 3) = MAX_WATER_COLOR.mV[3]; } } - mWaterTexturep = new LLViewerImage(raw, FALSE); + mWaterTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mWaterTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mWaterTexturep.get()); + gGL.getTexUnit(0)->bind(mWaterTexturep); mWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - gImageList.addImage(mWaterTexturep); } } @@ -1193,7 +1189,7 @@ F32 LLSurface::getWaterHeight() const BOOL LLSurface::generateWaterTexture(const F32 x, const F32 y, const F32 width, const F32 height) { - if (!getWaterTexture()) + if (!getWaterTexture() || !mWaterTexturep->hasGLTexture()) { return FALSE; } diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 310ab5d2c3..1f672d2250 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -46,7 +46,7 @@ #include "llvowater.h" #include "llpatchvertexarray.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLTimer; class LLUUID; @@ -133,8 +133,8 @@ public: void setWaterHeight(F32 height); F32 getWaterHeight() const; - LLViewerImage *getSTexture(); - LLViewerImage *getWaterTexture(); + LLViewerTexture *getSTexture(); + LLViewerTexture *getWaterTexture(); BOOL hasZData() const { return mHasZData; } void dirtyAllPatches(); // Use this to dirty all patches when changing terrain parameters @@ -205,8 +205,8 @@ protected: // The textures should never be directly initialized - use the setter methods! - LLPointer<LLViewerImage> mSTexturep; // Texture for surface - LLPointer<LLViewerImage> mWaterTexturep; // Water texture + LLPointer<LLViewerTexture> mSTexturep; // Texture for surface + LLPointer<LLViewerTexture> mWaterTexturep; // Water texture LLPointer<LLVOWater> mWaterObjp; diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 716ab8eef4..a570a89b28 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -72,7 +72,7 @@ LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height, BOOL has_bump) : // ORDER_LAST => must render these after the hints are created. - LLDynamicTexture( width, height, 4, LLDynamicTexture::ORDER_LAST, TRUE ), + LLViewerDynamicTexture( width, height, 4, LLViewerDynamicTexture::ORDER_LAST, TRUE ), mNeedsUpdate( TRUE ), mNeedsUpload( FALSE ), mUploadPending( FALSE ), // Not used for any logic here, just to sync sending of updates @@ -91,8 +91,8 @@ LLTexLayerSetBuffer::~LLTexLayerSetBuffer() if( mBumpTex.notNull()) { mBumpTex = NULL ; - LLImageGL::sGlobalTextureMemoryInBytes -= mWidth * mHeight * 4; - LLTexLayerSetBuffer::sGLBumpByteCount -= mWidth * mHeight * 4; + LLImageGL::sGlobalTextureMemoryInBytes -= mFullWidth * mFullHeight * 4; + LLTexLayerSetBuffer::sGLBumpByteCount -= mFullWidth * mFullHeight * 4; } } @@ -100,7 +100,7 @@ LLTexLayerSetBuffer::~LLTexLayerSetBuffer() void LLTexLayerSetBuffer::restoreGLTexture() { createBumpTexture() ; - LLDynamicTexture::restoreGLTexture() ; + LLViewerDynamicTexture::restoreGLTexture() ; } //virtual @@ -109,11 +109,11 @@ void LLTexLayerSetBuffer::destroyGLTexture() if( mBumpTex.notNull() ) { mBumpTex = NULL ; - LLImageGL::sGlobalTextureMemoryInBytes -= mWidth * mHeight * 4; - LLTexLayerSetBuffer::sGLBumpByteCount -= mWidth * mHeight * 4; + LLImageGL::sGlobalTextureMemoryInBytes -= mFullWidth * mFullHeight * 4; + LLTexLayerSetBuffer::sGLBumpByteCount -= mFullWidth * mFullHeight * 4; } - LLDynamicTexture::destroyGLTexture() ; + LLViewerDynamicTexture::destroyGLTexture() ; } void LLTexLayerSetBuffer::createBumpTexture() @@ -121,7 +121,7 @@ void LLTexLayerSetBuffer::createBumpTexture() if( mHasBump ) { LLGLSUIDefault gls_ui; - mBumpTex = new LLImageGL(FALSE) ; + mBumpTex = LLViewerTextureManager::getLocalTexture(FALSE) ; if(!mBumpTex->createGLTexture()) { mBumpTex = NULL ; @@ -135,13 +135,13 @@ void LLTexLayerSetBuffer::createBumpTexture() gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RGBA8, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RGBA8, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, NULL); stop_glerror(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLImageGL::sGlobalTextureMemoryInBytes += mWidth * mHeight * 4; - LLTexLayerSetBuffer::sGLBumpByteCount += mWidth * mHeight * 4; + LLImageGL::sGlobalTextureMemoryInBytes += mFullWidth * mFullHeight * 4; + LLTexLayerSetBuffer::sGLBumpByteCount += mFullWidth * mFullHeight * 4; } } @@ -184,7 +184,7 @@ void LLTexLayerSetBuffer::pushProjection() const glMatrixMode(GL_PROJECTION); gGL.pushMatrix(); glLoadIdentity(); - glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); + glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); gGL.pushMatrix(); @@ -230,14 +230,14 @@ void LLTexLayerSetBuffer::preRender(BOOL clear_depth) pushProjection(); // keep depth buffer, we don't need to clear it - LLDynamicTexture::preRender(FALSE); + LLViewerDynamicTexture::preRender(FALSE); } void LLTexLayerSetBuffer::postRender(BOOL success) { popProjection(); - LLDynamicTexture::postRender(success); + LLViewerDynamicTexture::postRender(success); } BOOL LLTexLayerSetBuffer::render() @@ -256,7 +256,7 @@ BOOL LLTexLayerSetBuffer::render() if( mBumpTex.notNull() ) { // Composite the bump data - success &= mTexLayerSet->renderBump( mOrigin.mX, mOrigin.mY, mWidth, mHeight ); + success &= mTexLayerSet->renderBump( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); stop_glerror(); if (success) @@ -267,14 +267,14 @@ BOOL LLTexLayerSetBuffer::render() gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTex->getTexName()); stop_glerror(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mOrigin.mX, mOrigin.mY, mWidth, mHeight); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight); stop_glerror(); // if we need to upload the data, read it back into a buffer if( upload_now ) { - baked_bump_data = new U8[ mWidth * mHeight * 4 ]; - glReadPixels(mOrigin.mX, mOrigin.mY, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_bump_data ); + baked_bump_data = new U8[ mFullWidth * mFullHeight * 4 ]; + glReadPixels(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_bump_data ); stop_glerror(); } } @@ -282,7 +282,7 @@ BOOL LLTexLayerSetBuffer::render() // Composite the color data LLGLSUIDefault gls_ui; - success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mWidth, mHeight ); + success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); gGL.flush(); if( upload_now ) @@ -303,7 +303,7 @@ BOOL LLTexLayerSetBuffer::render() gGL.setSceneBlendType(LLRender::BT_ALPHA); // we have valid texture data now - mTexture->setGLTextureCreated(true); + mGLTexturep->setGLTextureCreated(true); mNeedsUpdate = FALSE; delete [] baked_bump_data; @@ -312,7 +312,7 @@ BOOL LLTexLayerSetBuffer::render() bool LLTexLayerSetBuffer::isInitialized(void) const { - return mTexture.notNull() && mTexture->isGLTextureCreated(); + return mGLTexturep.notNull() && mGLTexturep->isGLTextureCreated(); } BOOL LLTexLayerSetBuffer::updateImmediate() @@ -333,9 +333,9 @@ BOOL LLTexLayerSetBuffer::updateImmediate() void LLTexLayerSetBuffer::readBackAndUpload(const U8* baked_bump_data) { // pointers for storing data to upload - U8* baked_color_data = new U8[ mWidth * mHeight * 4 ]; + U8* baked_color_data = new U8[ mFullWidth * mFullHeight * 4 ]; - glReadPixels(mOrigin.mX, mOrigin.mY, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_color_data ); + glReadPixels(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_color_data ); stop_glerror(); llinfos << "Baked " << mTexLayerSet->getBodyRegion() << llendl; @@ -350,16 +350,16 @@ void LLTexLayerSetBuffer::readBackAndUpload(const U8* baked_bump_data) LLGLSUIDefault gls_ui; - LLPointer<LLImageRaw> baked_mask_image = new LLImageRaw(mWidth, mHeight, 1 ); + LLPointer<LLImageRaw> baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 ); U8* baked_mask_data = baked_mask_image->getData(); - mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mWidth, mHeight); + mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight); // writes into baked_color_data const char* comment_text = NULL; S32 baked_image_components = mBumpTex.notNull() ? 5 : 4; // red green blue [bump] clothing - LLPointer<LLImageRaw> baked_image = new LLImageRaw( mWidth, mHeight, baked_image_components ); + LLPointer<LLImageRaw> baked_image = new LLImageRaw( mFullWidth, mFullHeight, baked_image_components ); U8* baked_image_data = baked_image->getData(); @@ -368,9 +368,9 @@ void LLTexLayerSetBuffer::readBackAndUpload(const U8* baked_bump_data) comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // 5 channels: rgb, heightfield/alpha, mask S32 i = 0; - for( S32 u = 0; u < mWidth; u++ ) + for( S32 u = 0; u < mFullWidth; u++ ) { - for( S32 v = 0; v < mHeight; v++ ) + for( S32 v = 0; v < mFullHeight; v++ ) { baked_image_data[5*i + 0] = baked_color_data[4*i + 0]; baked_image_data[5*i + 1] = baked_color_data[4*i + 1]; @@ -384,9 +384,9 @@ void LLTexLayerSetBuffer::readBackAndUpload(const U8* baked_bump_data) else { S32 i = 0; - for( S32 u = 0; u < mWidth; u++ ) + for( S32 u = 0; u < mFullWidth; u++ ) { - for( S32 v = 0; v < mHeight; v++ ) + for( S32 v = 0; v < mFullHeight; v++ ) { baked_image_data[4*i + 0] = baked_color_data[4*i + 0]; baked_image_data[4*i + 1] = baked_color_data[4*i + 1]; @@ -555,11 +555,7 @@ void LLTexLayerSetBuffer::bindBumpTexture( U32 stage ) gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_TEXTURE, mBumpTex->getTexName()); gGL.getTexUnit(0)->activate(); - if( mLastBindTime != LLImageGL::sLastFrameTime ) - { - mLastBindTime = LLImageGL::sLastFrameTime; - LLImageGL::updateBoundTexMem(mWidth * mHeight * 4); - } + mGLTexturep->updateBindStats(mFullWidth * mFullHeight * 4); } else { @@ -673,7 +669,6 @@ LLTexLayerSet::~LLTexLayerSet() deleteCaches(); std::for_each(mLayerList.begin(), mLayerList.end(), DeletePointer()); std::for_each(mMaskLayerList.begin(), mMaskLayerList.end(), DeletePointer()); - delete mComposite; } //----------------------------------------------------------------------------- @@ -886,7 +881,6 @@ void LLTexLayerSet::destroyComposite() { if( mComposite ) { - delete mComposite; mComposite = NULL; } } @@ -960,11 +954,11 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 width, S32 height, bool forceCle LLGLSNoAlphaTest gls_no_alpha_test; gGL.flush(); { - LLImageGL* image_gl = LLTexLayerStaticImageList::getInstance()->getImageGL(info->mStaticAlphaFileName, TRUE); - if( image_gl ) + LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE); + if( tex ) { LLGLSUIDefault gls_ui; - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE ); gl_rect_2d_simple_tex( width, height ); } @@ -1409,16 +1403,16 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height, BOOL render_morph) if( (getInfo()->mLocalTexture != -1) && !getInfo()->mUseLocalTextureAlphaOnly ) { { - LLImageGL* image_gl = NULL; - if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) ) + LLViewerTexture* tex = NULL; + if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &tex ) ) { - if( image_gl ) + if( tex ) { LLGLDisable alpha_test(getInfo()->mWriteAllChannels ? GL_ALPHA_TEST : 0); - LLTexUnit::eTextureAddressMode old_mode = image_gl->getAddressMode(); + LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); gl_rect_2d_simple_tex( width, height ); @@ -1437,10 +1431,10 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height, BOOL render_morph) if( !getInfo()->mStaticImageFileName.empty() ) { { - LLImageGL* image_gl = LLTexLayerStaticImageList::getInstance()->getImageGL(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); - if( image_gl ) + LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); + if( tex ) { - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -1548,11 +1542,11 @@ BOOL LLTexLayer::blendAlphaTexture(S32 width, S32 height) if( !getInfo()->mStaticImageFileName.empty() ) { - LLImageGL* image_gl = LLTexLayerStaticImageList::getInstance()->getImageGL( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); - if( image_gl ) + LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); + if( tex ) { LLGLSNoAlphaTest gls_no_alpha_test; - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -1565,13 +1559,13 @@ BOOL LLTexLayer::blendAlphaTexture(S32 width, S32 height) { if (getInfo()->mLocalTexture >=0 && getInfo()->mLocalTexture < TEX_NUM_INDICES) { - LLImageGL* image_gl = NULL; - if (mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl)) + LLViewerTexture* tex = NULL; + if (mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &tex)) { - if (image_gl) + if (tex) { LLGLSNoAlphaTest gls_no_alpha_test; - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); success = TRUE; @@ -1623,16 +1617,16 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC // Accumulate the alpha component of the texture if( getInfo()->mLocalTexture != -1 ) { - LLImageGL* image_gl = NULL; - if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) ) + LLViewerTexture* tex = NULL; + if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &tex ) ) { - if( image_gl && (image_gl->getComponents() == 4) ) + if( tex && (tex->getComponents() == 4) ) { LLGLSNoAlphaTest gls_no_alpha_test; - LLTexUnit::eTextureAddressMode old_mode = image_gl->getAddressMode(); + LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); gl_rect_2d_simple_tex( width, height ); @@ -1649,14 +1643,14 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC if( !getInfo()->mStaticImageFileName.empty() ) { - LLImageGL* image_gl = LLTexLayerStaticImageList::getInstance()->getImageGL(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); - if( image_gl ) + LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask); + if( tex ) { - if( (image_gl->getComponents() == 4) || - ( (image_gl->getComponents() == 1) && getInfo()->mStaticImageIsMask ) ) + if( (tex->getComponents() == 4) || + ( (tex->getComponents() == 1) && getInfo()->mStaticImageIsMask ) ) { LLGLSNoAlphaTest gls_no_alpha_test; - gGL.getTexUnit(0)->bind(image_gl); + gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } @@ -1856,16 +1850,16 @@ void LLTexLayerStaticImageList::deleteCachedImages() //mStaticImageLists uses LLPointers, clear() will cause deletion mStaticImageListTGA.clear(); - mStaticImageListGL.clear(); + mStaticImageList.clear(); mGLBytes = 0; mTGABytes = 0; } } -// Note: in general, for a given image image we'll call either getImageTga() or getImageGL(). +// Note: in general, for a given image image we'll call either getImageTga() or getTexture(). // We call getImageTga() if the image is used as an alpha gradient. -// Otherwise, we call getImageGL() +// Otherwise, we call getTexture() // Returns an LLImageTGA that contains the encoded data from a tga file named file_name. // Caches the result to speed identical subsequent requests. @@ -1897,19 +1891,19 @@ LLImageTGA* LLTexLayerStaticImageList::getImageTGA(const std::string& file_name) // Returns a GL Image (without a backing ImageRaw) that contains the decoded data from a tga file named file_name. // Caches the result to speed identical subsequent requests. -LLImageGL* LLTexLayerStaticImageList::getImageGL(const std::string& file_name, BOOL is_mask) +LLViewerTexture* LLTexLayerStaticImageList::getTexture(const std::string& file_name, BOOL is_mask) { - LLPointer<LLImageGL> image_gl; + LLPointer<LLViewerTexture> tex; const char *namekey = mImageNames.addString(file_name); - image_gl_map_t::const_iterator iter = mStaticImageListGL.find(namekey); - if( iter != mStaticImageListGL.end() ) + texture_map_t::const_iterator iter = mStaticImageList.find(namekey); + if( iter != mStaticImageList.end() ) { - image_gl = iter->second; + tex = iter->second; } else { - image_gl = new LLImageGL( FALSE ); + tex = LLViewerTextureManager::getLocalTexture( FALSE ); LLPointer<LLImageRaw> image_raw = new LLImageRaw; if( loadImageRaw( file_name, image_raw ) ) { @@ -1917,23 +1911,23 @@ LLImageGL* LLTexLayerStaticImageList::getImageGL(const std::string& file_name, B { // Note: these are static, unchanging images so it's ok to assume // that once an image is a mask it's always a mask. - image_gl->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); + tex->setExplicitFormat( GL_ALPHA8, GL_ALPHA ); } - image_gl->createGLTexture(0, image_raw); + tex->createGLTexture(0, image_raw); - gGL.getTexUnit(0)->bind(image_gl); - image_gl->setAddressMode(LLTexUnit::TAM_CLAMP); + gGL.getTexUnit(0)->bind(tex); + tex->setAddressMode(LLTexUnit::TAM_CLAMP); - mStaticImageListGL [ namekey ] = image_gl; - mGLBytes += (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents(); + mStaticImageList [ namekey ] = tex; + mGLBytes += (S32)tex->getWidth() * tex->getHeight() * tex->getComponents(); } else { - image_gl = NULL; + tex = NULL; } } - return image_gl; + return tex; } // Reads a .tga file, decodes it, and puts the decoded data in image_raw. diff --git a/indra/newview/lltexlayer.h b/indra/newview/lltexlayer.h index 5890440108..c3ad07a218 100644 --- a/indra/newview/lltexlayer.h +++ b/indra/newview/lltexlayer.h @@ -40,7 +40,6 @@ class LLVOAvatar; class LLVOAvatarSelf; -class LLImageGL; class LLImageTGA; class LLImageRaw; class LLXmlTreeNode; @@ -195,7 +194,7 @@ public: LLVOAvatarSelf* getAvatar() const { return mAvatar; } const std::string getBodyRegion() const; - BOOL hasComposite() const { return (mComposite != NULL); } + BOOL hasComposite() const { return (mComposite.notNull()); } void setBump(BOOL b) { mHasBump = b; } BOOL hasBump() const { return mHasBump; } LLVOAvatarDefines::EBakedTextureIndex getBakedTexIndex() { return mBakedTexIndex; } @@ -208,7 +207,7 @@ private: typedef std::vector<LLTexLayer *> layer_list_t; layer_list_t mLayerList; layer_list_t mMaskLayerList; - LLTexLayerSetBuffer* mComposite; + LLPointer<LLTexLayerSetBuffer> mComposite; LLVOAvatarSelf* const mAvatar; // Backlink only; don't make this an LLPointer. BOOL mUpdatesEnabled; BOOL mHasBump; @@ -241,7 +240,7 @@ private: }; // The composite image that a LLTexLayerSet writes to. Each LLTexLayerSet has one. -class LLTexLayerSetBuffer : public LLDynamicTexture +class LLTexLayerSetBuffer : public LLViewerDynamicTexture { public: LLTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height, BOOL has_bump); @@ -282,7 +281,7 @@ private: BOOL mNeedsUpload; BOOL mUploadPending; LLUUID mUploadID; // Identifys the current upload process (null if none). Used to avoid overlaps (eg, when the user rapidly makes two changes outside of Face Edit) - LLPointer<LLImageGL> mBumpTex; // zero if none + LLPointer<LLViewerTexture> mBumpTex; // zero if none static S32 sGLByteCount; static S32 sGLBumpByteCount; @@ -302,7 +301,7 @@ public: LLTexLayerStaticImageList(); ~LLTexLayerStaticImageList(); - LLImageGL* getImageGL(const std::string& file_name, BOOL is_mask); + LLViewerTexture* getTexture(const std::string& file_name, BOOL is_mask); LLImageTGA* getImageTGA(const std::string& file_name); void deleteCachedImages(); @@ -314,8 +313,8 @@ private: private: LLStringTable mImageNames; - typedef std::map< const char*, LLPointer<LLImageGL> > image_gl_map_t; - image_gl_map_t mStaticImageListGL; + typedef std::map< const char*, LLPointer<LLViewerTexture> > texture_map_t; + texture_map_t mStaticImageList; typedef std::map< const char*, LLPointer<LLImageTGA> > image_tga_map_t; image_tga_map_t mStaticImageListTGA; diff --git a/indra/newview/lltexlayerparams.cpp b/indra/newview/lltexlayerparams.cpp index e00f6aeb04..c9117a84a5 100644 --- a/indra/newview/lltexlayerparams.cpp +++ b/indra/newview/lltexlayerparams.cpp @@ -89,12 +89,12 @@ void LLTexLayerParamAlpha::getCacheByteCount(S32* gl_bytes) iter != sInstances.end(); iter++) { LLTexLayerParamAlpha* instance = *iter; - LLImageGL* image_gl = instance->mCachedProcessedImageGL; - if (image_gl) + LLViewerTexture* tex = instance->mCachedProcessedTexture; + if (tex) { - S32 bytes = (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents(); + S32 bytes = (S32)tex->getWidth() * tex->getHeight() * tex->getComponents(); - if (image_gl->getHasGLTexture()) + if (tex->hasValidGLTexture()) { *gl_bytes += bytes; } @@ -104,7 +104,7 @@ void LLTexLayerParamAlpha::getCacheByteCount(S32* gl_bytes) LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLTexLayer* layer) : LLTexLayerParam(layer), - mCachedProcessedImageGL(NULL), + mCachedProcessedTexture(NULL), mNeedsCreateTexture(FALSE), mStaticImageInvalid(FALSE), mAvgDistortionVec(1.f, 1.f, 1.f), @@ -115,7 +115,7 @@ LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLTexLayer* layer) : LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLVOAvatar* avatar) : LLTexLayerParam(avatar), - mCachedProcessedImageGL(NULL), + mCachedProcessedTexture(NULL), mNeedsCreateTexture(FALSE), mStaticImageInvalid(FALSE), mAvgDistortionVec(1.f, 1.f, 1.f), @@ -134,7 +134,7 @@ LLTexLayerParamAlpha::~LLTexLayerParamAlpha() void LLTexLayerParamAlpha::deleteCaches() { mStaticImageTGA = NULL; // deletes image - mCachedProcessedImageGL = NULL; + mCachedProcessedTexture = NULL; mStaticImageRaw = NULL; mNeedsCreateTexture = FALSE; } @@ -266,22 +266,22 @@ BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height) const S32 image_tga_width = mStaticImageTGA->getWidth(); const S32 image_tga_height = mStaticImageTGA->getHeight(); - if (!mCachedProcessedImageGL || - (mCachedProcessedImageGL->getWidth() != image_tga_width) || - (mCachedProcessedImageGL->getHeight() != image_tga_height) || + if (!mCachedProcessedTexture || + (mCachedProcessedTexture->getWidth() != image_tga_width) || + (mCachedProcessedTexture->getHeight() != image_tga_height) || (weight_changed)) { // llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl; mCachedEffectiveWeight = effective_weight; - if (!mCachedProcessedImageGL) + if (!mCachedProcessedTexture) { - mCachedProcessedImageGL = new LLImageGL(image_tga_width, image_tga_height, 1, FALSE); + mCachedProcessedTexture = LLViewerTextureManager::getLocalTexture(image_tga_width, image_tga_height, 1, FALSE); // We now have something in one of our caches - LLTexLayerSet::sHasCaches |= mCachedProcessedImageGL ? TRUE : FALSE; + LLTexLayerSet::sHasCaches |= mCachedProcessedTexture ? TRUE : FALSE; - mCachedProcessedImageGL->setExplicitFormat(GL_ALPHA8, GL_ALPHA); + mCachedProcessedTexture->setExplicitFormat(GL_ALPHA8, GL_ALPHA); } // Applies domain and effective weight to data as it is decoded. Also resizes the raw image if needed. @@ -291,20 +291,20 @@ BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height) mNeedsCreateTexture = TRUE; } - if (mCachedProcessedImageGL) + if (mCachedProcessedTexture) { { // Create the GL texture, and then hang onto it for future use. if (mNeedsCreateTexture) { - mCachedProcessedImageGL->createGLTexture(0, mStaticImageRaw); + mCachedProcessedTexture->createGLTexture(0, mStaticImageRaw); mNeedsCreateTexture = FALSE; - gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); - mCachedProcessedImageGL->setAddressMode(LLTexUnit::TAM_CLAMP); + gGL.getTexUnit(0)->bind(mCachedProcessedTexture); + mCachedProcessedTexture->setAddressMode(LLTexUnit::TAM_CLAMP); } LLGLSNoAlphaTest gls_no_alpha_test; - gGL.getTexUnit(0)->bind(mCachedProcessedImageGL); + gGL.getTexUnit(0)->bind(mCachedProcessedTexture); gl_rect_2d_simple_tex(width, height); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); @@ -315,7 +315,7 @@ BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height) // (It's not really a "cache" in that case, but the logic is the same) if (mAvatar->isSelf()) { - mCachedProcessedImageGL = NULL; + mCachedProcessedTexture = NULL; } } else diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h index 8c01738317..49feb01b5e 100644 --- a/indra/newview/lltexlayerparams.h +++ b/indra/newview/lltexlayerparams.h @@ -80,7 +80,7 @@ public: BOOL getMultiplyBlend() const; private: - LLPointer<LLImageGL> mCachedProcessedImageGL; + LLPointer<LLViewerTexture> mCachedProcessedTexture; LLPointer<LLImageTGA> mStaticImageTGA; LLPointer<LLImageRaw> mStaticImageRaw; BOOL mNeedsCreateTexture; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 243ac7803e..211a441d64 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -37,13 +37,13 @@ #include "llrender.h" #include "llagent.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llcheckboxctrl.h" #include "llcombobox.h" #include "llbutton.h" #include "lldraghandle.h" #include "llfocusmgr.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llfolderview.h" #include "llfoldervieweventlistener.h" #include "llinventory.h" @@ -146,7 +146,7 @@ public: void onTextureSelect( const LLTextureEntry& te ); protected: - LLPointer<LLViewerImage> mTexturep; + LLPointer<LLViewerTexture> mTexturep; LLTextureCtrl* mOwner; LLUUID mImageAssetID; // Currently selected texture @@ -263,9 +263,9 @@ void LLFloaterTexturePicker::updateImageStats() if (mTexturep.notNull()) { //RN: have we received header data for this image? - if (mTexturep->getWidth(0) > 0 && mTexturep->getHeight(0) > 0) + if (mTexturep->getFullWidth() > 0 && mTexturep->getFullHeight() > 0) { - std::string formatted_dims = llformat("%d x %d", mTexturep->getWidth(0),mTexturep->getHeight(0)); + std::string formatted_dims = llformat("%d x %d", mTexturep->getFullWidth(),mTexturep->getFullHeight()); mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); } else @@ -532,13 +532,13 @@ void LLFloaterTexturePicker::draw() mTexturep = NULL; if(mImageAssetID.notNull()) { - mTexturep = gImageList.getImage(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); - mTexturep->setBoostLevel(LLViewerImage::BOOST_PREVIEW); + mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); + mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); } else if (!mFallbackImageName.empty()) { - mTexturep = gImageList.getImageFromFile(mFallbackImageName); - mTexturep->setBoostLevel(LLViewerImage::BOOST_PREVIEW); + mTexturep = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName); + mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); } if (mTentativeLabel) @@ -1191,14 +1191,14 @@ void LLTextureCtrl::draw() } else if (!mImageAssetID.isNull()) { - mTexturep = gImageList.getImage(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); - mTexturep->setBoostLevel(LLViewerImage::BOOST_PREVIEW); + mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, MIPMAP_YES, IMMEDIATE_NO); + mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); } else if (!mFallbackImageName.empty()) { // Show fallback image. - mTexturep = gImageList.getImageFromFile(mFallbackImageName); - mTexturep->setBoostLevel(LLViewerImage::BOOST_PREVIEW); + mTexturep = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName); + mTexturep->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); } // Border diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index ebe2cd2e5f..e30cdb2e97 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -45,7 +45,7 @@ class LLButton; class LLFloaterTexturePicker; class LLInventoryItem; -class LLViewerImage; +class LLViewerTexture; // used for setting drag & drop callbacks. typedef boost::function<BOOL (LLUICtrl*, LLInventoryItem*)> drag_n_drop_callback; @@ -189,7 +189,7 @@ private: drag_n_drop_callback mDropCallback; commit_callback_t mOnCancelCallback; commit_callback_t mOnSelectCallback; - LLPointer<LLViewerImage> mTexturep; + LLPointer<LLViewerTexture> mTexturep; LLUIColor mBorderColor; LLUUID mImageItemID; LLUUID mImageAssetID; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index be535761fc..63af170fa9 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -44,8 +44,8 @@ #include "llagent.h" #include "lltexturecache.h" -#include "llviewerimagelist.h" -#include "llviewerimage.h" +#include "llviewertexturelist.h" +#include "llviewertexture.h" #include "llviewerregion.h" ////////////////////////////////////////////////////////////////////////////// @@ -469,8 +469,8 @@ void LLTextureFetchWorker::clearPackets() U32 LLTextureFetchWorker::calcWorkPriority() { -// llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerImage::maxDecodePriority()); - F32 priority_scale = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerImage::maxDecodePriority(); +// llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerTexture::maxDecodePriority()); + F32 priority_scale = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerFetchedTexture::maxDecodePriority(); mWorkPriority = (U32)(mImagePriority * priority_scale); return mWorkPriority; } @@ -512,7 +512,7 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) void LLTextureFetchWorker::setImagePriority(F32 priority) { -// llassert_always(priority >= 0 && priority <= LLViewerImage::maxDecodePriority()); +// llassert_always(priority >= 0 && priority <= LLViewerTexture::maxDecodePriority()); F32 delta = fabs(priority - mImagePriority); if (delta > (mImagePriority * .05f) || mState == DONE) { @@ -542,7 +542,7 @@ void LLTextureFetchWorker::startWork(S32 param) llassert(mFormattedImage.isNull()); } -#include "llviewerimagelist.h" // debug +#include "llviewertexturelist.h" // debug // Called from LLWorkerThread::processRequest() bool LLTextureFetchWorker::doWork(S32 param) @@ -796,7 +796,7 @@ bool LLTextureFetchWorker::doWork(S32 param) mFormattedImage->deleteData(); #endif mRequestedSize -= cur_size; - // F32 priority = mImagePriority / (F32)LLViewerImage::maxDecodePriority(); // 0-1 + // F32 priority = mImagePriority / (F32)LLViewerTexture::maxDecodePriority(); // 0-1 S32 offset = cur_size; mBufferSize = cur_size; // This will get modified by callbackHttpGet() std::string url; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 282fbb6481..97719a9468 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -38,7 +38,7 @@ #include "lluuid.h" #include "llworkerthread.h" -class LLViewerImage; +class LLViewerTexture; class LLTextureFetchWorker; class LLTextureCache; class LLHost; diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 44cd8f0371..70a8ab9f61 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -49,8 +49,8 @@ #include "lltexturecache.h" #include "lltexturefetch.h" #include "llviewerobject.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llappviewer.h" extern F32 texmem_lower_bound_scale; @@ -58,7 +58,7 @@ extern F32 texmem_lower_bound_scale; LLTextureView *gTextureView = NULL; //static -std::set<LLViewerImage*> LLTextureView::sDebugImages; +std::set<LLViewerFetchedTexture*> LLTextureView::sDebugImages; //////////////////////////////////////////////////////////////////////////// @@ -79,7 +79,7 @@ static S32 texture_bar_height = 8; class LLTextureBar : public LLView { public: - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerFetchedTexture> mImagep; S32 mHilite; public: @@ -109,8 +109,8 @@ public: { LLTextureBar* bar1p = (LLTextureBar*)i1; LLTextureBar* bar2p = (LLTextureBar*)i2; - LLViewerImage *i1p = bar1p->mImagep; - LLViewerImage *i2p = bar2p->mImagep; + LLViewerFetchedTexture *i1p = bar1p->mImagep; + LLViewerFetchedTexture *i2p = bar2p->mImagep; F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority if (pri1 > pri2) @@ -128,10 +128,10 @@ public: { LLTextureBar* bar1p = (LLTextureBar*)i1; LLTextureBar* bar2p = (LLTextureBar*)i2; - LLViewerImage *i1p = bar1p->mImagep; - LLViewerImage *i2p = bar2p->mImagep; - U32 pri1 = i1p->mFetchPriority; - U32 pri2 = i2p->mFetchPriority; + LLViewerFetchedTexture *i1p = bar1p->mImagep; + LLViewerFetchedTexture *i2p = bar2p->mImagep; + U32 pri1 = i1p->getFetchPriority() ; + U32 pri2 = i2p->getFetchPriority() ; if (pri1 > pri2) return true; else if (pri2 > pri1) @@ -315,10 +315,10 @@ void LLTextureBar::draw() pip_x += pip_width + pip_space; // we don't want to show bind/resident pips for textures using the default texture - if (mImagep->getHasGLTexture()) + if (mImagep->hasValidGLTexture()) { // Draw the bound pip - last_event = mImagep->sLastFrameTime - mImagep->mLastBindTime; + last_event = mImagep->getTimePassedSinceLastBound(); if (last_event < 1.f) { clr = mImagep->getMissed() ? LLColor4::red : LLColor4::magenta1; @@ -342,7 +342,7 @@ void LLTextureBar::draw() // draw the image size at the end { std::string num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), - mImagep->getDiscardLevel(), mImagep->mTextureMemory); + mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory() : 0); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); } @@ -400,13 +400,13 @@ private: void LLGLTexMemBar::draw() { - S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sBoundTextureMemoryInBytes); - S32 max_bound_mem = LLViewerImage::sMaxBoundTextureMemInMegaBytes; - S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerImage::sTotalTextureMemoryInBytes); - S32 max_total_mem = LLViewerImage::sMaxTotalTextureMemInMegaBytes; - F32 discard_bias = LLViewerImage::sDesiredDiscardBias; + S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); + S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; + S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); + S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; + F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f); - S32 h_offset = (S32)((texture_bar_height + 2.8f) * mTextureView->mNumTextureBars); + S32 h_offset = (S32)((texture_bar_height + 2.5f) * mTextureView->mNumTextureBars + 2.5f); //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; @@ -477,14 +477,14 @@ void LLGLTexMemBar::draw() //---------------------------------------------------------------------------- text = llformat("Textures: Count: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d(%d) RAW:%d mRaw:%d mAux:%d CB:%d", - gImageList.getNumImages(), + gTextureList.getNumImages(), LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), LLLFSThread::sLocal->getPending(), LLImageWorker::sCount, LLImageWorker::getWorkerThread()->getNumDeletes(), - LLImageRaw::sRawImageCount, LLViewerImage::sRawCount, LLViewerImage::sAuxCount, - gImageList.mCallbackList.size()); + LLImageRaw::sRawImageCount, LLViewerFetchedTexture::sRawCount, LLViewerFetchedTexture::sAuxCount, + gTextureList.mCallbackList.size()); LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, h_offset + line_height*2, text_color, LLFontGL::LEFT, LLFontGL::TOP); @@ -557,7 +557,7 @@ LLTextureView::~LLTextureView() mGLTexMemBar = 0; } -typedef std::pair<F32,LLViewerImage*> decode_pair_t; +typedef std::pair<F32,LLViewerFetchedTexture*> decode_pair_t; struct compare_decode_pair { bool operator()(const decode_pair_t& a, const decode_pair_t& b) @@ -587,18 +587,19 @@ void LLTextureView::draw() llinfos << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << llendl; } - for (LLViewerImageList::image_priority_list_t::iterator iter = gImageList.mImageList.begin(); - iter != gImageList.mImageList.end(); ) + for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin(); + iter != gTextureList.mImageList.end(); ) { - LLPointer<LLViewerImage> imagep = *iter++; + LLPointer<LLViewerFetchedTexture> imagep = *iter++; S32 cur_discard = imagep->getDiscardLevel(); S32 desired_discard = imagep->mDesiredDiscardLevel; if (mPrintList) { + S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory() : 0 ; llinfos << imagep->getID() - << "\t" << imagep->mTextureMemory + << "\t" << tex_mem << "\t" << imagep->getBoostLevel() << "\t" << imagep->getDecodePriority() << "\t" << imagep->getWidth() @@ -643,8 +644,8 @@ void LLTextureView::draw() { struct f : public LLSelectedTEFunctor { - LLViewerImage* mImage; - f(LLViewerImage* image) : mImage(image) {} + LLViewerFetchedTexture* mImage; + f(LLViewerFetchedTexture* image) : mImage(image) {} virtual bool apply(LLViewerObject* object, S32 te) { return (mImage == object->getTEImage(te)); @@ -705,7 +706,7 @@ void LLTextureView::draw() for (display_list_t::iterator iter = display_image_list.begin(); iter != display_image_list.end(); iter++) { - LLViewerImage* imagep = iter->second; + LLViewerFetchedTexture* imagep = iter->second; S32 hilite = 0; F32 pri = iter->first; if (pri >= 1 * HIGH_PRIORITY) @@ -735,7 +736,7 @@ void LLTextureView::draw() reshape(getRect().getWidth(), getRect().getHeight(), TRUE); /* - count = gImageList.getNumImages(); + count = gTextureList.getNumImages(); std::string info_string; info_string = llformat("Global Info:\nTexture Count: %d", count); mInfoTextp->setText(info_string); @@ -757,7 +758,7 @@ void LLTextureView::draw() } -BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite) +BOOL LLTextureView::addBar(LLViewerFetchedTexture *imagep, S32 hilite) { llassert(imagep); diff --git a/indra/newview/lltextureview.h b/indra/newview/lltextureview.h index 99b6db9662..20be17aef4 100644 --- a/indra/newview/lltextureview.h +++ b/indra/newview/lltextureview.h @@ -35,7 +35,7 @@ #include "llcontainerview.h" -class LLViewerImage; +class LLViewerFetchedTexture; class LLTextureBar; class LLGLTexMemBar; @@ -54,12 +54,12 @@ public: /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); - static void addDebugImage(LLViewerImage* image) { sDebugImages.insert(image); } - static void removeDebugImage(LLViewerImage* image) { sDebugImages.insert(image); } + static void addDebugImage(LLViewerFetchedTexture* image) { sDebugImages.insert(image); } + static void removeDebugImage(LLViewerFetchedTexture* image) { sDebugImages.insert(image); } static void clearDebugImages() { sDebugImages.clear(); } private: - BOOL addBar(LLViewerImage *image, BOOL hilight = FALSE); + BOOL addBar(LLViewerFetchedTexture *image, BOOL hilight = FALSE); void removeAllBars(); private: @@ -75,7 +75,7 @@ private: LLGLTexMemBar* mGLTexMemBar; public: - static std::set<LLViewerImage*> sDebugImages; + static std::set<LLViewerFetchedTexture*> sDebugImages; }; extern LLTextureView *gTextureView; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 72ed8f8108..3a7ef4dfc9 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -59,7 +59,7 @@ #include "lltoolmgr.h" #include "lltrans.h" #include "llui.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerinventory.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -1146,7 +1146,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, { return; } - LLViewerImage* image = gImageList.getImage(asset_id); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); S32 num_faces = hit_obj->getNumTEs(); for( S32 face = 0; face < num_faces; face++ ) @@ -1164,7 +1164,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, void LLToolDragAndDrop::dropTextureOneFaceAvatar(LLVOAvatar* avatar, S32 hit_face, LLInventoryItem* item) { if (hit_face == -1) return; - LLViewerImage* image = gImageList.getImage(item->getAssetUUID()); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(item->getAssetUUID()); avatar->userSetOptionalTE( hit_face, image); } @@ -1189,7 +1189,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, return; } // update viewer side image in anticipation of update from simulator - LLViewerImage* image = gImageList.getImage(asset_id); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); hit_obj->setTEImage(hit_face, image); dialog_refresh_all(); diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp index 3dc0ea646a..b70cff3869 100644 --- a/indra/newview/lltoolgun.cpp +++ b/indra/newview/lltoolgun.cpp @@ -42,7 +42,7 @@ #include "llresmgr.h" #include "llfontgl.h" #include "llui.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewercamera.h" #include "llhudmanager.h" #include "lltoolmgr.h" diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp index af0d784a3e..ae3f2f55de 100644 --- a/indra/newview/lltoolmorph.cpp +++ b/indra/newview/lltoolmorph.cpp @@ -58,7 +58,7 @@ #include "lltoolmgr.h" #include "llui.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobject.h" #include "llviewerwindow.h" #include "llvoavatarself.h" @@ -81,7 +81,7 @@ LLVisualParamHint::LLVisualParamHint( LLViewerVisualParam *param, F32 param_weight) : - LLDynamicTexture(width, height, 3, LLDynamicTexture::ORDER_MIDDLE, TRUE ), + LLViewerDynamicTexture(width, height, 3, LLViewerDynamicTexture::ORDER_MIDDLE, TRUE ), mNeedsUpdate( TRUE ), mIsVisible( FALSE ), mJointMesh( mesh ), @@ -155,7 +155,7 @@ void LLVisualParamHint::preRender(BOOL clear_depth) avatarp->updateGeometry(avatarp->mDrawable); avatarp->updateLOD(); - LLDynamicTexture::preRender(clear_depth); + LLViewerDynamicTexture::preRender(clear_depth); } //----------------------------------------------------------------------------- @@ -169,7 +169,7 @@ BOOL LLVisualParamHint::render() glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f); + glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -177,7 +177,7 @@ BOOL LLVisualParamHint::render() LLGLSUIDefault gls_ui; //LLGLState::verify(TRUE); - mBackgroundp->draw(0, 0, mWidth, mHeight); + mBackgroundp->draw(0, 0, mFullWidth, mFullHeight); glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -224,13 +224,13 @@ BOOL LLVisualParamHint::render() gGL.flush(); - LLViewerCamera::getInstance()->setAspect((F32)mWidth / (F32)mHeight); + LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / (F32)mFullHeight); LLViewerCamera::getInstance()->setOriginAndLookAt( camera_pos, // camera LLVector3(0.f, 0.f, 1.f), // up target_pos ); // point of interest - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mWidth, mHeight, FALSE); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); if (avatarp->mDrawable.notNull()) { @@ -244,7 +244,7 @@ BOOL LLVisualParamHint::render() } avatarp->setVisualParamWeight(mVisualParam, mLastParamWeight); gGL.color4f(1,1,1,1); - mTexture->setGLTextureCreated(true); + mGLTexturep->setGLTextureCreated(true); return TRUE; } @@ -256,7 +256,7 @@ void LLVisualParamHint::draw() { if (!mIsVisible) return; - gGL.getTexUnit(0)->bind(getTexture()); + gGL.getTexUnit(0)->bind(this); gGL.color4f(1.f, 1.f, 1.f, 1.f); @@ -264,13 +264,13 @@ void LLVisualParamHint::draw() gGL.begin(LLRender::QUADS); { gGL.texCoord2i(0, 1); - gGL.vertex2i(0, mHeight); + gGL.vertex2i(0, mFullHeight); gGL.texCoord2i(0, 0); gGL.vertex2i(0, 0); gGL.texCoord2i(1, 0); - gGL.vertex2i(mWidth, 0); + gGL.vertex2i(mFullWidth, 0); gGL.texCoord2i(1, 1); - gGL.vertex2i(mWidth, mHeight); + gGL.vertex2i(mFullWidth, mFullHeight); } gGL.end(); @@ -280,7 +280,7 @@ void LLVisualParamHint::draw() //----------------------------------------------------------------------------- // LLVisualParamReset() //----------------------------------------------------------------------------- -LLVisualParamReset::LLVisualParamReset() : LLDynamicTexture(1, 1, 1, ORDER_RESET, FALSE) +LLVisualParamReset::LLVisualParamReset() : LLViewerDynamicTexture(1, 1, 1, ORDER_RESET, FALSE) { } diff --git a/indra/newview/lltoolmorph.h b/indra/newview/lltoolmorph.h index 11de8160eb..b7df718ba2 100644 --- a/indra/newview/lltoolmorph.h +++ b/indra/newview/lltoolmorph.h @@ -42,7 +42,7 @@ #include "llstrider.h" #include "llviewervisualparam.h" #include "llframetimer.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLViewerJointMesh; class LLPolyMesh; @@ -51,17 +51,18 @@ class LLViewerObject; //----------------------------------------------------------------------------- // LLVisualParamHint //----------------------------------------------------------------------------- -class LLVisualParamHint -: public LLDynamicTexture +class LLVisualParamHint : public LLViewerDynamicTexture { +protected: + virtual ~LLVisualParamHint(); + public: LLVisualParamHint( S32 pos_x, S32 pos_y, S32 width, S32 height, LLViewerJointMesh *mesh, LLViewerVisualParam *param, - F32 param_weight); - virtual ~LLVisualParamHint(); + F32 param_weight); BOOL needsRender(); void preRender(BOOL clear_depth); @@ -94,13 +95,15 @@ protected: LLUIImagePtr mBackgroundp; - typedef std::set<LLVisualParamHint*> instance_list_t; + typedef std::set< LLVisualParamHint* > instance_list_t; static instance_list_t sInstances; }; // this class resets avatar data at the end of an update cycle -class LLVisualParamReset : public LLDynamicTexture +class LLVisualParamReset : public LLViewerDynamicTexture { +protected: + /*virtual */ ~LLVisualParamReset(){} public: LLVisualParamReset(); /*virtual */ BOOL render(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 0a71c14120..30c97cdfa3 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -49,7 +49,7 @@ #include "llsky.h" #include "llvieweraudio.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerthrottle.h" #include "llviewerwindow.h" #include "llvoavatarself.h" @@ -212,7 +212,7 @@ static bool handleMaxPartCountChanged(const LLSD& newvalue) static bool handleVideoMemoryChanged(const LLSD& newvalue) { - gImageList.updateMaxResidentTexMem(newvalue.asInteger()); + gTextureList.updateMaxResidentTexMem(newvalue.asInteger()); return true; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index a340514e3b..c4ed4db3e2 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -48,7 +48,6 @@ #include "llfirstuse.h" #include "llhudmanager.h" #include "llimagebmp.h" -#include "llimagegl.h" #include "llmemory.h" #include "llselectmgr.h" #include "llsky.h" @@ -74,7 +73,7 @@ #include "llviewershadermgr.h" #include "llfasttimer.h" #include "llfloatertools.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llfocusmgr.h" #include "llcubemap.h" #include "llviewerregion.h" @@ -84,9 +83,9 @@ #include "llwaterparammanager.h" #include "llpostprocess.h" -extern LLPointer<LLImageGL> gStartImageGL; +extern LLPointer<LLViewerTexture> gStartTexture; -LLPointer<LLImageGL> gDisconnectedImagep = NULL; +LLPointer<LLViewerTexture> gDisconnectedImagep = NULL; // used to toggle renderer back on after teleport const F32 TELEPORT_RENDER_DELAY = 20.f; // Max time a teleport is allowed to take before we raise the curtain @@ -136,7 +135,7 @@ void display_startup() if (frame_count++ > 1) // make sure we have rendered a frame first { - LLDynamicTexture::updateAllInstances(); + LLViewerDynamicTexture::updateAllInstances(); } LLGLState::checkStates(); @@ -383,7 +382,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["arriving"]); - gImageList.mForceResetTextureStats = TRUE; + gTextureList.mForceResetTextureStats = TRUE; gAgent.resetView(TRUE, TRUE); break; @@ -506,7 +505,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); - if (LLDynamicTexture::updateAllInstances()) + if (LLViewerDynamicTexture::updateAllInstances()) { gGL.setColorMask(true, true); glClear(GL_DEPTH_BUFFER_BIT); @@ -690,13 +689,13 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLMemType mt_iu(LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE); LLFastTimer t(LLFastTimer::FTM_IMAGE_UPDATE); - LLViewerImage::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), + LLViewerTexture::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean()); - gBumpImageList.updateImages(); // must be called before gImageList version so that it's textures are thrown out first. + gBumpImageList.updateImages(); // must be called before gTextureList version so that it's textures are thrown out first. const F32 max_image_decode_time = llmin(0.005f, 0.005f*10.f*gFrameIntervalSeconds); // 50 ms/second decode time (no more than 5ms/frame) - gImageList.updateImages(max_image_decode_time); + gTextureList.updateImages(max_image_decode_time); stop_glerror(); } llpushcallstacks ; @@ -1279,8 +1278,7 @@ void render_disconnected_background() //llinfos << "Bitmap load failed" << llendl; return; } - - gDisconnectedImagep = new LLImageGL( FALSE ); + LLPointer<LLImageRaw> raw = new LLImageRaw; if (!image_bmp->decode(raw, 0.0f)) { @@ -1306,8 +1304,8 @@ void render_disconnected_background() raw->expandToPowerOfTwo(); - gDisconnectedImagep->createGLTexture(0, raw); - gStartImageGL = gDisconnectedImagep; + gDisconnectedImagep = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE ); + gStartTexture = gDisconnectedImagep; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index b6f0dafae6..8fbb59bc74 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -52,7 +52,7 @@ #include "lltexlayer.h" #include "llviewercamera.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerjointmesh.h" #include "llvoavatar.h" #include "llsky.h" @@ -230,7 +230,7 @@ void LLViewerJointMesh::setColor( F32 red, F32 green, F32 blue, F32 alpha ) //-------------------------------------------------------------------- // LLViewerJointMesh::getTexture() //-------------------------------------------------------------------- -//LLViewerImage *LLViewerJointMesh::getTexture() +//LLViewerTexture *LLViewerJointMesh::getTexture() //{ // return mTexture; //} @@ -238,7 +238,7 @@ void LLViewerJointMesh::setColor( F32 red, F32 green, F32 blue, F32 alpha ) //-------------------------------------------------------------------- // LLViewerJointMesh::setTexture() //-------------------------------------------------------------------- -void LLViewerJointMesh::setTexture( LLViewerImage *texture ) +void LLViewerJointMesh::setTexture( LLViewerTexture *texture ) { mTexture = texture; @@ -557,7 +557,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { if( mLayerSet->hasComposite() ) { - gGL.getTexUnit(0)->bind(mLayerSet->getComposite()->getTexture()); + gGL.getTexUnit(0)->bind(mLayerSet->getComposite()); } else { @@ -567,19 +567,22 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { llwarns << "Layerset without composite" << llendl; } - gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT)); + gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT)); } } else if ( !is_dummy && mTexture.notNull() ) { - old_mode = mTexture->getAddressMode(); - gGL.getTexUnit(0)->bind(mTexture.get()); + if(mTexture->hasGLTexture()) + { + old_mode = mTexture->getAddressMode(); + } + gGL.getTexUnit(0)->bind(mTexture); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } else { - gGL.getTexUnit(0)->bind(gImageList.getImage(IMG_DEFAULT_AVATAR)); + gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR)); } if (gRenderForSelect) @@ -633,7 +636,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) if (mTexture.notNull() && !is_dummy) { - gGL.getTexUnit(0)->bind(mTexture.get()); + gGL.getTexUnit(0)->bind(mTexture); gGL.getTexUnit(0)->setTextureAddressMode(old_mode); } diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index 0cae48df93..0248502789 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -34,7 +34,7 @@ #define LL_LLVIEWERJOINTMESH_H #include "llviewerjoint.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llpolymesh.h" #include "v4color.h" #include "llapr.h" @@ -72,7 +72,7 @@ protected: LLColor4 mColor; // color value // LLColor4 mSpecular; // specular color (always white for now) F32 mShiny; // shiny value - LLPointer<LLViewerImage> mTexture; // ptr to a global texture + LLPointer<LLViewerTexture> mTexture; // ptr to a global texture LLTexLayerSet* mLayerSet; // ptr to a layer set owned by the avatar U32 mTestImageName; // handle to a temporary texture for previewing uploads LLPolyMesh* mMesh; // ptr to a global polymesh @@ -110,7 +110,7 @@ public: void setSpecular( const LLColor4& color, F32 shiny ) { /*mSpecular = color;*/ mShiny = shiny; }; // Sets the shape texture - void setTexture( LLViewerImage *texture ); + void setTexture( LLViewerTexture *texture ); void setTestTexture( U32 name ) { mTestImageName = name; } diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 5d1cb824a2..bfc258506f 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -40,12 +40,12 @@ #include "llmimetypes.h" #include "llviewercontrol.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewerparcelmedia.h" #include "llviewerparcelmgr.h" #include "llviewerwindow.h" #include "llversionviewer.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llevent.h" // LLSimpleListener #include "llmediamanager.h" @@ -59,58 +59,58 @@ class LLViewerMediaImpl : public LLMediaObserver { - public: - LLViewerMediaImpl() - : mMediaSource( NULL ), - mMovieImageID(), - mMovieImageHasMips(false) - { } - - void destroyMediaSource(); - - void play(const std::string& media_url, - const std::string& mime_type, - const LLUUID& placeholder_texture_id, - S32 media_width, S32 media_height, U8 media_auto_scale, - U8 media_loop); - - void stop(); - void pause(); - void start(); - void seek(F32 time); - void setVolume(F32 volume); - LLMediaBase::EStatus getStatus(); - - /*virtual*/ void onMediaSizeChange(const EventType& event_in); - /*virtual*/ void onMediaContentsChange(const EventType& event_in); - - void updateMovieImage(const LLUUID& image_id, BOOL active); - void updateImagesMediaStreams(); - LLUUID getMediaTextureID(); - - // Internally set our desired browser user agent string, including - // the Second Life version and skin name. Used because we can - // switch skins without restarting the app. - static void updateBrowserUserAgent(); - - // Callback for when the SkinCurrent control is changed to - // switch the user agent string to indicate the new skin. - static bool handleSkinCurrentChanged(const LLSD& newvalue); - - public: - - // a single media url with some data and an impl. - LLMediaBase* mMediaSource; - LLUUID mMovieImageID; - bool mMovieImageHasMips; - std::string mMediaURL; - std::string mMimeType; - private: - void initializePlaceholderImage(LLViewerImage *placeholder_image, LLMediaBase *media_source); +public: + LLViewerMediaImpl() + : mMediaSource( NULL ), + mMovieImageID(), + mMovieImageHasMips(false) + { } + + void destroyMediaSource(); + + void play(const std::string& media_url, + const std::string& mime_type, + const LLUUID& placeholder_texture_id, + S32 media_width, S32 media_height, U8 media_auto_scale, + U8 media_loop); + + void stop(); + void pause(); + void start(); + void seek(F32 time); + void setVolume(F32 volume); + LLMediaBase::EStatus getStatus(); + + /*virtual*/ void onMediaSizeChange(const EventType& event_in); + /*virtual*/ void onMediaContentsChange(const EventType& event_in); + + void restoreMovieImage(); + void updateImagesMediaStreams(); + LLUUID getMediaTextureID(); + + // Internally set our desired browser user agent string, including + // the Second Life version and skin name. Used because we can + // switch skins without restarting the app. + static void updateBrowserUserAgent(); + + // Callback for when the SkinCurrent control is changed to + // switch the user agent string to indicate the new skin. + static bool handleSkinCurrentChanged(const LLSD& newvalue); + +public: + + // a single media url with some data and an impl. + LLMediaBase* mMediaSource; + LLUUID mMovieImageID; + bool mMovieImageHasMips; + std::string mMediaURL; + std::string mMimeType; + +private: + void initializePlaceholderImage(LLViewerMediaTexture *placeholder_image, LLMediaBase *media_source); }; static LLViewerMediaImpl sViewerMediaImpl; - ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::destroyMediaSource() @@ -118,12 +118,11 @@ void LLViewerMediaImpl::destroyMediaSource() LLMediaManager* mgr = LLMediaManager::getInstance(); if ( mMediaSource ) { - bool was_playing = LLViewerMedia::isMediaPlaying(); mMediaSource->remObserver(this); mgr->destroySource( mMediaSource ); // Restore the texture - updateMovieImage(LLUUID::null, was_playing); + restoreMovieImage(); } mMediaSource = NULL; @@ -229,49 +228,36 @@ LLMediaBase::EStatus LLViewerMediaImpl::getStatus() } ////////////////////////////////////////////////////////////////////////////////////////// -// static -void LLViewerMediaImpl::updateMovieImage(const LLUUID& uuid, BOOL active) +void LLViewerMediaImpl::restoreMovieImage() { // IF the media image hasn't changed, do nothing - if (mMovieImageID == uuid) + if (mMovieImageID.isNull()) { return; } - // If we have changed media uuid, restore the old one - if (!mMovieImageID.isNull()) - { - LLViewerImage* oldImage = LLViewerImage::getImage( mMovieImageID ); - if (oldImage) - { - oldImage->reinit(mMovieImageHasMips); - oldImage->mIsMediaTexture = FALSE; - } - mMovieImageID.setNull(); - } - // If the movie is playing, set the new media image - if (active && !uuid.isNull()) + + //restore the movie image to the old one + LLViewerMediaTexture* media = LLViewerTextureManager::findMediaTexture( mMovieImageID ) ; + if (media) { - LLViewerImage* viewerImage = LLViewerImage::getImage( uuid ); - if( viewerImage ) + if(media->getOldTexture())//set back to the old texture if it exists { - mMovieImageID = uuid; - // Can't use mipmaps for movies because they don't update the full image - mMovieImageHasMips = viewerImage->getUseMipMaps(); - viewerImage->reinit(FALSE); - viewerImage->mIsMediaTexture = TRUE; + media->switchToTexture(media->getOldTexture()) ; + media->setPlaying(FALSE) ; } + media->reinit(mMovieImageHasMips); } + mMovieImageID.setNull(); } ////////////////////////////////////////////////////////////////////////////////////////// -// static void LLViewerMediaImpl::updateImagesMediaStreams() { LLMediaManager::updateClass(); } -void LLViewerMediaImpl::initializePlaceholderImage(LLViewerImage *placeholder_image, LLMediaBase *media_source) +void LLViewerMediaImpl::initializePlaceholderImage(LLViewerMediaTexture *placeholder_image, LLMediaBase *media_source) { int media_width = media_source->getMediaWidth(); int media_height = media_source->getMediaHeight(); @@ -308,19 +294,14 @@ void LLViewerMediaImpl::initializePlaceholderImage(LLViewerImage *placeholder_im // placeholder_image->setExplicitFormat() placeholder_image->setUseMipMaps(FALSE); - - // MEDIAOPT: set this dynamically on play/stop - placeholder_image->mIsMediaTexture = true; } - - // virtual void LLViewerMediaImpl::onMediaContentsChange(const EventType& event_in) { LLMediaBase* media_source = event_in.getSubject(); - LLViewerImage* placeholder_image = gImageList.getImage( mMovieImageID ); - if ((placeholder_image) && (placeholder_image->getHasGLTexture())) + LLViewerMediaTexture* placeholder_image = LLViewerTextureManager::getMediaTexture( mMovieImageID ) ; + if (placeholder_image && placeholder_image->hasValidGLTexture()) { if (placeholder_image->getUseMipMaps()) { @@ -345,7 +326,7 @@ void LLViewerMediaImpl::onMediaContentsChange(const EventType& event_in) void LLViewerMediaImpl::onMediaSizeChange(const EventType& event_in) { LLMediaBase* media_source = event_in.getSubject(); - LLViewerImage* placeholder_image = gImageList.getImage( mMovieImageID ); + LLViewerMediaTexture* placeholder_image = LLViewerTextureManager::getMediaTexture( mMovieImageID ) ; if (placeholder_image) { initializePlaceholderImage(placeholder_image, media_source); @@ -356,75 +337,6 @@ void LLViewerMediaImpl::onMediaSizeChange(const EventType& event_in) } } - - // Get the image we're using - - /* - // update media stream if required - LLMediaEngine* media_engine = LLMediaEngine::getInstance(); - if (media_engine) - { - if ( media_engine->update() ) - { - LLUUID media_uuid = media_engine->getImageUUID(); - updateMovieImage(media_uuid, TRUE); - if (!media_uuid.isNull()) - { - LLViewerImage* viewerImage = getImage( media_uuid ); - if( viewerImage ) - { - LLMediaBase* renderer = media_engine->getMediaRenderer(); - if ((renderer->getTextureWidth() != viewerImage->getWidth()) || - (renderer->getTextureHeight() != viewerImage->getHeight()) || - (renderer->getTextureDepth() != viewerImage->getComponents()) || - (viewerImage->getHasGLTexture() == FALSE)) - { - // destroy existing GL image - viewerImage->destroyGLTexture(); - - // set new size - viewerImage->setSize( renderer->getTextureWidth(), - renderer->getTextureHeight(), - renderer->getTextureDepth() ); - - LLPointer<LLImageRaw> raw = new LLImageRaw(renderer->getTextureWidth(), - renderer->getTextureHeight(), - renderer->getTextureDepth()); - raw->clear(0x7f,0x7f,0x7f,0xff); - viewerImage->createGLTexture(0, raw); - } - - // Set the explicit format the instance wants - viewerImage->setExplicitFormat(renderer->getTextureFormatInternal(), - renderer->getTextureFormatPrimary(), - renderer->getTextureFormatType(), - renderer->getTextureFormatSwapBytes()); - // This should be redundant, but just in case: - viewerImage->setUseMipMaps(FALSE); - - LLImageRaw* rawImage = media_engine->getImageRaw(); - if ( rawImage ) - { - viewerImage->setSubImage(rawImage, 0, 0, - renderer->getMediaWidth(), - renderer->getMediaHeight()); - } - } - else - { - llwarns << "MediaEngine update unable to get viewer image for GL texture" << llendl; - } - } - } - else - { - LLUUID media_uuid = media_engine->getImageUUID(); - updateMovieImage(media_uuid, FALSE); - } - } - */ - - LLUUID LLViewerMediaImpl::getMediaTextureID() { return mMovieImageID; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index da3c94225b..0bb1bd7857 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -183,7 +183,7 @@ #include "llviewercamera.h" #include "llviewergenericmessage.h" #include "llviewergesture.h" -#include "llviewerimagelist.h" // gImageList +#include "llviewertexturelist.h" // gTextureList #include "llviewerinventory.h" #include "llviewermenufile.h" // init_menu_file() #include "llviewermessage.h" @@ -1155,7 +1155,7 @@ class LLAdvancedToggleDisableTextures : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLViewerImage::sDontLoadVolumeTextures = !LLViewerImage::sDontLoadVolumeTextures; + LLViewerTexture::sDontLoadVolumeTextures = !LLViewerTexture::sDontLoadVolumeTextures; return true; } }; @@ -1164,7 +1164,7 @@ class LLAdvancedCheckDisableTextures : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = LLViewerImage::sDontLoadVolumeTextures; // <-- make this using LLCacheControl + bool new_value = LLViewerTexture::sDontLoadVolumeTextures; // <-- make this using LLCacheControl return new_value; } }; @@ -6345,7 +6345,7 @@ void handle_selected_texture_info(void*) { if (!node->isTESelected(i)) continue; - LLViewerImage* img = node->getObject()->getTEImage(i); + LLViewerTexture* img = node->getObject()->getTEImage(i); LLUUID image_id = img->getID(); faces_per_texture[image_id].push_back(i); } @@ -6355,7 +6355,7 @@ void handle_selected_texture_info(void*) { LLUUID image_id = it->first; U8 te = it->second[0]; - LLViewerImage* img = node->getObject()->getTEImage(te); + LLViewerTexture* img = node->getObject()->getTEImage(te); S32 height = img->getHeight(); S32 width = img->getWidth(); S32 components = img->getComponents(); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 6576ea81ed..e34c47368c 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -47,7 +47,7 @@ #include "llfloaterperms.h" #include "llstatusbar.h" #include "llviewercontrol.h" // gSavedSettings -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "lluictrlfactory.h" #include "llviewerinventory.h" #include "llviewermenu.h" // gMenuHolder @@ -481,7 +481,7 @@ void handle_compress_image(void*) BOOL success; - success = LLViewerImageList::createUploadFile(infile, outfile, IMG_CODEC_TGA); + success = LLViewerTextureList::createUploadFile(infile, outfile, IMG_CODEC_TGA); if (success) { @@ -537,7 +537,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, else if( exten == "bmp") { asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerImageList::createUploadFile(src_filename, + if (!LLViewerTextureList::createUploadFile(src_filename, filename, IMG_CODEC_BMP )) { @@ -552,7 +552,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, else if( exten == "tga") { asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerImageList::createUploadFile(src_filename, + if (!LLViewerTextureList::createUploadFile(src_filename, filename, IMG_CODEC_TGA )) { @@ -567,7 +567,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, else if( exten == "jpg" || exten == "jpeg") { asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerImageList::createUploadFile(src_filename, + if (!LLViewerTextureList::createUploadFile(src_filename, filename, IMG_CODEC_JPEG )) { @@ -582,7 +582,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, else if( exten == "png") { asset_type = LLAssetType::AT_TEXTURE; - if (!LLViewerImageList::createUploadFile(src_filename, + if (!LLViewerTextureList::createUploadFile(src_filename, filename, IMG_CODEC_PNG )) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index a96ccfd848..cf3491ef03 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -70,7 +70,7 @@ #include "llrendersphere.h" #include "lltooldraganddrop.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerinventory.h" #include "llviewerobjectlist.h" #include "llviewerparceloverlay.h" @@ -2919,14 +2919,14 @@ void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */) S32 tex_count = getNumTEs(); for (i = 0; i < tex_count; i++) { - getTEImage(i)->setBoostLevel(LLViewerImage::BOOST_SELECTED); + getTEImage(i)->setBoostLevel(LLViewerTexture::BOOST_SELECTED); } if (isSculpted()) { LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); LLUUID sculpt_id = sculpt_params->getSculptTexture(); - gImageList.getImage(sculpt_id)->setBoostLevel(LLViewerImage::BOOST_SELECTED); + LLViewerTextureManager::getFetchedTexture(sculpt_id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE)->setBoostLevel(LLViewerTexture::BOOST_SELECTED); } if (boost_children) @@ -3554,8 +3554,8 @@ void LLViewerObject::setNumTEs(const U8 num_tes) { if (num_tes) { - LLPointer<LLViewerImage> *new_images; - new_images = new LLPointer<LLViewerImage>[num_tes]; + LLPointer<LLViewerTexture> *new_images; + new_images = new LLPointer<LLViewerTexture>[num_tes]; for (i = 0; i < num_tes; i++) { if (i < getNumTEs()) @@ -3689,11 +3689,11 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) // if (mDrawable.notNull() && mDrawable->isVisible()) // { const LLUUID& image_id = getTE(te)->getID(); - mTEImages[te] = gImageList.getImage(image_id); + mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); // } } -void LLViewerObject::setTEImage(const U8 te, LLViewerImage *imagep) +void LLViewerObject::setTEImage(const U8 te, LLViewerTexture *imagep) { if (mTEImages[te] != imagep) { @@ -3715,7 +3715,7 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos uuid == LLUUID::null) { retval = LLPrimitive::setTETexture(te, uuid); - mTEImages[te] = gImageList.getImageFromHost(uuid, host); + mTEImages[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); setChanged(TEXTURE); if (mDrawable.notNull()) { @@ -3726,6 +3726,18 @@ S32 LLViewerObject::setTETextureCore(const U8 te, const LLUUID& uuid, LLHost hos } +void LLViewerObject::changeTEImage(const LLViewerTexture* old_image, LLViewerTexture* new_image) +{ + U32 end = getNumTEs() ; + for (U32 face = 0 ; face < end ; face++) + { + if(old_image == mTEImages[face]) + { + mTEImages[face] = new_image ; + } + } +} + S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) { // Invalid host == get from the agent's sim @@ -3970,20 +3982,20 @@ S32 LLViewerObject::setTERotation(const U8 te, const F32 r) } -LLViewerImage *LLViewerObject::getTEImage(const U8 face) const +LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const { // llassert(mTEImages); if (face < getNumTEs()) { - LLViewerImage* image = mTEImages[face]; + LLViewerTexture* image = mTEImages[face]; if (image) { return image; } else { - return (LLViewerImage*)((LLImageGL*)LLViewerImage::sDefaultImagep); + return (LLViewerTexture*)(LLViewerFetchedTexture::sDefaultImagep); } } @@ -4104,7 +4116,7 @@ void LLViewerObject::setDebugText(const std::string &utf8text) updateText(); } -void LLViewerObject::setIcon(LLViewerImage* icon_image) +void LLViewerObject::setIcon(LLViewerTexture* icon_image) { if (!mIcon) { @@ -4194,14 +4206,14 @@ void LLViewerObject::setParticleSource(const LLPartSysData& particle_parameters, if (mPartSourcep->getImage()->getID() != mPartSourcep->mPartSysData.mPartImageID) { - LLViewerImage* image; + LLViewerTexture* image; if (mPartSourcep->mPartSysData.mPartImageID == LLUUID::null) { - image = gImageList.getImageFromFile("pixiesmall.tga"); + image = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.tga"); } else { - image = gImageList.getImage(mPartSourcep->mPartSysData.mPartImageID); + image = LLViewerTextureManager::getFetchedTexture(mPartSourcep->mPartSysData.mPartImageID); } mPartSourcep->setImage(image); } @@ -4243,14 +4255,14 @@ void LLViewerObject::unpackParticleSource(const S32 block_num, const LLUUID& own { if (mPartSourcep->getImage()->getID() != mPartSourcep->mPartSysData.mPartImageID) { - LLViewerImage* image; + LLViewerTexture* image; if (mPartSourcep->mPartSysData.mPartImageID == LLUUID::null) { - image = gImageList.getImageFromFile("pixiesmall.j2c"); + image = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } else { - image = gImageList.getImage(mPartSourcep->mPartSysData.mPartImageID); + image = LLViewerTextureManager::getFetchedTexture(mPartSourcep->mPartSysData.mPartImageID); } mPartSourcep->setImage(image); } @@ -4290,14 +4302,14 @@ void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_ { if (mPartSourcep->getImage()->getID() != mPartSourcep->mPartSysData.mPartImageID) { - LLViewerImage* image; + LLViewerTexture* image; if (mPartSourcep->mPartSysData.mPartImageID == LLUUID::null) { - image = gImageList.getImageFromFile("pixiesmall.j2c"); + image = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } else { - image = gImageList.getImage(mPartSourcep->mPartSysData.mPartImageID); + image = LLViewerTextureManager::getFetchedTexture(mPartSourcep->mPartSysData.mPartImageID); } mPartSourcep->setImage(image); } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 2b2c2d5a95..cda2c5114f 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -68,7 +68,7 @@ class LLPartSysData; class LLPrimitive; class LLPipeline; class LLTextureEntry; -class LLViewerImage; +class LLViewerTexture; class LLViewerInventoryItem; class LLViewerObject; class LLViewerPartSourceScript; @@ -312,8 +312,9 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags ); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ BOOL setMaterial(const U8 material); - virtual void setTEImage(const U8 te, LLViewerImage *imagep); // Not derived from LLPrimitive - LLViewerImage *getTEImage(const U8 te) const; + virtual void setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive + void changeTEImage(const LLViewerTexture* old_image, LLViewerTexture* new_image) ; + LLViewerTexture *getTEImage(const U8 te) const; void fitFaceTexture(const U8 face); void sendTEUpdate() const; // Sends packed representation of all texture entry information @@ -354,7 +355,7 @@ public: void setCanSelect(BOOL canSelect); void setDebugText(const std::string &utf8text); - void setIcon(LLViewerImage* icon_image); + void setIcon(LLViewerTexture* icon_image); void clearIcon(); void markForUpdate(BOOL priority); @@ -527,7 +528,7 @@ public: // Last total CRC received from sim, used for caching U32 mTotalCRC; - LLPointer<LLViewerImage> *mTEImages; + LLPointer<LLViewerTexture> *mTEImages; // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 468c9fbb66..8939faeb91 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -66,7 +66,7 @@ #include "lltoolpie.h" #include "llkeyboard.h" #include "u64.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "lldatapacker.h" #ifdef LL_STANDALONE #include <zlib.h> @@ -558,7 +558,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) { num_updates = mObjects.count() - mCurLazyUpdateIndex; max_value = mObjects.count(); - gImageList.setUpdateStats(TRUE); + gTextureList.setUpdateStats(TRUE); } else { diff --git a/indra/newview/llviewerparcelmediaautoplay.cpp b/indra/newview/llviewerparcelmediaautoplay.cpp index dbb9c32008..7ba2172c3f 100644 --- a/indra/newview/llviewerparcelmediaautoplay.cpp +++ b/indra/newview/llviewerparcelmediaautoplay.cpp @@ -39,7 +39,7 @@ #include "llviewerparcelmgr.h" #include "lluuid.h" #include "message.h" -#include "llviewerimagelist.h" // for texture stats +#include "llviewertexturelist.h" // for texture stats #include "llagent.h" const F32 AUTOPLAY_TIME = 5; // how many seconds before we autoplay @@ -113,13 +113,13 @@ BOOL LLViewerParcelMediaAutoPlay::tick() { if (this_media_texture_id.notNull()) // and if the media texture is good { - LLViewerImage *image = gImageList.getImage(this_media_texture_id, FALSE); + LLViewerMediaTexture *image = LLViewerTextureManager::getMediaTexture(this_media_texture_id, FALSE) ; F32 image_size = 0; if (image) { - image_size = image->mMaxVirtualSize; + image_size = image->getMaxVirtualSize() ; } if (gAgent.getVelocity().magVec() < AUTOPLAY_SPEED) // and if the agent is stopped (slow enough) diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index dc9b26eedc..a702d3a85d 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -60,8 +60,8 @@ #include "llsdutil.h" #include "llstatusbar.h" #include "llui.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerparcelmedia.h" #include "llviewerparceloverlay.h" @@ -80,8 +80,8 @@ U8* LLViewerParcelMgr::sPackedOverlay = NULL; LLUUID gCurrentMovieID = LLUUID::null; -LLPointer<LLViewerImage> sBlockedImage; -LLPointer<LLViewerImage> sPassImage; +LLPointer<LLViewerTexture> sBlockedImage; +LLPointer<LLViewerTexture> sPassImage; // Local functions void optionally_start_music(const std::string& music_url); @@ -143,8 +143,8 @@ LLViewerParcelMgr::LLViewerParcelMgr() mCollisionSegments = new U8[(mParcelsPerEdge+1)*(mParcelsPerEdge+1)]; resetSegments(mCollisionSegments); - mBlockedImage = gImageList.getImageFromFile("noentrylines.j2c"); - mPassImage = gImageList.getImageFromFile("noentrypasslines.j2c"); + mBlockedImage = LLViewerTextureManager::getFetchedTextureFromFile("noentrylines.j2c"); + mPassImage = LLViewerTextureManager::getFetchedTextureFromFile("noentrypasslines.j2c"); S32 overlay_size = mParcelsPerEdge * mParcelsPerEdge / PARCEL_OVERLAY_CHUNKS; sPackedOverlay = new U8[overlay_size]; @@ -2382,12 +2382,12 @@ void LLViewerParcelMgr::cleanupGlobals() LLParcelSelection::sNullSelection = NULL; } -LLViewerImage* LLViewerParcelMgr::getBlockedImage() const +LLViewerTexture* LLViewerParcelMgr::getBlockedImage() const { return sBlockedImage; } -LLViewerImage* LLViewerParcelMgr::getPassImage() const +LLViewerTexture* LLViewerParcelMgr::getPassImage() const { return sPassImage; } diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index dc6c2a6287..427ed4a6f2 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -46,7 +46,7 @@ class LLUUID; class LLMessageSystem; class LLParcel; -class LLViewerImage; +class LLViewerTexture; class LLViewerRegion; // Constants for sendLandOwner @@ -291,8 +291,8 @@ private: static bool callbackJoinLand(const LLSD& notification, const LLSD& response); //void finishClaim(BOOL user_to_user_sale, U32 join); - LLViewerImage* getBlockedImage() const; - LLViewerImage* getPassImage() const; + LLViewerTexture* getBlockedImage() const; + LLViewerTexture* getPassImage() const; private: BOOL mSelected; @@ -341,8 +341,8 @@ private: BOOL mRenderSelection; S32 mCollisionBanned; LLFrameTimer mCollisionTimer; - LLImageGL* mBlockedImage; - LLImageGL* mPassImage; + LLViewerTexture* mBlockedImage; + LLViewerTexture* mPassImage; // Media S32 mMediaParcelId; diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 2056a4be1b..1a91240abb 100644 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -43,13 +43,13 @@ #include "v2math.h" // newview includes -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewercontrol.h" #include "llsurface.h" #include "llviewerregion.h" #include "llagent.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llselectmgr.h" #include "llfloatertools.h" #include "llglheaders.h" @@ -69,10 +69,9 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_ { // Create a texture to hold color information. // 4 components - // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges - mTexture = new LLImageGL(FALSE); + // Use mipmaps = FALSE, clamped, NEAREST filter, for sharp edges mImageRaw = new LLImageRaw(mParcelGridsPerEdge, mParcelGridsPerEdge, OVERLAY_IMG_COMPONENTS); - mTexture->createGLTexture(0, mImageRaw); + mTexture = LLViewerTextureManager::getLocalTexture(mImageRaw.get(), FALSE); gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->bind(mTexture); mTexture->setAddressMode(LLTexUnit::TAM_CLAMP); diff --git a/indra/newview/llviewerparceloverlay.h b/indra/newview/llviewerparceloverlay.h index 9bed1dde34..e673b811ed 100644 --- a/indra/newview/llviewerparceloverlay.h +++ b/indra/newview/llviewerparceloverlay.h @@ -39,7 +39,7 @@ #include "lldarray.h" #include "llframetimer.h" #include "lluuid.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLViewerRegion; class LLVector3; @@ -53,7 +53,7 @@ public: ~LLViewerParcelOverlay(); // ACCESS - LLImageGL* getTexture() const { return mTexture; } + LLViewerTexture* getTexture() const { return mTexture; } BOOL isOwned(const LLVector3& pos) const; BOOL isOwnedSelf(const LLVector3& pos) const; @@ -99,7 +99,7 @@ private: S32 mParcelGridsPerEdge; - LLPointer<LLImageGL> mTexture; + LLPointer<LLViewerTexture> mTexture; LLPointer<LLImageRaw> mImageRaw; // Size: mParcelGridsPerEdge * mParcelGridsPerEdge diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index b74f9e9f2c..ec39819bc8 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -98,7 +98,7 @@ LLViewerPart::~LLViewerPart() --LLViewerPartSim::sParticleCount2 ; } -void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb) +void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerTexture *imagep, LLVPCallback cb) { LLMemType mt(LLMemType::MTYPE_PARTICLES); mPartID = LLViewerPart::sNextPartID; diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index 208675e7bf..8f1f72518a 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -39,10 +39,10 @@ #include "llpartdata.h" #include "llviewerpartsource.h" -class LLViewerImage; +class LLViewerTexture; class LLViewerPart; class LLViewerRegion; -class LLViewerImage; +class LLViewerTexture; class LLVOPartGroup; typedef void (*LLVPCallback)(LLViewerPart &part, const F32 dt); @@ -60,7 +60,7 @@ public: public: LLViewerPart(); - void init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb); + void init(LLPointer<LLViewerPartSource> sourcep, LLViewerTexture *imagep, LLVPCallback cb); U32 mPartID; // Particle ID used primarily for moving between groups @@ -72,7 +72,7 @@ public: // Current particle state (possibly used for rendering) - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerTexture> mImagep; LLVector3 mPosAgent; LLVector3 mVelocity; LLVector3 mAccel; diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index 38c75a84d1..a8cbcd86c6 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -39,7 +39,7 @@ #include "llagent.h" #include "lldrawable.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llvoavatar.h" @@ -78,7 +78,7 @@ void LLViewerPartSource::update(const F32 dt) LLUUID LLViewerPartSource::getImageUUID() const { - LLViewerImage* imagep = mImagep; + LLViewerTexture* imagep = mImagep; if(imagep) { return imagep->getID(); @@ -100,8 +100,8 @@ LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) llassert(source_objp); mSourceObjectp = source_objp; mPosAgent = mSourceObjectp->getPositionAgent(); - mImagep = gImageList.getImageFromFile("pixiesmall.j2c"); - gGL.getTexUnit(0)->bind(mImagep.get()); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); + gGL.getTexUnit(0)->bind(mImagep); mImagep->setAddressMode(LLTexUnit::TAM_CLAMP); } @@ -491,7 +491,7 @@ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::createPSS(LLViewer } -void LLViewerPartSourceScript::setImage(LLViewerImage *imagep) +void LLViewerPartSourceScript::setImage(LLViewerTexture *imagep) { LLMemType mt(LLMemType::MTYPE_PARTICLES); mImagep = imagep; @@ -551,7 +551,7 @@ void LLViewerPartSourceSpiral::update(const F32 dt) LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { - mImagep = gImageList.getImageFromFile("pixiesmall.j2c"); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } const F32 RATE = 0.025f; @@ -720,7 +720,7 @@ void LLViewerPartSourceBeam::update(const F32 dt) if (!mImagep) { - mImagep = gImageList.getImageFromFile("pixiesmall.j2c"); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } LLViewerPart* part = new LLViewerPart(); @@ -806,7 +806,7 @@ void LLViewerPartSourceChat::update(const F32 dt) LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { - mImagep = gImageList.getImageFromFile("pixiesmall.j2c"); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } diff --git a/indra/newview/llviewerpartsource.h b/indra/newview/llviewerpartsource.h index 31e671af3a..540e30eb19 100644 --- a/indra/newview/llviewerpartsource.h +++ b/indra/newview/llviewerpartsource.h @@ -45,7 +45,7 @@ // // -class LLViewerImage; +class LLViewerTexture; class LLViewerObject; class LLViewerPart; @@ -90,7 +90,7 @@ protected: F32 mLastUpdateTime; F32 mLastPartTime; LLUUID mOwnerUUID; - LLPointer<LLViewerImage> mImagep; + LLPointer<LLViewerTexture> mImagep; // Particle information U32 mPartFlags; // Flags for the particle @@ -123,8 +123,8 @@ public: static LLPointer<LLViewerPartSourceScript> unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, LLDataPacker &dp); static LLPointer<LLViewerPartSourceScript> createPSS(LLViewerObject *source_objp, const LLPartSysData& particle_parameters); - LLViewerImage *getImage() const { return mImagep; } - void setImage(LLViewerImage *imagep); + LLViewerTexture *getImage() const { return mImagep; } + void setImage(LLViewerTexture *imagep); LLPartSysData mPartSysData; void setTargetObject(LLViewerObject *objp); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index c79ded1dce..709fcdcf01 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -45,7 +45,7 @@ #include "pipeline.h" #include "lltexturefetch.h" #include "llviewerobjectlist.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "lltexlayer.h" #include "lltexlayerparams.h" #include "llsurface.h" @@ -424,7 +424,7 @@ void output_statistics(void*) { llinfos << "Number of orphans: " << gObjectList.getOrphanCount() << llendl; llinfos << "Number of dead objects: " << gObjectList.mNumDeadObjects << llendl; - llinfos << "Num images: " << gImageList.getNumImages() << llendl; + llinfos << "Num images: " << gTextureList.getNumImages() << llendl; llinfos << "Texture usage: " << LLImageGL::sGlobalTextureMemoryInBytes << llendl; llinfos << "Texture working set: " << LLImageGL::sBoundTextureMemoryInBytes << llendl; llinfos << "Raw usage: " << LLImageRaw::sGlobalRawMemory << llendl; @@ -567,7 +567,7 @@ void update_statistics(U32 frame_count) { gTotalWorldBytes += gVLManager.getTotalBytes(); gTotalObjectBytes += gObjectBits / 8; - gTotalTextureBytes += gImageList.mTextureBits / 8; + gTotalTextureBytes += gTextureList.mTextureBits / 8; // make sure we have a valid time delta for this frame if (gFrameIntervalSeconds > 0.f) @@ -619,7 +619,7 @@ void update_statistics(U32 frame_count) F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); LLViewerStats::getInstance()->mLayersKBitStat.addValue(layer_bits/1024.f); LLViewerStats::getInstance()->mObjectKBitStat.addValue(gObjectBits/1024.f); - LLViewerStats::getInstance()->mTextureKBitStat.addValue(gImageList.mTextureBits/1024.f); + LLViewerStats::getInstance()->mTextureKBitStat.addValue(gTextureList.mTextureBits/1024.f); LLViewerStats::getInstance()->mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); LLViewerStats::getInstance()->mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -633,7 +633,7 @@ void update_statistics(U32 frame_count) gDebugTimers[0].unpause(); } - LLViewerStats::getInstance()->mTexturePacketsStat.addValue(gImageList.mTexturePackets); + LLViewerStats::getInstance()->mTexturePacketsStat.addValue(gTextureList.mTexturePackets); { static F32 visible_avatar_frames = 0.f; @@ -654,8 +654,8 @@ void update_statistics(U32 frame_count) gObjectBits = 0; // gDecodedBits = 0; - gImageList.mTextureBits = 0; - gImageList.mTexturePackets = 0; + gTextureList.mTextureBits = 0; + gTextureList.mTexturePackets = 0; } diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 399b7c6bc1..23f3f46570 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -54,7 +54,7 @@ #include "lltooldraganddrop.h" #include "lltrans.h" #include "llviewercontrol.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerwindow.h" #include "llviewerinventory.h" #include "lluictrlfactory.h" diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp new file mode 100644 index 0000000000..92e00e0cae --- /dev/null +++ b/indra/newview/llviewertexture.cpp @@ -0,0 +1,2375 @@ +/** + * @file llviewertexture.cpp + * @brief Object which handles a received image (and associated texture(s)) + * + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llviewertexture.h" + +// Library includes +#include "imageids.h" +#include "llmath.h" +#include "llerror.h" +#include "llgl.h" +#include "llglheaders.h" +#include "llhost.h" +#include "llimage.h" +#include "llimagebmp.h" +#include "llimagej2c.h" +#include "llimagetga.h" +#include "llmemtype.h" +#include "llstl.h" +#include "llvfile.h" +#include "llvfs.h" +#include "message.h" +#include "lltimer.h" + +// viewer includes +#include "llimagegl.h" +#include "lldrawpool.h" +#include "lltexturefetch.h" +#include "llviewertexturelist.h" +#include "llviewercontrol.h" +#include "pipeline.h" +#include "llappviewer.h" +/////////////////////////////////////////////////////////////////////////////// + +// statics +LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL; +LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap ; +LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL ; + +S32 LLViewerTexture::sImageCount = 0; +S32 LLViewerTexture::sRawCount = 0; +S32 LLViewerTexture::sAuxCount = 0; +LLTimer LLViewerTexture::sEvaluationTimer; +F32 LLViewerTexture::sDesiredDiscardBias = 0.f; +F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; +S32 LLViewerTexture::sBoundTextureMemoryInBytes = 0; +S32 LLViewerTexture::sTotalTextureMemoryInBytes = 0; +S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0; +S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0; +S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ; +BOOL LLViewerTexture::sDontLoadVolumeTextures = FALSE; + +const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by +const F32 desired_discard_bias_max = 1.5f; // max number of levels to reduce image quality by + +//---------------------------------------------------------------------------------------------- +//namespace: LLViewerTextureAccess +//---------------------------------------------------------------------------------------------- +LLViewerMediaTexture* LLViewerTextureManager::createMediaTexture(const LLUUID &media_id, BOOL usemipmaps, LLImageGL* gl_image) +{ + return new LLViewerMediaTexture(media_id, usemipmaps, gl_image) ; +} + +LLViewerTexture* LLViewerTextureManager::findTexture(const LLUUID& id) +{ + LLViewerTexture* tex ; + //search fetched texture list + tex = gTextureList.findImage(id) ; + + //search media texture list + if(!tex) + { + tex = LLViewerTextureManager::findMediaTexture(id) ; + } + return tex ; +} + +LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id) +{ + LLViewerMediaTexture::media_map_t::iterator iter = LLViewerMediaTexture::sMediaMap.find(media_id); + if(iter == LLViewerMediaTexture::sMediaMap.end()) + return NULL; + + ((LLViewerMediaTexture*)(iter->second))->getLastReferencedTimer()->reset() ; + return iter->second; +} + +LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id, BOOL usemipmaps, LLImageGL* gl_image) +{ + LLViewerMediaTexture* tex = LLViewerTextureManager::findMediaTexture(id) ; + if(!tex) + { + tex = LLViewerTextureManager::createMediaTexture(id, usemipmaps, gl_image) ; + } + + LLViewerTexture* old_tex = tex->getOldTexture() ; + if(!old_tex) + { + //if there is a fetched texture with the same id, replace it by this media texture + old_tex = gTextureList.findImage(id) ; + if(old_tex) + { + tex->setOldTexture(old_tex) ; + } + } + + if (gSavedSettings.getBOOL("ParcelMediaAutoPlayEnable") && gSavedSettings.getBOOL("AudioStreamingVideo")) + { + if(!tex->isPlaying()) + { + if(old_tex) + { + old_tex->switchToTexture(tex) ; + } + tex->setPlaying(TRUE) ; + } + } + tex->getLastReferencedTimer()->reset() ; + + return tex ; +} + +LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLViewerTexture* tex, BOOL report_error) +{ + S8 type = tex->getType() ; + if(type == LLViewerTexture::FETCHED_TEXTURE || type == LLViewerTexture::LOD_TEXTURE) + { + return static_cast<LLViewerFetchedTexture*>(tex) ; + } + + if(report_error) + { + llerrs << "not a fetched texture type: " << type << llendl ; + } + + return NULL ; +} + +LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(BOOL usemipmaps, BOOL generate_gl_tex) +{ + LLPointer<LLViewerTexture> tex = new LLViewerTexture(usemipmaps) ; + if(generate_gl_tex) + { + tex->generateGLTexture() ; + } + return tex ; +} +LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID& id, BOOL usemipmaps, BOOL generate_gl_tex) +{ + LLPointer<LLViewerTexture> tex = new LLViewerTexture(id, usemipmaps) ; + if(generate_gl_tex) + { + tex->generateGLTexture() ; + } + return tex ; +} +LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps) +{ + LLPointer<LLViewerTexture> tex = new LLViewerTexture(raw, usemipmaps) ; + return tex ; +} +LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex) +{ + LLPointer<LLViewerTexture> tex = new LLViewerTexture(width, height, components, usemipmaps) ; + if(generate_gl_tex) + { + tex->generateGLTexture() ; + } + return tex ; +} + +LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture( + const LLUUID &image_id, + BOOL usemipmaps, + BOOL level_immediate, + S8 texture_type, + LLGLint internal_format, + LLGLenum primary_format, + LLHost request_from_host) +{ + return gTextureList.getImage(image_id, usemipmaps, level_immediate, texture_type, internal_format, primary_format, request_from_host) ; +} + +LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile( + const std::string& filename, + BOOL usemipmaps, + BOOL level_immediate, + S8 texture_type, + LLGLint internal_format, + LLGLenum primary_format, + const LLUUID& force_id) +{ + return gTextureList.getImageFromFile(filename, usemipmaps, level_immediate, texture_type, internal_format, primary_format, force_id) ; +} + +LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const LLUUID& image_id, LLHost host) +{ + return gTextureList.getImageFromHost(image_id, host) ; +} + +void LLViewerTextureManager::init() +{ + LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3); + raw->clear(0x77, 0x77, 0x77, 0xFF); + LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE) ; + +#if 1 + LLPointer<LLViewerFetchedTexture> imagep = new LLViewerFetchedTexture(IMG_DEFAULT, TRUE); + LLViewerFetchedTexture::sDefaultImagep = imagep; + + const S32 dim = 128; + LLPointer<LLImageRaw> image_raw = new LLImageRaw(dim,dim,3); + U8* data = image_raw->getData(); + for (S32 i = 0; i<dim; i++) + { + for (S32 j = 0; j<dim; j++) + { +#if 0 + const S32 border = 2; + if (i<border || j<border || i>=(dim-border) || j>=(dim-border)) + { + *data++ = 0xff; + *data++ = 0xff; + *data++ = 0xff; + } + else +#endif + { + *data++ = 0x7f; + *data++ = 0x7f; + *data++ = 0x7f; + } + } + } + imagep->createGLTexture(0, image_raw); + image_raw = NULL; + gTextureList.addImage(imagep); + LLViewerFetchedTexture::sDefaultImagep->dontDiscard(); +#else + LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, TRUE); +#endif + + LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, TRUE, TRUE); + LLViewerFetchedTexture::sSmokeImagep->setNoDelete() ; + + LLViewerTexture::initClass() ; + + if(LLFastTimer::sMetricLog) + { + LLViewerTextureManager::sTesterp = new LLTexturePipelineTester() ; + } +} + +void LLViewerTextureManager::cleanup() +{ + stop_glerror(); + + LLImageGL::sDefaultGLTexture = NULL ; + LLViewerTexture::sNullImagep = NULL; + LLViewerFetchedTexture::sDefaultImagep = NULL; + LLViewerFetchedTexture::sSmokeImagep = NULL; + LLViewerFetchedTexture::sMissingAssetImagep = NULL; + LLViewerFetchedTexture::sWhiteImagep = NULL; + + LLViewerMediaTexture::sMediaMap.clear() ; +} + +//---------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------- +//start of LLViewerTexture +//---------------------------------------------------------------------------------------------- +// static +void LLViewerTexture::initClass() +{ + LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ; +} + +// static +void LLViewerTexture::cleanupClass() +{ +} + +// tuning params +const F32 discard_bias_delta = .05f; +const F32 discard_delta_time = 0.5f; +const S32 min_non_tex_system_mem = (128<<20); // 128 MB +// non-const (used externally +F32 texmem_lower_bound_scale = 0.85f; +F32 texmem_middle_bound_scale = 0.925f; + +//static +void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity) +{ + if(LLViewerTextureManager::sTesterp) + { + LLViewerTextureManager::sTesterp->update() ; + } + LLViewerMediaTexture::updateClass() ; + + sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes + sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes + sMaxBoundTextureMemInMegaBytes = gTextureList.getMaxResidentTexMem();//in MB + sMaxTotalTextureMemInMegaBytes = gTextureList.getMaxTotalTextureMem() ;//in MB + sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small. + + if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes || + BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes) + { + //when texture memory overflows, lower down the threashold to release the textures more aggressively. + sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB + + // If we are using more texture memory than we should, + // scale up the desired discard level + if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) + { + sDesiredDiscardBias += discard_bias_delta; + sEvaluationTimer.reset(); + } + } + else if (sDesiredDiscardBias > 0.0f && + BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale && + BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale) + { + // If we are using less texture memory than we should, + // scale down the desired discard level + if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) + { + sDesiredDiscardBias -= discard_bias_delta; + sEvaluationTimer.reset(); + } + } + sDesiredDiscardBias = llclamp(sDesiredDiscardBias, desired_discard_bias_min, desired_discard_bias_max); +} + +//end of static functions +//------------------------------------------------------------------------------------------- +const U32 LLViewerTexture::sCurrentFileVersion = 1; + +LLViewerTexture::LLViewerTexture(BOOL usemipmaps) +{ + init(true); + mUseMipMaps = usemipmaps ; + + mID.generate(); + sImageCount++; +} + +LLViewerTexture::LLViewerTexture(const LLUUID& id, BOOL usemipmaps) + : mID(id) +{ + init(true); + mUseMipMaps = usemipmaps ; + + sImageCount++; +} + +LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps) +{ + init(true); + + mFullWidth = width ; + mFullHeight = height ; + mUseMipMaps = usemipmaps ; + mComponents = components ; + + mID.generate(); + sImageCount++; +} + +LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) +{ + init(true); + mUseMipMaps = usemipmaps ; + mGLTexturep = new LLImageGL(raw, usemipmaps) ; + + // Create an empty image of the specified size and width + mID.generate(); + sImageCount++; +} + +LLViewerTexture::~LLViewerTexture() +{ + sImageCount--; +} + +void LLViewerTexture::init(bool firstinit) +{ + mBoostLevel = LLViewerTexture::BOOST_NONE; + + mFullWidth = 0; + mFullHeight = 0; + mUseMipMaps = FALSE ; + mComponents = 0 ; + + mTextureState = NO_DELETE ; + mDontDiscard = FALSE; + mMaxVirtualSize = 0.f; +} + +//virtual +S8 LLViewerTexture::getType() const +{ + return LLViewerTexture::LOCAL_TEXTURE ; +} + +void LLViewerTexture::cleanup() +{ + mFaceList.clear() ; + + if(mGLTexturep) + { + mGLTexturep->cleanup(); + } +} + +// virtual +void LLViewerTexture::dump() +{ + if(mGLTexturep) + { + mGLTexturep->dump(); + } + + llinfos << "LLViewerTexture" + << " mID " << mID + << llendl; +} + +void LLViewerTexture::setBoostLevel(S32 level) +{ + if(mBoostLevel != level) + { + mBoostLevel = level ; + if(mBoostLevel != LLViewerTexture::BOOST_NONE) + { + setNoDelete() ; + } + } +} + + +bool LLViewerTexture::bindDefaultImage(S32 stage) const +{ + if (stage < 0) return false; + + bool res = true; + if (LLViewerFetchedTexture::sDefaultImagep.notNull() && (this != LLViewerFetchedTexture::sDefaultImagep.get())) + { + // use default if we've got it + res = gGL.getTexUnit(stage)->bind(LLViewerFetchedTexture::sDefaultImagep); + } + if (!res && LLViewerTexture::sNullImagep.notNull() && (this != LLViewerTexture::sNullImagep)) + { + res = gGL.getTexUnit(stage)->bind(LLViewerTexture::sNullImagep) ; + } + if (!res) + { + llwarns << "LLViewerTexture::bindDefaultImage failed." << llendl; + } + stop_glerror(); + if(LLViewerTextureManager::sTesterp) + { + LLViewerTextureManager::sTesterp->updateGrayTextureBinding() ; + } + return res; +} + +//virtual +BOOL LLViewerTexture::isMissingAsset()const +{ + return FALSE; +} + +//virtual +void LLViewerTexture::forceImmediateUpdate() +{ +} + +void LLViewerTexture::addTextureStats(F32 virtual_size) const +{ + if (virtual_size > mMaxVirtualSize) + { + mMaxVirtualSize = virtual_size; + } +} + +void LLViewerTexture::resetTextureStats(BOOL zero) +{ + if (zero) + { + mMaxVirtualSize = 0.0f; + } + else + { + mMaxVirtualSize -= mMaxVirtualSize * .10f; // decay by 5%/update + } +} + +void LLViewerTexture::addFace(LLFace* facep) +{ + mFaceList.push_back(facep) ; +} +void LLViewerTexture::removeFace(LLFace* facep) +{ + mFaceList.remove(facep) ; +} + +void LLViewerTexture::switchToTexture(LLViewerTexture* new_texture) +{ + if(this == new_texture) + { + return ; + } + + new_texture->addTextureStats(getMaxVirtualSize()) ; + + for(ll_face_list_t::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ) + { + LLFace* facep = *iter++ ; + facep->setTexture(new_texture) ; + facep->getViewerObject()->changeTEImage(this, new_texture) ; + gPipeline.markTextured(facep->getDrawable()); + } +} + +void LLViewerTexture::forceActive() +{ + mTextureState = ACTIVE ; +} + +void LLViewerTexture::setActive() +{ + if(mTextureState != NO_DELETE) + { + mTextureState = ACTIVE ; + } +} + +//set the texture to stay in memory +void LLViewerTexture::setNoDelete() +{ + mTextureState = NO_DELETE ; +} + +void LLViewerTexture::generateGLTexture() +{ + if(mGLTexturep.isNull()) + { + mGLTexturep = new LLImageGL(mFullWidth, mFullHeight, mComponents, mUseMipMaps) ; + } +} + +LLImageGL* LLViewerTexture::getGLTexture() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep ; +} + +BOOL LLViewerTexture::createGLTexture() +{ + if(mGLTexturep.isNull()) + { + generateGLTexture() ; + } + + return mGLTexturep->createGLTexture() ; +} + +BOOL LLViewerTexture::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename) +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->createGLTexture(discard_level, imageraw, usename) ; +} + +void LLViewerTexture::setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes) +{ + llassert_always(mGLTexturep.notNull()) ; + + mGLTexturep->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes) ; +} +void LLViewerTexture::setAddressMode(LLTexUnit::eTextureAddressMode mode) +{ + llassert_always(mGLTexturep.notNull()) ; + mGLTexturep->setAddressMode(mode) ; +} +void LLViewerTexture::setFilteringOption(LLTexUnit::eTextureFilterOptions option) +{ + llassert_always(mGLTexturep.notNull()) ; + mGLTexturep->setFilteringOption(option) ; +} + +//virtual +S32 LLViewerTexture::getWidth(S32 discard_level) const +{ + llassert_always(mGLTexturep.notNull()) ; + return mGLTexturep->getWidth(discard_level) ; +} + +//virtual +S32 LLViewerTexture::getHeight(S32 discard_level) const +{ + llassert_always(mGLTexturep.notNull()) ; + return mGLTexturep->getHeight(discard_level) ; +} + +S32 LLViewerTexture::getMaxDiscardLevel() const +{ + llassert_always(mGLTexturep.notNull()) ; + return mGLTexturep->getMaxDiscardLevel() ; +} +S32 LLViewerTexture::getDiscardLevel() const +{ + llassert_always(mGLTexturep.notNull()) ; + return mGLTexturep->getDiscardLevel() ; +} +S8 LLViewerTexture::getComponents() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getComponents() ; +} + +LLGLuint LLViewerTexture::getTexName() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getTexName() ; +} + +BOOL LLViewerTexture::hasValidGLTexture() const +{ + if(mGLTexturep.notNull()) + { + return mGLTexturep->getHasGLTexture() ; + } + return FALSE ; +} + +BOOL LLViewerTexture::hasGLTexture() const +{ + return mGLTexturep.notNull() ; +} + +BOOL LLViewerTexture::getBoundRecently() const +{ + if(mGLTexturep.notNull()) + { + return mGLTexturep->getBoundRecently() ; + } + return FALSE ; +} + +LLTexUnit::eTextureType LLViewerTexture::getTarget(void) const +{ + llassert_always(mGLTexturep.notNull()) ; + return mGLTexturep->getTarget() ; +} + +BOOL LLViewerTexture::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height) +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->setSubImage(imageraw, x_pos, y_pos, width, height) ; +} + +BOOL LLViewerTexture::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->setSubImage(datap, data_width, data_height, x_pos, y_pos, width, height) ; +} + +void LLViewerTexture::setGLTextureCreated (bool initialized) +{ + llassert_always(mGLTexturep.notNull()) ; + + mGLTexturep->setGLTextureCreated (initialized) ; +} + +LLTexUnit::eTextureAddressMode LLViewerTexture::getAddressMode(void) const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getAddressMode() ; +} + +S32 LLViewerTexture::getTextureMemory() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->mTextureMemory ; +} + +LLGLenum LLViewerTexture::getPrimaryFormat() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getPrimaryFormat() ; +} + +BOOL LLViewerTexture::getIsAlphaMask() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getIsAlphaMask() ; +} + +BOOL LLViewerTexture::getMask(const LLVector2 &tc) +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getMask(tc) ; +} + +F32 LLViewerTexture::getTimePassedSinceLastBound() +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getTimePassedSinceLastBound() ; +} +BOOL LLViewerTexture::getMissed() const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->getMissed() ; +} + +BOOL LLViewerTexture::isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->isValidForSculpt(discard_level, image_width, image_height, ncomponents) ; +} + +BOOL LLViewerTexture::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) const +{ + llassert_always(mGLTexturep.notNull()) ; + + return mGLTexturep->readBackRaw(discard_level, imageraw, compressed_ok) ; +} + +void LLViewerTexture::destroyGLTexture() +{ + if(mGLTexturep.notNull() && mGLTexturep->getHasGLTexture()) + { + mGLTexturep->destroyGLTexture() ; + mTextureState = DELETED ; + } +} + +//virtual +void LLViewerTexture::updateBindStatsForTester() +{ + if(LLViewerTextureManager::sTesterp) + { + LLViewerTextureManager::sTesterp->updateTextureBindingStats(this) ; + } +} +//---------------------------------------------------------------------------------------------- +//end of LLViewerTexture +//---------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------------------- +//start of LLViewerFetchedTexture +//---------------------------------------------------------------------------------------------- + +//static +F32 LLViewerFetchedTexture::maxDecodePriority() +{ + return 2000000.f; +} + +LLViewerFetchedTexture::LLViewerFetchedTexture(const LLUUID& id, BOOL usemipmaps) + : LLViewerTexture(id, usemipmaps) +{ + init(TRUE) ; + generateGLTexture() ; +} + +LLViewerFetchedTexture::LLViewerFetchedTexture(const LLImageRaw* raw, BOOL usemipmaps) + : LLViewerTexture(raw, usemipmaps) +{ + init(TRUE) ; +} + +LLViewerFetchedTexture::LLViewerFetchedTexture(const std::string& full_path, const LLUUID& id, BOOL usemipmaps) + : LLViewerTexture(id, usemipmaps), + mLocalFileName(full_path) +{ + init(TRUE) ; + generateGLTexture() ; +} + +void LLViewerFetchedTexture::init(bool firstinit) +{ + mOrigWidth = 0; + mOrigHeight = 0; + mNeedsAux = FALSE; + mRequestedDiscardLevel = -1; + mRequestedDownloadPriority = 0.f; + mFullyLoaded = FALSE; + mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; + mMinDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; + + mDecodingAux = FALSE; + + mKnownDrawWidth = 0; + mKnownDrawHeight = 0; + + if (firstinit) + { + mDecodePriority = 0.f; + mInImageList = 0; + } + + // Only set mIsMissingAsset true when we know for certain that the database + // does not contain this image. + mIsMissingAsset = FALSE; + + mNeedsCreateTexture = FALSE; + + mIsRawImageValid = FALSE; + mRawDiscardLevel = INVALID_DISCARD_LEVEL; + mMinDiscardLevel = 0; + + mHasFetcher = FALSE; + mIsFetching = FALSE; + mFetchState = 0; + mFetchPriority = 0; + mDownloadProgress = 0.f; + mFetchDeltaTime = 999999.f; + mDecodeFrame = 0; + mVisibleFrame = 0; + mForSculpt = FALSE ; + mIsFetched = FALSE ; +} + +LLViewerFetchedTexture::~LLViewerFetchedTexture() +{ + if (mHasFetcher) + { + LLAppViewer::getTextureFetch()->deleteRequest(getID(), true); + } + cleanup(); +} + +//virtual +S8 LLViewerFetchedTexture::getType() const +{ + return LLViewerTexture::FETCHED_TEXTURE ; +} + +void LLViewerFetchedTexture::cleanup() +{ + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + LLLoadedCallbackEntry *entryp = *iter++; + // We never finished loading the image. Indicate failure. + // Note: this allows mLoadedCallbackUserData to be cleaned up. + entryp->mCallback( FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData ); + delete entryp; + } + mLoadedCallbackList.clear(); + mNeedsAux = FALSE; + + // Clean up image data + destroyRawImage(); +} + +void LLViewerFetchedTexture::setForSculpt() +{ + mForSculpt = TRUE ; +} + +BOOL LLViewerFetchedTexture::isDeleted() +{ + return mTextureState == DELETED ; +} + +BOOL LLViewerFetchedTexture::isInactive() +{ + return mTextureState == INACTIVE ; +} + +BOOL LLViewerFetchedTexture::isDeletionCandidate() +{ + return mTextureState == DELETION_CANDIDATE ; +} + +void LLViewerFetchedTexture::setDeletionCandidate() +{ + if(mGLTexturep.notNull() && mGLTexturep->getTexName() && (mTextureState == INACTIVE)) + { + mTextureState = DELETION_CANDIDATE ; + } +} + +//set the texture inactive +void LLViewerFetchedTexture::setInactive() +{ + if(mTextureState == ACTIVE && mGLTexturep.notNull() && mGLTexturep->getTexName() && !mGLTexturep->getBoundRecently()) + { + mTextureState = INACTIVE ; + } +} + +// virtual +void LLViewerFetchedTexture::dump() +{ + LLViewerTexture::dump(); + + llinfos << "LLViewerFetchedTexture" + << " mIsMissingAsset " << (S32)mIsMissingAsset + << " mFullWidth " << mFullWidth + << " mFullHeight " << mFullHeight + << " mOrigWidth" << mOrigWidth + << " mOrigHeight" << mOrigHeight + << llendl; +} + +/////////////////////////////////////////////////////////////////////////////// +// ONLY called from LLViewerFetchedTextureList +void LLViewerFetchedTexture::destroyTexture() +{ + if(LLImageGL::sGlobalTextureMemoryInBytes < sMaxDesiredTextureMemInBytes)//not ready to release unused memory. + { + return ; + } + if (mNeedsCreateTexture)//return if in the process of generating a new texture. + { + return ; + } + + destroyGLTexture() ; + mFullyLoaded = FALSE ; +} + +// ONLY called from LLViewerTextureList +BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) +{ + if (!mNeedsCreateTexture) + { + destroyRawImage(); + return FALSE; + } + mNeedsCreateTexture = FALSE; + if (mRawImage.isNull()) + { + llerrs << "LLViewerTexture trying to create texture with no Raw Image" << llendl; + } +// llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ", +// mRawDiscardLevel, +// mRawImage->getWidth(), mRawImage->getHeight(),mRawImage->getDataSize()) +// << mID.getString() << llendl; + BOOL res = TRUE; + if (!gNoRender) + { + // store original size only for locally-sourced images + if (!mLocalFileName.empty()) + { + mOrigWidth = mRawImage->getWidth(); + mOrigHeight = mRawImage->getHeight(); + + // leave black border, do not scale image content + mRawImage->expandToPowerOfTwo(MAX_IMAGE_SIZE, FALSE); + + mFullWidth = mRawImage->getWidth(); + mFullHeight = mRawImage->getHeight(); + } + else + { + mOrigWidth = mFullWidth; + mOrigHeight = mFullHeight; + } + + bool size_okay = true; + + U32 raw_width = mRawImage->getWidth() << mRawDiscardLevel; + U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel; + if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE ) + { + llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl; + size_okay = false; + } + + if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight())) + { + // A non power-of-two image was uploaded (through a non standard client) + llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl; + size_okay = false; + } + + if( !size_okay ) + { + // An inappropriately-sized image was uploaded (through a non standard client) + // We treat these images as missing assets which causes them to + // be renderd as 'missing image' and to stop requesting data + setIsMissingAsset(); + destroyRawImage(); + return FALSE; + } + + res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename); + setActive() ; + } + + // + // Iterate through the list of image loading callbacks to see + // what sort of data they need. + // + // *TODO: Fix image callback code + BOOL imageraw_callbacks = FALSE; + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + LLLoadedCallbackEntry *entryp = *iter++; + if (entryp->mNeedsImageRaw) + { + imageraw_callbacks = TRUE; + break; + } + } + + if (!imageraw_callbacks) + { + mNeedsAux = FALSE; + destroyRawImage(); + } + return res; +} + +// Call with 0,0 to turn this feature off. +void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) +{ + mKnownDrawWidth = width; + mKnownDrawHeight = height; + addTextureStats((F32)(width * height)); +} + +//virtual +void LLViewerFetchedTexture::processTextureStats() +{ + if(mFullyLoaded)//already loaded + { + return ; + } + + if(!mFullWidth || !mFullHeight) + { + mDesiredDiscardLevel = getMaxDiscardLevel() ; + } + else + { + mDesiredDiscardLevel = 0; + if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) + { + mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + } + + if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel)) + { + mFullyLoaded = TRUE ; + } + } +} + +//texture does not have any data, so we don't know the size of the image, treat it like 32 * 32. +F32 LLViewerFetchedTexture::calcDecodePriorityForUnknownTexture(F32 pixel_priority) +{ + static const F64 log_2 = log(2.0); + + F32 desired = (F32)(log(32.0/pixel_priority) / log_2); + S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired + 1; + ddiscard = llclamp(ddiscard, 1, 9); + + return ddiscard*100000.f; +} + +F32 LLViewerFetchedTexture::calcDecodePriority() +{ +#ifndef LL_RELEASE_FOR_DOWNLOAD + if (mID == LLAppViewer::getTextureFetch()->mDebugID) + { + LLAppViewer::getTextureFetch()->mDebugCount++; // for setting breakpoints + } +#endif + + if(mFullyLoaded)//already loaded for static texture + { + return -4.0f ; //alreay fetched + } + + if (mNeedsCreateTexture) + { + return mDecodePriority; // no change while waiting to create + } + + F32 priority; + S32 cur_discard = getDiscardLevel(); + bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel)); + F32 pixel_priority = fsqrtf(mMaxVirtualSize); + const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame + mDecodeFrame++; + if (pixel_priority > 0.f) + { + mVisibleFrame = mDecodeFrame; + } + + if (mIsMissingAsset) + { + priority = 0.0f; + } + else if (mDesiredDiscardLevel > getMaxDiscardLevel()) + { + // Don't decode anything we don't need + priority = -1.0f; + } + else if (mBoostLevel == LLViewerTexture::BOOST_UI && !have_all_data) + { + priority = 1.f; + } + else if (pixel_priority <= 0.f && !have_all_data) + { + // Not on screen but we might want some data + if (mBoostLevel > BOOST_HIGH) + { + // Always want high boosted images + priority = 1.f; + } + else if (mVisibleFrame == 0 || (mDecodeFrame - mVisibleFrame > MIN_NOT_VISIBLE_FRAMES)) + { + // Don't decode anything that isn't visible unless it's important + priority = -2.0f; + } + else + { + // Leave the priority as-is + return mDecodePriority; + } + } + else if (cur_discard < 0) + { + priority = calcDecodePriorityForUnknownTexture(pixel_priority) ; + } + else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel)) + { + // larger mips are corrupted + priority = -3.0f; + } + else if (cur_discard <= mDesiredDiscardLevel) + { + priority = -4.0f; + } + else + { + // priority range = 100000-400000 + S32 ddiscard = cur_discard - mDesiredDiscardLevel; + if (getDontDiscard()) + { + ddiscard+=2; + } + else if (mGLTexturep.notNull() && !mGLTexturep->getBoundRecently() && mBoostLevel == 0) + { + ddiscard-=2; + } + ddiscard = llclamp(ddiscard, 0, 4); + priority = ddiscard*100000.f; + } + if (priority > 0.0f) + { + pixel_priority = llclamp(pixel_priority, 0.0f, priority-1.f); // priority range = 100000-900000 + if ( mBoostLevel > BOOST_HIGH) + { + priority = 1000000.f + pixel_priority + 1000.f * mBoostLevel; + } + else + { + priority += 0.f + pixel_priority + 1000.f * mBoostLevel; + } + } + return priority; +} +//============================================================================ + +void LLViewerFetchedTexture::setDecodePriority(F32 priority) +{ + llassert(!mInImageList); + mDecodePriority = priority; +} + +bool LLViewerFetchedTexture::updateFetch() +{ + mFetchState = 0; + mFetchPriority = 0; + mFetchDeltaTime = 999999.f; + mRequestDeltaTime = 999999.f; + +#ifndef LL_RELEASE_FOR_DOWNLOAD + if (mID == LLAppViewer::getTextureFetch()->mDebugID) + { + LLAppViewer::getTextureFetch()->mDebugCount++; // for setting breakpoints + } +#endif + + if (mNeedsCreateTexture) + { + // We may be fetching still (e.g. waiting on write) + // but don't check until we've processed the raw data we have + return false; + } + if (mIsMissingAsset) + { + llassert_always(!mHasFetcher); + return false; // skip + } + if (!mLoadedCallbackList.empty() && mRawImage.notNull()) + { + return false; // process any raw image data in callbacks before replacing + } + + S32 current_discard = getDiscardLevel() ; + S32 desired_discard = getDesiredDiscardLevel(); + F32 decode_priority = getDecodePriority(); + decode_priority = llmax(decode_priority, 0.0f); + + if (mIsFetching) + { + // Sets mRawDiscardLevel, mRawImage, mAuxRawImage + S32 fetch_discard = current_discard; + if (mRawImage.notNull()) sRawCount--; + if (mAuxRawImage.notNull()) sAuxCount--; + bool finished = LLAppViewer::getTextureFetch()->getRequestFinished(getID(), fetch_discard, mRawImage, mAuxRawImage); + if (mRawImage.notNull()) sRawCount++; + if (mAuxRawImage.notNull()) sAuxCount++; + if (finished) + { + mIsFetching = FALSE; + } + else + { + mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, + mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); + } + + // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) + if (mRawImage.notNull()) + { + if(LLViewerTextureManager::sTesterp) + { + mIsFetched = TRUE ; + LLViewerTextureManager::sTesterp->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)) ; + } + mRawDiscardLevel = fetch_discard; + if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && + (current_discard < 0 || mRawDiscardLevel < current_discard)) + { + if (getComponents() != mRawImage->getComponents()) + { + // We've changed the number of components, so we need to move any + // objects using this pool to a different pool. + mComponents = mRawImage->getComponents(); + mGLTexturep->setComponents(mComponents) ; + + gTextureList.dirtyImage(this); + } + mIsRawImageValid = TRUE; + gTextureList.mCreateTextureList.insert(this); + mNeedsCreateTexture = TRUE; + mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; + mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; + } + else + { + // Data is ready but we don't need it + // (received it already while fetcher was writing to disk) + destroyRawImage(); + return false; // done + } + } + + if (!mIsFetching) + { + if ((decode_priority > 0) && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL)) + { + // We finished but received no data + if (current_discard < 0) + { + setIsMissingAsset(); + desired_discard = -1; + } + else + { + llwarns << mID << ": Setting min discard to " << current_discard << llendl; + mMinDiscardLevel = current_discard; + desired_discard = current_discard; + } + destroyRawImage(); + } + else if (mRawImage.isNull()) + { + // We have data, but our fetch failed to return raw data + // *TODO: FIgure out why this is happening and fix it + destroyRawImage(); + } + } + else + { + LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority); + } + } + + bool make_request = true; + + if (decode_priority <= 0) + { + make_request = false; + } + else if (mNeedsCreateTexture || mIsMissingAsset) + { + make_request = false; + } + else if (current_discard >= 0 && current_discard <= mMinDiscardLevel) + { + make_request = false; + } + else + { + if (mIsFetching) + { + if (mRequestedDiscardLevel <= desired_discard) + { + make_request = false; + } + } + else + { + if (current_discard >= 0 && current_discard <= desired_discard) + { + make_request = false; + } + } + } + + if (make_request) + { + S32 w=0, h=0, c=0; + if (current_discard >= 0) + { + w = mGLTexturep->getWidth(0); + h = mGLTexturep->getHeight(0); + c = mComponents; + } + if (!mDontDiscard) + { + if (mBoostLevel == 0) + { + desired_discard = llmax(desired_discard, current_discard-1); + } + else + { + desired_discard = llmax(desired_discard, current_discard-2); + } + } + + // bypass texturefetch directly by pulling from LLTextureCache + bool fetch_request_created = false; + if (mLocalFileName.empty()) + { + fetch_request_created = LLAppViewer::getTextureFetch()->createRequest(getID(), getTargetHost(), decode_priority, + w, h, c, desired_discard, + needsAux()); + } + else + { + fetch_request_created = LLAppViewer::getTextureFetch()->createRequest(mLocalFileName, getID(),getTargetHost(), decode_priority, + w, h, c, desired_discard, + needsAux()); + } + + if (fetch_request_created) + { + mHasFetcher = TRUE; + mIsFetching = TRUE; + mRequestedDiscardLevel = desired_discard; + mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority, + mFetchPriority, mFetchDeltaTime, mRequestDeltaTime); + } + + // if createRequest() failed, we're finishing up a request for this UUID, + // wait for it to complete + } + else if (mHasFetcher && !mIsFetching) + { + // Only delete requests that haven't receeived any network data for a while + const F32 FETCH_IDLE_TIME = 5.f; + if (mLastPacketTimer.getElapsedTimeF32() > FETCH_IDLE_TIME) + { +// llinfos << "Deleting request: " << getID() << " Discard: " << current_discard << " <= min:" << mMinDiscardLevel << " or priority == 0: " << decode_priority << llendl; + LLAppViewer::getTextureFetch()->deleteRequest(getID(), true); + mHasFetcher = FALSE; + } + } + + llassert_always(mRawImage.notNull() || (!mNeedsCreateTexture && !mIsRawImageValid)); + + return mIsFetching ? true : false; +} + +void LLViewerFetchedTexture::setIsMissingAsset() +{ + llwarns << mLocalFileName << " " << mID << ": Marking image as missing" << llendl; + if (mHasFetcher) + { + LLAppViewer::getTextureFetch()->deleteRequest(getID(), true); + mHasFetcher = FALSE; + mIsFetching = FALSE; + mFetchState = 0; + mFetchPriority = 0; + } + mIsMissingAsset = TRUE; +} + +void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_callback, + S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, void* userdata) +{ + // + // Don't do ANYTHING here, just add it to the global callback list + // + if (mLoadedCallbackList.empty()) + { + // Put in list to call this->doLoadedCallbacks() periodically + gTextureList.mCallbackList.insert(this); + } + LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata); + mLoadedCallbackList.push_back(entryp); + mNeedsAux |= needs_aux; + if (mNeedsAux && mAuxRawImage.isNull() && getDiscardLevel() >= 0) + { + // We need aux data, but we've already loaded the image, and it didn't have any + llwarns << "No aux data available for callback for image:" << getID() << llendl; + } +} + +bool LLViewerFetchedTexture::doLoadedCallbacks() +{ + if (mNeedsCreateTexture) + { + return false; + } + + bool res = false; + + if (isMissingAsset()) + { + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + LLLoadedCallbackEntry *entryp = *iter++; + // We never finished loading the image. Indicate failure. + // Note: this allows mLoadedCallbackUserData to be cleaned up. + entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData); + delete entryp; + } + mLoadedCallbackList.clear(); + + // Remove ourself from the global list of textures with callbacks + gTextureList.mCallbackList.erase(this); + } + + S32 gl_discard = getDiscardLevel(); + + // If we don't have a legit GL image, set it to be lower than the worst discard level + if (gl_discard == -1) + { + gl_discard = MAX_DISCARD_LEVEL + 1; + } + + // + // Determine the quality levels of textures that we can provide to callbacks + // and whether we need to do decompression/readback to get it + // + S32 current_raw_discard = MAX_DISCARD_LEVEL + 1; // We can always do a readback to get a raw discard + S32 best_raw_discard = gl_discard; // Current GL quality level + S32 current_aux_discard = MAX_DISCARD_LEVEL + 1; + S32 best_aux_discard = MAX_DISCARD_LEVEL + 1; + + if (mIsRawImageValid) + { + // If we have an existing raw image, we have a baseline for the raw and auxiliary quality levels. + best_raw_discard = llmin(best_raw_discard, mRawDiscardLevel); + best_aux_discard = llmin(best_aux_discard, mRawDiscardLevel); // We always decode the aux when we decode the base raw + current_aux_discard = llmin(current_aux_discard, best_aux_discard); + } + else + { + // We have no data at all, we need to get it + // Do this by forcing the best aux discard to be 0. + best_aux_discard = 0; + } + + + // + // See if any of the callbacks would actually run using the data that we can provide, + // and also determine if we need to perform any readbacks or decodes. + // + bool run_gl_callbacks = false; + bool run_raw_callbacks = false; + bool need_readback = false; + + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + LLLoadedCallbackEntry *entryp = *iter++; + if (entryp->mNeedsImageRaw) + { + if (mNeedsAux) + { + // + // Need raw and auxiliary channels + // + if (entryp->mLastUsedDiscard > current_aux_discard) + { + // We have useful data, run the callbacks + run_raw_callbacks = true; + } + } + else + { + if (entryp->mLastUsedDiscard > current_raw_discard) + { + // We have useful data, just run the callbacks + run_raw_callbacks = true; + } + else if (entryp->mLastUsedDiscard > best_raw_discard) + { + // We can readback data, and then run the callbacks + need_readback = true; + run_raw_callbacks = true; + } + } + } + else + { + // Needs just GL + if (entryp->mLastUsedDiscard > gl_discard) + { + // We have enough data, run this callback requiring GL data + run_gl_callbacks = true; + } + } + } + + // + // Do a readback if required, OR start off a texture decode + // + if (need_readback && (getMaxDiscardLevel() > gl_discard)) + { + // Do a readback to get the GL data into the raw image + // We have GL data. + + destroyRawImage(); + readBackRawImage(gl_discard); + llassert_always(mRawImage.notNull()); + llassert_always(!mNeedsAux || mAuxRawImage.notNull()); + } + + // + // Run raw/auxiliary data callbacks + // + if (run_raw_callbacks && mIsRawImageValid && (mRawDiscardLevel <= getMaxDiscardLevel())) + { + // Do callbacks which require raw image data. + //llinfos << "doLoadedCallbacks raw for " << getID() << llendl; + + // Call each party interested in the raw data. + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + callback_list_t::iterator curiter = iter++; + LLLoadedCallbackEntry *entryp = *curiter; + if (entryp->mNeedsImageRaw && (entryp->mLastUsedDiscard > mRawDiscardLevel)) + { + // If we've loaded all the data there is to load or we've loaded enough + // to satisfy the interested party, then this is the last time that + // we're going to call them. + + llassert_always(mRawImage.notNull()); + if(mNeedsAux && mAuxRawImage.isNull()) + { + llwarns << "Raw Image with no Aux Data for callback" << llendl; + } + BOOL final = mRawDiscardLevel <= entryp->mDesiredDiscard ? TRUE : FALSE; + //llinfos << "Running callback for " << getID() << llendl; + //llinfos << mRawImage->getWidth() << "x" << mRawImage->getHeight() << llendl; + if (final) + { + //llinfos << "Final!" << llendl; + } + entryp->mLastUsedDiscard = mRawDiscardLevel; + entryp->mCallback(TRUE, this, mRawImage, mAuxRawImage, mRawDiscardLevel, final, entryp->mUserData); + if (final) + { + iter = mLoadedCallbackList.erase(curiter); + delete entryp; + } + res = true; + } + } + } + + // + // Run GL callbacks + // + if (run_gl_callbacks && (gl_discard <= getMaxDiscardLevel())) + { + //llinfos << "doLoadedCallbacks GL for " << getID() << llendl; + + // Call the callbacks interested in GL data. + for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); + iter != mLoadedCallbackList.end(); ) + { + callback_list_t::iterator curiter = iter++; + LLLoadedCallbackEntry *entryp = *curiter; + if (!entryp->mNeedsImageRaw && (entryp->mLastUsedDiscard > gl_discard)) + { + BOOL final = gl_discard <= entryp->mDesiredDiscard ? TRUE : FALSE; + entryp->mLastUsedDiscard = gl_discard; + entryp->mCallback(TRUE, this, NULL, NULL, gl_discard, final, entryp->mUserData); + if (final) + { + iter = mLoadedCallbackList.erase(curiter); + delete entryp; + } + res = true; + } + } + } + + // + // If we have no callbacks, take us off of the image callback list. + // + if (mLoadedCallbackList.empty()) + { + gTextureList.mCallbackList.erase(this); + } + + // Done with any raw image data at this point (will be re-created if we still have callbacks) + destroyRawImage(); + + return res; +} + +//virtual +void LLViewerFetchedTexture::forceImmediateUpdate() +{ + //only immediately update a deleted texture which is now being re-used. + if(!isDeleted()) + { + return ; + } + //if already called forceImmediateUpdate() + if(mInImageList && mDecodePriority == LLViewerFetchedTexture::maxDecodePriority()) + { + return ; + } + + gTextureList.forceImmediateUpdate(this) ; + return ; +} + +// Was in LLImageGL +LLImageRaw* LLViewerFetchedTexture::readBackRawImage(S8 discard_level) +{ + llassert_always(mGLTexturep.notNull()) ; + llassert_always(discard_level >= 0); + llassert_always(mComponents > 0); + if (mRawImage.notNull()) + { + llerrs << "called with existing mRawImage" << llendl; + mRawImage = NULL; + } + mRawImage = new LLImageRaw(mGLTexturep->getWidth(discard_level), mGLTexturep->getHeight(discard_level), mComponents); + sRawCount++; + mRawDiscardLevel = discard_level; + mGLTexturep->readBackRaw(mRawDiscardLevel, mRawImage, false); + mIsRawImageValid = TRUE; + + return mRawImage; +} + +void LLViewerFetchedTexture::destroyRawImage() +{ + if (mRawImage.notNull()) sRawCount--; + if (mAuxRawImage.notNull()) sAuxCount--; + mRawImage = NULL; + mAuxRawImage = NULL; + mIsRawImageValid = FALSE; + mRawDiscardLevel = INVALID_DISCARD_LEVEL; +} +//---------------------------------------------------------------------------------------------- +//end of LLViewerFetchedTexture +//---------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------------------- +//start of LLViewerLODTexture +//---------------------------------------------------------------------------------------------- +LLViewerLODTexture::LLViewerLODTexture(const LLUUID& id, BOOL usemipmaps) + : LLViewerFetchedTexture(id, usemipmaps) +{ + init(TRUE) ; +} + +LLViewerLODTexture::LLViewerLODTexture(const std::string& full_path, const LLUUID& id, BOOL usemipmaps) + : LLViewerFetchedTexture(full_path, id, usemipmaps) +{ + init(TRUE) ; +} + +void LLViewerLODTexture::init(bool firstinit) +{ + mTexelsPerImage = 64.f*64.f; + mDiscardVirtualSize = 0.f; + mCalculatedDiscardLevel = -1.f; +} + +//virtual +S8 LLViewerLODTexture::getType() const +{ + return LLViewerTexture::LOD_TEXTURE ; +} + +// This is gauranteed to get called periodically for every texture +//virtual +void LLViewerLODTexture::processTextureStats() +{ + // Generate the request priority and render priority + if (mDontDiscard || !mUseMipMaps) + { + mDesiredDiscardLevel = 0; + if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) + mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + } + else if (mBoostLevel < LLViewerTexture::BOOST_HIGH && mMaxVirtualSize <= 10.f) + { + // If the image has not been significantly visible in a while, we don't want it + mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, (S8)(MAX_DISCARD_LEVEL + 1)); + } + else if (!mFullWidth || !mFullHeight) + { + mDesiredDiscardLevel = getMaxDiscardLevel() ; + } + else + { + //static const F64 log_2 = log(2.0); + static const F64 log_4 = log(4.0); + + S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT); + S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT); + mTexelsPerImage = (F32)fullwidth * fullheight; + + F32 discard_level = 0.f; + + // If we know the output width and height, we can force the discard + // level to the correct value, and thus not decode more texture + // data than we need to. + /*if (mBoostLevel == LLViewerTexture::BOOST_UI || + mBoostLevel == LLViewerTexture::BOOST_PREVIEW || + mBoostLevel == LLViewerTexture::BOOST_AVATAR_SELF) // JAMESDEBUG what about AVATAR_BAKED_SELF? + { + discard_level = 0; // full res + } + else*/ if (mKnownDrawWidth && mKnownDrawHeight) + { + S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight; + + // Use log_4 because we're in square-pixel space, so an image + // with twice the width and twice the height will have mTexelsPerImage + // 4 * draw_size + discard_level = (F32)(log(mTexelsPerImage/draw_texels) / log_4); + } + else + { + if ((mCalculatedDiscardLevel >= 0.f) && + (llabs(mMaxVirtualSize - mDiscardVirtualSize) < mMaxVirtualSize*.20f)) + { + // < 20% change in virtual size = no change in desired discard + discard_level = mCalculatedDiscardLevel; + } + else + { + // Calculate the required scale factor of the image using pixels per texel + discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4); + mDiscardVirtualSize = mMaxVirtualSize; + mCalculatedDiscardLevel = discard_level; + } + } + if (mBoostLevel < LLViewerTexture::BOOST_HIGH) + { + static const F32 discard_bias = -.5f; // Must be < 1 or highest discard will never load! + discard_level += discard_bias; + discard_level += sDesiredDiscardBias; + discard_level *= sDesiredDiscardScale; // scale + } + discard_level = floorf(discard_level); +// discard_level -= (gTextureList.mVideoMemorySetting>>1); // more video ram = higher detail + + F32 min_discard = 0.f; + if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) + min_discard = 1.f; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 + + discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL); + + // Can't go higher than the max discard level + mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level); + // Clamp to min desired discard + mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel); + + // + // At this point we've calculated the quality level that we want, + // if possible. Now we check to see if we have it, and take the + // proper action if we don't. + // + + BOOL increase_discard = FALSE; + S32 current_discard = getDiscardLevel(); + if ((sDesiredDiscardBias > 0.0f) && + (current_discard >= 0 && mDesiredDiscardLevel >= current_discard)) + { + if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) + { + // Limit the amount of GL memory bound each frame + if (mDesiredDiscardLevel > current_discard) + { + increase_discard = TRUE; + } + } + if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale) + { + // Only allow GL to have 2x the video card memory + if (!mGLTexturep->getBoundRecently()) + { + increase_discard = TRUE; + } + } + if (increase_discard) + { + // llinfos << "DISCARDED: " << mID << " Discard: " << current_discard << llendl; + sBoundTextureMemoryInBytes -= mGLTexturep->mTextureMemory; + sTotalTextureMemoryInBytes -= mGLTexturep->mTextureMemory; + // Increase the discard level (reduce the texture res) + S32 new_discard = current_discard+1; + mGLTexturep->setDiscardLevel(new_discard); + sBoundTextureMemoryInBytes += mGLTexturep->mTextureMemory; + sTotalTextureMemoryInBytes += mGLTexturep->mTextureMemory; + if(LLViewerTextureManager::sTesterp) + { + LLViewerTextureManager::sTesterp->setStablizingTime() ; + } + } + } + } +} + +//---------------------------------------------------------------------------------------------- +//end of LLViewerLODTexture +//---------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------------------- +//start of LLViewerMediaTexture +//---------------------------------------------------------------------------------------------- +//static +void LLViewerMediaTexture::updateClass() +{ + static const F32 MAX_INACTIVE_TIME = 30.f ; + + for(media_map_t::iterator iter = sMediaMap.begin() ; iter != sMediaMap.end(); ) + { + LLViewerMediaTexture* mediap = iter->second; + ++iter ; + + if(mediap->getNumRefs() == 1 && mediap->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME) //one by sMediaMap + { + sMediaMap.erase(mediap->getID()) ; + } + } +} + +LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LLImageGL* gl_image) + : LLViewerTexture(id, usemipmaps) +{ + sMediaMap.insert(std::make_pair(id, this)); + + mGLTexturep = gl_image ; + if(mGLTexturep.isNull()) + { + generateGLTexture() ; + } + mIsPlaying = FALSE ; +} + +void LLViewerMediaTexture::reinit(BOOL usemipmaps /* = TRUE */) +{ + mGLTexturep = NULL ; + init(false); + mUseMipMaps = usemipmaps ; + mIsPlaying = FALSE ; + getLastReferencedTimer()->reset() ; + + generateGLTexture() ; +} + +void LLViewerMediaTexture::setUseMipMaps(BOOL mipmap) +{ + mUseMipMaps = mipmap; + + if(mGLTexturep.notNull()) + { + mGLTexturep->setUseMipMaps(mipmap) ; + } +} + +//virtual +S8 LLViewerMediaTexture::getType() const +{ + return LLViewerTexture::MEDIA_TEXTURE ; +} + +void LLViewerMediaTexture::setOldTexture(LLViewerTexture* tex) +{ + mOldTexturep = tex ; +} + +LLViewerTexture* LLViewerMediaTexture::getOldTexture() const +{ + return mOldTexturep ; +} +//---------------------------------------------------------------------------------------------- +//end of LLViewerMediaTexture +//---------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------------------- +//start of LLTexturePipelineTester +//---------------------------------------------------------------------------------------------- +LLTexturePipelineTester::LLTexturePipelineTester() : + LLMetricPerformanceTester("TextureTester", FALSE) +{ + addMetricString("TotalBytesLoaded") ; + addMetricString("TotalBytesLoadedFromCache") ; + addMetricString("TotalBytesLoadedForLargeImage") ; + addMetricString("TotalBytesLoadedForSculpties") ; + addMetricString("StartFetchingTime") ; + addMetricString("TotalGrayTime") ; + addMetricString("TotalStablizingTime") ; + addMetricString("StartTimeLoadingSculpties") ; + addMetricString("EndTimeLoadingSculpties") ; + + addMetricString("Time") ; + addMetricString("TotalBytesBound") ; + addMetricString("TotalBytesBoundForLargeImage") ; + addMetricString("PercentageBytesBound") ; + + mTotalBytesLoaded = 0 ; + mTotalBytesLoadedFromCache = 0 ; + mTotalBytesLoadedForLargeImage = 0 ; + mTotalBytesLoadedForSculpties = 0 ; + + reset() ; +} + +LLTexturePipelineTester::~LLTexturePipelineTester() +{ + LLViewerTextureManager::sTesterp = NULL ; +} + +void LLTexturePipelineTester::update() +{ + mLastTotalBytesUsed = mTotalBytesUsed ; + mLastTotalBytesUsedForLargeImage = mTotalBytesUsedForLargeImage ; + mTotalBytesUsed = 0 ; + mTotalBytesUsedForLargeImage = 0 ; + + if(LLAppViewer::getTextureFetch()->getNumRequests() > 0) //fetching list is not empty + { + if(mPause) + { + //start a new fetching session + reset() ; + mStartFetchingTime = LLImageGL::sLastFrameTime ; + mPause = FALSE ; + } + + //update total gray time + if(mUsingDefaultTexture) + { + mUsingDefaultTexture = FALSE ; + mTotalGrayTime = LLImageGL::sLastFrameTime - mStartFetchingTime ; + } + + //update the stablizing timer. + updateStablizingTime() ; + + outputTestResults() ; + } + else if(!mPause) + { + //stop the current fetching session + mPause = TRUE ; + outputTestResults() ; + reset() ; + } +} + +void LLTexturePipelineTester::reset() +{ + mPause = TRUE ; + + mUsingDefaultTexture = FALSE ; + mStartStablizingTime = 0.0f ; + mEndStablizingTime = 0.0f ; + + mTotalBytesUsed = 0 ; + mTotalBytesUsedForLargeImage = 0 ; + mLastTotalBytesUsed = 0 ; + mLastTotalBytesUsedForLargeImage = 0 ; + + mStartFetchingTime = 0.0f ; + + mTotalGrayTime = 0.0f ; + mTotalStablizingTime = 0.0f ; + + mStartTimeLoadingSculpties = 1.0f ; + mEndTimeLoadingSculpties = 0.0f ; +} + +//virtual +void LLTexturePipelineTester::outputTestRecord(LLSD *sd) +{ + (*sd)[mCurLabel]["TotalBytesLoaded"] = (LLSD::Integer)mTotalBytesLoaded ; + (*sd)[mCurLabel]["TotalBytesLoadedFromCache"] = (LLSD::Integer)mTotalBytesLoadedFromCache ; + (*sd)[mCurLabel]["TotalBytesLoadedForLargeImage"] = (LLSD::Integer)mTotalBytesLoadedForLargeImage ; + (*sd)[mCurLabel]["TotalBytesLoadedForSculpties"] = (LLSD::Integer)mTotalBytesLoadedForSculpties ; + + (*sd)[mCurLabel]["StartFetchingTime"] = (LLSD::Real)mStartFetchingTime ; + (*sd)[mCurLabel]["TotalGrayTime"] = (LLSD::Real)mTotalGrayTime ; + (*sd)[mCurLabel]["TotalStablizingTime"] = (LLSD::Real)mTotalStablizingTime ; + + (*sd)[mCurLabel]["StartTimeLoadingSculpties"] = (LLSD::Real)mStartTimeLoadingSculpties ; + (*sd)[mCurLabel]["EndTimeLoadingSculpties"] = (LLSD::Real)mEndTimeLoadingSculpties ; + + (*sd)[mCurLabel]["Time"] = LLImageGL::sLastFrameTime ; + (*sd)[mCurLabel]["TotalBytesBound"] = (LLSD::Integer)mLastTotalBytesUsed ; + (*sd)[mCurLabel]["TotalBytesBoundForLargeImage"] = (LLSD::Integer)mLastTotalBytesUsedForLargeImage ; + (*sd)[mCurLabel]["PercentageBytesBound"] = (LLSD::Real)(100.f * mLastTotalBytesUsed / mTotalBytesLoaded) ; +} + +void LLTexturePipelineTester::updateTextureBindingStats(const LLViewerTexture* imagep) +{ + U32 mem_size = (U32)imagep->getTextureMemory() ; + mTotalBytesUsed += mem_size ; + + if(MIN_LARGE_IMAGE_AREA <= (U32)(mem_size / (U32)imagep->getComponents())) + { + mTotalBytesUsedForLargeImage += mem_size ; + } +} + +void LLTexturePipelineTester::updateTextureLoadingStats(const LLViewerFetchedTexture* imagep, const LLImageRaw* raw_imagep, BOOL from_cache) +{ + U32 data_size = (U32)raw_imagep->getDataSize() ; + mTotalBytesLoaded += data_size ; + + if(from_cache) + { + mTotalBytesLoadedFromCache += data_size ; + } + + if(MIN_LARGE_IMAGE_AREA <= (U32)(data_size / (U32)raw_imagep->getComponents())) + { + mTotalBytesLoadedForLargeImage += data_size ; + } + + if(imagep->isForSculpt()) + { + mTotalBytesLoadedForSculpties += data_size ; + + if(mStartTimeLoadingSculpties > mEndTimeLoadingSculpties) + { + mStartTimeLoadingSculpties = LLImageGL::sLastFrameTime ; + } + mEndTimeLoadingSculpties = LLImageGL::sLastFrameTime ; + } +} + +void LLTexturePipelineTester::updateGrayTextureBinding() +{ + mUsingDefaultTexture = TRUE ; +} + +void LLTexturePipelineTester::setStablizingTime() +{ + if(mStartStablizingTime <= mStartFetchingTime) + { + mStartStablizingTime = LLImageGL::sLastFrameTime ; + } + mEndStablizingTime = LLImageGL::sLastFrameTime ; +} + +void LLTexturePipelineTester::updateStablizingTime() +{ + if(mStartStablizingTime > mStartFetchingTime) + { + F32 t = mEndStablizingTime - mStartStablizingTime ; + + if(t > 0.0001f && (t - mTotalStablizingTime) < 0.0001f) + { + //already stablized + mTotalStablizingTime = LLImageGL::sLastFrameTime - mStartStablizingTime ; + + //cancel the timer + mStartStablizingTime = 0.f ; + mEndStablizingTime = 0.f ; + } + else + { + mTotalStablizingTime = t ; + } + } + mTotalStablizingTime = 0.f ; +} + +//virtual +void LLTexturePipelineTester::compareTestSessions(std::ofstream* os) +{ + LLTexturePipelineTester::LLTextureTestSession* base_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(mBaseSessionp) ; + LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(mCurrentSessionp) ; + if(!base_sessionp || !current_sessionp) + { + llerrs << "type of test session does not match!" << llendl ; + } + + //compare and output the comparison + *os << llformat("%s\n", mName.c_str()) ; + *os << llformat("AggregateResults\n") ; + + compareTestResults(os, "TotalFetchingTime", base_sessionp->mTotalFetchingTime, current_sessionp->mTotalFetchingTime) ; + compareTestResults(os, "TotalGrayTime", base_sessionp->mTotalGrayTime, current_sessionp->mTotalGrayTime) ; + compareTestResults(os, "TotalStablizingTime", base_sessionp->mTotalStablizingTime, current_sessionp->mTotalStablizingTime); + compareTestResults(os, "StartTimeLoadingSculpties", base_sessionp->mStartTimeLoadingSculpties, current_sessionp->mStartTimeLoadingSculpties) ; + compareTestResults(os, "TotalTimeLoadingSculpties", base_sessionp->mTotalTimeLoadingSculpties, current_sessionp->mTotalTimeLoadingSculpties) ; + + compareTestResults(os, "TotalBytesLoaded", base_sessionp->mTotalBytesLoaded, current_sessionp->mTotalBytesLoaded) ; + compareTestResults(os, "TotalBytesLoadedFromCache", base_sessionp->mTotalBytesLoadedFromCache, current_sessionp->mTotalBytesLoadedFromCache) ; + compareTestResults(os, "TotalBytesLoadedForLargeImage", base_sessionp->mTotalBytesLoadedForLargeImage, current_sessionp->mTotalBytesLoadedForLargeImage) ; + compareTestResults(os, "TotalBytesLoadedForSculpties", base_sessionp->mTotalBytesLoadedForSculpties, current_sessionp->mTotalBytesLoadedForSculpties) ; + + *os << llformat("InstantResults\n") ; + S32 size = llmin(base_sessionp->mInstantPerformanceListCounter, current_sessionp->mInstantPerformanceListCounter) ; + for(S32 i = 0 ; i < size ; i++) + { + *os << llformat("Time(B-T)-%.4f-%.4f\n", base_sessionp->mInstantPerformanceList[i].mTime, current_sessionp->mInstantPerformanceList[i].mTime) ; + + compareTestResults(os, "AverageBytesUsedPerSecond", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond, + current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; + + compareTestResults(os, "AverageBytesUsedForLargeImagePerSecond", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond, + current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; + + compareTestResults(os, "AveragePercentageBytesUsedPerSecond", base_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond, + current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + } + + if(size < base_sessionp->mInstantPerformanceListCounter) + { + for(S32 i = size ; i < base_sessionp->mInstantPerformanceListCounter ; i++) + { + *os << llformat("Time(B-T)-%.4f- \n", base_sessionp->mInstantPerformanceList[i].mTime) ; + + *os << llformat(", AverageBytesUsedPerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; + *os << llformat(", AverageBytesUsedForLargeImagePerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; + *os << llformat(", AveragePercentageBytesUsedPerSecond, %.4f, N/A \n", base_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + } + } + else if(size < current_sessionp->mInstantPerformanceListCounter) + { + for(S32 i = size ; i < current_sessionp->mInstantPerformanceListCounter ; i++) + { + *os << llformat("Time(B-T)- -%.4f\n", current_sessionp->mInstantPerformanceList[i].mTime) ; + + *os << llformat(", AverageBytesUsedPerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; + *os << llformat(", AverageBytesUsedForLargeImagePerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; + *os << llformat(", AveragePercentageBytesUsedPerSecond, N/A, %.4f\n", current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + } + } +} + +//virtual +LLMetricPerformanceTester::LLTestSession* LLTexturePipelineTester::loadTestSession(LLSD* log) +{ + LLTexturePipelineTester::LLTextureTestSession* sessionp = new LLTexturePipelineTester::LLTextureTestSession() ; + if(!sessionp) + { + return NULL ; + } + + F32 total_fetching_time = 0.f ; + F32 total_gray_time = 0.f ; + F32 total_stablizing_time = 0.f ; + F32 total_loading_sculpties_time = 0.f ; + + F32 start_fetching_time = -1.f ; + F32 start_fetching_sculpties_time = 0.f ; + + F32 last_time = 0.0f ; + S32 frame_count = 0 ; + + sessionp->mInstantPerformanceListCounter = 0 ; + sessionp->mInstantPerformanceList.resize(128) ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0 ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0 ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f ; + + //load a session + BOOL in_log = (*log).has(mCurLabel) ; + while(in_log) + { + LLSD::String label = mCurLabel ; + incLabel() ; + in_log = (*log).has(mCurLabel) ; + + if(sessionp->mInstantPerformanceListCounter >= (S32)sessionp->mInstantPerformanceList.size()) + { + sessionp->mInstantPerformanceList.resize(sessionp->mInstantPerformanceListCounter + 128) ; + } + + //time + F32 start_time = (*log)[label]["StartFetchingTime"].asReal() ; + F32 cur_time = (*log)[label]["Time"].asReal() ; + if(start_time - start_fetching_time > 0.0001f) //fetching has paused for a while + { + sessionp->mTotalFetchingTime += total_fetching_time ; + sessionp->mTotalGrayTime += total_gray_time ; + sessionp->mTotalStablizingTime += total_stablizing_time ; + + sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time ; + sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time ; + + start_fetching_time = start_time ; + total_fetching_time = 0.0f ; + total_gray_time = 0.f ; + total_stablizing_time = 0.f ; + total_loading_sculpties_time = 0.f ; + } + else + { + total_fetching_time = cur_time - start_time ; + total_gray_time = (*log)[label]["TotalGrayTime"].asReal() ; + total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal() ; + + total_loading_sculpties_time = (*log)[label]["EndTimeLoadingSculpties"].asReal() - (*log)[label]["StartTimeLoadingSculpties"].asReal() ; + if(start_fetching_sculpties_time < 0.f && total_loading_sculpties_time > 0.f) + { + start_fetching_sculpties_time = (*log)[label]["StartTimeLoadingSculpties"].asReal() ; + } + } + + //total loaded bytes + sessionp->mTotalBytesLoaded = (*log)[label]["TotalBytesLoaded"].asInteger() ; + sessionp->mTotalBytesLoadedFromCache = (*log)[label]["TotalBytesLoadedFromCache"].asInteger() ; + sessionp->mTotalBytesLoadedForLargeImage = (*log)[label]["TotalBytesLoadedForLargeImage"].asInteger() ; + sessionp->mTotalBytesLoadedForSculpties = (*log)[label]["TotalBytesLoadedForSculpties"].asInteger() ; + + //instant metrics + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond += + (*log)[label]["TotalBytesBound"].asInteger() ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond += + (*log)[label]["TotalBytesBoundForLargeImage"].asInteger() ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond += + (*log)[label]["PercentageBytesBound"].asReal() ; + frame_count++ ; + if(cur_time - last_time >= 1.0f) + { + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond /= frame_count ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond /= frame_count ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond /= frame_count ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = last_time ; + + frame_count = 0 ; + last_time = cur_time ; + sessionp->mInstantPerformanceListCounter++ ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0 ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0 ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f ; + } + } + + sessionp->mTotalFetchingTime += total_fetching_time ; + sessionp->mTotalGrayTime += total_gray_time ; + sessionp->mTotalStablizingTime += total_stablizing_time ; + + if(sessionp->mStartTimeLoadingSculpties < 0.f) + { + sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time ; + } + sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time ; + + return sessionp; +} + +LLTexturePipelineTester::LLTextureTestSession::LLTextureTestSession() +{ + reset() ; +} +LLTexturePipelineTester::LLTextureTestSession::~LLTextureTestSession() +{ +} +void LLTexturePipelineTester::LLTextureTestSession::reset() +{ + mTotalFetchingTime = 0.0f ; + + mTotalGrayTime = 0.0f ; + mTotalStablizingTime = 0.0f ; + + mStartTimeLoadingSculpties = 0.0f ; + mTotalTimeLoadingSculpties = 0.0f ; + + mTotalBytesLoaded = 0 ; + mTotalBytesLoadedFromCache = 0 ; + mTotalBytesLoadedForLargeImage = 0 ; + mTotalBytesLoadedForSculpties = 0 ; + + mInstantPerformanceListCounter = 0 ; +} +//---------------------------------------------------------------------------------------------- +//end of LLTexturePipelineTester +//---------------------------------------------------------------------------------------------- + diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h new file mode 100644 index 0000000000..142c212435 --- /dev/null +++ b/indra/newview/llviewertexture.h @@ -0,0 +1,672 @@ +/** + * @file llviewertexture.h + * @brief Object for managing images and their textures + * + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLVIEWERTEXTURE_H +#define LL_LLVIEWERTEXTURE_H + +#include "lltexture.h" +#include "lltimer.h" +#include "llframetimer.h" +#include "llhost.h" +#include "llgltypes.h" +#include "llrender.h" +#include "llmetricperformancetester.h" + +#include <map> +#include <list> + +#define MIN_VIDEO_RAM_IN_MEGA_BYTES 32 +#define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons. + +class LLFace; +class LLImageGL ; +class LLViewerTexture; +class LLViewerFetchedTexture ; +class LLViewerMediaTexture ; +class LLTexturePipelineTester ; + +typedef void (*loaded_callback_func)( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); + +class LLVFile; +class LLMessageSystem; + +class LLLoadedCallbackEntry +{ +public: + LLLoadedCallbackEntry(loaded_callback_func cb, + S32 discard_level, + BOOL need_imageraw, // Needs image raw for the callback + void* userdata ) + : mCallback(cb), + mLastUsedDiscard(MAX_DISCARD_LEVEL+1), + mDesiredDiscard(discard_level), + mNeedsImageRaw(need_imageraw), + mUserData(userdata) + { + } + + loaded_callback_func mCallback; + S32 mLastUsedDiscard; + S32 mDesiredDiscard; + BOOL mNeedsImageRaw; + void* mUserData; +}; + +class LLTextureBar; + +class LLViewerTexture : public LLTexture +{ +public: + enum + { + MAX_IMAGE_SIZE_DEFAULT = 1024, + INVALID_DISCARD_LEVEL = 0x7fff + }; + enum + { + LOCAL_TEXTURE, + MEDIA_TEXTURE, + DYNAMIC_TEXTURE, + FETCHED_TEXTURE, + LOD_TEXTURE, + INVALID_TEXTURE_TYPE + }; + + enum EBoostLevel + { + BOOST_NONE = 0, + BOOST_AVATAR_BAKED = 1, + BOOST_AVATAR = 2, + BOOST_CLOUDS = 3, + BOOST_SCULPTED = 4, + + BOOST_HIGH = 10, + BOOST_TERRAIN = 11, // has to be high priority for minimap / low detail + BOOST_SELECTED = 12, + BOOST_HUD = 13, + BOOST_AVATAR_BAKED_SELF = 14, + BOOST_UI = 15, + BOOST_PREVIEW = 16, + BOOST_MAP = 17, + BOOST_MAP_LAYER = 18, + BOOST_AVATAR_SELF = 19, // needed for baking avatar + BOOST_MAX_LEVEL + }; + +protected: + virtual ~LLViewerTexture(); + LOG_CLASS(LLViewerTexture); + +public: + static void initClass(); + static void cleanupClass(); + static void updateClass(const F32 velocity, const F32 angular_velocity) ; + + LLViewerTexture(BOOL usemipmaps = TRUE); + LLViewerTexture(const LLUUID& id, BOOL usemipmaps) ; + LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) ; + LLViewerTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps) ; + + virtual S8 getType() const; + virtual BOOL isMissingAsset()const ; + virtual void dump(); // debug info to llinfos + + /*virtual*/ bool bindDefaultImage(const S32 stage = 0) const ; + /*virtual*/ void forceImmediateUpdate() ; + + const LLUUID& getID() const { return mID; } + + void setBoostLevel(S32 level); + S32 getBoostLevel() { return mBoostLevel; } + + //maxVirtualSize of the texture + void addTextureStats(F32 virtual_size) const ; + void resetTextureStats(BOOL zero = FALSE); + F32 getMaxVirtualSize()const {return mMaxVirtualSize ;} + + LLFrameTimer* getLastReferencedTimer() {return &mLastReferencedTimer ;} + + S32 getFullWidth() const { return mFullWidth; } + S32 getFullHeight() const { return mFullHeight; } + + void addFace(LLFace* facep) ; + void removeFace(LLFace* facep) ; + + void generateGLTexture() ; + void destroyGLTexture() ; + + //--------------------------------------------------------------------------------------------- + //functions to access LLImageGL + //--------------------------------------------------------------------------------------------- + /*virtual*/S32 getWidth(S32 discard_level = -1) const; + /*virtual*/S32 getHeight(S32 discard_level = -1) const; + + BOOL hasGLTexture() const ; + BOOL hasValidGLTexture() const ; + LLGLuint getTexName() const ; + BOOL createGLTexture() ; + BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); + + void setFilteringOption(LLTexUnit::eTextureFilterOptions option); + void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE); + void setAddressMode(LLTexUnit::eTextureAddressMode mode); + BOOL setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height); + BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height); + void setGLTextureCreated (bool initialized); + + LLTexUnit::eTextureAddressMode getAddressMode(void) const ; + S32 getMaxDiscardLevel() const; + S32 getDiscardLevel() const; + S8 getComponents() const ; + BOOL getBoundRecently() const; + S32 getTextureMemory() const ; + LLGLenum getPrimaryFormat() const; + BOOL getIsAlphaMask() const ; + LLTexUnit::eTextureType getTarget(void) const ; + BOOL getMask(const LLVector2 &tc); + F32 getTimePassedSinceLastBound(); + BOOL getMissed() const ; + BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; + BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) const; + //--------------------------------------------------------------------------------------------- + //end of functions to access LLImageGL + //--------------------------------------------------------------------------------------------- + + void switchToTexture(LLViewerTexture* new_texture) ; //make all faces pointing to this texture to point to new_texture. + + //----------------- + /*virtual*/ void setActive() ; + void forceActive() ; + void setNoDelete() ; + void dontDiscard() { mDontDiscard = 1; mTextureState = NO_DELETE; } + BOOL getDontDiscard() const { return mDontDiscard; } + //----------------- + + /*virtual*/ void updateBindStatsForTester() ; +protected: + void cleanup() ; + void init(bool firstinit) ; + +private: + //note: do not make this function public. + /*virtual*/ LLImageGL* getGLTexture() const ; + +protected: + LLUUID mID; + S32 mBoostLevel; // enum describing priority level + S32 mFullWidth; + S32 mFullHeight; + BOOL mUseMipMaps ; + S8 mComponents; + mutable F32 mMaxVirtualSize; // The largest virtual size of the image, in pixels - how much data to we need? + + LLFrameTimer mLastReferencedTimer; + + typedef std::list<LLFace*> ll_face_list_t ; + ll_face_list_t mFaceList ; //reverse pointer pointing to the faces using this image as texture + + //GL texture + LLPointer<LLImageGL> mGLTexturep ; + S8 mDontDiscard; // Keep full res version of this image (for UI, etc) + +protected: + typedef enum + { + DELETED = 0, //removed from memory + DELETION_CANDIDATE, //ready to be removed from memory + INACTIVE, //not be used for the last certain period (i.e., 30 seconds). + ACTIVE, //just being used, can become inactive if not being used for a certain time (10 seconds). + NO_DELETE = 99 //stay in memory, can not be removed. + } LLGLTexureState; + LLGLTexureState mTextureState ; + +public: + static const U32 sCurrentFileVersion; + static S32 sImageCount; + static S32 sRawCount; + static S32 sAuxCount; + static LLTimer sEvaluationTimer; + static F32 sDesiredDiscardBias; + static F32 sDesiredDiscardScale; + static S32 sBoundTextureMemoryInBytes; + static S32 sTotalTextureMemoryInBytes; + static S32 sMaxBoundTextureMemInMegaBytes; + static S32 sMaxTotalTextureMemInMegaBytes; + static S32 sMaxDesiredTextureMemInBytes ; + static BOOL sDontLoadVolumeTextures; + + static LLPointer<LLViewerTexture> sNullImagep; // Null texture for non-textured objects. +}; + + +// +//textures are managed in gTextureList. +//raw image data is fetched from remote or local cache +//but the raw image this texture pointing to is fixed. +// +class LLViewerFetchedTexture : public LLViewerTexture +{ + friend class LLTextureBar; // debug info only + friend class LLTextureView; // debug info only + +protected: + /*virtual*/ ~LLViewerFetchedTexture(); +public: + LLViewerFetchedTexture(const LLUUID& id, BOOL usemipmaps = TRUE); + LLViewerFetchedTexture(const LLImageRaw* raw, BOOL usemipmaps); + LLViewerFetchedTexture(const std::string& full_path, const LLUUID& id, BOOL usemipmaps = TRUE); + +public: + static F32 maxDecodePriority(); + + struct Compare + { + // lhs < rhs + bool operator()(const LLPointer<LLViewerFetchedTexture> &lhs, const LLPointer<LLViewerFetchedTexture> &rhs) const + { + const LLViewerFetchedTexture* lhsp = (const LLViewerFetchedTexture*)lhs; + const LLViewerFetchedTexture* rhsp = (const LLViewerFetchedTexture*)rhs; + // greater priority is "less" + const F32 lpriority = lhsp->getDecodePriority(); + const F32 rpriority = rhsp->getDecodePriority(); + if (lpriority > rpriority) // higher priority + return true; + if (lpriority < rpriority) + return false; + return lhsp < rhsp; + } + }; + +public: + /*virtual*/ S8 getType() const ; + /*virtual*/ void forceImmediateUpdate() ; + /*virtual*/ void dump() ; + + // Set callbacks to get called when the image gets updated with higher + // resolution versions. + void setLoadedCallback(loaded_callback_func cb, + S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, + void* userdata); + bool hasCallbacks() { return mLoadedCallbackList.empty() ? false : true; } + bool doLoadedCallbacks(); + + // ONLY call from LLViewerTextureList + BOOL createTexture(S32 usename = 0); + void destroyTexture() ; + + virtual void processTextureStats() ; + F32 calcDecodePriority() ; + + BOOL needsAux() const { return mNeedsAux; } + + // Host we think might have this image, used for baked av textures. + void setTargetHost(LLHost host) { mTargetHost = host; } + LLHost getTargetHost() const { return mTargetHost; } + + // Set the decode priority for this image... + // DON'T CALL THIS UNLESS YOU KNOW WHAT YOU'RE DOING, it can mess up + // the priority list, and cause horrible things to happen. + void setDecodePriority(F32 priority = -1.0f); + F32 getDecodePriority() const { return mDecodePriority; }; + + // setDesiredDiscardLevel is only used by LLViewerTextureList + void setDesiredDiscardLevel(S32 discard) { mDesiredDiscardLevel = discard; } + S32 getDesiredDiscardLevel() { return mDesiredDiscardLevel; } + void setMinDiscardLevel(S32 discard) { mMinDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel,(S8)discard); } + + bool updateFetch(); + + // Override the computation of discard levels if we know the exact output + // size of the image. Used for UI textures to not decode, even if we have + // more data. + void setKnownDrawSize(S32 width, S32 height); + + void setIsMissingAsset(); + /*virtual*/ BOOL isMissingAsset() const { return mIsMissingAsset; } + + // returns dimensions of original image for local files (before power of two scaling) + // and returns 0 for all asset system images + S32 getOriginalWidth() { return mOrigWidth; } + S32 getOriginalHeight() { return mOrigHeight; } + + BOOL isInImageList() const {return mInImageList ;} + void setInImageList(BOOL flag) {mInImageList = flag ;} + + const std::string& getLocalFileName() const {return mLocalFileName ;} + LLFrameTimer* getLastPacketTimer() {return &mLastPacketTimer;} + + U32 getFetchPriority() const { return mFetchPriority ;} + F32 getDownloadProgress() const {return mDownloadProgress ;} + + LLImageRaw* readBackRawImage(S8 discard_level) ; + void destroyRawImage(); + + //--------------- + BOOL isDeleted() ; + BOOL isInactive() ; + BOOL isDeletionCandidate(); + void setDeletionCandidate() ; + void setInactive() ; + BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; } + //--------------- + + void setForSculpt(); + BOOL isForSculpt() const {return mForSculpt;} + +private: + void init(bool firstinit) ; + void cleanup() ; + + F32 calcDecodePriorityForUnknownTexture(F32 pixel_priority) ; + +private: + BOOL mFullyLoaded; + +protected: + S32 mOrigWidth; + S32 mOrigHeight; + + // Override the computation of discard levels if we know the exact output size of the image. + // Used for UI textures to not decode, even if we have more data. + S32 mKnownDrawWidth; + S32 mKnownDrawHeight; + + std::string mLocalFileName; + + S8 mDesiredDiscardLevel; // The discard level we'd LIKE to have - if we have it and there's space + S8 mMinDesiredDiscardLevel; // The minimum discard level we'd like to have + S32 mMinDiscardLevel; + + S32 mRequestedDiscardLevel; + F32 mRequestedDownloadPriority; + S32 mFetchState; + U32 mFetchPriority; + F32 mDownloadProgress; + F32 mFetchDeltaTime; + F32 mRequestDeltaTime; + S32 mDecodeFrame; + S32 mVisibleFrame; // decode frame where image was last visible + + S8 mNeedsAux; // We need to decode the auxiliary channels + S8 mDecodingAux; // Are we decoding high components + S8 mIsRawImageValid; + S8 mHasFetcher; // We've made a fecth request + S8 mIsFetching; // Fetch request is active + + mutable S8 mIsMissingAsset; // True if we know that there is no image asset with this image id in the database. + + F32 mDecodePriority; // The priority for decoding this image. + typedef std::list<LLLoadedCallbackEntry*> callback_list_t; + callback_list_t mLoadedCallbackList; + + LLPointer<LLImageRaw> mRawImage; + S32 mRawDiscardLevel; + + // Used ONLY for cloth meshes right now. Make SURE you know what you're + // doing if you use it for anything else! - djs + LLPointer<LLImageRaw> mAuxRawImage; + + LLHost mTargetHost; // if LLHost::invalid, just request from agent's simulator + + // Timers + LLFrameTimer mLastPacketTimer; // Time since last packet. + + BOOL mInImageList; // TRUE if image is in list (in which case don't reset priority!) + BOOL mNeedsCreateTexture; + + BOOL mForSculpt ; //a flag if the texture is used as sculpt data. + BOOL mIsFetched ; //is loaded from remote or from cache, not generated locally. + +public: + static LLPointer<LLViewerFetchedTexture> sMissingAssetImagep; // Texture to show for an image asset that is not in the database + static LLPointer<LLViewerFetchedTexture> sWhiteImagep; // Texture to show NOTHING (whiteness) + static LLPointer<LLViewerFetchedTexture> sDefaultImagep; // "Default" texture for error cases, the only case of fetched texture which is generated in local. + static LLPointer<LLViewerFetchedTexture> sSmokeImagep; // Old "Default" translucent texture +}; + +// +//the image data is fetched from remote or from local cache +//the resolution of the texture is adjustable: depends on the view-dependent parameters. +// +class LLViewerLODTexture : public LLViewerFetchedTexture +{ +protected: + /*virtual*/ ~LLViewerLODTexture(){} + +public: + LLViewerLODTexture(const LLUUID& id, BOOL usemipmaps = TRUE); + LLViewerLODTexture(const std::string& full_path, const LLUUID& id, BOOL usemipmaps = TRUE); + + /*virtual*/ S8 getType() const; + // Process image stats to determine priority/quality requirements. + /*virtual*/ void processTextureStats(); + +private: + void init(bool firstinit) ; + +private: + + F32 mTexelsPerImage; // Texels per image. + F32 mDiscardVirtualSize; // Virtual size used to calculate desired discard + F32 mCalculatedDiscardLevel; // Last calculated discard level +}; + +// +//the image data is fetched from the media pipeline periodically +//the resolution of the texture is also adjusted by the media pipeline +// +class LLViewerMediaTexture : public LLViewerTexture +{ +protected: + /*virtual*/ ~LLViewerMediaTexture() {} + +public: + LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps = TRUE, LLImageGL* gl_image = NULL) ; + + /*virtual*/ S8 getType() const; + + void reinit(BOOL usemipmaps = TRUE); + + BOOL getUseMipMaps() {return mUseMipMaps ; } + void setUseMipMaps(BOOL mipmap) ; + + void setOldTexture(LLViewerTexture* tex) ; + LLViewerTexture* getOldTexture() const ; + + void setPlaying(BOOL playing) {mIsPlaying = playing ;} + BOOL isPlaying() const {return mIsPlaying;} + +private: + LLPointer<LLViewerTexture> mOldTexturep ; //the texture this media texture replaces. + BOOL mIsPlaying ; + +public: + static void updateClass() ; + +public: + typedef std::map< LLUUID, LLPointer<LLViewerMediaTexture> > media_map_t ; + static media_map_t sMediaMap ; +}; + +//just an interface class, do not create instance from this class. +class LLViewerTextureManager +{ +private: + //make the constructor private to preclude creating instances from this class. + LLViewerTextureManager(){} + +public: + //texture pipeline tester + static LLTexturePipelineTester* sTesterp ; + + //returns NULL if tex is not a LLViewerFetchedTexture nor derived from LLViewerFetchedTexture. + static LLViewerFetchedTexture* staticCastToFetchedTexture(LLViewerTexture* tex, BOOL report_error = FALSE) ; + + // + //"find-texture" just check if the texture exists, if yes, return it, otherwise return null. + // + static LLViewerTexture* findTexture(const LLUUID& id) ; + static LLViewerMediaTexture* findMediaTexture(const LLUUID& id) ; + + static LLViewerMediaTexture* createMediaTexture(const LLUUID& id, BOOL usemipmaps = TRUE, LLImageGL* gl_image = NULL) ; + + // + //"get-texture" will create a new texture if the texture does not exist. + // + static LLViewerMediaTexture* getMediaTexture(const LLUUID& id, BOOL usemipmaps = TRUE, LLImageGL* gl_image = NULL) ; + + static LLPointer<LLViewerTexture> getLocalTexture(BOOL usemipmaps = TRUE, BOOL generate_gl_tex = TRUE); + static LLPointer<LLViewerTexture> getLocalTexture(const LLUUID& id, BOOL usemipmaps, BOOL generate_gl_tex = TRUE) ; + static LLPointer<LLViewerTexture> getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps) ; + static LLPointer<LLViewerTexture> getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex = TRUE) ; + + static LLViewerFetchedTexture* getFetchedTexture(const LLUUID &image_id, + BOOL usemipmap = TRUE, + BOOL level_immediate = FALSE, // Get the requested level immediately upon creation. + S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, + LLGLint internal_format = 0, + LLGLenum primary_format = 0, + LLHost request_from_host = LLHost() + ); + + static LLViewerFetchedTexture* getFetchedTextureFromFile(const std::string& filename, + BOOL usemipmap = TRUE, + BOOL level_immediate = FALSE, // Get the requested level immediately upon creation. + S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, + LLGLint internal_format = 0, + LLGLenum primary_format = 0, + const LLUUID& force_id = LLUUID::null + ); + + static LLViewerFetchedTexture* getFetchedTextureFromHost(const LLUUID& image_id, LLHost host) ; + + static void init() ; + static void cleanup() ; +}; +// +//this class is used for test/debug only +//it tracks the activities of the texture pipeline +//records them, and outputs them to log files +// +class LLTexturePipelineTester : public LLMetricPerformanceTester +{ + enum + { + MIN_LARGE_IMAGE_AREA = 262144 //512 * 512 + }; +public: + LLTexturePipelineTester() ; + ~LLTexturePipelineTester() ; + + void update(); + void updateTextureBindingStats(const LLViewerTexture* imagep) ; + void updateTextureLoadingStats(const LLViewerFetchedTexture* imagep, const LLImageRaw* raw_imagep, BOOL from_cache) ; + void updateGrayTextureBinding() ; + void setStablizingTime() ; + + /*virtual*/ void analyzePerformance(std::ofstream* os, LLSD* base, LLSD* current) ; + +private: + void reset() ; + void updateStablizingTime() ; + + /*virtual*/ void outputTestRecord(LLSD* sd) ; + +private: + BOOL mPause ; +private: + BOOL mUsingDefaultTexture; //if set, some textures are still gray. + + U32 mTotalBytesUsed ; //total bytes of textures bound/used for the current frame. + U32 mTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the current frame for images larger than 256 * 256. + U32 mLastTotalBytesUsed ; //total bytes of textures bound/used for the previous frame. + U32 mLastTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the previous frame for images larger than 256 * 256. + + // + //data size + // + U32 mTotalBytesLoaded ; //total bytes fetched by texture pipeline + U32 mTotalBytesLoadedFromCache ; //total bytes fetched by texture pipeline from local cache + U32 mTotalBytesLoadedForLargeImage ; //total bytes fetched by texture pipeline for images larger than 256 * 256. + U32 mTotalBytesLoadedForSculpties ; //total bytes fetched by texture pipeline for sculpties + + // + //time + //NOTE: the error tolerances of the following timers is one frame time. + // + F32 mStartFetchingTime ; + F32 mTotalGrayTime ; //total loading time when no gray textures. + F32 mTotalStablizingTime ; //total stablizing time when texture memory overflows + F32 mStartTimeLoadingSculpties ; //the start moment of loading sculpty images. + F32 mEndTimeLoadingSculpties ; //the end moment of loading sculpty images. + F32 mStartStablizingTime ; + F32 mEndStablizingTime ; + +private: + // + //The following members are used for performance analyzing + // + class LLTextureTestSession : public LLTestSession + { + public: + LLTextureTestSession() ; + /*virtual*/ ~LLTextureTestSession() ; + + void reset() ; + + F32 mTotalFetchingTime ; + F32 mTotalGrayTime ; + F32 mTotalStablizingTime ; + F32 mStartTimeLoadingSculpties ; + F32 mTotalTimeLoadingSculpties ; + + S32 mTotalBytesLoaded ; + S32 mTotalBytesLoadedFromCache ; + S32 mTotalBytesLoadedForLargeImage ; + S32 mTotalBytesLoadedForSculpties ; + + typedef struct _texture_instant_preformance_t + { + S32 mAverageBytesUsedPerSecond ; + S32 mAverageBytesUsedForLargeImagePerSecond ; + F32 mAveragePercentageBytesUsedPerSecond ; + F32 mTime ; + }texture_instant_preformance_t ; + std::vector<texture_instant_preformance_t> mInstantPerformanceList ; + S32 mInstantPerformanceListCounter ; + }; + + /*virtual*/ LLMetricPerformanceTester::LLTestSession* loadTestSession(LLSD* log) ; + /*virtual*/ void compareTestSessions(std::ofstream* os) ; +}; + +#endif diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp new file mode 100644 index 0000000000..c96914975b --- /dev/null +++ b/indra/newview/llviewertexturelist.cpp @@ -0,0 +1,1510 @@ +/** + * @file llviewertexturelist.cpp + * @brief Object for managing the list of images within a region + * + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llviewertexturelist.h" + +#include "imageids.h" +#include "llgl.h" // fot gathering stats from GL +#include "llimagegl.h" +#include "llimagebmp.h" +#include "llimagej2c.h" +#include "llimagetga.h" +#include "llimagejpeg.h" +#include "llimagepng.h" + +#include "llsdserialize.h" +#include "llsys.h" +#include "llvfs.h" +#include "llvfile.h" +#include "llvfsthread.h" +#include "llxmltree.h" +#include "message.h" + +#include "llagent.h" +#include "lltexturecache.h" +#include "lltexturefetch.h" +#include "llviewercontrol.h" +#include "llviewertexture.h" +#include "llviewermedia.h" +#include "llviewerregion.h" +#include "llviewerstats.h" +#include "pipeline.h" +#include "llappviewer.h" +#include "lluictrlfactory.h" // for LLXUIParser +#include <sys/stat.h> + +//////////////////////////////////////////////////////////////////////////// + +void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; + +const S32 IMAGES_PER_REQUEST = 42; +const S32 IMAGES_MIN_UPDATES = 4; // Always update the highest N images each frame +const S32 IMAGES_MAX_PACKET_UPDATES = 1; // Only send N packets of IMAGES_PER_REQUEST in a frame +const F32 RESEND_IMAGE_REQUEST_TIME = 15.f; // seconds + +LLViewerTextureList gTextureList; + +/////////////////////////////////////////////////////////////////////////////// + +LLViewerTextureList::LLViewerTextureList() + : mForceResetTextureStats(FALSE), + mUpdateStats(FALSE), + mMaxResidentTexMemInMegaBytes(0), + mMaxTotalTextureMemInMegaBytes(0) +{ +} + +void LLViewerTextureList::init() +{ + mNumImages = 0; + mMaxResidentTexMemInMegaBytes = 0; + mMaxTotalTextureMemInMegaBytes = 0 ; + if (gNoRender) + { + // Don't initialize GL stuff if we're not rendering. + return; + } + + mUpdateStats = TRUE; + + // Update how much texture RAM we're allowed to use. + updateMaxResidentTexMem(0); // 0 = use current + + doPreloadImages(); +} + + +void LLViewerTextureList::doPreloadImages() +{ + LL_DEBUGS("ViewerImages") << "Preloading images..." << LL_ENDL; + + // Set the "missing asset" image + LLViewerFetchedTexture::sMissingAssetImagep = LLViewerTextureManager::getFetchedTextureFromFile("missing_asset.tga", MIPMAP_NO, IMMEDIATE_YES); + + // Set the "white" image + LLViewerFetchedTexture::sWhiteImagep = LLViewerTextureManager::getFetchedTextureFromFile("white.tga", MIPMAP_NO, IMMEDIATE_YES); + + LLUIImageList* image_list = LLUIImageList::getInstance(); + + image_list->initFromFile(); + + // turn off clamping and bilinear filtering for uv picking images + //LLViewerFetchedTexture* uv_test = preloadUIImage("uv_test1.tga", LLUUID::null, FALSE); + //uv_test->setClamp(FALSE, FALSE); + //uv_test->setMipFilterNearest(TRUE, TRUE); + //uv_test = preloadUIImage("uv_test2.tga", LLUUID::null, FALSE); + //uv_test->setClamp(FALSE, FALSE); + //uv_test->setMipFilterNearest(TRUE, TRUE); + + // prefetch specific UUIDs + LLViewerTextureManager::getFetchedTexture(IMG_SHOT, TRUE); + LLViewerTextureManager::getFetchedTexture(IMG_SMOKE_POOF, TRUE); + LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTextureFromFile("silhouette.j2c", MIPMAP_YES, IMMEDIATE_YES); + if (image) + { + image->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(image); + } + image = LLViewerTextureManager::getFetchedTextureFromFile("noentrylines.j2c", MIPMAP_YES, IMMEDIATE_YES); + if (image) + { + image->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(image); + } + image = LLViewerTextureManager::getFetchedTextureFromFile("noentrypasslines.j2c", MIPMAP_YES, IMMEDIATE_YES); + if (image) + { + image->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(image); + } + image = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL, MIPMAP_YES, IMMEDIATE_YES); + if (image) + { + image->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(image); + } + image = LLViewerTextureManager::getFetchedTextureFromFile("transparent.j2c", MIPMAP_YES, IMMEDIATE_YES, LLViewerTexture::FETCHED_TEXTURE, + 0,0,LLUUID("8dcd4a48-2d37-4909-9f78-f7a9eb4ef903")); + if (image) + { + image->setAddressMode(LLTexUnit::TAM_WRAP); + mImagePreloads.insert(image); + } + +} + +static std::string get_texture_list_name() +{ + return std::string("texture_list_") + gSavedSettings.getString("LoginLocation") + ".xml"; +} + +void LLViewerTextureList::doPrefetchImages() +{ + if (LLAppViewer::instance()->getPurgeCache()) + { + // cache was purged, no point + return; + } + + // Pre-fetch textures from last logout + LLSD imagelist; + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, get_texture_list_name()); + llifstream file; + file.open(filename); + if (file.is_open()) + { + LLSDSerialize::fromXML(imagelist, file); + } + for (LLSD::array_iterator iter = imagelist.beginArray(); + iter != imagelist.endArray(); ++iter) + { + LLSD imagesd = *iter; + LLUUID uuid = imagesd["uuid"]; + S32 pixel_area = imagesd["area"]; + S32 texture_type = imagesd["type"]; + + if(LLViewerTexture::FETCHED_TEXTURE == texture_type || LLViewerTexture::LOD_TEXTURE == texture_type) + { + LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture(uuid, MIPMAP_TRUE, FALSE, texture_type); + if (image) + { + image->addTextureStats((F32)pixel_area); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////// + +LLViewerTextureList::~LLViewerTextureList() +{ +} + +void LLViewerTextureList::shutdown() +{ + // clear out preloads + mImagePreloads.clear(); + + // Write out list of currently loaded textures for precaching on startup + typedef std::set<std::pair<S32,LLViewerFetchedTexture*> > image_area_list_t; + image_area_list_t image_area_list; + for (image_priority_list_t::iterator iter = mImageList.begin(); + iter != mImageList.end(); ++iter) + { + LLViewerFetchedTexture* image = *iter; + if (!image->hasGLTexture() || + !image->getUseDiscard() || + image->needsAux() || + image->getTargetHost() != LLHost::invalid) + { + continue; // avoid UI, baked, and other special images + } + S32 desired = image->getDesiredDiscardLevel(); + if (desired >= 0 && desired < MAX_DISCARD_LEVEL) + { + S32 pixel_area = image->getWidth(desired) * image->getHeight(desired); + image_area_list.insert(std::make_pair(pixel_area, image)); + } + } + + LLSD imagelist; + const S32 max_count = 1000; + S32 count = 0; + S32 image_type ; + for (image_area_list_t::reverse_iterator riter = image_area_list.rbegin(); + riter != image_area_list.rend(); ++riter) + { + LLViewerFetchedTexture* image = riter->second; + image_type = (S32)image->getType() ; + imagelist[count]["area"] = riter->first; + imagelist[count]["uuid"] = image->getID(); + imagelist[count]["type"] = image_type; + if (++count >= max_count) + break; + } + + if (count > 0 && !gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "").empty()) + { + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, get_texture_list_name()); + llofstream file; + file.open(filename); + LLSDSerialize::toPrettyXML(imagelist, file); + } + + // + // Clean up "loaded" callbacks. + // + mCallbackList.clear(); + + // Flush all of the references + mLoadingStreamList.clear(); + mCreateTextureList.clear(); + + mUUIDMap.clear(); + + mImageList.clear(); +} + +void LLViewerTextureList::dump() +{ + llinfos << "LLViewerTextureList::dump()" << llendl; + for (image_priority_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it) + { + LLViewerFetchedTexture* image = *it; + + llinfos << "priority " << image->getDecodePriority() + << " boost " << image->getBoostLevel() + << " size " << image->getWidth() << "x" << image->getHeight() + << " discard " << image->getDiscardLevel() + << " desired " << image->getDesiredDiscardLevel() + << " http://asset.siva.lindenlab.com/" << image->getID() << ".texture" + << llendl; + } +} + +void LLViewerTextureList::destroyGL(BOOL save_state) +{ + LLImageGL::destroyGL(save_state); +} + +void LLViewerTextureList::restoreGL() +{ + LLImageGL::restoreGL(); +} + +/* Vertical tab container button image IDs + Seem to not decode when running app in debug. + + const LLUUID BAD_IMG_ONE("1097dcb3-aef9-8152-f471-431d840ea89e"); + const LLUUID BAD_IMG_TWO("bea77041-5835-1661-f298-47e2d32b7a70"); + */ + +/////////////////////////////////////////////////////////////////////////////// + +LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string& filename, + BOOL usemipmaps, + BOOL level_immediate, + S8 texture_type, + LLGLint internal_format, + LLGLenum primary_format, + const LLUUID& force_id) +{ + if (gNoRender) + { + // Never mind that this ignores image_set_id; + // getImage() will handle that later. + return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, TRUE); + } + + std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename); + if (full_path.empty()) + { + llwarns << "Failed to find local image file: " << filename << llendl; + return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, TRUE); + } + + // generate UUID based on hash of filename + LLUUID new_id; + if (force_id.notNull()) + { + new_id = force_id; + } + else + { + new_id.generate(full_path); + } + + LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id); + + if (imagep.isNull()) + { + switch(texture_type) + { + case LLViewerTexture::FETCHED_TEXTURE: + imagep = new LLViewerFetchedTexture(full_path, new_id, usemipmaps); + break ; + case LLViewerTexture::LOD_TEXTURE: + imagep = new LLViewerLODTexture(full_path, new_id, usemipmaps); + break ; + default: + llerrs << "Invalid texture type " << texture_type << llendl ; + } + + if (internal_format && primary_format) + { + imagep->setExplicitFormat(internal_format, primary_format); + } + + addImage(imagep); + + if (level_immediate) + { + imagep->dontDiscard(); + imagep->setBoostLevel(LLViewerFetchedTexture::BOOST_UI); + } + } + + imagep->setGLTextureCreated(true); + + return imagep; +} + + +LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id, + BOOL usemipmaps, + BOOL level_immediate, + S8 texture_type, + LLGLint internal_format, + LLGLenum primary_format, + LLHost request_from_host) +{ + // Return the image with ID image_id + // If the image is not found, creates new image and + // enqueues a request for transmission + + if ((&image_id == NULL) || image_id.isNull()) + { + return (LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, TRUE)); + } + + LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id); + + if (imagep.isNull()) + { + imagep = createImage(image_id, usemipmaps, level_immediate, texture_type, internal_format, primary_format, request_from_host) ; + } + + imagep->setGLTextureCreated(true); + + return imagep; +} + +//when this function is called, there is no such texture in the gTextureList with image_id. +LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id, + BOOL usemipmaps, + BOOL level_immediate, + S8 texture_type, + LLGLint internal_format, + LLGLenum primary_format, + LLHost request_from_host) +{ + LLPointer<LLViewerFetchedTexture> imagep ; + switch(texture_type) + { + case LLViewerTexture::FETCHED_TEXTURE: + imagep = new LLViewerFetchedTexture(image_id, usemipmaps); + break ; + case LLViewerTexture::LOD_TEXTURE: + imagep = new LLViewerLODTexture(image_id, usemipmaps); + break ; + default: + llerrs << "Invalid texture type " << texture_type << llendl ; + } + + // Might want to request from host other than where the agent is. JC + imagep->setTargetHost(request_from_host); + + if (internal_format && primary_format) + { + imagep->setExplicitFormat(internal_format, primary_format); + } + + addImage(imagep); + + if (level_immediate) + { + imagep->dontDiscard(); + imagep->setBoostLevel(LLViewerFetchedTexture::BOOST_UI); + } + else + { + //by default, the texure can not be removed from memory even if it is not used. + //here turn this off + //if this texture should be set to NO_DELETE, either pass level_immediate == TRUE here, or call setNoDelete() afterwards. + imagep->forceActive() ; + } + + return imagep ; +} + +LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id) +{ + uuid_map_t::iterator iter = mUUIDMap.find(image_id); + if(iter == mUUIDMap.end()) + return NULL; + return iter->second; +} + +void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image) +{ + llassert(image); + if (image->isInImageList()) + { + llerrs << "LLViewerTextureList::addImageToList - Image already in list" << llendl; + } + llverify((mImageList.insert(image)).second == true); + image->setInImageList(TRUE) ; +} + +void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) +{ + llassert(image); + if (!image->isInImageList()) + { + llinfos << "RefCount: " << image->getNumRefs() << llendl ; + uuid_map_t::iterator iter = mUUIDMap.find(image->getID()); + if(iter == mUUIDMap.end() || iter->second != image) + { + llinfos << "Image is not in mUUIDMap!" << llendl ; + } + llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl; + } + llverify(mImageList.erase(image) == 1); + image->setInImageList(FALSE) ; +} + +void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image) +{ + if (!new_image) + { + llwarning("No image to add to image list", 0); + return; + } + LLUUID image_id = new_image->getID(); + + LLViewerFetchedTexture *image = findImage(image_id); + if (image) + { + llwarns << "Image with ID " << image_id << " already in list" << llendl; + } + mNumImages++; + + addImageToList(new_image); + mUUIDMap[image_id] = new_image; +} + + +void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image) +{ + if( image) + { + if (image->hasCallbacks()) + { + mCallbackList.erase(image); + } + + llverify(mUUIDMap.erase(image->getID()) == 1); + mNumImages--; + removeImageFromList(image); + } +} + +/////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////////// + +void LLViewerTextureList::dirtyImage(LLViewerFetchedTexture *image) +{ + mDirtyTextureList.insert(image); +} + +//////////////////////////////////////////////////////////////////////////// + +void LLViewerTextureList::updateImages(F32 max_time) +{ + LLViewerStats::getInstance()->mNumImagesStat.addValue(mNumImages); + LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); + LLViewerStats::getInstance()->mGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); + LLViewerStats::getInstance()->mGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); + LLViewerStats::getInstance()->mRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory)); + LLViewerStats::getInstance()->mFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); + + updateImagesDecodePriorities(); + max_time -= updateImagesFetchTextures(max_time); + max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); + max_time -= updateImagesCreateTextures(max_time); + max_time = llmin(llmax(max_time, 0.001f*10.f*gFrameIntervalSeconds), 0.001f); + if (!mDirtyTextureList.empty()) + { + LLFastTimer t(LLFastTimer::FTM_IMAGE_MARK_DIRTY); + gPipeline.dirtyPoolObjectTextures(mDirtyTextureList); + mDirtyTextureList.clear(); + } + bool didone = false; + for (image_list_t::iterator iter = mCallbackList.begin(); + iter != mCallbackList.end(); ) + { + //trigger loaded callbacks on local textures immediately + LLViewerFetchedTexture* image = *iter++; + if (!image->getLocalFileName().empty()) + { + // Do stuff to handle callbacks, update priorities, etc. + didone = image->doLoadedCallbacks(); + } + else if (!didone) + { + // Do stuff to handle callbacks, update priorities, etc. + didone = image->doLoadedCallbacks(); + } + } + if (!gNoRender && !gGLManager.mIsDisabled) + { + LLViewerMedia::updateImagesMediaStreams(); + } + updateImagesUpdateStats(); +} + +void LLViewerTextureList::updateImagesDecodePriorities() +{ + // Update the decode priority for N images each frame + { + const size_t max_update_count = llmin((S32) (1024*gFrameIntervalSeconds) + 1, 32); //target 1024 textures per second + S32 update_counter = llmin(max_update_count, mUUIDMap.size()/10); + uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID); + while(update_counter > 0 && !mUUIDMap.empty()) + { + if (iter == mUUIDMap.end()) + { + iter = mUUIDMap.begin(); + } + mLastUpdateUUID = iter->first; + LLPointer<LLViewerFetchedTexture> imagep = iter->second; + ++iter; // safe to incrament now + + // + // Flush formatted images using a lazy flush + // + const F32 LAZY_FLUSH_TIMEOUT = 30.f; // stop decoding + const F32 MAX_INACTIVE_TIME = 50.f; // actually delete + S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference + if (imagep->hasCallbacks()) + { + min_refs++; // Add an extra reference if we're on the loaded callback list + } + S32 num_refs = imagep->getNumRefs(); + if (num_refs == min_refs) + { + if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > LAZY_FLUSH_TIMEOUT) + { + // Remove the unused image from the image list + deleteImage(imagep); + imagep = NULL; // should destroy the image + } + continue; + } + else + { + if(imagep->isDeleted()) + { + continue ; + } + else if(imagep->isDeletionCandidate()) + { + imagep->destroyTexture() ; + continue ; + } + else if(imagep->isInactive()) + { + if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME) + { + imagep->setDeletionCandidate() ; + } + continue ; + } + else + { + imagep->getLastReferencedTimer()->reset(); + + //reset texture state. + imagep->setInactive() ; + } + } + + imagep->processTextureStats(); + F32 old_priority = imagep->getDecodePriority(); + F32 old_priority_test = llmax(old_priority, 0.0f); + F32 decode_priority = imagep->calcDecodePriority(); + F32 decode_priority_test = llmax(decode_priority, 0.0f); + // Ignore < 20% difference + if ((decode_priority_test < old_priority_test * .8f) || + (decode_priority_test > old_priority_test * 1.25f)) + { + removeImageFromList(imagep); + imagep->setDecodePriority(decode_priority); + addImageToList(imagep); + } + update_counter--; + } + } +} + +/* + static U8 get_image_type(LLViewerFetchedTexture* imagep, LLHost target_host) + { + // Having a target host implies this is a baked image. I don't + // believe that boost level has been set at this point. JC + U8 type_from_host = (target_host.isOk() + ? LLImageBase::TYPE_AVATAR_BAKE + : LLImageBase::TYPE_NORMAL); + S32 boost_level = imagep->getBoostLevel(); + U8 type_from_boost = ( (boost_level == LLViewerFetchedTexture::BOOST_AVATAR_BAKED + || boost_level == LLViewerFetchedTexture::BOOST_AVATAR_BAKED_SELF) + ? LLImageBase::TYPE_AVATAR_BAKE + : LLImageBase::TYPE_NORMAL); + if (type_from_host == LLImageBase::TYPE_NORMAL + && type_from_boost == LLImageBase::TYPE_AVATAR_BAKE) + { + llwarns << "TAT: get_image_type() type_from_host doesn't match type_from_boost" + << " host " << target_host + << " boost " << imagep->getBoostLevel() + << " imageid " << imagep->getID() + << llendl; + imagep->dump(); + } + return type_from_host; + } + */ + +F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) +{ + if (gNoRender || gGLManager.mIsDisabled) return 0.0f; + + // + // Create GL textures for all textures that need them (images which have been + // decoded, but haven't been pushed into GL). + // + LLFastTimer t(LLFastTimer::FTM_IMAGE_CREATE); + + LLTimer create_timer; + image_list_t::iterator enditer = mCreateTextureList.begin(); + for (image_list_t::iterator iter = mCreateTextureList.begin(); + iter != mCreateTextureList.end();) + { + image_list_t::iterator curiter = iter++; + enditer = iter; + LLViewerFetchedTexture *imagep = *curiter; + imagep->createTexture(); + if (create_timer.getElapsedTimeF32() > max_time) + { + break; + } + } + mCreateTextureList.erase(mCreateTextureList.begin(), enditer); + return create_timer.getElapsedTimeF32(); +} + +void LLViewerTextureList::forceImmediateUpdate(LLViewerFetchedTexture* imagep) +{ + if(!imagep) + { + return ; + } + if(imagep->isInImageList()) + { + removeImageFromList(imagep); + } + + imagep->processTextureStats(); + F32 decode_priority = LLViewerFetchedTexture::maxDecodePriority() ; + imagep->setDecodePriority(decode_priority); + mImageList.insert(imagep); + imagep->setInImageList(TRUE) ; + + return ; +} + +F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) +{ + LLTimer image_op_timer; + + // Update the decode priority for N images each frame + // Make a list with 32 high priority entries + 256 cycled entries + const size_t max_priority_count = llmin((S32) (256*10.f*gFrameIntervalSeconds)+1, 32); + const size_t max_update_count = llmin((S32) (1024*10.f*gFrameIntervalSeconds)+1, 256); + + // 32 high priority entries + std::set<LLViewerFetchedTexture*> entries; + size_t update_counter = llmin(max_priority_count, mImageList.size()); + image_priority_list_t::iterator iter1 = mImageList.begin(); + while(update_counter > 0) + { + // added extra granularity and verbosity for crash logging during 1.19.1 RC. -Brad + if(iter1 == mImageList.end()) + { + llerrs << "DEV-12002: update_counter not calculated correctly!" << llendl; + return 0.f; + } + + LLPointer<LLViewerFetchedTexture> const & ptr = *iter1; + + LLViewerFetchedTexture * img = ptr.get(); + + // added extra granularity and verbosity for crash logging during 1.19.1 RC. -Brad + if(img == NULL) + { + llwarns << "DEV-12002: image is NULL!" << llendl; + } + + entries.insert(img); + + ++iter1; + update_counter--; + } + + // 256 cycled entries + update_counter = llmin(max_update_count, mUUIDMap.size()); + uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchUUID); + while(update_counter > 0) + { + if (iter2 == mUUIDMap.end()) + { + iter2 = mUUIDMap.begin(); + } + mLastFetchUUID = iter2->first; + entries.insert(iter2->second); + ++iter2; + update_counter--; + } + + S32 min_count = max_priority_count + max_update_count/4; + for (std::set<LLViewerFetchedTexture*>::iterator iter3 = entries.begin(); + iter3 != entries.end(); ) + { + LLPointer<LLViewerFetchedTexture> imagep = *iter3++; + + imagep->updateFetch(); + if (min_count <= 0 && image_op_timer.getElapsedTimeF32() > max_time) + { + break; + } + min_count--; + } + return image_op_timer.getElapsedTimeF32(); +} + +void LLViewerTextureList::updateImagesUpdateStats() +{ + if (mUpdateStats) + { + for (image_priority_list_t::iterator iter = mImageList.begin(); + iter != mImageList.end(); ) + { + LLViewerFetchedTexture* imagep = *iter++; + imagep->resetTextureStats(mForceResetTextureStats); + } + mUpdateStats = FALSE; + mForceResetTextureStats = FALSE; + } +} + +void LLViewerTextureList::decodeAllImages(F32 max_time) +{ + LLTimer timer; + if(gNoRender) return; + + // Update texture stats and priorities + std::vector<LLPointer<LLViewerFetchedTexture> > image_list; + for (image_priority_list_t::iterator iter = mImageList.begin(); + iter != mImageList.end(); ) + { + LLViewerFetchedTexture* imagep = *iter++; + image_list.push_back(imagep); + imagep->setInImageList(FALSE) ; + } + mImageList.clear(); + for (std::vector<LLPointer<LLViewerFetchedTexture> >::iterator iter = image_list.begin(); + iter != image_list.end(); ++iter) + { + LLViewerFetchedTexture* imagep = *iter; + imagep->processTextureStats(); + F32 decode_priority = imagep->calcDecodePriority(); + imagep->setDecodePriority(decode_priority); + mImageList.insert(imagep); + imagep->setInImageList(TRUE) ; + } + image_list.clear(); + + // Update fetch (decode) + for (image_priority_list_t::iterator iter = mImageList.begin(); + iter != mImageList.end(); ) + { + LLViewerFetchedTexture* imagep = *iter++; + imagep->updateFetch(); + } + // Run threads + S32 fetch_pending = 0; + while (1) + { + LLAppViewer::instance()->getTextureCache()->update(1); // unpauses the texture cache thread + LLAppViewer::instance()->getImageDecodeThread()->update(1); // unpauses the image thread + fetch_pending = LLAppViewer::instance()->getTextureFetch()->update(1); // unpauses the texture fetch thread + if (fetch_pending == 0 || timer.getElapsedTimeF32() > max_time) + { + break; + } + } + // Update fetch again + for (image_priority_list_t::iterator iter = mImageList.begin(); + iter != mImageList.end(); ) + { + LLViewerFetchedTexture* imagep = *iter++; + imagep->updateFetch(); + } + max_time -= timer.getElapsedTimeF32(); + max_time = llmax(max_time, .001f); + F32 create_time = updateImagesCreateTextures(max_time); + + LL_DEBUGS("ViewerImages") << "decodeAllImages() took " << timer.getElapsedTimeF32() << " seconds. " + << " fetch_pending " << fetch_pending + << " create_time " << create_time + << LL_ENDL; +} + + +BOOL LLViewerTextureList::createUploadFile(const std::string& filename, + const std::string& out_filename, + const U8 codec) +{ + // First, load the image. + LLPointer<LLImageRaw> raw_image = new LLImageRaw; + + switch (codec) + { + case IMG_CODEC_BMP: + { + LLPointer<LLImageBMP> bmp_image = new LLImageBMP; + + if (!bmp_image->load(filename)) + { + return FALSE; + } + + if (!bmp_image->decode(raw_image, 0.0f)) + { + return FALSE; + } + } + break; + case IMG_CODEC_TGA: + { + LLPointer<LLImageTGA> tga_image = new LLImageTGA; + + if (!tga_image->load(filename)) + { + return FALSE; + } + + if (!tga_image->decode(raw_image)) + { + return FALSE; + } + + if( (tga_image->getComponents() != 3) && + (tga_image->getComponents() != 4) ) + { + tga_image->setLastError( "Image files with less than 3 or more than 4 components are not supported." ); + return FALSE; + } + } + break; + case IMG_CODEC_JPEG: + { + LLPointer<LLImageJPEG> jpeg_image = new LLImageJPEG; + + if (!jpeg_image->load(filename)) + { + return FALSE; + } + + if (!jpeg_image->decode(raw_image, 0.0f)) + { + return FALSE; + } + } + break; + case IMG_CODEC_PNG: + { + LLPointer<LLImagePNG> png_image = new LLImagePNG; + + if (!png_image->load(filename)) + { + return FALSE; + } + + if (!png_image->decode(raw_image, 0.0f)) + { + return FALSE; + } + } + break; + default: + return FALSE; + } + + LLPointer<LLImageJ2C> compressedImage = convertToUploadFile(raw_image); + + if( !compressedImage->save(out_filename) ) + { + llinfos << "Couldn't create output file " << out_filename << llendl; + return FALSE; + } + + // test to see if the encode and save worked. + LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C; + if( !integrity_test->loadAndValidate( out_filename ) ) + { + llinfos << "Image: " << out_filename << " is corrupt." << llendl; + return FALSE; + } + + return TRUE; +} + +// note: modifies the argument raw_image!!!! +LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image) +{ + raw_image->biasedScaleToPowerOfTwo(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C(); + compressedImage->setRate(0.f); + + if (gSavedSettings.getBOOL("LosslessJ2CUpload") && + (raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)) + compressedImage->setReversible(TRUE); + + compressedImage->encode(raw_image, 0.0f); + + return compressedImage; +} + +// Returns min setting for TextureMemory (in MB) +S32 LLViewerTextureList::getMinVideoRamSetting() +{ + S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); + //min texture mem sets to 64M if total physical mem is more than 1.5GB + return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM_IN_MEGA_BYTES ; +} + +//static +// Returns max setting for TextureMemory (in MB) +S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) +{ + S32 max_texmem; + if (gGLManager.mVRAM != 0) + { + // Treat any card with < 32 MB (shudder) as having 32 MB + // - it's going to be swapping constantly regardless + S32 max_vram = gGLManager.mVRAM; + max_vram = llmax(max_vram, getMinVideoRamSetting()); + max_texmem = max_vram; + if (!get_recommended) + max_texmem *= 2; + } + else + { + if (get_recommended) + max_texmem = 128; + else + max_texmem = 512; + llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl; + } + + S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB + //llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl; + if (get_recommended) + max_texmem = llmin(max_texmem, (S32)(system_ram/2)); + else + max_texmem = llmin(max_texmem, (S32)(system_ram)); + + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); + + return max_texmem; +} + +const S32 VIDEO_CARD_FRAMEBUFFER_MEM = 12; // MB +const S32 MIN_MEM_FOR_NON_TEXTURE = 512 ; //MB +void LLViewerTextureList::updateMaxResidentTexMem(S32 mem) +{ + // Initialize the image pipeline VRAM settings + S32 cur_mem = gSavedSettings.getS32("TextureMemory"); + F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); + S32 default_mem = getMaxVideoRamSetting(true); // recommended default + if (mem == 0) + { + mem = cur_mem > 0 ? cur_mem : default_mem; + } + else if (mem < 0) + { + mem = default_mem; + } + + // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise + mem = llmin(mem, (S32) (mem_multiplier * (F32) default_mem)); + + mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting()); + if (mem != cur_mem) + { + gSavedSettings.setS32("TextureMemory", mem); + return; //listener will re-enter this function + } + + // TODO: set available resident texture mem based on use by other subsystems + // currently max(12MB, VRAM/4) assumed... + + S32 vb_mem = mem; + S32 fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4); + mMaxResidentTexMemInMegaBytes = (vb_mem - fb_mem) ; //in MB + + mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2; + if (mMaxResidentTexMemInMegaBytes > 640) + { + mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes >> 2); + } + + //system mem + S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB + + //minimum memory reserved for non-texture use. + //if system_raw >= 1GB, reserve at least 512MB for non-texture use; + //otherwise reserve half of the system_ram for non-texture use. + S32 min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; + + if (mMaxTotalTextureMemInMegaBytes > system_ram - min_non_texture_mem) + { + mMaxTotalTextureMemInMegaBytes = system_ram - min_non_texture_mem ; + } + + llinfos << "Total Video Memory set to: " << vb_mem << " MB" << llendl; + llinfos << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << llendl; +} + +/////////////////////////////////////////////////////////////////////////////// + +// static +void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_data) +{ + LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); + + // Receive image header, copy into image object and decompresses + // if this is a one-packet image. + + LLUUID id; + + char ip_string[256]; + u32_to_ip_string(msg->getSenderIP(),ip_string); + + if (msg->getReceiveCompressedSize()) + { + gTextureList.mTextureBits += msg->getReceiveCompressedSize() * 8; + } + else + { + gTextureList.mTextureBits += msg->getReceiveSize() * 8; + } + gTextureList.mTexturePackets++; + + U8 codec; + U16 packets; + U32 totalbytes; + msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id); + msg->getU8Fast(_PREHASH_ImageID, _PREHASH_Codec, codec); + msg->getU16Fast(_PREHASH_ImageID, _PREHASH_Packets, packets); + msg->getU32Fast(_PREHASH_ImageID, _PREHASH_Size, totalbytes); + + S32 data_size = msg->getSizeFast(_PREHASH_ImageData, _PREHASH_Data); + if (!data_size) + { + return; + } + if (data_size < 0) + { + // msg->getSizeFast() is probably trying to tell us there + // was an error. + llerrs << "image header chunk size was negative: " + << data_size << llendl; + return; + } + + // this buffer gets saved off in the packet list + U8 *data = new U8[data_size]; + msg->getBinaryDataFast(_PREHASH_ImageData, _PREHASH_Data, data, data_size); + + LLViewerFetchedTexture *image = LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); + if (!image) + { + delete [] data; + return; + } + image->getLastPacketTimer()->reset(); + bool res = LLAppViewer::getTextureFetch()->receiveImageHeader(msg->getSender(), id, codec, packets, totalbytes, data_size, data); + if (!res) + { + delete[] data; + } +} + +// static +void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_data) +{ + LLMemType mt1(LLMemType::MTYPE_APPFMTIMAGE); + LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); + + // Receives image packet, copy into image object, + // checks if all packets received, decompresses if so. + + LLUUID id; + U16 packet_num; + + char ip_string[256]; + u32_to_ip_string(msg->getSenderIP(),ip_string); + + if (msg->getReceiveCompressedSize()) + { + gTextureList.mTextureBits += msg->getReceiveCompressedSize() * 8; + } + else + { + gTextureList.mTextureBits += msg->getReceiveSize() * 8; + } + gTextureList.mTexturePackets++; + + //llprintline("Start decode, image header..."); + msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id); + msg->getU16Fast(_PREHASH_ImageID, _PREHASH_Packet, packet_num); + S32 data_size = msg->getSizeFast(_PREHASH_ImageData, _PREHASH_Data); + + if (!data_size) + { + return; + } + if (data_size < 0) + { + // msg->getSizeFast() is probably trying to tell us there + // was an error. + llerrs << "image data chunk size was negative: " + << data_size << llendl; + return; + } + if (data_size > MTUBYTES) + { + llerrs << "image data chunk too large: " << data_size << " bytes" << llendl; + return; + } + U8 *data = new U8[data_size]; + msg->getBinaryDataFast(_PREHASH_ImageData, _PREHASH_Data, data, data_size); + + LLViewerFetchedTexture *image = LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); + if (!image) + { + delete [] data; + return; + } + image->getLastPacketTimer()->reset(); + bool res = LLAppViewer::getTextureFetch()->receiveImagePacket(msg->getSender(), id, packet_num, data_size, data); + if (!res) + { + delete[] data; + } +} + + +// We've been that the asset server does not contain the requested image id. +// static +void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **user_data) +{ + LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); + LLUUID image_id; + msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, image_id); + + LLViewerFetchedTexture* image = gTextureList.findImage( image_id ); + if( image ) + { + image->setIsMissingAsset(); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +//static +const U32 SIXTEEN_MEG = 0x1000000; +S32 LLViewerTextureList::calcMaxTextureRAM() +{ + // Decide the maximum amount of RAM we should allow the user to allocate to texture cache + LLMemoryInfo memory_info; + U32 available_memory = memory_info.getPhysicalMemoryClamped(); + + clamp_rescale((F32)available_memory, + (F32)(SIXTEEN_MEG * 16), + (F32)U32_MAX, + (F32)(SIXTEEN_MEG * 4), + (F32)(U32_MAX >> 1)); + return available_memory; +} + +/////////////////////////////////////////////////////////////////////////////// + +// explicitly cleanup resources, as this is a singleton class with process +// lifetime so ability to perform std::map operations in destructor is not +// guaranteed. +void LLUIImageList::cleanUp() +{ + mUIImages.clear(); + mUITextureList.clear() ; +} + +LLUIImagePtr LLUIImageList::getUIImageByID(const LLUUID& image_id) +{ + // use id as image name + std::string image_name = image_id.asString(); + + // look for existing image + uuid_ui_image_map_t::iterator found_it = mUIImages.find(image_name); + if (found_it != mUIImages.end()) + { + return found_it->second; + } + + return loadUIImageByID(image_id); +} + +LLUIImagePtr LLUIImageList::getUIImage(const std::string& image_name) +{ + // look for existing image + uuid_ui_image_map_t::iterator found_it = mUIImages.find(image_name); + if (found_it != mUIImages.end()) + { + return found_it->second; + } + + return loadUIImageByName(image_name, image_name); +} + +LLUIImagePtr LLUIImageList::loadUIImageByName(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect) +{ + LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTextureFromFile(filename, MIPMAP_NO, IMMEDIATE_YES); + return loadUIImage(imagep, name, use_mips, scale_rect); +} + +LLUIImagePtr LLUIImageList::loadUIImageByID(const LLUUID& id, BOOL use_mips, const LLRect& scale_rect) +{ + LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(id, MIPMAP_NO, IMMEDIATE_YES); + return loadUIImage(imagep, id.asString(), use_mips, scale_rect); +} + +LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect) +{ + if (!imagep) return NULL; + + imagep->setAddressMode(LLTexUnit::TAM_CLAMP); + + //all UI images are non-deletable + imagep->setNoDelete() ; + + LLUIImagePtr new_imagep = new LLUIImage(name, imagep); + mUIImages.insert(std::make_pair(name, new_imagep)); + mUITextureList.push_back(imagep) ; + + LLUIImageLoadData* datap = new LLUIImageLoadData; + datap->mImageName = name; + datap->mImageScaleRegion = scale_rect; + + imagep->setLoadedCallback(onUIImageLoaded, 0, FALSE, FALSE, datap); + + return new_imagep; +} + +LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect) +{ + // look for existing image + uuid_ui_image_map_t::iterator found_it = mUIImages.find(name); + if (found_it != mUIImages.end()) + { + // image already loaded! + llerrs << "UI Image " << name << " already loaded." << llendl; + } + + return loadUIImageByName(name, filename, use_mips, scale_rect); +} + +//static +void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* user_data ) +{ + if(!success || !user_data) + { + return; + } + + LLUIImageLoadData* image_datap = (LLUIImageLoadData*)user_data; + std::string ui_image_name = image_datap->mImageName; + LLRect scale_rect = image_datap->mImageScaleRegion; + if (final) + { + delete image_datap; + } + + LLUIImageList* instance = getInstance(); + + uuid_ui_image_map_t::iterator found_it = instance->mUIImages.find(ui_image_name); + if (found_it != instance->mUIImages.end()) + { + LLUIImagePtr imagep = found_it->second; + + // for images grabbed from local files, apply clipping rectangle to restore original dimensions + // from power-of-2 gl image + if (success && imagep.notNull() && src_vi && !src_vi->getLocalFileName().empty()) + { + F32 clip_x = (F32)src_vi->getOriginalWidth() / (F32)src_vi->getFullWidth(); + F32 clip_y = (F32)src_vi->getOriginalHeight() / (F32)src_vi->getFullHeight(); + imagep->setClipRegion(LLRectf(0.f, clip_y, clip_x, 0.f)); + if (scale_rect != LLRect::null) + { + imagep->setScaleRegion( + LLRectf(llclamp((F32)scale_rect.mLeft / (F32)imagep->getWidth(), 0.f, 1.f), + llclamp((F32)scale_rect.mTop / (F32)imagep->getHeight(), 0.f, 1.f), + llclamp((F32)scale_rect.mRight / (F32)imagep->getWidth(), 0.f, 1.f), + llclamp((F32)scale_rect.mBottom / (F32)imagep->getHeight(), 0.f, 1.f))); + } + } + } +} + +struct UIImageDeclaration : public LLInitParam::Block<UIImageDeclaration> +{ + Mandatory<std::string> name; + Optional<std::string> file_name; + Optional<bool> preload; + Optional<LLRect> scale_rect; + Optional<bool> use_mips; + + UIImageDeclaration() + : name("name"), + file_name("file_name"), + preload("preload", false), + scale_rect("scale"), + use_mips("use_mips", false) + {} +}; + +struct UIImageDeclarations : public LLInitParam::Block<UIImageDeclarations> +{ + Mandatory<S32> version; + Multiple<UIImageDeclaration> textures; + + UIImageDeclarations() + : version("version"), + textures("texture") + {} +}; + +bool LLUIImageList::initFromFile() +{ + // construct path to canonical textures.xml in default skin dir + std::string base_file_path = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, "default", "textures", "textures.xml"); + + LLXMLNodePtr root; + + if (!LLXMLNode::parseFile(base_file_path, root, NULL)) + { + llwarns << "Unable to parse UI image list file " << base_file_path << llendl; + return false; + } + + std::vector<std::string> paths; + // path to current selected skin + paths.push_back(gDirUtilp->getSkinDir() + + gDirUtilp->getDirDelimiter() + + "textures" + + gDirUtilp->getDirDelimiter() + + "textures.xml"); + // path to user overrides on current skin + paths.push_back(gDirUtilp->getUserSkinDir() + + gDirUtilp->getDirDelimiter() + + "textures" + + gDirUtilp->getDirDelimiter() + + "textures.xml"); + + // apply skinned xml files incrementally + for(std::vector<std::string>::iterator path_it = paths.begin(); + path_it != paths.end(); + ++path_it) + { + // don't reapply base file to itself + if (!path_it->empty() && (*path_it) != base_file_path) + { + LLXMLNodePtr update_root; + if (LLXMLNode::parseFile(*path_it, update_root, NULL)) + { + LLXMLNode::updateNode(root, update_root); + } + } + } + + UIImageDeclarations images; + LLXUIParser::instance().readXUI(root, images); + + if (!images.validateBlock()) return false; + + enum e_decode_pass + { + PASS_DECODE_NOW, + PASS_DECODE_LATER, + NUM_PASSES + }; + + for (S32 cur_pass = PASS_DECODE_NOW; cur_pass < NUM_PASSES; cur_pass++) + { + for (LLInitParam::ParamIterator<UIImageDeclaration>::const_iterator image_it = images.textures().begin(); + image_it != images.textures().end(); + ++image_it) + { + std::string file_name = image_it->file_name.isProvided() ? image_it->file_name() : image_it->name(); + + // load high priority textures on first pass (to kick off decode) + enum e_decode_pass decode_pass = image_it->preload ? PASS_DECODE_NOW : PASS_DECODE_LATER; + if (decode_pass != cur_pass) + { + continue; + } + preloadUIImage(image_it->name, file_name, image_it->use_mips, image_it->scale_rect); + } + + if (cur_pass == PASS_DECODE_NOW && !gSavedSettings.getBOOL("NoPreload")) + { + gTextureList.decodeAllImages(10.f); // decode preloaded images + } + } + return true; +} + + diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h new file mode 100644 index 0000000000..11d1dd855f --- /dev/null +++ b/indra/newview/llviewertexturelist.h @@ -0,0 +1,243 @@ +/** + * @file llviewertexturelist.h + * @brief Object for managing the list of images within a region + * + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLVIEWERTEXTURELIST_H +#define LL_LLVIEWERTEXTURELIST_H + +#include "lluuid.h" +//#include "message.h" +#include "llgl.h" +#include "llstat.h" +#include "llviewertexture.h" +#include "llui.h" +#include <list> +#include <set> + +const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; + +const BOOL MIPMAP_YES = TRUE; +const BOOL MIPMAP_NO = FALSE; + +const BOOL GL_TEXTURE_YES = TRUE; +const BOOL GL_TEXTURE_NO = FALSE; + +const BOOL IMMEDIATE_YES = TRUE; +const BOOL IMMEDIATE_NO = FALSE; + +class LLImageJ2C; +class LLMessageSystem; +class LLTextureView; + +typedef void (*LLImageCallback)(BOOL success, + LLViewerFetchedTexture *src_vi, + LLImageRaw* src, + LLImageRaw* src_aux, + S32 discard_level, + BOOL final, + void* userdata); + +class LLViewerTextureList +{ + LOG_CLASS(LLViewerTextureList); + + friend class LLTextureView; + friend class LLViewerTextureManager; + +public: + static BOOL createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec); + static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image); + static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data ); + static S32 calcMaxTextureRAM(); + static void receiveImageHeader(LLMessageSystem *msg, void **user_data); + static void receiveImagePacket(LLMessageSystem *msg, void **user_data); + +public: + LLViewerTextureList(); + ~LLViewerTextureList(); + + void init(); + void shutdown(); + void dump(); + void destroyGL(BOOL save_state = TRUE); + void restoreGL(); + + LLViewerFetchedTexture *findImage(const LLUUID &image_id); + + void dirtyImage(LLViewerFetchedTexture *image); + + // Using image stats, determine what images are necessary, and perform image updates. + void updateImages(F32 max_time); + void forceImmediateUpdate(LLViewerFetchedTexture* imagep) ; + + // Decode and create textures for all images currently in list. + void decodeAllImages(F32 max_decode_time); + + void handleIRCallback(void **data, const S32 number); + + void setUpdateStats(BOOL b) { mUpdateStats = b; } + + S32 getMaxResidentTexMem() const { return mMaxResidentTexMemInMegaBytes; } + S32 getMaxTotalTextureMem() const { return mMaxTotalTextureMemInMegaBytes;} + S32 getNumImages() { return mImageList.size(); } + + void updateMaxResidentTexMem(S32 mem); + + void doPreloadImages(); + void doPrefetchImages(); + + static S32 getMinVideoRamSetting(); + static S32 getMaxVideoRamSetting(bool get_recommended = false); + +private: + void updateImagesDecodePriorities(); + F32 updateImagesCreateTextures(F32 max_time); + F32 updateImagesFetchTextures(F32 max_time); + void updateImagesUpdateStats(); + + void addImage(LLViewerFetchedTexture *image); + void deleteImage(LLViewerFetchedTexture *image); + + void addImageToList(LLViewerFetchedTexture *image); + void removeImageFromList(LLViewerFetchedTexture *image); + + LLViewerFetchedTexture * getImage(const LLUUID &image_id, + BOOL usemipmap = TRUE, + BOOL level_immediate = FALSE, // Get the requested level immediately upon creation. + S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, + LLGLint internal_format = 0, + LLGLenum primary_format = 0, + LLHost request_from_host = LLHost() + ); + + LLViewerFetchedTexture * getImageFromFile(const std::string& filename, + BOOL usemipmap = TRUE, + BOOL level_immediate = FALSE, // Get the requested level immediately upon creation. + S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, + LLGLint internal_format = 0, + LLGLenum primary_format = 0, + const LLUUID& force_id = LLUUID::null + ); + + LLViewerFetchedTexture* createImage(const LLUUID &image_id, + BOOL usemipmap = TRUE, + BOOL level_immediate = FALSE, // Get the requested level immediately upon creation. + S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, + LLGLint internal_format = 0, + LLGLenum primary_format = 0, + LLHost request_from_host = LLHost() + ); + + // Request image from a specific host, used for baked avatar textures. + // Implemented in header in case someone changes default params above. JC + LLViewerFetchedTexture* getImageFromHost(const LLUUID& image_id, LLHost host) + { return getImage(image_id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); } + +public: + typedef std::set<LLPointer<LLViewerFetchedTexture> > image_list_t; + image_list_t mLoadingStreamList; + image_list_t mCreateTextureList; + image_list_t mCallbackList; + + // Note: just raw pointers because they are never referenced, just compared against + std::set<LLViewerFetchedTexture*> mDirtyTextureList; + + BOOL mForceResetTextureStats; + +private: + typedef std::map< LLUUID, LLPointer<LLViewerFetchedTexture> > uuid_map_t; + uuid_map_t mUUIDMap; + LLUUID mLastUpdateUUID; + LLUUID mLastFetchUUID; + + typedef std::set<LLPointer<LLViewerFetchedTexture>, LLViewerFetchedTexture::Compare> image_priority_list_t; + image_priority_list_t mImageList; + + // simply holds on to LLViewerFetchedTexture references to stop them from being purged too soon + std::set<LLPointer<LLViewerFetchedTexture> > mImagePreloads; + + BOOL mUpdateStats; + S32 mMaxResidentTexMemInMegaBytes; + S32 mMaxTotalTextureMemInMegaBytes; + LLFrameTimer mForceDecodeTimer; + +public: + U32 mTextureBits; + U32 mTexturePackets; + +private: + S32 mNumImages; + static void (*sUUIDCallback)(void**, const LLUUID &); +}; + +class LLUIImageList : public LLImageProviderInterface, public LLSingleton<LLUIImageList> +{ +public: + // LLImageProviderInterface + LLUIImagePtr getUIImageByID(const LLUUID& id); + LLUIImagePtr getUIImage(const std::string& name); + void cleanUp(); + + bool initFromFile(); + + LLUIImagePtr preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect); + + static void onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ); +private: + LLUIImagePtr loadUIImageByName(const std::string& name, const std::string& filename, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null); + LLUIImagePtr loadUIImageByID(const LLUUID& id, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null); + + LLUIImagePtr loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null); + + + struct LLUIImageLoadData + { + std::string mImageName; + LLRect mImageScaleRegion; + }; + + typedef std::map< std::string, LLPointer<LLUIImage> > uuid_ui_image_map_t; + uuid_ui_image_map_t mUIImages; + + // + //keep a copy of UI textures to prevent them to be deleted. + //mGLTexturep of each UI texture equals to some LLUIImage.mImage. + std::list< LLPointer<LLViewerFetchedTexture> > mUITextureList ; +}; + +const BOOL GLTEXTURE_TRUE = TRUE; +const BOOL GLTEXTURE_FALSE = FALSE; +const BOOL MIPMAP_TRUE = TRUE; +const BOOL MIPMAP_FALSE = FALSE; + +extern LLViewerTextureList gTextureList; + +#endif diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2caa8f2309..637d072cf4 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -161,7 +161,7 @@ #include "llvieweraudio.h" #include "llviewercamera.h" #include "llviewergesture.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerinventory.h" #include "llviewerkeyboard.h" #include "llviewermenu.h" @@ -1356,8 +1356,8 @@ LLViewerWindow::LLViewerWindow( // Init the image list. Must happen after GL is initialized and before the images that // LLViewerWindow needs are requested. - gImageList.init(); - LLViewerImage::initClass(); + gTextureList.init(); + LLViewerTextureManager::init() ; gBumpImageList.init(); // Init font system, but don't actually load the fonts yet @@ -1687,7 +1687,7 @@ void LLViewerWindow::shutdownGL() gSky.cleanup(); stop_glerror(); - gImageList.shutdown(); + gTextureList.shutdown(); stop_glerror(); gBumpImageList.shutdown(); @@ -1699,7 +1699,7 @@ void LLViewerWindow::shutdownGL() gPipeline.cleanup(); stop_glerror(); - LLViewerImage::cleanupClass(); + LLViewerTextureManager::cleanup() ; llinfos << "Cleaning up select manager" << llendl; LLSelectMgr::getInstance()->cleanup(); @@ -4439,7 +4439,7 @@ void LLViewerWindow::stopGL(BOOL save_state) //Note: --bao //if not necessary, do not change the order of the function calls in this function. //if change something, make sure it will not break anything. - //especially be careful to put anything behind gImageList.destroyGL(save_state); + //especially be careful to put anything behind gTextureList.destroyGL(save_state); if (!gGLManager.mIsDisabled) { llinfos << "Shutting down GL..." << llendl; @@ -4464,7 +4464,7 @@ void LLViewerWindow::stopGL(BOOL save_state) LLVOAvatar::destroyGL(); stop_glerror(); - LLDynamicTexture::destroyGL(); + LLViewerDynamicTexture::destroyGL(); stop_glerror(); if (gPipeline.isInit()) @@ -4482,9 +4482,9 @@ void LLViewerWindow::stopGL(BOOL save_state) gPostProcess->invalidate(); } - gImageList.destroyGL(save_state); + gTextureList.destroyGL(save_state); stop_glerror(); - + gGLManager.mIsDisabled = TRUE; stop_glerror(); @@ -4497,7 +4497,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) //Note: --bao //if not necessary, do not change the order of the function calls in this function. //if change something, make sure it will not break anything. - //especially, be careful to put something before gImageList.restoreGL(); + //especially, be careful to put something before gTextureList.restoreGL(); if (gGLManager.mIsDisabled) { llinfos << "Restoring GL..." << llendl; @@ -4505,8 +4505,9 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) initGLDefaults(); LLGLState::restoreGL(); - gImageList.restoreGL(); - + + gTextureList.restoreGL(); + // for future support of non-square pixels, and fonts that are properly stretched //LLFontGL::destroyDefaultFonts(); initFonts(); @@ -4517,7 +4518,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) LLManipTranslate::restoreGL(); gBumpImageList.restoreGL(); - LLDynamicTexture::restoreGL(); + LLViewerDynamicTexture::restoreGL(); LLVOAvatar::restoreGL(); gResizeScreenTexture = TRUE; @@ -5104,7 +5105,7 @@ void LLPickInfo::updateXYCoords() if (mObjectFace > -1) { const LLTextureEntry* tep = getObject()->getTE(mObjectFace); - LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID()); + LLPointer<LLViewerTexture> imagep = LLViewerTextureManager::getFetchedTexture(tep->getID()); if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) { LLCoordGL coords; diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index e52fec7909..f26ba6f46e 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -39,8 +39,8 @@ #include "v3math.h" #include "llsurface.h" #include "lltextureview.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "noise.h" #include "llregionhandle.h" // for from_region_handle @@ -106,7 +106,7 @@ void LLVLComposition::setDetailTextureID(S32 corner, const LLUUID& id) { return; } - mDetailTextures[corner] = gImageList.getImage(id); + mDetailTextures[corner] = LLViewerTextureManager::getFetchedTexture(id); mDetailTextures[corner]->setNoDelete() ; mRawImages[corner] = NULL; } @@ -229,7 +229,7 @@ BOOL LLVLComposition::generateComposition() { if (mDetailTextures[i]->getDiscardLevel() < 0) { - mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN); // in case we are at low detail + mDetailTextures[i]->setBoostLevel(LLViewerTexture::BOOST_TERRAIN); // in case we are at low detail mDetailTextures[i]->addTextureStats(BASE_SIZE*BASE_SIZE); return FALSE; } @@ -237,8 +237,8 @@ BOOL LLVLComposition::generateComposition() (mDetailTextures[i]->getWidth() < BASE_SIZE || mDetailTextures[i]->getHeight() < BASE_SIZE))) { - S32 width = mDetailTextures[i]->getWidth(0); - S32 height = mDetailTextures[i]->getHeight(0); + S32 width = mDetailTextures[i]->getFullWidth(); + S32 height = mDetailTextures[i]->getFullHeight(); S32 min_dim = llmin(width, height); S32 ddiscard = 0; while (min_dim > BASE_SIZE && ddiscard < MAX_DISCARD_LEVEL) @@ -246,7 +246,7 @@ BOOL LLVLComposition::generateComposition() ddiscard++; min_dim /= 2; } - mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN); // in case we are at low detail + mDetailTextures[i]->setBoostLevel(LLViewerTexture::BOOST_TERRAIN); // in case we are at low detail mDetailTextures[i]->setMinDiscardLevel(ddiscard); return FALSE; } @@ -280,7 +280,7 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, { // Read back a raw image for this discard level, if it exists mRawImages[i] = new LLImageRaw; - S32 min_dim = llmin(mDetailTextures[i]->getWidth(0), mDetailTextures[i]->getHeight(0)); + S32 min_dim = llmin(mDetailTextures[i]->getFullWidth(), mDetailTextures[i]->getFullHeight()); S32 ddiscard = 0; while (min_dim > BASE_SIZE && ddiscard < MAX_DISCARD_LEVEL) { @@ -336,7 +336,7 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, // // - LLViewerImage *texturep; + LLViewerTexture *texturep; U32 tex_width, tex_height, tex_comps; U32 tex_stride; F32 tex_x_scalef, tex_y_scalef; @@ -455,7 +455,7 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, for (S32 i = 0; i < 4; i++) { // Un-boost detatil textures (will get re-boosted if rendering in high detail) - mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_NONE); + mDetailTextures[i]->setBoostLevel(LLViewerTexture::BOOST_NONE); mDetailTextures[i]->setMinDiscardLevel(MAX_DISCARD_LEVEL + 1); } @@ -467,7 +467,7 @@ LLUUID LLVLComposition::getDetailTextureID(S32 corner) return mDetailTextures[corner]->getID(); } -LLViewerImage* LLVLComposition::getDetailTexture(S32 corner) +LLViewerFetchedTexture* LLVLComposition::getDetailTexture(S32 corner) { return mDetailTextures[corner]; } diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index 6d5db3c050..d1b3dc4495 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -34,7 +34,7 @@ #define LL_LLVLCOMPOSITION_H #include "llviewerlayer.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLSurface; @@ -62,7 +62,7 @@ public: CORNER_COUNT = 4 }; LLUUID getDetailTextureID(S32 corner); - LLViewerImage* getDetailTexture(S32 corner); + LLViewerFetchedTexture* getDetailTexture(S32 corner); F32 getStartHeight(S32 corner); F32 getHeightRange(S32 corner); @@ -79,7 +79,7 @@ protected: LLSurface *mSurfacep; BOOL mTexturesLoaded; - LLPointer<LLViewerImage> mDetailTextures[CORNER_COUNT]; + LLPointer<LLViewerFetchedTexture> mDetailTextures[CORNER_COUNT]; LLPointer<LLImageRaw> mRawImages[CORNER_COUNT]; F32 mStartHeight[CORNER_COUNT]; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e351c904e6..258061190b 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -67,7 +67,7 @@ #include "lltexlayer.h" #include "lltoolmorph.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -717,8 +717,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mRippleTimeLast = 0.f; - mShadowImagep = gImageList.getImageFromFile("foot_shadow.j2c"); - gGL.getTexUnit(0)->bind(mShadowImagep.get()); + mShadowImagep = LLViewerTextureManager::getFetchedTextureFromFile("foot_shadow.j2c"); + gGL.getTexUnit(0)->bind(mShadowImagep); mShadowImagep->setAddressMode(LLTexUnit::TAM_CLAMP); mInAir = FALSE; @@ -2499,7 +2499,7 @@ void LLVOAvatar::idleUpdateLoadingEffect() particle_parameters.mPartData.mStartColor = LLColor4(1, 1, 1, 0.5f); particle_parameters.mPartData.mEndColor = LLColor4(1, 1, 1, 0.0f); particle_parameters.mPartData.mStartScale.mV[VX] = 0.8f; - LLViewerImage* cloud = gImageList.getImageFromFile("cloud-particle.j2c"); + LLViewerTexture* cloud = LLViewerTextureManager::getFetchedTextureFromFile("cloud-particle.j2c"); particle_parameters.mPartImageID = cloud->getID(); particle_parameters.mMaxAge = 0.f; particle_parameters.mPattern = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE; @@ -3869,7 +3869,7 @@ U32 LLVOAvatar::renderFootShadows() LLGLDepthTest test(GL_TRUE, GL_FALSE); //render foot shadows LLGLEnable blend(GL_BLEND); - gGL.getTexUnit(0)->bind(mShadowImagep.get()); + gGL.getTexUnit(0)->bind(mShadowImagep); glColor4fv(mShadow0Facep->getRenderColor().mV); mShadow0Facep->renderIndexed(foot_mask); glColor4fv(mShadow1Facep->getRenderColor().mV); @@ -3945,7 +3945,7 @@ void LLVOAvatar::updateTextures(LLAgent &agent) { if (layer_baked[i] && !mBakedTextureDatas[i].mIsLoaded) { - gGL.getTexUnit(0)->bind(getImage(mBakedTextureDatas[i].mTextureIndex)); + gGL.getTexUnit(0)->bind(getImage( mBakedTextureDatas[i].mTextureIndex )); } } } @@ -3955,7 +3955,7 @@ void LLVOAvatar::updateTextures(LLAgent &agent) mHasGrey = FALSE; // debug for (U32 index = 0; index < getNumTEs(); index++) { - LLViewerImage *imagep = getImage(index); + LLViewerFetchedTexture *imagep = LLViewerTextureManager::staticCastToFetchedTexture(getImage(index), TRUE); if (imagep) { const LLTextureEntry *te = getTE(index); @@ -4007,15 +4007,15 @@ void LLVOAvatar::updateTextures(LLAgent &agent) } -void LLVOAvatar::addLocalTextureStats(ETextureIndex idx, LLViewerImage* imagep, - F32 texel_area_ratio, BOOL render_avatar, BOOL covered_by_baked, U32 index) +void LLVOAvatar::addLocalTextureStats( ETextureIndex idx, LLViewerFetchedTexture* imagep, + F32 texel_area_ratio, BOOL render_avatar, BOOL covered_by_baked, U32 index ) { // No local texture stats for non-self avatars return; } -void LLVOAvatar::addBakedTextureStats( LLViewerImage* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level) +void LLVOAvatar::addBakedTextureStats( LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level) { mMaxPixelArea = llmax(pixel_area, mMaxPixelArea); mMinPixelArea = llmin(pixel_area, mMinPixelArea); @@ -4024,13 +4024,13 @@ void LLVOAvatar::addBakedTextureStats( LLViewerImage* imagep, F32 pixel_area, F3 } //virtual -void LLVOAvatar::setImage(const U8 te, LLViewerImage *imagep) +void LLVOAvatar::setImage(const U8 te, LLViewerTexture *imagep) { setTEImage(te, imagep); } //virtual -LLViewerImage* LLVOAvatar::getImage(const U8 te) const +LLViewerTexture* LLVOAvatar::getImage(const U8 te) const { return getTEImage(te); } @@ -5213,7 +5213,7 @@ void LLVOAvatar::updateShadowFaces() sprite.setSize(0.4f + cos_elev * 0.8f, 0.3f); LLVector3 sun_vec = gSky.mVOSkyp ? gSky.mVOSkyp->getToSun() : LLVector3(0.f, 0.f, 0.f); - if (mShadowImagep->getHasGLTexture()) + if (mShadowImagep->hasValidGLTexture()) { LLVector3 normal; LLVector3d shadow_pos; @@ -5772,10 +5772,10 @@ void LLVOAvatar::updateMeshTextures() // if user has never specified a texture, assign the default for (U32 i=0; i < getNumTEs(); i++) { - const LLViewerImage* te_image = getImage(i); + const LLViewerTexture* te_image = getImage(i); if(!te_image || te_image->getID().isNull() || (te_image->getID() == IMG_DEFAULT)) { - setImage(i, gImageList.getImage(i == TEX_HAIR ? IMG_DEFAULT : IMG_DEFAULT_AVATAR)); // IMG_DEFAULT_AVATAR = a special texture that's never rendered. + setImage(i, LLViewerTextureManager::getFetchedTexture(i == TEX_HAIR ? IMG_DEFAULT : IMG_DEFAULT_AVATAR)); // IMG_DEFAULT_AVATAR = a special texture that's never rendered. } } @@ -5829,7 +5829,7 @@ void LLVOAvatar::updateMeshTextures() { if (use_lkg_baked_layer[i] && !self_customizing ) { - LLViewerImage* baked_img = gImageList.getImageFromHost( mBakedTextureDatas[i].mLastTextureIndex, target_host ); + LLViewerFetchedTexture* baked_img = LLViewerTextureManager::getFetchedTextureFromHost( mBakedTextureDatas[i].mLastTextureIndex, target_host ); mBakedTextureDatas[i].mIsUsed = TRUE; for (U32 k=0; k < mBakedTextureDatas[i].mMeshes.size(); k++) { @@ -5838,7 +5838,7 @@ void LLVOAvatar::updateMeshTextures() } else if (!self_customizing && is_layer_baked[i]) { - LLViewerImage* baked_img = getImage( mBakedTextureDatas[i].mTextureIndex ); + LLViewerFetchedTexture* baked_img = LLViewerTextureManager::staticCastToFetchedTexture(getImage( mBakedTextureDatas[i].mTextureIndex ), TRUE) ; if( baked_img->getID() == mBakedTextureDatas[i].mLastTextureIndex ) { // Even though the file may not be finished loading, we'll consider it loaded and use it (rather than doing compositing). @@ -5873,7 +5873,7 @@ void LLVOAvatar::updateMeshTextures() if (!is_layer_baked[BAKED_HAIR] || self_customizing) { const LLColor4 color = mTexHairColor ? mTexHairColor->getColor() : LLColor4(1,1,1,1); - LLViewerImage* hair_img = getImage( TEX_HAIR ); + LLViewerTexture* hair_img = getImage( TEX_HAIR ); for (U32 i = 0; i < mBakedTextureDatas[BAKED_HAIR].mMeshes.size(); i++) { mBakedTextureDatas[BAKED_HAIR].mMeshes[i]->setColor( color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW] ); @@ -5907,7 +5907,7 @@ void LLVOAvatar::updateMeshTextures() //----------------------------------------------------------------------------- // setLocalTexture() //----------------------------------------------------------------------------- -void LLVOAvatar::setLocalTexture(ETextureIndex type, LLViewerImage* tex, BOOL baked_version_exists, U32 index) +void LLVOAvatar::setLocalTexture( ETextureIndex type, LLViewerTexture* in_tex, BOOL baked_version_ready, U32 index ) { // invalid for anyone but self llassert(0); @@ -6153,7 +6153,7 @@ void LLVOAvatar::dumpAvatarTEs( const std::string& context ) iter++) { const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; - const LLViewerImage* te_image = getImage(iter->first); + const LLViewerTexture* te_image = getImage(iter->first); if( !te_image ) { llinfos << " " << texture_dict->mName << ": null ptr" << llendl; @@ -6319,7 +6319,7 @@ void LLVOAvatar::onFirstTEMessageReceived() // (That is, don't do a transition from unbaked to baked.) if (layer_baked) { - LLViewerImage* image = getImage( mBakedTextureDatas[i].mTextureIndex ); + LLViewerFetchedTexture* image = LLViewerTextureManager::staticCastToFetchedTexture(getImage( mBakedTextureDatas[i].mTextureIndex ), TRUE) ; mBakedTextureDatas[i].mLastTextureIndex = image->getID(); // If we have more than one texture for the other baked layers, we'll want to call this for them too. if ( (i == BAKED_HEAD) || (i == BAKED_UPPER) || (i == BAKED_LOWER) ) @@ -6381,7 +6381,8 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) && mBakedTextureDatas[baked_index].mLastTextureIndex != IMG_DEFAULT && baked_index != BAKED_SKIRT) { - setTEImage(mBakedTextureDatas[baked_index].mTextureIndex, gImageList.getImage(mBakedTextureDatas[baked_index].mLastTextureIndex)); + setTEImage(mBakedTextureDatas[baked_index].mTextureIndex, + LLViewerTextureManager::getFetchedTexture(mBakedTextureDatas[baked_index].mLastTextureIndex, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE)); } } @@ -6518,7 +6519,7 @@ void LLVOAvatar::getAnimNames( LLDynamicArray<std::string>* names ) names->put( "enter_away_from_keyboard_state" ); } -void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) +void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) { if (!userdata) return; @@ -6571,7 +6572,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerImage *src_vi, if (texture_dict->mIsUsedByBakedTexture) { const ETextureIndex texture_index = iter->first; - const LLViewerImage *baked_img = self->getImage(texture_index); + const LLViewerTexture *baked_img = self->getImage(texture_index); if (id == baked_img->getID()) { const EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; @@ -6609,7 +6610,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerImage *src_vi, } // static -void LLVOAvatar::onInitialBakedTextureLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) +void LLVOAvatar::onInitialBakedTextureLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) { LLUUID *avatar_idp = (LLUUID *)userdata; LLVOAvatar *selfp = (LLVOAvatar *)gObjectList.findObject(*avatar_idp); @@ -6624,7 +6625,7 @@ void LLVOAvatar::onInitialBakedTextureLoaded( BOOL success, LLViewerImage *src_v } } -void LLVOAvatar::onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +void LLVOAvatar::onBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) { //llinfos << "onBakedTextureLoaded: " << src_vi->getID() << llendl; @@ -6659,7 +6660,7 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) mHeadMesh1.setTexture( head_baked ); */ for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { - LLViewerImage* image_baked = getImage( mBakedTextureDatas[i].mTextureIndex ); + LLViewerTexture* image_baked = getImage( mBakedTextureDatas[i].mTextureIndex ); if (id == image_baked->getID()) { mBakedTextureDatas[i].mIsLoaded = true; @@ -6734,7 +6735,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) { if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex)te) == type) { - LLViewerImage* te_image = avatar->getImage((ETextureIndex)te); + LLViewerTexture* te_image = avatar->getImage((ETextureIndex)te); if( te_image ) { std::string uuid_str; @@ -7623,7 +7624,7 @@ U32 calc_shame(LLVOVolume* volume, std::set<LLUUID> &textures) { LLFace* face = drawablep->getFace(i); const LLTextureEntry* te = face->getTextureEntry(); - LLViewerImage* img = face->getTexture(); + LLViewerTexture* img = face->getTexture(); textures.insert(img->getID()); diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 283b9ea156..f36d64aa8e 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -370,7 +370,7 @@ public: private: LLFace* mShadow0Facep; LLFace* mShadow1Facep; - LLPointer<LLViewerImage> mShadowImagep; + LLPointer<LLViewerTexture> mShadowImagep; //-------------------------------------------------------------------- // Impostors @@ -432,8 +432,8 @@ private: // Constants //-------------------------------------------------------------------- public: - virtual LLViewerImage::EBoostLevel getAvatarBoostLevel() const { return LLViewerImage::BOOST_AVATAR; } - virtual LLViewerImage::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerImage::BOOST_AVATAR_BAKED; } + virtual LLViewerTexture::EBoostLevel getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR; } + virtual LLViewerTexture::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED; } virtual S32 getTexImageSize() const; virtual S32 getTexImageArea() const { return getTexImageSize()*getTexImageSize(); } @@ -450,7 +450,7 @@ public: // Loading status //-------------------------------------------------------------------- public: - virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; + virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex index) const; protected: BOOL isFullyBaked(); @@ -462,9 +462,9 @@ protected: public: void releaseComponentTextures(); // ! BACKWARDS COMPATIBILITY ! protected: - static void onBakedTextureMasksLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - static void onInitialBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); - static void onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onBakedTextureMasksLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onInitialBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onBakedTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); virtual void removeMissingBakedTextures(); void useBakedTexture(const LLUUID& id); @@ -489,15 +489,15 @@ protected: // Local Textures //-------------------------------------------------------------------- protected: - virtual void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerImage* tex, BOOL baked_version_exits, U32 index = 0); - virtual void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex type, LLViewerImage* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); + virtual void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index = 0); + virtual void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex type, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); //-------------------------------------------------------------------- // Texture accessors //-------------------------------------------------------------------- private: - virtual void setImage(const U8 te, LLViewerImage *imagep); - virtual LLViewerImage* getImage(const U8 te) const; + virtual void setImage(const U8 te, LLViewerTexture *imagep); + virtual LLViewerTexture* getImage(const U8 te) const; virtual const LLTextureEntry* getTexEntry(const U8 te_num) const; virtual void setTexEntry(const U8 index, const LLTextureEntry &te); @@ -508,7 +508,7 @@ private: //-------------------------------------------------------------------- protected: void deleteLayerSetCaches(bool clearAll = true); - void addBakedTextureStats(LLViewerImage* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level); + void addBakedTextureStats(LLViewerFetchedTexture* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level); //-------------------------------------------------------------------- // Composites diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 55e72cc437..4a80882c89 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -69,7 +69,7 @@ #include "lltoolmorph.h" #include "lltrans.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -103,7 +103,7 @@ struct LocalTextureData mWearableID(IMG_DEFAULT_AVATAR), mTexEntry(NULL) {} - LLPointer<LLViewerImage> mImage; + LLPointer<LLViewerFetchedTexture> mImage; BOOL mIsBakedReady; S32 mDiscard; LLUUID mWearableID; // UUID of the wearable that this texture belongs to, not of the image itself @@ -675,7 +675,7 @@ void LLVOAvatarSelf::stopMotionFromSource(const LLUUID& source_id) } // virtual -void LLVOAvatarSelf::setLocalTextureTE(U8 te, LLViewerImage* image, BOOL set_by_user, U32 index) +void LLVOAvatarSelf::setLocalTextureTE(U8 te, LLViewerTexture* image, BOOL set_by_user, U32 index) { if (te >= TEX_NUM_INDICES) { @@ -716,9 +716,10 @@ void LLVOAvatarSelf::removeMissingBakedTextures() for (U32 i = 0; i < mBakedTextureDatas.size(); i++) { const S32 te = mBakedTextureDatas[i].mTextureIndex; - if (getTEImage(te)->isMissingAsset()) + LLViewerTexture* tex = getTEImage(te) ; + if (!tex || tex->isMissingAsset()) { - setTEImage(te, gImageList.getImage(IMG_DEFAULT_AVATAR)); + setTEImage(te, LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR)); removed = TRUE; } } @@ -1008,7 +1009,7 @@ LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *viewer_obj } // virtual -void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src_raw, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src_raw, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) { //llinfos << "onLocalTextureLoaded: " << src_vi->getID() << llendl; @@ -1074,9 +1075,9 @@ BOOL LLVOAvatarSelf::getLocalTextureRaw(ETextureIndex index, LLImageRaw* image_r */ // virtual -BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLImageGL** image_gl_pp, U32 index) const +BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLViewerTexture** tex_pp, U32 index) const { - *image_gl_pp = NULL; + *tex_pp = NULL; if (!isIndexLocalTexture(type)) return FALSE; if (getLocalTextureID(type, index) == IMG_DEFAULT_AVATAR) return TRUE; @@ -1086,7 +1087,7 @@ BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLImageGL** image_gl_ { return FALSE; } - *image_gl_pp = local_tex_data->mImage; + *tex_pp = local_tex_data->mImage; return TRUE; } @@ -1230,7 +1231,7 @@ void LLVOAvatarSelf::invalidateComposite( LLTexLayerSet* layerset, BOOL set_by_u llassert(isSelf()); ETextureIndex baked_te = getBakedTE( layerset ); - setTEImage( baked_te, gImageList.getImage(IMG_DEFAULT_AVATAR) ); + setTEImage( baked_te, LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR) ); layerset->requestUpload(); } } @@ -1319,12 +1320,12 @@ void LLVOAvatarSelf::getLocalTextureByteCount(S32* gl_bytes) const const LocalTextureData *local_tex_data = local_tex_vec[num]; if (local_tex_data) { - const LLViewerImage* image_gl = local_tex_data->mImage; + const LLViewerFetchedTexture* image_gl = local_tex_data->mImage; if (image_gl) { S32 bytes = (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents(); - if (image_gl->getHasGLTexture()) + if (image_gl->hasValidGLTexture()) { *gl_bytes += bytes; } @@ -1335,10 +1336,16 @@ void LLVOAvatarSelf::getLocalTextureByteCount(S32* gl_bytes) const } // virtual -void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerImage* tex, BOOL baked_version_ready, U32 index) +void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_tex, BOOL baked_version_ready, U32 index) { if (!isIndexLocalTexture(type)) return; + LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(src_tex, TRUE) ; + if(!tex) + { + return ; + } + S32 desired_discard = isSelf() ? 0 : 2; LocalTextureData *local_tex_data = getLocalTextureData(type,index); if (!baked_version_ready) @@ -1415,7 +1422,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const } else { - const LLViewerImage* image = local_tex_data->mImage; + const LLViewerFetchedTexture* image = local_tex_data->mImage; llinfos << "LocTex " << name << ": " << "Discard " << image->getDiscardLevel() << ", " @@ -1431,7 +1438,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const } else { - llinfos << "LocTex " << name << ": No LLViewerImage" << llendl; + llinfos << "LocTex " << name << ": No LLViewerTexture" << llendl; } } } @@ -1441,7 +1448,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const // onLocalTextureLoaded() //----------------------------------------------------------------------------- -void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src_raw, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) +void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src_raw, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata) { LLAvatarTexData *data = (LLAvatarTexData *)userdata; LLVOAvatarSelf *self = (LLVOAvatarSelf *)gObjectList.findObject(data->mAvatarID); @@ -1555,8 +1562,8 @@ BOOL LLVOAvatarSelf::updateIsFullyLoaded() continue; // Check for the case that texture is defined but not sufficiently loaded to display anything. - LLViewerImage* baked_img = getImage( texture_data.mTextureIndex ); - if (!baked_img || !baked_img->getHasGLTexture()) + LLViewerTexture* baked_img = getImage( texture_data.mTextureIndex ); + if (!baked_img || !baked_img->hasValidGLTexture()) { loading = TRUE; } @@ -1646,7 +1653,7 @@ BOOL LLVOAvatarSelf::canGrabLocalTexture(ETextureIndex type, U32 index) const return TRUE; } -void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerImage* imagep, +void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL render_avatar, BOOL covered_by_baked, U32 index ) { if (!isIndexLocalTexture(type)) return; @@ -1698,7 +1705,7 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid ) { // Baked textures live on other sims. LLHost target_host = getObjectHost(); - setTEImage( te, gImageList.getImageFromHost( uuid, target_host ) ); + setTEImage( te, LLViewerTextureManager::getFetchedTextureFromHost( uuid, target_host ) ); updateMeshTextures(); dirtyMesh(); diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 588e3e67d8..7e8a36427d 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -34,6 +34,7 @@ #ifndef LL_LLVOAVATARSELF_H #define LL_LLVOAVATARSELF_H +#include "llviewertexture.h" #include "llvoavatar.h" struct LocalTextureData; @@ -141,8 +142,8 @@ private: // LLVOAvatar Constants //-------------------------------------------------------------------- public: - /*virtual*/ LLViewerImage::EBoostLevel getAvatarBoostLevel() const { return LLViewerImage::BOOST_AVATAR_SELF; } - /*virtual*/ LLViewerImage::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerImage::BOOST_AVATAR_BAKED_SELF; } + /*virtual*/ LLViewerTexture::EBoostLevel getAvatarBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_SELF; } + /*virtual*/ LLViewerTexture::EBoostLevel getAvatarBakedBoostLevel() const { return LLViewerTexture::BOOST_AVATAR_BAKED_SELF; } /*virtual*/ S32 getTexImageSize() const { return LLVOAvatar::getTexImageSize()*4; } /** Rendering @@ -169,18 +170,18 @@ public: // Local Textures //-------------------------------------------------------------------- public: - BOOL getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, LLImageGL** image_gl_pp, U32 index = 0) const; + BOOL getLocalTextureGL(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture** image_gl_pp, U32 index = 0) const; const LLUUID& getLocalTextureID(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; - void setLocalTextureTE(U8 te, LLViewerImage* image, BOOL set_by_user, U32 index = 0); + void setLocalTextureTE(U8 te, LLViewerTexture* image, BOOL set_by_user, U32 index = 0); const LLUUID& grabLocalTexture(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; BOOL canGrabLocalTexture(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const; protected: - /*virtual*/ void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerImage* tex, BOOL baked_version_exits, U32 index = 0); - void localTextureLoaded(BOOL succcess, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + /*virtual*/ void setLocalTexture(LLVOAvatarDefines::ETextureIndex type, LLViewerTexture* tex, BOOL baked_version_exits, U32 index = 0); + void localTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); void getLocalTextureByteCount(S32* gl_byte_count) const; - /*virtual*/ void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex i, LLViewerImage* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); + /*virtual*/ void addLocalTextureStats(LLVOAvatarDefines::ETextureIndex i, LLViewerFetchedTexture* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked, U32 index = 0); private: - static void onLocalTextureLoaded(BOOL succcess, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); + static void onLocalTextureLoaded(BOOL succcess, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); //-------------------------------------------------------------------- // Baked textures diff --git a/indra/newview/llvoclouds.cpp b/indra/newview/llvoclouds.cpp index 9095ee43c8..fbc4e2e609 100644 --- a/indra/newview/llvoclouds.cpp +++ b/indra/newview/llvoclouds.cpp @@ -44,7 +44,7 @@ #include "llprimitive.h" #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llvosky.h" @@ -61,8 +61,8 @@ LLVOClouds::LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re mCloudGroupp = NULL; mbCanSelect = FALSE; setNumTEs(1); - LLViewerImage* image = gImageList.getImage(gCloudTextureID); - image->setBoostLevel(LLViewerImage::BOOST_CLOUDS); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(gCloudTextureID); + image->setBoostLevel(LLViewerTexture::BOOST_CLOUDS); setTEImage(0, image); } diff --git a/indra/newview/llvoclouds.h b/indra/newview/llvoclouds.h index f70ea5b9e7..95e6b96e4e 100644 --- a/indra/newview/llvoclouds.h +++ b/indra/newview/llvoclouds.h @@ -37,7 +37,7 @@ #include "lltable.h" #include "v4coloru.h" -class LLViewerImage; +class LLViewerTexture; class LLViewerCloudGroup; class LLCloudGroup; diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index a956ec8ab3..cf6eb8e9fd 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -46,7 +46,7 @@ #include "llsurfacepatch.h" #include "llvosky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "pipeline.h" #include "llspatialpartition.h" @@ -106,7 +106,7 @@ void LLVOGrass::updateSpecies() SpeciesMap::const_iterator it = sSpeciesTable.begin(); mSpecies = (*it).first; } - setTEImage(0, gImageList.getImage(sSpeciesTable[mSpecies]->mTextureID)); + setTEImage(0, LLViewerTextureManager::getFetchedTexture(sSpeciesTable[mSpecies]->mTextureID, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE)); } diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h index 11b79d519c..124400d356 100644 --- a/indra/newview/llvograss.h +++ b/indra/newview/llvograss.h @@ -38,7 +38,7 @@ #include <map> class LLSurfacePatch; -class LLViewerImage; +class LLViewerTexture; class LLVOGrass : public LLAlphaObject diff --git a/indra/newview/llvoground.h b/indra/newview/llvoground.h index f485bd0aa4..af3fcd65d4 100644 --- a/indra/newview/llvoground.h +++ b/indra/newview/llvoground.h @@ -36,7 +36,7 @@ #include "stdtypes.h" #include "v3color.h" #include "v4coloru.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewerobject.h" class LLVOGround : public LLStaticViewerObject diff --git a/indra/newview/llvoicevisualizer.cpp b/indra/newview/llvoicevisualizer.cpp index a361a1160c..9bafc03a6d 100644 --- a/indra/newview/llvoicevisualizer.cpp +++ b/indra/newview/llvoicevisualizer.cpp @@ -42,9 +42,8 @@ #include "llvoicevisualizer.h" #include "llviewercamera.h" #include "llviewerobject.h" -#include "llimagegl.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llvoiceclient.h" #include "llrender.h" @@ -143,7 +142,7 @@ LLVoiceVisualizer::LLVoiceVisualizer( const U8 type ) for (int i=0; i<NUM_VOICE_SYMBOL_WAVES; i++) { mSoundSymbol.mWaveFadeOutStartTime [i] = mCurrentTime; - mSoundSymbol.mTexture [i] = gImageList.getImageFromFile(sound_level_img[i], FALSE, TRUE); + mSoundSymbol.mTexture [i] = LLViewerTextureManager::getFetchedTextureFromFile(sound_level_img[i], FALSE, TRUE); mSoundSymbol.mWaveActive [i] = false; mSoundSymbol.mWaveOpacity [i] = 1.0f; mSoundSymbol.mWaveExpansion [i] = 1.0f; diff --git a/indra/newview/llvoicevisualizer.h b/indra/newview/llvoicevisualizer.h index 0cbf24b786..1887849300 100644 --- a/indra/newview/llvoicevisualizer.h +++ b/indra/newview/llvoicevisualizer.h @@ -121,7 +121,7 @@ class LLVoiceVisualizer : public LLHUDEffect bool mWaveActive [ NUM_VOICE_SYMBOL_WAVES ]; F64 mWaveFadeOutStartTime [ NUM_VOICE_SYMBOL_WAVES ]; F32 mWaveOpacity [ NUM_VOICE_SYMBOL_WAVES ]; - LLPointer<LLImageGL> mTexture [ NUM_VOICE_SYMBOL_WAVES ]; + LLPointer<LLViewerFetchedTexture> mTexture [ NUM_VOICE_SYMBOL_WAVES ]; bool mActive; LLVector3 mPosition; }; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index d4df141477..993cf522e9 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -49,7 +49,7 @@ #include "llglheaders.h" #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llworld.h" @@ -212,8 +212,8 @@ void LLSkyTex::init() for (S32 i = 0; i < 2; ++i) { - mImageGL[i] = new LLImageGL(FALSE); - mImageGL[i]->setAddressMode(LLTexUnit::TAM_CLAMP); + mTexture[i] = LLViewerTextureManager::getLocalTexture(FALSE); + mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP); mImageRaw[i] = new LLImageRaw(sResolution, sResolution, sComponents); initEmpty(i); @@ -222,16 +222,16 @@ void LLSkyTex::init() void LLSkyTex::cleanupGL() { - mImageGL[0] = NULL; - mImageGL[1] = NULL; + mTexture[0] = NULL; + mTexture[1] = NULL; } void LLSkyTex::restoreGL() { for (S32 i = 0; i < 2; i++) { - mImageGL[i] = new LLImageGL(FALSE); - mImageGL[i]->setAddressMode(LLTexUnit::TAM_CLAMP); + mTexture[i] = LLViewerTextureManager::getLocalTexture(FALSE); + mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP); } } @@ -289,13 +289,13 @@ void LLSkyTex::create(const F32 brightness) void LLSkyTex::createGLImage(S32 which) { - mImageGL[which]->createGLTexture(0, mImageRaw[which]); - mImageGL[which]->setAddressMode(LLTexUnit::TAM_CLAMP); + mTexture[which]->createGLTexture(0, mImageRaw[which]); + mTexture[which]->setAddressMode(LLTexUnit::TAM_CLAMP); } void LLSkyTex::bindTexture(BOOL curr) { - gGL.getTexUnit(0)->bind(mImageGL[getWhich(curr)]); + gGL.getTexUnit(0)->bind(mTexture[getWhich(curr)]); } /*************************************** @@ -376,11 +376,11 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mSun.setIntensity(SUN_INTENSITY); mMoon.setIntensity(0.1f * SUN_INTENSITY); - mSunTexturep = gImageList.getImage(gSunTextureID, TRUE, TRUE); + mSunTexturep = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, TRUE); mSunTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mMoonTexturep = gImageList.getImage(gMoonTextureID, TRUE, TRUE); + mMoonTexturep = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, TRUE); mMoonTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mBloomTexturep = gImageList.getImage(IMG_BLOOM1); + mBloomTexturep = LLViewerTextureManager::getFetchedTexture(IMG_BLOOM1); mBloomTexturep->setNoDelete() ; mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -390,7 +390,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) LLVOSky::~LLVOSky() { - // Don't delete images - it'll get deleted by gImageList on shutdown + // Don't delete images - it'll get deleted by gTextureList on shutdown // This needs to be done for each texture mCubeMap = NULL; @@ -472,11 +472,11 @@ void LLVOSky::restoreGL() { mSkyTex[i].restoreGL(); } - mSunTexturep = gImageList.getImage(gSunTextureID, TRUE, TRUE); + mSunTexturep = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, TRUE); mSunTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mMoonTexturep = gImageList.getImage(gMoonTextureID, TRUE, TRUE); + mMoonTexturep = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, TRUE); mMoonTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - mBloomTexturep = gImageList.getImage(IMG_BLOOM1); + mBloomTexturep = LLViewerTextureManager::getFetchedTexture(IMG_BLOOM1); mBloomTexturep->setNoDelete() ; mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 5e23065153..466cdfdcd0 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -36,7 +36,7 @@ #include "stdtypes.h" #include "v3color.h" #include "v4coloru.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llviewerobject.h" #include "llframetimer.h" @@ -122,7 +122,7 @@ class LLSkyTex private: static S32 sResolution; static S32 sComponents; - LLPointer<LLImageGL> mImageGL[2]; + LLPointer<LLViewerTexture> mTexture[2]; LLPointer<LLImageRaw> mImageRaw[2]; LLColor4 *mSkyData; LLVector3 *mSkyDirs; // Cache of sky direction vectors @@ -567,9 +567,9 @@ public: BOOL isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; } LLFace* getReflFace() const { return mFace[FACE_REFLECTION]; } - LLViewerImage* getSunTex() const { return mSunTexturep; } - LLViewerImage* getMoonTex() const { return mMoonTexturep; } - LLViewerImage* getBloomTex() const { return mBloomTexturep; } + LLViewerTexture* getSunTex() const { return mSunTexturep; } + LLViewerTexture* getMoonTex() const { return mMoonTexturep; } + LLViewerTexture* getBloomTex() const { return mBloomTexturep; } void forceSkyUpdate(void) { mForceUpdate = TRUE; } public: @@ -579,9 +579,9 @@ public: protected: ~LLVOSky(); - LLPointer<LLViewerImage> mSunTexturep; - LLPointer<LLViewerImage> mMoonTexturep; - LLPointer<LLViewerImage> mBloomTexturep; + LLPointer<LLViewerFetchedTexture> mSunTexturep; + LLPointer<LLViewerFetchedTexture> mMoonTexturep; + LLPointer<LLViewerFetchedTexture> mBloomTexturep; static S32 sResolution; static S32 sTileResX; diff --git a/indra/newview/llvotextbubble.cpp b/indra/newview/llvotextbubble.cpp index de69aac037..9871965458 100644 --- a/indra/newview/llvotextbubble.cpp +++ b/indra/newview/llvotextbubble.cpp @@ -43,7 +43,7 @@ #include "llbox.h" #include "lldrawable.h" #include "llface.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llvolume.h" #include "pipeline.h" #include "llviewerregion.h" @@ -125,7 +125,7 @@ void LLVOTextBubble::updateTextures(LLAgent &agent) const LLTextureEntry *te = getTE(i); F32 texel_area_ratio = fabs(te->mScaleS * te->mScaleT); texel_area_ratio = llclamp(texel_area_ratio, .125f, 16.f); - LLViewerImage *imagep = getTEImage(i); + LLViewerTexture *imagep = getTEImage(i); if (imagep) { imagep->addTextureStats(mPixelArea / texel_area_ratio); @@ -142,9 +142,9 @@ LLDrawable *LLVOTextBubble::createDrawable(LLPipeline *pipeline) for (U32 i = 0; i < getNumTEs(); i++) { - LLViewerImage *imagep; + LLViewerTexture *imagep; const LLTextureEntry *texture_entry = getTE(i); - imagep = gImageList.getImage(texture_entry->getID()); + imagep = LLViewerTextureManager::getFetchedTexture(texture_entry->getID()); mDrawable->addFace((LLFacePool*) NULL, imagep); } @@ -194,7 +194,7 @@ BOOL LLVOTextBubble::updateGeometry(LLDrawable *drawable) { LLFace *face = drawable->getFace(i); face->setTEOffset(i); - face->setTexture(LLViewerImage::sSmokeImagep); + face->setTexture(LLViewerFetchedTexture::sSmokeImagep); face->setState(LLFace::FULLBRIGHT); } diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index b602b93025..d1cac4c77e 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -48,7 +48,7 @@ #include "lldrawable.h" #include "llface.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llworld.h" @@ -311,10 +311,10 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys, // // Load Species-Specific data // - mTreeImagep = gImageList.getImage(sSpeciesTable[mSpecies]->mTextureID); + mTreeImagep = LLViewerTextureManager::getFetchedTexture(sSpeciesTable[mSpecies]->mTextureID, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); if (mTreeImagep) { - gGL.getTexUnit(0)->bind(mTreeImagep.get()); + gGL.getTexUnit(0)->bind(mTreeImagep); } mBranchLength = sSpeciesTable[mSpecies]->mBranchLength; mTrunkLength = sSpeciesTable[mSpecies]->mTrunkLength; diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 42a6d54f62..13817fa111 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -39,7 +39,7 @@ class LLFace; class LLDrawPool; - +class LLViewerFetchedTexture; class LLVOTree : public LLViewerObject { @@ -160,7 +160,7 @@ protected: LLVector3 mWind; LLPointer<LLVertexBuffer> mReferenceBuffer; //reference geometry for generating tree mesh - LLPointer<LLViewerImage> mTreeImagep; // Pointer to proper tree image + LLPointer<LLViewerFetchedTexture> mTreeImagep; // Pointer to proper tree image U8 mSpecies; // Species of tree F32 mBranchLength; // Scale (length) of tree branches @@ -184,7 +184,7 @@ protected: // complete rebuild when not animating LLVector3 mLastPosition; LLQuaternion mLastRotation; - + U32 mFrameCount; typedef std::map<U32, TreeSpeciesData*> SpeciesMap; diff --git a/indra/newview/llvotreenew.h b/indra/newview/llvotreenew.h index 02f6d3a056..3fec5855ef 100644 --- a/indra/newview/llvotreenew.h +++ b/indra/newview/llvotreenew.h @@ -41,7 +41,7 @@ #include "llstrider.h" #include "v2math.h" #include "v3math.h" -#include "llviewerimage.h" +#include "llviewertexture.h" class LLFace; class LLDrawPool; @@ -187,7 +187,7 @@ public: //LLTreeParams mParams; U8 mSpecies; - LLPointer<LLViewerImage> mTreeImagep; + LLPointer<LLViewerTexture> mTreeImagep; LLMatrix4 mTrunkFlareFrames[MAX_FLARE]; F32 mSegSplitsError[3]; U32 mRandOffset[MAX_LEVELS]; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index f31f09f60e..bef38bb669 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -59,7 +59,7 @@ #include "llsky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llviewertextureanim.h" #include "llworld.h" @@ -427,7 +427,7 @@ void LLVOVolume::updateTextures() return; } - if (LLViewerImage::sDontLoadVolumeTextures || mDrawable.isNull()) // || !mDrawable->isVisible()) + if (LLViewerTexture::sDontLoadVolumeTextures || mDrawable.isNull()) // || !mDrawable->isVisible()) { return; } @@ -443,7 +443,7 @@ void LLVOVolume::updateTextures() { LLFace* face = mDrawable->getFace(i); const LLTextureEntry *te = face->getTextureEntry(); - LLViewerImage *imagep = face->getTexture(); + LLViewerTexture *imagep = face->getTexture(); if (!imagep || !te || face->mExtents[0] == face->mExtents[1]) { @@ -456,7 +456,7 @@ void LLVOVolume::updateTextures() { F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea(); vsize = area; - imagep->setBoostLevel(LLViewerImage::BOOST_HUD); + imagep->setBoostLevel(LLViewerTexture::BOOST_HUD); face->setPixelArea(area); // treat as full screen } else @@ -486,10 +486,14 @@ void LLVOVolume::updateTextures() } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) { - F32 pri = imagep->getDecodePriority(); - pri = llmax(pri, 0.0f); - if (pri < min_vsize) min_vsize = pri; - if (pri > max_vsize) max_vsize = pri; + LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ; + if(img) + { + F32 pri = img->getDecodePriority(); + pri = llmax(pri, 0.0f); + if (pri < min_vsize) min_vsize = pri; + if (pri > max_vsize) max_vsize = pri; + } } else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_FACE_AREA)) { @@ -503,7 +507,7 @@ void LLVOVolume::updateTextures() { LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); LLUUID id = sculpt_params->getSculptTexture(); - mSculptTexture = gImageList.getImage(id); + mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); if (mSculptTexture.notNull()) { S32 lod = llmin(mLOD, 3); @@ -511,7 +515,7 @@ void LLVOVolume::updateTextures() F32 tex_size = lodf * MAX_SCULPT_REZ; mSculptTexture->addTextureStats(2.f * tex_size * tex_size); mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), - (S32)LLViewerImage::BOOST_SCULPTED)); + (S32)LLViewerTexture::BOOST_SCULPTED)); mSculptTexture->setForSculpt() ; } @@ -625,7 +629,7 @@ void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) LLFace* LLVOVolume::addFace(S32 f) { const LLTextureEntry* te = getTE(f); - LLViewerImage* imagep = getTEImage(f); + LLViewerTexture* imagep = getTEImage(f); return mDrawable->addFace(te, imagep); } @@ -701,7 +705,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail if (isSculpted()) { - mSculptTexture = gImageList.getImage(volume_params.getSculptID()); + mSculptTexture = LLViewerTextureManager::getFetchedTexture(volume_params.getSculptID(), TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); if (mSculptTexture.notNull()) { sculpt(); @@ -783,9 +787,9 @@ void LLVOVolume::sculpt() sculpt_height = 0; sculpt_data = NULL ; - if(LLViewerImage::sTesterp) + if(LLViewerTextureManager::sTesterp) { - LLViewerImage::sTesterp->updateGrayTextureBinding(); + LLViewerTextureManager::sTesterp->updateGrayTextureBinding(); } } else @@ -796,9 +800,9 @@ void LLVOVolume::sculpt() sculpt_data = raw_image->getData(); - if(LLViewerImage::sTesterp) + if(LLViewerTextureManager::sTesterp) { - mSculptTexture->updateBindStats() ; + mSculptTexture->updateBindStatsForTester() ; } } getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level); @@ -1257,7 +1261,7 @@ BOOL LLVOVolume::isRootEdit() const return TRUE; } -void LLVOVolume::setTEImage(const U8 te, LLViewerImage *imagep) +void LLVOVolume::setTEImage(const U8 te, LLViewerTexture *imagep) { BOOL changed = (mTEImages[te] != imagep); LLViewerObject::setTEImage(te, imagep); @@ -2056,7 +2060,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e { LLFace* face = mDrawable->getFace(face_hit); - if (pick_transparent || !face->getTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))) + if (pick_transparent || !face->getTexture() || !face->getTexture()->hasGLTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))) { v_end = p; if (face_hitp != NULL) @@ -2167,7 +2171,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0); - LLViewerImage* tex = facep->getTexture(); + LLViewerTexture* tex = facep->getTexture(); U8 glow = 0; @@ -2318,7 +2322,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (facep->hasGeometry() && facep->mPixelArea > FORCE_CULL_AREA) { const LLTextureEntry* te = facep->getTextureEntry(); - LLViewerImage* tex = facep->getTexture(); + LLViewerTexture* tex = facep->getTexture(); if (facep->isState(LLFace::TEXTURE_ANIM)) { @@ -2566,7 +2570,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: LLSpatialGroup::buffer_map_t buffer_map; - LLViewerImage* last_tex = NULL; + LLViewerTexture* last_tex = NULL; S32 buffer_index = 0; if (distance_sort) @@ -2578,7 +2582,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { //pull off next face LLFace* facep = *face_iter; - LLViewerImage* tex = facep->getTexture(); + LLViewerTexture* tex = facep->getTexture(); if (distance_sort) { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 5d7b373b3c..d343d4db74 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -34,7 +34,7 @@ #define LL_LLVOVOLUME_H #include "llviewerobject.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llframetimer.h" #include "llapr.h" #include "m3math.h" // LLMatrix3 @@ -153,7 +153,7 @@ public: /*virtual*/ void setScale(const LLVector3 &scale, BOOL damped); - /*virtual*/ void setTEImage(const U8 te, LLViewerImage *imagep); + /*virtual*/ void setTEImage(const U8 te, LLViewerTexture *imagep); /*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid); /*virtual*/ S32 setTEColor(const U8 te, const LLColor3 &color); /*virtual*/ S32 setTEColor(const U8 te, const LLColor4 &color); @@ -237,7 +237,7 @@ private: BOOL mVolumeChanged; F32 mVObjRadius; LLVolumeInterface *mVolumeImpl; - LLPointer<LLViewerImage> mSculptTexture; + LLPointer<LLViewerFetchedTexture> mSculptTexture; // statics public: diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index d23c746b75..427119285b 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -45,7 +45,7 @@ #include "llsurface.h" #include "llvosky.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llworld.h" #include "pipeline.h" diff --git a/indra/newview/llvowater.h b/indra/newview/llvowater.h index cdda48f6f2..28a5633c58 100644 --- a/indra/newview/llvowater.h +++ b/indra/newview/llvowater.h @@ -34,7 +34,7 @@ #define LL_VOWATER_H #include "llviewerobject.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "v2math.h" const U32 N_RES = 16; //32 // number of subdivisions of wave tile diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp index a26ccedfb2..3e97f9dbef 100644 --- a/indra/newview/llwaterparamset.cpp +++ b/indra/newview/llwaterparamset.cpp @@ -39,7 +39,7 @@ #include "llwaterparammanager.h" #include "lluictrlfactory.h" #include "llsliderctrl.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewercontrol.h" #include "lluuid.h" diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index 1e35a31cb6..e8c4046660 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -35,7 +35,7 @@ #include "llagent.h" #include "llagentwearables.h" #include "llfloatercustomize.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llinventorymodel.h" #include "llviewerregion.h" #include "llvoavatar.h" @@ -459,7 +459,7 @@ BOOL LLWearable::isDirty() const { if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType) { - LLViewerImage* avatar_image = avatar->getTEImage( te ); + LLViewerTexture* avatar_image = avatar->getTEImage( te ); if( !avatar_image ) { llassert( 0 ); @@ -559,7 +559,7 @@ void LLWearable::writeToAvatar( BOOL set_by_user ) if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType) { const LLUUID& image_id = get_if_there(mTEMap, te, LLVOAvatarDictionary::getDefaultTextureImageID((ETextureIndex) te)); - LLViewerImage* image = gImageList.getImage( image_id ); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, FALSE, LLViewerTexture::LOD_TEXTURE ); avatar->setLocalTextureTE(te, image, set_by_user); } } @@ -631,7 +631,7 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL set_by_user ) } // Pull textures - LLViewerImage* image = gImageList.getImage( IMG_DEFAULT_AVATAR ); + LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( IMG_DEFAULT_AVATAR ); for( S32 te = 0; te < TEX_NUM_INDICES; te++ ) { if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == type) @@ -682,7 +682,7 @@ void LLWearable::readFromAvatar() { if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType) { - LLViewerImage* image = avatar->getTEImage( te ); + LLViewerTexture* image = avatar->getTEImage( te ); if( image ) { mTEMap[te] = image->getID(); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 692efd2b7a..5c6fc2cf21 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -46,8 +46,8 @@ #include "llregionhandle.h" #include "llsurface.h" #include "llviewercamera.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewernetwork.h" #include "llviewerobjectlist.h" #include "llviewerparceloverlay.h" @@ -109,8 +109,8 @@ LLWorld::LLWorld() : *(default_texture++) = MAX_WATER_COLOR.mV[2]; *(default_texture++) = MAX_WATER_COLOR.mV[3]; - mDefaultWaterTexturep = new LLViewerImage(raw, FALSE); - gGL.getTexUnit(0)->bind(mDefaultWaterTexturep.get()); + mDefaultWaterTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); + gGL.getTexUnit(0)->bind(mDefaultWaterTexturep); mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); } @@ -962,7 +962,7 @@ void LLWorld::shiftRegions(const LLVector3& offset) LLViewerPartSim::getInstance()->shift(offset); } -LLViewerImage* LLWorld::getDefaultWaterTexture() +LLViewerTexture* LLWorld::getDefaultWaterTexture() { return mDefaultWaterTexturep; } diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index b5380a6f6c..48025c700b 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -45,7 +45,7 @@ #include "llsingleton.h" #include "llstring.h" #include "llviewerpartsim.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llvowater.h" class LLViewerRegion; @@ -141,7 +141,7 @@ public: F32 getLandFarClip() const; void setLandFarClip(const F32 far_clip); - LLViewerImage *getDefaultWaterTexture(); + LLViewerTexture *getDefaultWaterTexture(); void updateWaterObjects(); void shiftRegions(const LLVector3& offset); @@ -192,7 +192,7 @@ private: std::list<LLVOWater*> mHoleWaterObjects; LLPointer<LLVOWater> mEdgeWaterObjects[8]; - LLPointer<LLViewerImage> mDefaultWaterTexturep; + LLPointer<LLViewerTexture> mDefaultWaterTexturep; }; diff --git a/indra/newview/llworldmap.cpp b/indra/newview/llworldmap.cpp index 827f12d19e..700971dcc4 100644 --- a/indra/newview/llworldmap.cpp +++ b/indra/newview/llworldmap.cpp @@ -43,7 +43,7 @@ #include "llviewercontrol.h" #include "llfloaterworldmap.h" #include "lltracker.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerregion.h" #include "llregionflags.h" #include "lltrans.h" @@ -519,9 +519,9 @@ void LLWorldMap::processMapLayerReply(LLMessageSystem* msg, void**) LLWorldMapLayer new_layer; new_layer.LayerDefined = TRUE; msg->getUUIDFast(_PREHASH_LayerData, _PREHASH_ImageID, new_layer.LayerImageID, block); - new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); + new_layer.LayerImage = LLViewerTextureManager::getFetchedTexture(new_layer.LayerImageID, MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); - gGL.getTexUnit(0)->bind(new_layer.LayerImage.get()); + gGL.getTexUnit(0)->bind(new_layer.LayerImage); new_layer.LayerImage->setAddressMode(LLTexUnit::TAM_CLAMP); U32 left, right, top, bottom; @@ -634,15 +634,15 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) siminfo->mMapImageID[agent_flags] = image_id; #ifdef IMMEDIATE_IMAGE_LOAD - siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); - gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); + siminfo->mCurrentImage = LLViewerTextureManager::getFetchedTexture(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); + gGL.getTexUnit(0)->bind(siminfo->mCurrentImage); siminfo->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); #endif if (siminfo->mMapImageID[2].notNull()) { #ifdef IMMEDIATE_IMAGE_LOAD - siminfo->mOverlayImage = gImageList.getImage(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE); + siminfo->mOverlayImage = LLViewerTextureManager::getFetchedTexture(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); #endif } else @@ -862,10 +862,10 @@ void LLWorldMap::dump() if (info->mCurrentImage) { llinfos << "image discard " << (S32)info->mCurrentImage->getDiscardLevel() - << " fullwidth " << info->mCurrentImage->getWidth(0) - << " fullheight " << info->mCurrentImage->getHeight(0) - << " maxvirt " << info->mCurrentImage->mMaxVirtualSize - << " maxdisc " << (S32)info->mCurrentImage->getMaxDiscardLevel() + << " fullwidth " << info->mCurrentImage->getFullWidth() + << " fullheight " << info->mCurrentImage->getFullHeight() + << " maxvirt " << info->mCurrentImage->getMaxVirtualSize() + //<< " maxdisc " << (S32)info->mCurrentImage->getMaxDiscardLevel() << llendl; } } diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h index 1db081c74a..9daee38752 100644 --- a/indra/newview/llworldmap.h +++ b/indra/newview/llworldmap.h @@ -45,7 +45,7 @@ #include "lluuid.h" #include "llpointer.h" #include "llsingleton.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "lleventinfo.h" #include "v3color.h" @@ -96,8 +96,8 @@ public: LLUUID mMapImageID[MAP_SIM_IMAGE_TYPES]; // Hold a reference to the currently displayed image. - LLPointer<LLViewerImage> mCurrentImage; - LLPointer<LLViewerImage> mOverlayImage; + LLPointer<LLViewerFetchedTexture> mCurrentImage; + LLPointer<LLViewerFetchedTexture> mOverlayImage; }; #define MAP_BLOCK_RES 256 @@ -105,7 +105,7 @@ public: struct LLWorldMapLayer { BOOL LayerDefined; - LLPointer<LLViewerImage> LayerImage; + LLPointer<LLViewerFetchedTexture> LayerImage; LLUUID LayerImageID; LLRect LayerExtents; diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 3deddf40ac..67bc205f62 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -54,8 +54,8 @@ #include "lltextureview.h" #include "lltracker.h" #include "llviewercamera.h" -#include "llviewerimage.h" -#include "llviewerimagelist.h" +#include "llviewertexture.h" +#include "llviewertexturelist.h" #include "llviewermenu.h" #include "llviewerparceloverlay.h" #include "llviewerregion.h" @@ -332,7 +332,7 @@ void LLWorldMapView::draw() continue; } LLWorldMapLayer *layer = &LLWorldMap::getInstance()->mMapLayers[LLWorldMap::getInstance()->mCurrentMap][layer_idx]; - LLViewerImage *current_image = layer->LayerImage; + LLViewerFetchedTexture *current_image = layer->LayerImage; if (current_image->isMissingAsset()) { @@ -367,10 +367,10 @@ void LLWorldMapView::draw() continue; } - current_image->setBoostLevel(LLViewerImage::BOOST_MAP_LAYER); + current_image->setBoostLevel(LLViewerTexture::BOOST_MAP_LAYER); current_image->setKnownDrawSize(llround(pix_width * LLUI::sGLScaleFactor.mV[VX]), llround(pix_height * LLUI::sGLScaleFactor.mV[VY])); - if (!current_image->getHasGLTexture()) + if (!current_image->hasValidGLTexture()) { continue; // better to draw nothing than the default image } @@ -434,8 +434,8 @@ void LLWorldMapView::draw() U64 handle = (*it).first; LLSimInfo* info = (*it).second; - LLViewerImage* simimage = info->mCurrentImage; - LLViewerImage* overlayimage = info->mOverlayImage; + LLViewerFetchedTexture* simimage = info->mCurrentImage; + LLViewerFetchedTexture* overlayimage = info->mOverlayImage; if (gMapScale < SIM_MAP_SCALE) { @@ -472,7 +472,7 @@ void LLWorldMapView::draw() bool sim_visible = (gMapScale >= map_scale_cutoff) && (simimage != NULL) && - (simimage->getHasGLTexture()); + (simimage->hasValidGLTexture()); if (sim_visible) { @@ -510,7 +510,7 @@ void LLWorldMapView::draw() (textures_requested_this_tick < MAX_REQUEST_PER_TICK))) { textures_requested_this_tick++; - info->mCurrentImage = gImageList.getImage(info->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); + info->mCurrentImage = LLViewerTextureManager::getFetchedTexture(info->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); info->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); simimage = info->mCurrentImage; gGL.getTexUnit(0)->bind(simimage); @@ -523,7 +523,7 @@ void LLWorldMapView::draw() (textures_requested_this_tick < MAX_REQUEST_PER_TICK))) { textures_requested_this_tick++; - info->mOverlayImage = gImageList.getImage(info->mMapImageID[2], MIPMAP_TRUE, FALSE); + info->mOverlayImage = LLViewerTextureManager::getFetchedTexture(info->mMapImageID[2], MIPMAP_TRUE, FALSE, LLViewerTexture::LOD_TEXTURE); info->mOverlayImage->setAddressMode(LLTexUnit::TAM_CLAMP); overlayimage = info->mOverlayImage; gGL.getTexUnit(0)->bind(overlayimage); @@ -546,13 +546,13 @@ void LLWorldMapView::draw() S32 draw_size = llround(gMapScale); if (simimage != NULL) { - simimage->setBoostLevel(LLViewerImage::BOOST_MAP); + simimage->setBoostLevel(LLViewerTexture::BOOST_MAP); simimage->setKnownDrawSize(llround(draw_size * LLUI::sGLScaleFactor.mV[VX]), llround(draw_size * LLUI::sGLScaleFactor.mV[VY])); } if (overlayimage != NULL) { - overlayimage->setBoostLevel(LLViewerImage::BOOST_MAP); + overlayimage->setBoostLevel(LLViewerTexture::BOOST_MAP); overlayimage->setKnownDrawSize(llround(draw_size * LLUI::sGLScaleFactor.mV[VX]), llround(draw_size * LLUI::sGLScaleFactor.mV[VY])); } @@ -581,7 +581,7 @@ void LLWorldMapView::draw() gGL.vertex3f(right, top, 0.f); gGL.end(); - if (gSavedSettings.getBOOL("MapShowLandForSale") && overlayimage && overlayimage->getHasGLTexture()) + if (gSavedSettings.getBOOL("MapShowLandForSale") && overlayimage && overlayimage->hasValidGLTexture()) { gGL.getTexUnit(0)->bind(overlayimage); gGL.color4f(1.f, 1.f, 1.f, alpha); diff --git a/indra/newview/llworldmapview.h b/indra/newview/llworldmapview.h index dd64da1371..41c9772694 100644 --- a/indra/newview/llworldmapview.h +++ b/indra/newview/llworldmapview.h @@ -39,7 +39,7 @@ #include "v3math.h" #include "v3dmath.h" #include "v4color.h" -#include "llviewerimage.h" +#include "llviewertexture.h" #include "llmapimagetype.h" #include "llworldmap.h" @@ -50,7 +50,7 @@ const S32 DEFAULT_TRACKING_ARROW_SIZE = 16; class LLColor4; class LLColor4U; class LLCoordGL; -class LLViewerImage; +class LLViewerTexture; class LLTextBox; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 88d2eab66d..38c81bf027 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -76,7 +76,7 @@ #include "lltool.h" #include "lltoolmgr.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -751,9 +751,9 @@ S32 LLPipeline::setLightingDetail(S32 level) class LLOctreeDirtyTexture : public LLOctreeTraveler<LLDrawable> { public: - const std::set<LLViewerImage*>& mTextures; + const std::set<LLViewerFetchedTexture*>& mTextures; - LLOctreeDirtyTexture(const std::set<LLViewerImage*>& textures) : mTextures(textures) { } + LLOctreeDirtyTexture(const std::set<LLViewerFetchedTexture*>& textures) : mTextures(textures) { } virtual void visit(const LLOctreeNode<LLDrawable>* node) { @@ -766,7 +766,8 @@ public: for (LLSpatialGroup::drawmap_elem_t::iterator j = i->second.begin(); j != i->second.end(); ++j) { LLDrawInfo* params = *j; - if (mTextures.find(params->mTexture) != mTextures.end()) + LLViewerFetchedTexture* tex = LLViewerTextureManager::staticCastToFetchedTexture(params->mTexture); + if (tex && mTextures.find(tex) != mTextures.end()) { group->setState(LLSpatialGroup::GEOM_DIRTY); } @@ -783,7 +784,7 @@ public: }; // Called when a texture changes # of channels (causes faces to move to alpha pool) -void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerImage*>& textures) +void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerFetchedTexture*>& textures) { assertInitialized(); @@ -815,7 +816,7 @@ void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerImage*>& texture } } -LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerImage *tex0) +LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) { assertInitialized(); @@ -887,7 +888,7 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerImage *tex0) } -LLDrawPool *LLPipeline::getPool(const U32 type, LLViewerImage *tex0) +LLDrawPool *LLPipeline::getPool(const U32 type, LLViewerTexture *tex0) { LLMemType mt(LLMemType::MTYPE_PIPELINE); LLDrawPool *poolp = findPool(type, tex0); @@ -904,7 +905,7 @@ LLDrawPool *LLPipeline::getPool(const U32 type, LLViewerImage *tex0) // static -LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerImage* imagep) +LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) { LLMemType mt(LLMemType::MTYPE_PIPELINE); U32 type = getPoolTypeFromTE(te, imagep); @@ -912,7 +913,7 @@ LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerImage* i } //static -U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerImage* imagep) +U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) { LLMemType mt_gpt(LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE); @@ -924,7 +925,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerImage* image bool alpha = te->getColor().mV[3] < 0.999f; if (imagep) { - alpha = alpha || (imagep->getComponents() == 4 && ! imagep->mIsMediaTexture) || (imagep->getComponents() == 2); + alpha = alpha || (imagep->getComponents() == 4 && imagep->getType() != LLViewerTexture::MEDIA_TEXTURE) || (imagep->getComponents() == 2); } if (alpha) @@ -2446,7 +2447,7 @@ void LLPipeline::renderHighlights() // Make sure the selection image gets downloaded and decoded if (!mFaceSelectImagep) { - mFaceSelectImagep = gImageList.getImage(IMG_FACE_SELECT); + mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT); } mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); @@ -2476,7 +2477,7 @@ void LLPipeline::renderHighlights() for (S32 i = 0; i < count; i++) { LLFace* facep = mHighlightFaces[i]; - facep->renderSelected(LLViewerImage::sNullImagep, color); + facep->renderSelected(LLViewerTexture::sNullImagep, color); } } @@ -2565,8 +2566,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) sUnderWaterRender = FALSE; } - gGL.getTexUnit(0)->bind(LLViewerImage::sDefaultImagep); - LLViewerImage::sDefaultImagep->setAddressMode(LLTexUnit::TAM_WRAP); + gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sDefaultImagep); + LLViewerFetchedTexture::sDefaultImagep->setAddressMode(LLTexUnit::TAM_WRAP); ////////////////////////////////////////////// // diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 5358fce766..fc02e7dd88 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -46,7 +46,7 @@ #include "lldrawable.h" #include "llrendertarget.h" -class LLViewerImage; +class LLViewerTexture; class LLEdge; class LLFace; class LLViewerObject; @@ -104,15 +104,15 @@ public: /// @brief Get a draw pool from pool type (POOL_SIMPLE, POOL_MEDIA) and texture. /// @return Draw pool, or NULL if not found. - LLDrawPool *findPool(const U32 pool_type, LLViewerImage *tex0 = NULL); + LLDrawPool *findPool(const U32 pool_type, LLViewerTexture *tex0 = NULL); /// @brief Get a draw pool for faces of the appropriate type and texture. Create if necessary. /// @return Always returns a draw pool. - LLDrawPool *getPool(const U32 pool_type, LLViewerImage *tex0 = NULL); + LLDrawPool *getPool(const U32 pool_type, LLViewerTexture *tex0 = NULL); /// @brief Figures out draw pool type from texture entry. Creates pool if necessary. - static LLDrawPool* getPoolFromTE(const LLTextureEntry* te, LLViewerImage* te_image); - static U32 getPoolTypeFromTE(const LLTextureEntry* te, LLViewerImage* imagep); + static LLDrawPool* getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* te_image); + static U32 getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep); void addPool(LLDrawPool *poolp); // Only to be used by LLDrawPool classes for splitting pools! void removePool( LLDrawPool* poolp ); @@ -150,7 +150,7 @@ public: ); // Something about these textures has changed. Dirty them. - void dirtyPoolObjectTextures(const std::set<LLViewerImage*>& textures); + void dirtyPoolObjectTextures(const std::set<LLViewerFetchedTexture*>& textures); void resetDrawOrders(); @@ -561,9 +561,9 @@ public: protected: std::vector<LLFace*> mSelectedFaces; - LLPointer<LLViewerImage> mFaceSelectImagep; - LLPointer<LLViewerImage> mBloomImagep; - LLPointer<LLViewerImage> mBloomImage2p; + LLPointer<LLViewerFetchedTexture> mFaceSelectImagep; + LLPointer<LLViewerTexture> mBloomImagep; + LLPointer<LLViewerTexture> mBloomImage2p; U32 mLightMask; U32 mLightMovingMask; |