GPU Font Cache improvements:
- If a strike has multiple atlases, check all for room for a new glyph
- Mark remaining atlases unused after a purge, then check for an unused
atlas before purging (reduces TextContext flushes and ghosting)
- Hide Atlas management a little better inside AtlasMgr

R=robertphillips@google.com, bsalomon@google.com

Author: jvanverth@google.com

Review URL: https://chromiumcodereview.appspot.com/21594005

git-svn-id: http://skia.googlecode.com/svn/trunk@10544 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index 5af0851..8f0f1cf 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -153,6 +153,12 @@
             goto HAS_ATLAS;
         }
 
+        // try to clear out an unused atlas before we flush
+        fContext->getFontCache()->freeAtlasExceptFor(fStrike);
+        if (fStrike->getGlyphAtlas(glyph, scaler)) {
+            goto HAS_ATLAS;
+        }
+
         // before we purge the cache, we must flush any accumulated draws
         this->flushGlyphs();
         fContext->flush();