Minor fixes for distance field fonts:
- Remove additional transform in drawpostext()
- Use bitmap fonts if rasterizer set in paint
- Correctly set scale ratio for drawtext()

R=bsalomon@google.com

Author: jvanverth@google.com

Review URL: https://codereview.chromium.org/79283004

git-svn-id: http://skia.googlecode.com/svn/trunk/src@12338 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkDraw.cpp b/core/SkDraw.cpp
index aa91df3..0288dee 100644
--- a/core/SkDraw.cpp
+++ b/core/SkDraw.cpp
@@ -2012,7 +2012,7 @@
         paintRef = &paintCopy;
     }
     if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) {
-        ctm = NULL;
+        ctm = &SkMatrix::I();
     }
     SkAutoGlyphCache    autoCache(*paintRef, &fDevice->fLeakyProperties, ctm);
 #else
@@ -2036,7 +2036,11 @@
     AlignProc          alignProc = pick_align_proc(paint.getTextAlign());
     SkDraw1Glyph       d1g;
     SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint);
+#if SK_DISTANCEFIELD_FONTS
+    TextMapState       tms(*ctm, constY);
+#else
     TextMapState       tms(*fMatrix, constY);
+#endif
     TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition);
 
     if (cache->isSubpixel()) {
diff --git a/gpu/GrBitmapTextContext.cpp b/gpu/GrBitmapTextContext.cpp
index 433eda1..8d955bb 100755
--- a/gpu/GrBitmapTextContext.cpp
+++ b/gpu/GrBitmapTextContext.cpp
@@ -124,7 +124,7 @@
     }
     if (NULL == fStrike) {
 #if SK_DISTANCEFIELD_FONTS
-        fStrike = fContext->getFontCache()->getStrike(scaler, true);
+        fStrike = fContext->getFontCache()->getStrike(scaler, false);
 #else
         fStrike = fContext->getFontCache()->getStrike(scaler);
 #endif
diff --git a/gpu/SkGpuDevice.cpp b/gpu/SkGpuDevice.cpp
index afdc7e9..063509a 100644
--- a/gpu/SkGpuDevice.cpp
+++ b/gpu/SkGpuDevice.cpp
@@ -1699,8 +1699,6 @@
         fDrawProcs->fContext = fContext;
 #if SK_DISTANCEFIELD_FONTS
         fDrawProcs->fFlags = 0;
-        fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag;
-        fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag;
 #endif
     }
 
@@ -1726,13 +1724,22 @@
             return;
         }
 #if SK_DISTANCEFIELD_FONTS
-        GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
-                                           paint.getTextSize());
-#else
-        GrBitmapTextContext context(fContext, grPaint, paint.getColor());
+        if (paint.getRasterizer()) {
 #endif
-        myDraw.fProcs = this->initDrawForText(&context);
-        this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint);
+            GrBitmapTextContext context(fContext, grPaint, paint.getColor());
+            myDraw.fProcs = this->initDrawForText(&context);
+            this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint);
+#if SK_DISTANCEFIELD_FONTS
+        } else {
+            GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
+                                               paint.getTextSize()/SkDrawProcs::kBaseDFFontSize);
+            myDraw.fProcs = this->initDrawForText(&context);
+            fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag;
+            fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag;
+            this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint);
+            fDrawProcs->fFlags = 0;
+       }
+#endif
     }
 }
 
@@ -1754,14 +1761,24 @@
             return;
         }
 #if SK_DISTANCEFIELD_FONTS
-        GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
-                                           paint.getTextSize()/SkDrawProcs::kBaseDFFontSize);
-#else
-        GrBitmapTextContext context(fContext, grPaint, paint.getColor());
+        if (paint.getRasterizer()) {
 #endif
-        myDraw.fProcs = this->initDrawForText(&context);
-        this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY,
-                                     scalarsPerPos, paint);
+            GrBitmapTextContext context(fContext, grPaint, paint.getColor());
+            myDraw.fProcs = this->initDrawForText(&context);
+            this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY,
+                                         scalarsPerPos, paint);
+#if SK_DISTANCEFIELD_FONTS
+        } else {
+            GrDistanceFieldTextContext context(fContext, grPaint, paint.getColor(),
+                                               paint.getTextSize()/SkDrawProcs::kBaseDFFontSize);
+            myDraw.fProcs = this->initDrawForText(&context);
+            fDrawProcs->fFlags |= SkDrawProcs::kSkipBakedGlyphTransform_Flag;
+            fDrawProcs->fFlags |= SkDrawProcs::kUseScaledGlyphs_Flag;
+            this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY,
+                                         scalarsPerPos, paint);
+            fDrawProcs->fFlags = 0;
+        }
+#endif
     }
 }