Revert of Change drawText() to generate positions and send to drawPosText() (patchset #4 id:60001 of https://codereview.chromium.org/653133004/)

Reason for revert:
A large number of GMs on Ubuntu12 are failing. The text layout on GPU is visibly different than that for 8888.

Original issue's description:
> Change drawText() to generate positions and send to drawPosText()
>
> The idea here is to have a central place that does layout for drawText(), and
> then always feed text through drawPosText(). This both makes all of the
> GrTextContexts consistent in drawText() output, and does a better job of
> stressing drawPosText().
>
> Because of the effect of matrices on hinting and approximation error, the
> generated text is not 100% identical to that produced by the raster pipeline.
>
> BUG=skia:2778
>
> Committed: https://skia.googlesource.com/skia/+/7851a56895c9c076f73a835a7dd51d3c6180c16f

TBR=cdalton.nvidia@gmail.com,bungeman@google.com,reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2778

Review URL: https://codereview.chromium.org/659993003
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index 9b4c4d7..b53ff79 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -11,6 +11,7 @@
 #include "GrGpu.h"
 #include "GrPath.h"
 #include "GrPathRange.h"
+#include "SkAutoKern.h"
 #include "SkDraw.h"
 #include "SkDrawProcs.h"
 #include "SkGlyphCache.h"
@@ -61,6 +62,96 @@
     return rec.getFormat() != SkMask::kARGB32_Format;
 }
 
+void GrStencilAndCoverTextContext::onDrawText(const GrPaint& paint,
+                                            const SkPaint& skPaint,
+                                            const char text[],
+                                            size_t byteLength,
+                                            SkScalar x, SkScalar y) {
+    SkASSERT(byteLength == 0 || text != NULL);
+
+    if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
+        return;
+    }
+
+    // This is the slow path, mainly used by Skia unit tests.  The other
+    // backends (8888, gpu, ...) use device-space dependent glyph caches. In
+    // order to match the glyph positions that the other code paths produce, we
+    // must also use device-space dependent glyph cache. This has the
+    // side-effect that the glyph shape outline will be in device-space,
+    // too. This in turn has the side-effect that NVPR can not stroke the paths,
+    // as the stroke in NVPR is defined in object-space.
+    // NOTE: here we have following coincidence that works at the moment:
+    // - When using the device-space glyphs, the transforms we pass to NVPR
+    // instanced drawing are the global transforms, and the view transform is
+    // identity. NVPR can not use non-affine transforms in the instanced
+    // drawing. This is taken care of by SkDraw::ShouldDrawTextAsPaths since it
+    // will turn off the use of device-space glyphs when perspective transforms
+    // are in use.
+
+    this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode, SkPoint::Make(0, 0));
+
+    // Transform our starting point.
+    if (fNeedsDeviceSpaceGlyphs) {
+        SkPoint loc;
+        fContextInitialMatrix.mapXY(x, y, &loc);
+        x = loc.fX;
+        y = loc.fY;
+    }
+
+    SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
+
+    fTransformType = GrPathRendering::kTranslate_PathTransformType;
+
+    const char* stop = text + byteLength;
+
+    // Measure first if needed.
+    if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) {
+        SkFixed    stopX = 0;
+        SkFixed    stopY = 0;
+
+        const char* textPtr = text;
+        while (textPtr < stop) {
+            // We don't need x, y here, since all subpixel variants will have the
+            // same advance.
+            const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &textPtr, 0, 0);
+
+            stopX += glyph.fAdvanceX;
+            stopY += glyph.fAdvanceY;
+        }
+        SkASSERT(textPtr == stop);
+
+        SkScalar alignX = SkFixedToScalar(stopX) * fTextRatio;
+        SkScalar alignY = SkFixedToScalar(stopY) * fTextRatio;
+
+        if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) {
+            alignX = SkScalarHalf(alignX);
+            alignY = SkScalarHalf(alignY);
+        }
+
+        x -= alignX;
+        y -= alignY;
+    }
+
+    SkAutoKern autokern;
+
+    SkFixed fixedSizeRatio = SkScalarToFixed(fTextRatio);
+
+    SkFixed fx = SkScalarToFixed(x);
+    SkFixed fy = SkScalarToFixed(y);
+    while (text < stop) {
+        const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0);
+        fx += SkFixedMul_portable(autokern.adjust(glyph), fixedSizeRatio);
+        if (glyph.fWidth) {
+            this->appendGlyph(glyph.getGlyphID(), SkFixedToScalar(fx), SkFixedToScalar(fy));
+        }
+
+        fx += SkFixedMul_portable(glyph.fAdvanceX, fixedSizeRatio);
+        fy += SkFixedMul_portable(glyph.fAdvanceY, fixedSizeRatio);
+    }
+
+    this->finish();
+}
+
 void GrStencilAndCoverTextContext::onDrawPosText(const GrPaint& paint,
                                                const SkPaint& skPaint,
                                                const char text[],