diff options
Diffstat (limited to 'indra/llrender')
-rwxr-xr-x | indra/llrender/llfontbitmapcache.cpp | 20 | ||||
-rwxr-xr-x | indra/llrender/llfontbitmapcache.h | 3 | ||||
-rwxr-xr-x | indra/llrender/llfontfreetype.cpp | 20 | ||||
-rwxr-xr-x | indra/llrender/llfontfreetype.h | 6 | ||||
-rwxr-xr-x | indra/llrender/llimagegl.cpp | 18 | ||||
-rwxr-xr-x | indra/llrender/llimagegl.h | 2 | ||||
-rwxr-xr-x | indra/llrender/llvertexbuffer.cpp | 7 | ||||
-rwxr-xr-x | indra/llrender/llvertexbuffer.h | 6 |
8 files changed, 66 insertions, 16 deletions
diff --git a/indra/llrender/llfontbitmapcache.cpp b/indra/llrender/llfontbitmapcache.cpp index c985f6b959..f128636ab2 100755 --- a/indra/llrender/llfontbitmapcache.cpp +++ b/indra/llrender/llfontbitmapcache.cpp @@ -29,7 +29,8 @@ #include "llgl.h" #include "llfontbitmapcache.h" -LLFontBitmapCache::LLFontBitmapCache(): +LLFontBitmapCache::LLFontBitmapCache() +: LLTrace::MemTrackable<LLFontBitmapCache>("LLFontBitmapCache"), mNumComponents(0), mBitmapWidth(0), mBitmapHeight(0), @@ -81,6 +82,7 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm { // We're out of space in the current image, or no image // has been allocated yet. Make a new one. + mImageRawVec.push_back(new LLImageRaw); mBitmapNum = mImageRawVec.size()-1; LLImageRaw *image_raw = getImageRaw(mBitmapNum); @@ -122,6 +124,9 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm image_gl->createGLTexture(0, image_raw); gGL.getTexUnit(0)->bind(image_gl); image_gl->setFilteringOption(LLTexUnit::TFO_POINT); // was setMipFilterNearest(TRUE, TRUE); + + claimMem(image_raw); + claimMem(image_gl); } else { @@ -151,7 +156,20 @@ void LLFontBitmapCache::destroyGL() void LLFontBitmapCache::reset() { + for (std::vector<LLPointer<LLImageRaw> >::iterator it = mImageRawVec.begin(), end_it = mImageRawVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageRawVec.clear(); + + for (std::vector<LLPointer<LLImageGL> >::iterator it = mImageGLVec.begin(), end_it = mImageGLVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageGLVec.clear(); mBitmapWidth = 0; diff --git a/indra/llrender/llfontbitmapcache.h b/indra/llrender/llfontbitmapcache.h index c93b0c7320..75df3a94a7 100755 --- a/indra/llrender/llfontbitmapcache.h +++ b/indra/llrender/llfontbitmapcache.h @@ -28,10 +28,11 @@ #define LL_LLFONTBITMAPCACHE_H #include <vector> +#include "lltrace.h" // Maintain a collection of bitmaps containing rendered glyphs. // Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL. -class LLFontBitmapCache: public LLRefCount +class LLFontBitmapCache : public LLTrace::MemTrackable<LLFontBitmapCache> { public: LLFontBitmapCache(); diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 4cc5b78b63..bde62f89b3 100755 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -101,7 +101,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index) } LLFontFreetype::LLFontFreetype() -: mFontBitmapCachep(new LLFontBitmapCache), +: LLTrace::MemTrackable<LLFontFreetype>("LLFontFreetype"), + mFontBitmapCachep(new LLFontBitmapCache), mValid(FALSE), mAscender(0.f), mDescender(0.f), @@ -126,7 +127,7 @@ LLFontFreetype::~LLFontFreetype() // Delete glyph info std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); - // mFontBitmapCachep will be cleaned up by LLPointer destructor. + delete mFontBitmapCachep; // mFallbackFonts cleaned up by LLPointer destructor } @@ -186,6 +187,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v S32 max_char_height = llround(0.5f + (y_max - y_min)); mFontBitmapCachep->init(components, max_char_width, max_char_height); + claimMem(mFontBitmapCachep); + if (!mFTFace->charmap) { @@ -200,6 +203,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v } mName = filename; + claimMem(mName); mPointSize = point_size; mStyle = LLFontGL::NORMAL; @@ -476,6 +480,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } else { + claimMem(gi); mCharGlyphInfoMap[wch] = gi; } } @@ -517,8 +522,15 @@ void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) void LLFontFreetype::resetBitmapCache() { - for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); + for (char_glyph_info_map_t::iterator it = mCharGlyphInfoMap.begin(), end_it = mCharGlyphInfoMap.end(); + it != end_it; + ++it) + { + disclaimMem(it->second); + delete it->second; + } mCharGlyphInfoMap.clear(); + disclaimMem(mFontBitmapCachep); mFontBitmapCachep->reset(); // Adding default glyph is skipped for fallback fonts here as well as in loadFace(). @@ -540,7 +552,7 @@ const std::string &LLFontFreetype::getName() const return mName; } -const LLPointer<LLFontBitmapCache> LLFontFreetype::getFontBitmapCache() const +const LLFontBitmapCache* LLFontFreetype::getFontBitmapCache() const { return mFontBitmapCachep; } diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index f1b23f22d5..2963fbd43d 100755 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -74,7 +74,7 @@ struct LLFontGlyphInfo extern LLFontManager *gFontManagerp; -class LLFontFreetype : public LLRefCount +class LLFontFreetype : public LLRefCount, public LLTrace::MemTrackable<LLFontFreetype> { public: LLFontFreetype(); @@ -134,7 +134,7 @@ public: const std::string& getName() const; - const LLPointer<LLFontBitmapCache> getFontBitmapCache() const; + const LLFontBitmapCache* getFontBitmapCache() const; void setStyle(U8 style); U8 getStyle() const; @@ -167,7 +167,7 @@ private: typedef boost::unordered_map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t; mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap - mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep; + mutable LLFontBitmapCache* mFontBitmapCachep; mutable S32 mRenderGlyphCount; mutable S32 mAddGlyphCount; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index d66b6d8432..4330a9891e 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -279,8 +279,10 @@ void LLImageGL::destroyGL(BOOL save_state) if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) { glimage->mSaveData = new LLImageRaw; + glimage->claimMem(glimage->mSaveData); if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. { + glimage->disclaimMem(glimage->mSaveData); glimage->mSaveData = NULL ; } } @@ -354,7 +356,8 @@ BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, const LLImageRaw* imageraw, B //---------------------------------------------------------------------------- LLImageGL::LLImageGL(BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -363,7 +366,8 @@ LLImageGL::LLImageGL(BOOL usemipmaps) } LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { llassert( components <= 4 ); init(usemipmaps); @@ -373,7 +377,8 @@ LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) } LLImageGL::LLImageGL(const LLImageRaw* imageraw, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable<LLImageGL>("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -387,6 +392,7 @@ LLImageGL::~LLImageGL() { LLImageGL::cleanup(); sImageList.erase(this); + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; sCount--; @@ -500,6 +506,7 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve } // pickmask validity depends on old image size, delete it + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1460,7 +1467,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); } + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)getMipBytes(discard_level); + claimMem(mTextureMemory); sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; @@ -1621,6 +1630,7 @@ void LLImageGL::destroyGLTexture() if(mTextureMemory != S32Bytes(0)) { sGlobalTextureMemory -= mTextureMemory; + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)0; } @@ -1970,6 +1980,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) return ; } + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1987,6 +1998,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) U32 size = pick_width * pick_height; size = (size + 7) / 8; // pixelcount-to-bits mPickMask = new U8[size]; + claimMem(size); mPickMaskWidth = pick_width - 1; mPickMaskHeight = pick_height - 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 09ea8a1124..816169a30c 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -42,7 +42,7 @@ class LLTextureAtlas ; #define MEGA_BYTES_TO_BYTES(x) ((x) << 20) //============================================================================ -class LLImageGL : public LLRefCount +class LLImageGL : public LLRefCount, public LLTrace::MemTrackable<LLImageGL> { friend class LLTexUnit; public: diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b1a5a194be..38351dd9ae 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -959,7 +959,8 @@ S32 LLVertexBuffer::determineUsage(S32 usage) return ret_usage; } -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : +LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) +: LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), LLRefCount(), mNumVerts(0), @@ -1096,7 +1097,9 @@ void LLVertexBuffer::waitFence() const void LLVertexBuffer::genBuffer(U32 size) { + disclaimMem(mSize); mSize = vbo_block_size(size); + claimMem(mSize); if (mUsage == GL_STREAM_DRAW_ARB) { @@ -1185,7 +1188,9 @@ void LLVertexBuffer::createGLBuffer(U32 size) static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + disclaimMem(mSize); mSize = size; + disclaimMem(mSize); } } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 0b4b87f338..92ea3bfc8e 100755 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -34,6 +34,7 @@ #include "v4coloru.h" #include "llstrider.h" #include "llrender.h" +#include "lltrace.h" #include <set> #include <vector> #include <list> @@ -98,7 +99,7 @@ public: //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer : public LLRefCount, public LLTrace::MemTrackable<LLVertexBuffer> { public: class MappedRegion @@ -112,7 +113,8 @@ public: }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) + : LLTrace::MemTrackable<LLVertexBuffer>("LLVertexBuffer"), + mUsage(rhs.mUsage) { *this = rhs; } |