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

Unified Diff: src/pdf/SkPDFUtils.cpp

Issue 1374383004: SkPDF: when drawing stroked path, draw using SVG rules for zero-length segments (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-10-06 (Tuesday) 12:31:14 EDT Created 5 years, 2 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 | « src/pdf/SkPDFUtils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFUtils.cpp
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index fc1bdbeb0617dfaf75108a43f1817345919c297b..108f2c10abd56e6d0ae94b263c89c5c9a5d34dd4 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -118,25 +118,27 @@ void SkPDFUtils::AppendRectangle(const SkRect& rect, SkWStream* content) {
// static
void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
- SkWStream* content) {
+ bool doConsumeDegerates, SkWStream* content) {
// Filling a path with no area results in a drawing in PDF renderers but
// Chrome expects to be able to draw some such entities with no visible
// result, so we detect those cases and discard the drawing for them.
// Specifically: moveTo(X), lineTo(Y) and moveTo(X), lineTo(X), lineTo(Y).
enum SkipFillState {
- kEmpty_SkipFillState = 0,
- kSingleLine_SkipFillState = 1,
- kNonSingleLine_SkipFillState = 2,
+ kEmpty_SkipFillState,
+ kSingleLine_SkipFillState,
+ kNonSingleLine_SkipFillState,
};
SkipFillState fillState = kEmpty_SkipFillState;
- if (paintStyle != SkPaint::kFill_Style) {
- fillState = kNonSingleLine_SkipFillState;
- }
+ //if (paintStyle != SkPaint::kFill_Style) {
+ // fillState = kNonSingleLine_SkipFillState;
+ //}
SkPoint lastMovePt = SkPoint::Make(0,0);
SkDynamicMemoryWStream currentSegment;
SkPoint args[4];
SkPath::Iter iter(path, false);
- for (SkPath::Verb verb = iter.next(args); verb != SkPath::kDone_Verb; verb = iter.next(args)) {
+ for (SkPath::Verb verb = iter.next(args, doConsumeDegerates);
+ verb != SkPath::kDone_Verb;
+ verb = iter.next(args, doConsumeDegerates)) {
// args gets all the points, even the implicit first point.
switch (verb) {
case SkPath::kMove_Verb:
@@ -146,13 +148,11 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
break;
case SkPath::kLine_Verb:
AppendLine(args[1].fX, args[1].fY, &currentSegment);
- if (fillState == kEmpty_SkipFillState) {
- if (args[0] != lastMovePt) {
- fillState = kSingleLine_SkipFillState;
- }
- } else if (fillState == kSingleLine_SkipFillState) {
- fillState = kNonSingleLine_SkipFillState;
+ if ((fillState == kEmpty_SkipFillState) && (args[0] != lastMovePt)) {
+ fillState = kSingleLine_SkipFillState;
+ break;
}
+ fillState = kNonSingleLine_SkipFillState;
break;
case SkPath::kQuad_Verb:
append_quad(args, &currentSegment);
@@ -165,6 +165,7 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
for (int i = 0; i < converter.countQuads(); ++i) {
append_quad(&quads[i * 2], &currentSegment);
}
+ fillState = kNonSingleLine_SkipFillState;
} break;
case SkPath::kCubic_Verb:
AppendCubic(args[1].fX, args[1].fY, args[2].fX, args[2].fY,
@@ -172,10 +173,10 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
fillState = kNonSingleLine_SkipFillState;
break;
case SkPath::kClose_Verb:
- if (fillState != kSingleLine_SkipFillState) {
+
ClosePath(&currentSegment);
- currentSegment.writeToStream(content);
- }
+
+ currentSegment.writeToStream(content);
currentSegment.reset();
break;
default:
« no previous file with comments | « src/pdf/SkPDFUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698