Add flag for SkGpuSurface creation to enable distance fields.

BUG=skia:2173
R=bsalomon@google.com, reed@google.com, bungeman@google.com

Author: jvanverth@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14525 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 238bcca..512420e 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -33,15 +33,15 @@
 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
                 "Dump the contents of the font cache before every purge.");
 
-#if SK_FORCE_DISTANCEFIELD_FONTS
-static const bool kForceDistanceFieldFonts = true;
-#else
-static const bool kForceDistanceFieldFonts = false;
-#endif
-
 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
-                                                       const SkDeviceProperties& properties)
+                                                       const SkDeviceProperties& properties,
+                                                       bool enable)
                                                     : GrTextContext(context, properties) {
+#if SK_FORCE_DISTANCEFIELD_FONTS
+    fEnableDFRendering = true;
+#else
+    fEnableDFRendering = enable;
+#endif
     fStrike = NULL;
 
     fCurrTexture = NULL;
@@ -56,7 +56,7 @@
 }
 
 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
-    if (!kForceDistanceFieldFonts && !paint.isDistanceFieldTextTEMP()) {
+    if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) {
         return false;
     }
 
diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h
index 58c0824..3dfffd1 100644
--- a/src/gpu/GrDistanceFieldTextContext.h
+++ b/src/gpu/GrDistanceFieldTextContext.h
@@ -17,7 +17,7 @@
  */
 class GrDistanceFieldTextContext : public GrTextContext {
 public:
-    GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&);
+    GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&, bool enable);
     virtual ~GrDistanceFieldTextContext();
 
     virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
@@ -33,6 +33,7 @@
     GrTextStrike*           fStrike;
     SkScalar                fTextRatio;
     bool                    fUseLCDText;
+    bool                    fEnableDFRendering;
 
     void init(const GrPaint&, const SkPaint&);
     void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 60b4e7c..714a6da 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -190,7 +190,9 @@
     fContext = context;
     fContext->ref();
 
-    fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyProperties));
+    bool useDFFonts = !!(flags & kDFFonts_Flag);
+    fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyProperties,
+                                                               useDFFonts));
     fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties));
 
     fRenderTarget = NULL;