// 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());
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();
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();
addBevel(dst, rect, r, dir);
break;
case SkPaint::kRound_Join:
- dst->addRoundRect(r, radius, radius);
+ dst->addRoundRect(r, radius, radius, dir);
break;
}
-
/*
* Copyright 2006 The Android Open Source Project
*
* 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
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;
////////////////////////////////////////////////////////////////