Index: src/pdf/SkPDFDevice.cpp |
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp |
index 31cbbb2accb7cf750a1dc878fe06ccf4c05157b5..ab9c2846e7a61b45ab202dbc398fd125bb90347f 100644 |
--- a/src/pdf/SkPDFDevice.cpp |
+++ b/src/pdf/SkPDFDevice.cpp |
@@ -16,6 +16,7 @@ |
#include "SkGlyphCache.h" |
#include "SkPaint.h" |
#include "SkPath.h" |
+#include "SkPathOps.h" |
#include "SkPDFFont.h" |
#include "SkPDFFormXObject.h" |
#include "SkPDFGraphicState.h" |
@@ -826,7 +827,6 @@ void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& origPath, |
} |
if (!pathIsMutable) { |
pathPtr = &modifiedPath; |
- pathIsMutable = true; |
ducky
2013/07/25 03:32:20
This code really doesn't do anything (I think, at
|
} |
bool fill = paint.getFillPath(origPath, pathPtr); |
@@ -842,6 +842,47 @@ void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& origPath, |
return; |
} |
+ // TODO(richardlin): This doesn't handle inverse stroke (line) operations. |
+ // Related to Issue 241. |
+ if (origPath.isInverseFillType()) { |
+ if (d.fClip->isEmpty()) { |
+ return; |
+ } |
+ if (!pathIsMutable) { |
+ pathPtr = &modifiedPath; |
+ } |
+ |
+ // Get bounds of clip in current transform space |
+ // (clip bounds are given in device space). |
+ SkRect bounds; |
+ SkMatrix transformInverse; |
+ if (!d.fMatrix->invert(&transformInverse)) { |
+ return; |
+ } |
+ bounds.set(d.fClip->getBounds()); |
+ transformInverse.mapRect(&bounds); |
+ |
+ // Extend the bounds by the line width, so the edge doesn't cause |
+ // a visible stroke. |
+ SkScalar lineWidth = paint.getStrokeWidth(); |
+ bounds = SkRect::MakeLTRB( |
+ bounds.left() - lineWidth, bounds.top() - lineWidth, |
+ bounds.right() + lineWidth, bounds.bottom() + lineWidth); |
+ |
+ SkPath fillPath; |
+ fillPath.addRect(bounds); |
+ |
+ // Create positive version of original path, since PathOps takes |
+ // inverse fills into account. |
+ SkPath origDup(origPath); |
+ origDup.toggleInverseFillType(); |
+ |
+ if (Op(fillPath, origDup, kDifference_PathOp, pathPtr)) { |
+ drawPath(d, *pathPtr, paint, NULL, true); |
+ } |
+ return; |
+ } |
+ |
if (handleRectAnnotation(pathPtr->getBounds(), *d.fMatrix, paint)) { |
return; |
} |