summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Sakhartchouk <alexst@google.com> 2010-06-30 16:53:43 -0700
committer Alex Sakhartchouk <alexst@google.com> 2010-06-30 16:53:43 -0700
commitb6b34891fa7f76c99f5e9a3096576ada86c99f1e (patch)
tree059ce75251532685d5651d06d47314a3ea62702d
parent81ea83d10883886013bc95eac2fe032acf1e7aa9 (diff)
Fixing freetype init/uninit code.
Removing debug output from stream. Change-Id: I401232e77cc011953e5ccc59069b22ec59958214
-rw-r--r--libs/rs/rsFont.cpp29
-rw-r--r--libs/rs/rsStream.cpp1
2 files changed, 14 insertions, 16 deletions
diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp
index 694ea1654b0d..2a47ca4f9184 100644
--- a/libs/rs/rsFont.cpp
+++ b/libs/rs/rsFont.cpp
@@ -39,6 +39,7 @@ Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL)
mAllocLine = __LINE__;
mInitialized = false;
mHasKerning = false;
+ mFace = NULL;
}
bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
@@ -63,8 +64,6 @@ bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
mFontSize = fontSize;
mDpi = dpi;
- //LOGE("Font initialized: %s", fullPath.string());
-
error = FT_Set_Char_Size(mFace, fontSize * 64, 0, dpi, 0);
if(error) {
LOGE("Unable to set font size on %s", fullPath.string());
@@ -206,8 +205,6 @@ Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph)
newGlyph->mGlyphIndex = FT_Get_Char_Index(mFace, glyph);
newGlyph->mIsValid = false;
- //LOGE("Glyph = %c, face index: %u", (unsigned char)glyph, newGlyph->mGlyphIndex);
-
updateGlyphCache(newGlyph);
return newGlyph;
@@ -261,6 +258,7 @@ FontState::FontState()
mMaxNumberOfQuads = 1024;
mCurrentQuadIndex = 0;
mRSC = NULL;
+ mLibrary = NULL;
}
FontState::~FontState()
@@ -281,13 +279,12 @@ FT_Library FontState::getLib()
return NULL;
}
}
+
return mLibrary;
}
void FontState::init(Context *rsc)
{
- //getLib();
-
mRSC = rsc;
}
@@ -350,8 +347,6 @@ bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *r
uint32_t endX = startX + bitmap->width;
uint32_t endY = startY + bitmap->rows;
- //LOGE("Bitmap width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
-
uint32_t cacheWidth = getCacheTextureType()->getDimX();
unsigned char *cacheBuffer = (unsigned char*)mTextTexture->getPtr();
@@ -508,13 +503,6 @@ void FontState::checkInit()
initVertexArrayBuffers();
- /*mTextMeshRefs = new ObjectBaseRef<SimpleMesh>[mNumMeshes];
-
- for(uint32_t i = 0; i < mNumMeshes; i ++){
- SimpleMesh *textMesh = createTextMesh();
- mTextMeshRefs[i].set(textMesh);
- }*/
-
mInitialized = true;
}
@@ -626,6 +614,11 @@ void FontState::renderText(const char *text, uint32_t len, uint32_t startIndex,
}
currentFont = mDefault.get();
}
+ if(!currentFont) {
+ LOGE("Unable to initialize any fonts");
+ return;
+ }
+
currentFont->renderUTF(text, len, startIndex, numGlyphs, x, y);
if(mCurrentQuadIndex != 0) {
@@ -681,8 +674,14 @@ void FontState::deinit(Context *rsc)
mDefault.clear();
+ Vector<Font*> fontsToDereference = mActiveFonts;
+ for(uint32_t i = 0; i < fontsToDereference.size(); i ++) {
+ fontsToDereference[i]->zeroUserRef();
+ }
+
if(mLibrary) {
FT_Done_FreeType( mLibrary );
+ mLibrary = NULL;
}
}
diff --git a/libs/rs/rsStream.cpp b/libs/rs/rsStream.cpp
index 39874a9b25dc..68241fa4cbe6 100644
--- a/libs/rs/rsStream.cpp
+++ b/libs/rs/rsStream.cpp
@@ -55,7 +55,6 @@ void IStream::loadString(String8 *s)
{
uint32_t len = loadU32();
s->setTo((const char *)&mData[mPos], len);
- LOGE("loadString %s", s->string());
mPos += len;
}