Convert drawText to using the find and place code.
BUG=skia:

Review URL: https://codereview.chromium.org/1448453002
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index f800465..37fe092 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -487,7 +487,7 @@
                                             const SkTextBlob* blob, SkScalar x, SkScalar y,
                                             SkDrawFilter* drawFilter, const SkIRect& clipRect,
                                             GrRenderTarget* rt, const GrClip& clip) {
-    // The color here is the GrPaint color, and it is used to determine whether we 
+    // The color here is the GrPaint color, and it is used to determine whether we
     // have to regenerate LCD text blobs.
     // We use this color vs the SkPaint color because it has the colorfilter applied.
     cacheBlob->fPaintColor = color;
@@ -686,8 +686,8 @@
 }
 
 inline GrAtlasTextBlob*
-GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, 
-                                const SkMatrix& viewMatrix, SkPaint* dfPaint, 
+GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
+                                const SkMatrix& viewMatrix, SkPaint* dfPaint,
                                 SkScalar* textRatio) {
     GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
 
@@ -725,7 +725,7 @@
                                  byteLength, x, y, clipRect, textRatio, &fallbackTxt, &fallbackPos,
                                  &offset, skPaint);
         if (fallbackTxt.count()) {
-            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix, 
+            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
                                       fallbackTxt, fallbackPos, 2, offset, clipRect);
         }
     } else {
@@ -764,8 +764,8 @@
                                     byteLength, pos, scalarsPerPosition, offset, clipRect,
                                     textRatio, &fallbackTxt, &fallbackPos);
         if (fallbackTxt.count()) {
-            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix, 
-                                      fallbackTxt, fallbackPos, scalarsPerPosition, offset, 
+            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
+                                      fallbackTxt, fallbackPos, scalarsPerPosition, offset,
                                       clipRect);
         }
     } else {
@@ -780,7 +780,7 @@
 }
 
 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
-                                    const GrClip& clip, 
+                                    const GrClip& clip,
                                     const GrPaint& paint, const SkPaint& skPaint,
                                     const SkMatrix& viewMatrix,
                                     const char text[], size_t byteLength,
@@ -826,73 +826,16 @@
     // Get GrFontScaler from cache
     GrFontScaler* fontScaler = GetGrFontScaler(cache);
 
-    // transform our starting point
-    {
-        SkPoint loc;
-        viewMatrix.mapXY(x, y, &loc);
-        x = loc.fX;
-        y = loc.fY;
-    }
-
-    // need to measure first
-    if (skPaint.getTextAlign() != SkPaint::kLeft_Align) {
-        SkVector    stopVector;
-        MeasureText(cache, glyphCacheProc, text, byteLength, &stopVector);
-
-        SkScalar    stopX = stopVector.fX;
-        SkScalar    stopY = stopVector.fY;
-
-        if (skPaint.getTextAlign() == SkPaint::kCenter_Align) {
-            stopX = SkScalarHalf(stopX);
-            stopY = SkScalarHalf(stopY);
+    SkFindAndPlaceGlyph::ProcessText(
+        text, byteLength, {x, y}, viewMatrix, skPaint.getTextAlign(), glyphCacheProc, cache,
+        [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
+            position += rounding;
+            this->bmpAppendGlyph(
+                blob, runIndex, glyph,
+                SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY),
+                color, fontScaler, clipRect);
         }
-        x -= stopX;
-        y -= stopY;
-    }
-
-    const char* stop = text + byteLength;
-
-    SkAutoKern autokern;
-
-    SkFixed fxMask = ~0;
-    SkFixed fyMask = ~0;
-    SkScalar halfSampleX, halfSampleY;
-    if (cache->isSubpixel()) {
-        halfSampleX = halfSampleY = SkFixedToScalar(SkGlyph::kSubpixelRound);
-        SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix);
-        if (kX_SkAxisAlignment == baseline) {
-            fyMask = 0;
-            halfSampleY = SK_ScalarHalf;
-        } else if (kY_SkAxisAlignment == baseline) {
-            fxMask = 0;
-            halfSampleX = SK_ScalarHalf;
-        }
-    } else {
-        halfSampleX = halfSampleY = SK_ScalarHalf;
-    }
-
-    Sk48Dot16 fx = SkScalarTo48Dot16(x + halfSampleX);
-    Sk48Dot16 fy = SkScalarTo48Dot16(y + halfSampleY);
-
-    while (text < stop) {
-        const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask);
-
-        fx += autokern.adjust(glyph);
-
-        if (glyph.fWidth) {
-            this->bmpAppendGlyph(blob,
-                                 runIndex,
-                                 glyph,
-                                 Sk48Dot16FloorToInt(fx),
-                                 Sk48Dot16FloorToInt(fy),
-                                 color,
-                                 fontScaler,
-                                 clipRect);
-        }
-
-        fx += glyph.fAdvanceX;
-        fy += glyph.fAdvanceY;
-    }
+    );
 }
 
 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIndex,
@@ -949,7 +892,7 @@
     SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc();
     SkAutoDescriptor desc;
     origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, nullptr, true);
-    SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypeface(), 
+    SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypeface(),
                                                              desc.getDesc());
 
     SkTArray<SkScalar> positions;
@@ -1932,7 +1875,7 @@
 };
 
 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
-                                         const SkTextBlobRunIterator& it, 
+                                         const SkTextBlobRunIterator& it,
                                          const GrClip& clip, const SkPaint& skPaint,
                                          SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
                                          const SkIRect& clipBounds, SkScalar x, SkScalar y) {
@@ -2029,7 +1972,7 @@
     }
 }
 
-inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob, 
+inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob,
                                                GrDrawContext* dc, GrRenderTarget* rt,
                                                const GrClip& clip, const SkPaint& skPaint,
                                                SkScalar transX, SkScalar transY,
@@ -2056,7 +1999,7 @@
 
 void GrAtlasTextContext::flush(const SkTextBlob* blob,
                                GrAtlasTextBlob* cacheBlob,
-                               GrDrawContext* dc, 
+                               GrDrawContext* dc,
                                GrRenderTarget* rt,
                                const SkPaint& skPaint,
                                const GrPaint& grPaint,