aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDraw.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-04 18:58:05 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-04 18:58:05 +0000
commit761fb62b0eb174783316d2a8b933fba896ca6355 (patch)
treeca7e444f0bc5e0dc88c8c8809de10e31e3ac5214 /src/core/SkDraw.cpp
parent67dc548cecfd586dafde417cfd630a8019ac347a (diff)
reenable fast stroked rects, now that we correctly handle non-square scale
also, degenerate non-antialias rectangles now draw properly git-svn-id: http://skia.googlecode.com/svn/trunk@1049 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r--src/core/SkDraw.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 4595fdf326..b122c4f93e 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -679,15 +679,17 @@ static inline SkPoint* as_rightbottom(SkRect* r) {
return ((SkPoint*)(void*)r) + 1;
}
-static bool easy_rect_join(const SkPaint& paint) {
-#if 0
- return SkPaint::kMiter_Join == paint.getStrokeJoin() &&
- paint.getStrokeMiter() >= SK_ScalarSqrt2;
-#else
- // return false until we handle non-square scaling in the matrix, where
- // the horizontal and vertical widths may differ.
- return false;
-#endif
+static bool easy_rect_join(const SkPaint& paint, const SkMatrix& matrix,
+ SkPoint* strokeSize) {
+ if (SkPaint::kMiter_Join != paint.getStrokeJoin() ||
+ paint.getStrokeMiter() < SK_ScalarSqrt2) {
+ return false;
+ }
+
+ SkASSERT(matrix.rectStaysRect());
+ SkPoint pt = { paint.getStrokeWidth(), paint.getStrokeWidth() };
+ matrix.mapVectors(strokeSize, &pt, 1);
+ return true;
}
enum RectType {
@@ -710,6 +712,7 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const {
const SkScalar width = paint.getStrokeWidth();
bool zeroWidth = (0 == width);
SkPaint::Style style = paint.getStyle();
+ SkPoint strokeSize;
if ((SkPaint::kStrokeAndFill_Style == style) && zeroWidth) {
style = SkPaint::kFill_Style;
@@ -723,7 +726,7 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const {
rtype = kFill_RectType;
} else if (zeroWidth) {
rtype = kHair_RectType;
- } else if (easy_rect_join(paint)) {
+ } else if (easy_rect_join(paint, *fMatrix, &strokeSize)) {
#ifdef SK_DISABLE_FAST_AA_STROKE_RECT
if (paint.isAntiAlias()) {
rtype = kPath_RectType;
@@ -785,9 +788,9 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const {
break;
case kStroke_RectType:
if (paint.isAntiAlias()) {
- SkScan::AntiFrameRect(devRect, width, clip, blitter);
+ SkScan::AntiFrameRect(devRect, strokeSize, clip, blitter);
} else {
- SkScan::FrameRect(devRect, width, clip, blitter);
+ SkScan::FrameRect(devRect, strokeSize, clip, blitter);
}
break;
case kHair_RectType: