SkPDF: paths as rects when possible
http://crrev.com/2269593003
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4652
Change-Id: I12e238e8f00ac1c54a1b8dcf82a5502240563288
Reviewed-on: https://skia-review.googlesource.com/4652
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index 0fe6fb5..189bc5c 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -122,6 +122,17 @@
// 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; // Both closure and direction need to be checked.
+ SkPath::Direction direction;
+ if (path.isRect(&rect, &isClosed, &direction) &&
+ isClosed && SkPath::kCW_Direction == direction)
+ {
+ SkPDFUtils::AppendRectangle(rect, content);
+ return;
+ }
+
enum SkipFillState {
kEmpty_SkipFillState,
kSingleLine_SkipFillState,