Revert of Use uint16s for texture coordinates when rendering text. (patchset #5 id:80001 of https://codereview.chromium.org/917373002/)

Reason for revert:
speculative revert for DEPS failures

https://codereview.chromium.org/932973002/

Original issue's description:
> Use uint16s for texture coordinates when rendering text.
>
> Allows us to push more vertices into a given vertex buffer, with
> a slight performance improvement.
>
> Committed: https://skia.googlesource.com/skia/+/059034d252007d0dd86fff5ffdbb53cbcb10d34b

TBR=joshualitt@google.com,robertphillips@google.com,bsalomon@google.com,reed@google.com,djsollen@google.com,jvanverth@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/920333003
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 21afc61..5e5aa6a 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -34,12 +34,12 @@
                 "Dump the contents of the font cache before every purge.");
 
 namespace {
-static const size_t kLCDTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
+static const size_t kLCDTextVASize = 2 * sizeof(SkPoint);
 
 // position + local coord
-static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
+static const size_t kColorTextVASize = 2 * sizeof(SkPoint);
 
-static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16);
+static const size_t kGrayTextVASize = 2 * sizeof(SkPoint) + sizeof(GrColor);
 
 static const int kVerticesPerGlyph = 4;
 static const int kIndicesPerGlyph = 6;
@@ -421,8 +421,8 @@
     vy += SkIntToFixed(glyph->fBounds.fTop);
 
     // keep them as ints until we've done the clip-test
-    int width = glyph->fBounds.width();
-    int height = glyph->fBounds.height();
+    SkFixed width = glyph->fBounds.width();
+    SkFixed height = glyph->fBounds.height();
 
     // check if we clipped out
     int x = vx >> 16;
@@ -463,6 +463,10 @@
     GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
     glyph->fPlot->setDrawToken(drawToken);
 
+    // now promote them to fixed (TODO: Rethink using fixed pt).
+    width = SkIntToFixed(width);
+    height = SkIntToFixed(height);
+
     // the current texture/maskformat must match what the glyph needs
     GrTexture* texture = glyph->fPlot->texture();
     SkASSERT(texture);
@@ -480,66 +484,39 @@
         fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, fCurrMaskFormat);
     }
 
+    SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX);
+    SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY);
+
     SkRect r;
     r.fLeft = SkFixedToFloat(vx);
     r.fTop = SkFixedToFloat(vy);
-    r.fRight = r.fLeft + width;
-    r.fBottom = r.fTop + height;
+    r.fRight = SkFixedToFloat(vx + width);
+    r.fBottom = SkFixedToFloat(vy + height);
 
     fVertexBounds.joinNonEmptyArg(r);
-    
-    int u0 = glyph->fAtlasLocation.fX;
-    int v0 = glyph->fAtlasLocation.fY;
-    int u1 = u0 + width;
-    int v1 = v0 + height;
 
     size_t vertSize = get_vertex_stride(fCurrMaskFormat);
-    intptr_t vertex = reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex;
 
-    // V0
-    SkPoint* position = reinterpret_cast<SkPoint*>(vertex);
-    position->set(r.fLeft, r.fTop);
-    if (kA8_GrMaskFormat == fCurrMaskFormat) {
-        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
-        *color = fPaint.getColor();
-    }
-    SkIPoint16* textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize -
-                                                              sizeof(SkIPoint16));
-    textureCoords->set(u0, v0);
-    vertex += vertSize;
-    
-    // V1
-    position = reinterpret_cast<SkPoint*>(vertex);
-    position->set(r.fLeft, r.fBottom);
-    if (kA8_GrMaskFormat == fCurrMaskFormat) {
-        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
-        *color = fPaint.getColor();
-    }
-    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
-    textureCoords->set(u0, v1);
-    vertex += vertSize;
-    
-    // V2
-    position = reinterpret_cast<SkPoint*>(vertex);
-    position->set(r.fRight, r.fBottom);
-    if (kA8_GrMaskFormat == fCurrMaskFormat) {
-        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
-        *color = fPaint.getColor();
-    }
-    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
-    textureCoords->set(u1, v1);
-    vertex += vertSize;
-    
-    // V3
-    position = reinterpret_cast<SkPoint*>(vertex);
-    position->set(r.fRight, r.fTop);
-    if (kA8_GrMaskFormat == fCurrMaskFormat) {
-        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
-        *color = fPaint.getColor();
-    }
-    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
-    textureCoords->set(u1, v0);
+    SkPoint* positions = reinterpret_cast<SkPoint*>(
+        reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
+    positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
 
+    // The texture coords are last in both the with and without color vertex layouts.
+    SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
+            reinterpret_cast<intptr_t>(positions) + vertSize  - sizeof(SkPoint));
+    textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
+                              SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
+                              SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + width)),
+                              SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + height)),
+                              vertSize);
+    if (kA8_GrMaskFormat == fCurrMaskFormat) {
+        // color comes after position.
+        GrColor* colors = reinterpret_cast<GrColor*>(positions + 1);
+        for (int i = 0; i < 4; ++i) {
+           *colors = fPaint.getColor();
+           colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors) + vertSize);
+        }
+    }
     fCurrVertex += 4;
 }