use direction from isRect in strokeRect, and only stroke if it is closed
Review URL: https://codereview.appspot.com/6846086

git-svn-id: http://skia.googlecode.com/svn/trunk@6528 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index fbf995b..6d3b4fd 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -610,9 +610,10 @@
     // If src is really a rect, call our specialty strokeRect() method
 #ifndef SK_IGNORE_NEW_STROKERECT
     {
-        SkRect rect;
-        if (src.isRect(&rect)) {
-            this->strokeRect(rect, dst);
+        bool isClosed;
+        SkPath::Direction dir;
+        if (src.isRect(&isClosed, &dir) && isClosed) {
+            this->strokeRect(src.getBounds(), dst, dir);
             // our answer should preserve the inverseness of the src
             if (src.isInverseFillType()) {
                 SkASSERT(!dst->isInverseFillType());
@@ -746,7 +747,8 @@
     path->addPoly(pts, 8, true);
 }
 
-void SkStroke::strokeRect(const SkRect& origRect, SkPath* dst) const {
+void SkStroke::strokeRect(const SkRect& origRect, SkPath* dst,
+                          SkPath::Direction dir) const {
     SkASSERT(dst != NULL);
     dst->reset();
 
@@ -755,11 +757,10 @@
         return;
     }
 
-    SkPath::Direction dir = SkPath::kCW_Direction;
     SkScalar rw = origRect.width();
     SkScalar rh = origRect.height();
     if ((rw < 0) ^ (rh < 0)) {
-        dir = SkPath::kCCW_Direction;
+        dir = reverse_direction(dir);
     }
     SkRect rect(origRect);
     rect.sort();
@@ -783,7 +784,7 @@
             addBevel(dst, rect, r, dir);
             break;
         case SkPaint::kRound_Join:
-            dst->addRoundRect(r, radius, radius);
+            dst->addRoundRect(r, radius, radius, dir);
             break;
     }
 
diff --git a/src/core/SkStroke.h b/src/core/SkStroke.h
index 5f0b475..4880516 100644
--- a/src/core/SkStroke.h
+++ b/src/core/SkStroke.h
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -6,16 +5,13 @@
  * found in the LICENSE file.
  */
 
-
 #ifndef SkStroke_DEFINED
 #define SkStroke_DEFINED
 
+#include "SkPath.h"
 #include "SkPoint.h"
 #include "SkPaint.h"
 
-struct SkRect;
-class SkPath;
-
 /** \class SkStroke
     SkStroke is the utility class that constructs paths by stroking
     geometries (lines, rects, ovals, roundrects, paths). This is
@@ -40,7 +36,11 @@
     bool    getDoFill() const { return SkToBool(fDoFill); }
     void    setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
 
-    void    strokeRect(const SkRect&, SkPath*) const;
+    /**
+     *  Stroke the specified rect, winding it in the specified direction..
+     */
+    void    strokeRect(const SkRect& rect, SkPath* result,
+                       SkPath::Direction = SkPath::kCW_Direction) const;
     void    strokePath(const SkPath& path, SkPath*) const;
 
     ////////////////////////////////////////////////////////////////