Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 19519017: Inverse fill support in PDF (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698