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

Unified Diff: src/pdf/SkPDFUtils.cpp

Issue 2269593003: SkPDF: paths as rects when possible (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/SkPDFUtils.cpp
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index 0fe6fb59a9dfe6691fc7df08dace0ac42af12af2..5371a8187c1022b1845c7a3fd31c0da5c6a53172 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -122,6 +122,25 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
// 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).
+
+ SkRect rect;
+ bool isClosed;
+ SkPath::Direction direction;
+ if (path.isRect(&rect, &isClosed, &direction)) {
+ if (isClosed && SkPath::kCW_Direction == direction) {
bungeman-skia 2016/08/22 19:28:18 Is the check for CW really needed? What's the outp
+ //SkPDFUtils::AppendRectangle(rect, content);
bungeman-skia 2016/08/22 19:28:18 Either this should be written and used or the comm
+ SkPDFUtils::AppendScalar(rect.left(), content);
+ content->writeText(" ");
+ SkPDFUtils::AppendScalar(rect.top(), content);
+ content->writeText(" ");
+ SkPDFUtils::AppendScalar(rect.width(), content);
+ content->writeText(" ");
+ SkPDFUtils::AppendScalar(rect.height(), content);
+ content->writeText(" re\n");
+ return;
+ }
+ }
+
enum SkipFillState {
kEmpty_SkipFillState,
kSingleLine_SkipFillState,
« 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