Detect when the caller was hairline AND strokeandfill, and resolve that into FILL
This fixes the unittests on WIN in the trybot for DEPS roll 4048
Review URL: https://codereview.appspot.com/6242057

git-svn-id: http://skia.googlecode.com/svn/trunk@4057 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index f1bbd7c..8a129fe 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -46,14 +46,16 @@
     bool isFillStyle() const {
         return kFill_Style == this->getStyle();
     }
-    
-    void setFillStyle();
-    void setHairlineStyle() { fWidth = 0; }
 
-    void setStrokeStyle(SkScalar width, bool strokeAndFill = false) {
-        fWidth = width;
-        fStrokeAndFill = strokeAndFill;
-    }
+    void setFillStyle();
+    void setHairlineStyle();
+    /**
+     *  Specify the strokewidth, and optionally if you want stroke + fill.
+     *  Note, if width==0, then this request is taken to mean:
+     *      strokeAndFill==true -> new style will be Fill
+     *      strokeAndFill==false -> new style will be Hairline
+     */
+    void setStrokeStyle(SkScalar width, bool strokeAndFill = false);
 
     void setStrokeParams(SkPaint::Cap cap, SkPaint::Join join, SkScalar miterLimit) {
         fCap = cap;
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 48d165a..6b95d9b 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -38,8 +38,14 @@
             fStrokeAndFill = false;
             break;
         case SkPaint::kStrokeAndFill_Style:
-            fWidth = paint.getStrokeWidth();
-            fStrokeAndFill = true;
+            if (0 == paint.getStrokeWidth()) {
+                // hairline+fill == fill
+                fWidth = kStrokeRec_FillStyleWidth;
+                fStrokeAndFill = false;
+            } else {
+                fWidth = paint.getStrokeWidth();
+                fStrokeAndFill = true;
+            }
             break;
         default:
             SkASSERT(!"unknown paint style");
@@ -67,6 +73,22 @@
 
 void SkStrokeRec::setFillStyle() {
     fWidth = kStrokeRec_FillStyleWidth;
+    fStrokeAndFill = false;
+}
+
+void SkStrokeRec::setHairlineStyle() {
+    fWidth = 0;
+    fStrokeAndFill = false;
+}
+
+void SkStrokeRec::setStrokeStyle(SkScalar width, bool strokeAndFill) {
+    if (strokeAndFill && (0 == width)) {
+        // hairline+fill == fill
+        this->setFillStyle();
+    } else {
+        fWidth = width;
+        fStrokeAndFill = strokeAndFill;
+    }
 }
 
 #include "SkStroke.h"
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index ff4db0b..fae2d4b 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -10,11 +10,32 @@
 #include "SkPath.h"
 #include "SkParse.h"
 #include "SkParsePath.h"
+#include "SkPathEffect.h"
 #include "SkRandom.h"
 #include "SkReader32.h"
 #include "SkSize.h"
 #include "SkWriter32.h"
 
+static void test_strokerec(skiatest::Reporter* reporter) {
+    SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
+    REPORTER_ASSERT(reporter, rec.isFillStyle());
+    
+    rec.setHairlineStyle();
+    REPORTER_ASSERT(reporter, rec.isHairlineStyle());
+    
+    rec.setStrokeStyle(SK_Scalar1, false);
+    REPORTER_ASSERT(reporter, SkStrokeRec::kStroke_Style == rec.getStyle());
+    
+    rec.setStrokeStyle(SK_Scalar1, true);
+    REPORTER_ASSERT(reporter, SkStrokeRec::kStrokeAndFill_Style == rec.getStyle());
+    
+    rec.setStrokeStyle(0, false);
+    REPORTER_ASSERT(reporter, SkStrokeRec::kHairline_Style == rec.getStyle());
+    
+    rec.setStrokeStyle(0, true);
+    REPORTER_ASSERT(reporter, SkStrokeRec::kFill_Style == rec.getStyle());
+}
+
 /**
  * cheapIsDirection can take a shortcut when a path is marked convex.
  * This function ensures that we always test cheapIsDirection when the path
@@ -1377,6 +1398,8 @@
     test_raw_iter(reporter);
     test_circle(reporter);
     test_oval(reporter);
+    
+    test_strokerec(reporter);
 }
 
 #include "TestClassDef.h"