diff options
| author | Yang Ni <yangni@google.com> | 2015-02-14 18:00:59 -0800 |
|---|---|---|
| committer | Yang Ni <yangni@google.com> | 2015-02-15 20:10:40 +0000 |
| commit | b8353c5943f4038fd7f08db3d958390ce9418798 (patch) | |
| tree | 2cfac49d1f790e077f40dfc7ba42904ee5658f50 /rsFont.cpp | |
| parent | 1ce0dfd82311d4922dbffdde302599410fc25c5d (diff) | |
| download | android_frameworks_rs-b8353c5943f4038fd7f08db3d958390ce9418798.tar.gz android_frameworks_rs-b8353c5943f4038fd7f08db3d958390ce9418798.tar.bz2 android_frameworks_rs-b8353c5943f4038fd7f08db3d958390ce9418798.zip | |
Revert "Replaced android::Vector with std::vector."
b/19148482
This reverts commit 93d6bc872b7d9fba63abfa7513d56b38d9c3d371.
I also made some changes to Make it work with HEAD.
Change-Id: I5e516976ec1d85ffe1cf388c01795348a9441982
Diffstat (limited to 'rsFont.cpp')
| -rw-r--r-- | rsFont.cpp | 69 |
1 files changed, 27 insertions, 42 deletions
@@ -33,7 +33,7 @@ using namespace android; using namespace android::renderscript; -Font::Font(Context *rsc) : ObjectBase(rsc) { +Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL) { mInitialized = false; mHasKerning = false; mFace = nullptr; @@ -76,21 +76,17 @@ bool Font::init(const char *name, float fontSize, uint32_t dpi, const void *data } void Font::preDestroy() const { - auto &activeFonts = mRSC->mStateFont.mActiveFonts; - - for (auto font = activeFonts.begin(), end = activeFonts.end(); font != end; - font++) { - - if (this == *font) { - activeFonts.erase(font); - return; + for (uint32_t ct = 0; ct < mRSC->mStateFont.mActiveFonts.size(); ct++) { + if (mRSC->mStateFont.mActiveFonts[ct] == this) { + mRSC->mStateFont.mActiveFonts.removeAt(ct); + break; } } } void Font::invalidateTextureCache() { for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) { - mCachedGlyphs[i]->mIsValid = false; + mCachedGlyphs.valueAt(i)->mIsValid = false; } } @@ -228,7 +224,7 @@ void Font::renderUTF(const char *text, uint32_t len, int32_t x, int32_t y, Font::CachedGlyphInfo* Font::getCachedUTFChar(int32_t utfChar) { - CachedGlyphInfo *cachedGlyph = mCachedGlyphs[(uint32_t)utfChar]; + CachedGlyphInfo *cachedGlyph = mCachedGlyphs.valueFor((uint32_t)utfChar); if (cachedGlyph == nullptr) { cachedGlyph = cacheGlyph((uint32_t)utfChar); } @@ -287,7 +283,7 @@ void Font::updateGlyphCache(CachedGlyphInfo *glyph) { Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph) { CachedGlyphInfo *newGlyph = new CachedGlyphInfo(); - mCachedGlyphs[glyph] = newGlyph; + mCachedGlyphs.add(glyph, newGlyph); #ifndef ANDROID_RS_SERIALIZE newGlyph->mGlyphIndex = FT_Get_Char_Index(mFace, glyph); newGlyph->mIsValid = false; @@ -300,14 +296,11 @@ Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph) { Font * Font::create(Context *rsc, const char *name, float fontSize, uint32_t dpi, const void *data, uint32_t dataLen) { rsc->mStateFont.checkInit(); - std::vector<Font*> &activeFonts = rsc->mStateFont.mActiveFonts; + Vector<Font*> &activeFonts = rsc->mStateFont.mActiveFonts; for (uint32_t i = 0; i < activeFonts.size(); i ++) { Font *ithFont = activeFonts[i]; - if (ithFont->mFontName == name && - ithFont->mFontSize == fontSize && - ithFont->mDpi == dpi) { - + if (ithFont->mFontName == name && ithFont->mFontSize == fontSize && ithFont->mDpi == dpi) { return ithFont; } } @@ -315,7 +308,7 @@ Font * Font::create(Context *rsc, const char *name, float fontSize, uint32_t dpi Font *newFont = new Font(rsc); bool isInitialized = newFont->init(name, fontSize, dpi, data, dataLen); if (isInitialized) { - activeFonts.push_back(newFont); + activeFonts.push(newFont); rsc->mStateFont.precacheLatin(newFont); return newFont; } @@ -332,7 +325,7 @@ Font::~Font() { #endif for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) { - CachedGlyphInfo *glyph = mCachedGlyphs[i]; + CachedGlyphInfo *glyph = mCachedGlyphs.valueAt(i); delete glyph; } } @@ -561,33 +554,25 @@ void FontState::initTextTexture() { mCacheBuffer = new uint8_t[mCacheWidth * mCacheHeight]; - Allocation *cacheAlloc = - Allocation::createAllocation(mRSC, texType.get(), - RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE); + Allocation *cacheAlloc = Allocation::createAllocation(mRSC, texType.get(), + RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE); mTextTexture.set(cacheAlloc); // Split up our cache texture into lines of certain widths int32_t nextLine = 0; - mCacheLines.push_back(new CacheTextureLine(16, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(24, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(24, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(32, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(32, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(40, texType->getDimX(), - nextLine, 0)); - nextLine += mCacheLines.back()->mMaxHeight; - mCacheLines.push_back(new CacheTextureLine(texType->getDimY() - nextLine, - texType->getDimX(), nextLine, 0)); + mCacheLines.push(new CacheTextureLine(16, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(40, texType->getDimX(), nextLine, 0)); + nextLine += mCacheLines.top()->mMaxHeight; + mCacheLines.push(new CacheTextureLine(texType->getDimY() - nextLine, texType->getDimX(), nextLine, 0)); } // Avoid having to reallocate memory and render quad by quad |
