Apply hairline optimization only if the path renderer wants it

Make the decision to convert thin, non-hairline paths to hairline
paths at the renderer level.

The current nv_path_rendering implementation does not render
hairlines. Rendering the hairlines with normal renderers cause
unneccessary gl program changes, which is quite slow.

Changes the behavior of non-nv_path_rendering paths to always perform
the optimization if the shape ends up being painted by a renderer that
wants the optimization. Previously the optimization was applied only
when callgraph started with SkCanvas::drawPath.

Applies the optimization for GrAAHairLineRenderer and
GrDefaultPathRenderer.

This changes gm results for dashing3_{msaa4,gpu} and drawlooper_msaa4.

R=bsalomon@google.com, jvanverth@google.com, rmistry@google.com

Author: kkinnunen@nvidia.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@12357 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkDrawProcs.h b/src/core/SkDrawProcs.h
index cc2f3ed..6911e5b 100644
--- a/src/core/SkDrawProcs.h
+++ b/src/core/SkDrawProcs.h
@@ -75,12 +75,32 @@
 #endif
 };
 
+bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
+                                   SkScalar* coverage);
+
 /**
  *  If the current paint is set to stroke and the stroke-width when applied to
  *  the matrix is <= 1.0, then this returns true, and sets coverage (simulating
  *  a stroke by drawing a hairline with partial coverage). If any of these
  *  conditions are false, then this returns false and coverage is ignored.
  */
-bool SkDrawTreatAsHairline(const SkPaint&, const SkMatrix&, SkScalar* coverage);
+inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix,
+                                  SkScalar* coverage) {
+    if (SkPaint::kStroke_Style != paint.getStyle()) {
+        return false;
+    }
+
+    SkScalar strokeWidth = paint.getStrokeWidth();
+    if (0 == strokeWidth) {
+        *coverage = SK_Scalar1;
+        return true;
+    }
+
+    if (!paint.isAntiAlias()) {
+        return false;
+    }
+
+    return SkDrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage);
+}
 
 #endif