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
diff --git a/rsFont.cpp b/rsFont.cpp
index 8f39ca9..8b38fde 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -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 @@
 }
 
 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 @@
 
 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 @@
 
 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 * 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 *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 @@
 #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 @@
     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