summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llfontfreetype.cpp64
-rw-r--r--indra/llrender/llfontfreetype.h2
-rw-r--r--indra/llrender/llfontregistry.cpp2
-rw-r--r--indra/llrender/llvertexbuffer.cpp24
4 files changed, 73 insertions, 19 deletions
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index de26d19efc..5c1f4ff8b3 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -106,6 +106,8 @@ LLFontFreetype::LLFontFreetype()
mAscender(0.f),
mDescender(0.f),
mLineHeight(0.f),
+ pFontBuffer(NULL),
+ mBufferSize(0),
mIsFallback(FALSE),
mFTFace(NULL),
mRenderGlyphCount(0),
@@ -128,6 +130,8 @@ LLFontFreetype::~LLFontFreetype()
mCharGlyphInfoMap.clear();
delete mFontBitmapCachep;
+ delete pFontBuffer;
+ disclaimMem(mBufferSize);
// mFallbackFonts cleaned up by LLPointer destructor
}
@@ -143,13 +147,64 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
int error;
+#ifdef LL_WINDOWS
+
+ if (mBufferSize > 0)
+ {
+ delete pFontBuffer;
+ disclaimMem(mBufferSize);
+ pFontBuffer = NULL;
+ mBufferSize = 0;
+ }
+
+ S32 file_size = 0;
+ LLFILE* file = LLFile::fopen(filename, "rb");
+ if (!file)
+ {
+ return FALSE;
+ }
+
+ if (!fseek(file, 0, SEEK_END))
+ {
+ file_size = ftell(file);
+ fseek(file, 0, SEEK_SET);
+ }
+
+ // Don't delete before FT_Done_Face
+ pFontBuffer = new(std::nothrow) U8[file_size];
+ if (!pFontBuffer)
+ {
+ fclose(file);
+ return FALSE;
+ }
+
+ mBufferSize = fread(pFontBuffer, 1, file_size, file);
+ fclose(file);
+
+ if (mBufferSize != file_size)
+ {
+ delete pFontBuffer;
+ mBufferSize = 0;
+ return FALSE;
+ }
+
+ error = FT_New_Memory_Face( gFTLibrary,
+ (FT_Byte*) pFontBuffer,
+ mBufferSize,
+ 0,
+ &mFTFace);
+#else
error = FT_New_Face( gFTLibrary,
filename.c_str(),
0,
- &mFTFace );
+ &mFTFace);
+#endif
- if (error)
+ if (error)
{
+ delete pFontBuffer;
+ pFontBuffer = NULL;
+ mBufferSize = 0;
return FALSE;
}
@@ -166,10 +221,15 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v
{
// Clean up freetype libs.
FT_Done_Face(mFTFace);
+ delete pFontBuffer;
+ pFontBuffer = NULL;
+ mBufferSize = 0;
mFTFace = NULL;
return FALSE;
}
+ claimMem(mBufferSize);
+
F32 y_max, y_min, x_max, x_min;
F32 ems_per_unit = 1.f/ mFTFace->units_per_EM;
F32 pixels_per_unit = pixels_per_em * ems_per_unit;
diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h
index a5ece42b88..26ba695418 100644
--- a/indra/llrender/llfontfreetype.h
+++ b/indra/llrender/llfontfreetype.h
@@ -158,6 +158,8 @@ private:
F32 mLineHeight;
LLFT_Face mFTFace;
+ U8* pFontBuffer;
+ S32 mBufferSize;
BOOL mIsFallback;
font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars)
diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp
index d003687415..3c829596ce 100644
--- a/indra/llrender/llfontregistry.cpp
+++ b/indra/llrender/llfontregistry.cpp
@@ -447,7 +447,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
if (!fontp->loadFace(font_path, extra_scale * point_size,
LLFontGL::sVertDPI, LLFontGL::sHorizDPI, 2, is_fallback))
{
- LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << LL_ENDL;
+ LL_INFOS_ONCE("LLFontRegistry") << "Couldn't load font " << *file_name_it << " from path " << local_path << LL_ENDL;
delete fontp;
fontp = NULL;
}
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index f10301b42d..a55ca5ed9c 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -98,7 +98,6 @@ U32 LLVertexBuffer::sCurVAOName = 1;
U32 LLVertexBuffer::sAllocatedIndexBytes = 0;
U32 LLVertexBuffer::sIndexCount = 0;
-LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL;
U32 LLVertexBuffer::sBindCount = 0;
U32 LLVertexBuffer::sSetCount = 0;
S32 LLVertexBuffer::sCount = 0;
@@ -191,6 +190,10 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
if (mUsage != GL_DYNAMIC_COPY_ARB)
{ //data will be provided by application
ret = (U8*) ll_aligned_malloc<64>(size);
+ if (!ret)
+ {
+ LL_ERRS() << "Failed to allocate for LLVBOPool buffer" << LL_ENDL;
+ }
}
}
else
@@ -859,11 +862,6 @@ void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
{
sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject;
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping;
-
- if (!sPrivatePoolp)
- {
- sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC);
- }
}
//static
@@ -906,12 +904,6 @@ void LLVertexBuffer::cleanupClass()
sStreamVBOPool.cleanup();
sDynamicVBOPool.cleanup();
sDynamicCopyVBOPool.cleanup();
-
- if(sPrivatePoolp)
- {
- LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp);
- sPrivatePoolp = NULL;
- }
}
//----------------------------------------------------------------------------
@@ -1202,7 +1194,7 @@ bool LLVertexBuffer::createGLBuffer(U32 size)
{
static int gl_buffer_idx = 0;
mGLBuffer = ++gl_buffer_idx;
- mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
+ mMappedData = (U8*)ll_aligned_malloc_16(size);
disclaimMem(mSize);
mSize = size;
claimMem(mSize);
@@ -1244,7 +1236,7 @@ bool LLVertexBuffer::createGLIndices(U32 size)
}
else
{
- mMappedIndexData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
+ mMappedIndexData = (U8*)ll_aligned_malloc_16(size);
static int gl_buffer_idx = 0;
mGLIndices = ++gl_buffer_idx;
mIndicesSize = size;
@@ -1267,7 +1259,7 @@ void LLVertexBuffer::destroyGLBuffer()
}
else
{
- FREE_MEM(sPrivatePoolp, (void*) mMappedData);
+ ll_aligned_free_16((void*)mMappedData);
mMappedData = NULL;
mEmpty = true;
}
@@ -1287,7 +1279,7 @@ void LLVertexBuffer::destroyGLIndices()
}
else
{
- FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData);
+ ll_aligned_free_16((void*)mMappedIndexData);
mMappedIndexData = NULL;
mEmpty = true;
}