Hairline stroke 1px wide paths.
Review URL: http://codereview.appspot.com/4317041/
git-svn-id: http://skia.googlecode.com/svn/trunk@1008 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3707b67..d102f3f 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -771,7 +771,22 @@
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
- if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
+ // This "if" is not part of the SkDraw::drawPath() lift.
+ // When we get a 1.0 wide stroke we hairline stroke it instead of creating
+ // a new stroked-path. This is motivated by canvas2D sites that draw
+ // lines as 1.0 wide stroked paths. We can consider doing an alpha-modulated-
+ // hairline for width < 1.0 when AA is enabled.
+ static const int gMatrixMask = ~(SkMatrix::kIdentity_Mask |
+ SkMatrix::kTranslate_Mask);
+ if (!paint.getPathEffect() &&
+ SkPaint::kStroke_Style == paint.getStyle() &&
+ !(draw.fMatrix->getType() & gMatrixMask) &&
+ SK_Scalar1 == paint.getStrokeWidth()) {
+ doFill = false;
+ }
+
+ if (doFill && (paint.getPathEffect() ||
+ paint.getStyle() != SkPaint::kFill_Style)) {
doFill = paint.getFillPath(*pathPtr, &tmpPath);
pathPtr = &tmpPath;
}