From 632e92fc3fa99e6a78fcbc67d6da68d5bd8334c3 Mon Sep 17 00:00:00 2001 From: fmalita Date: Wed, 22 Apr 2015 15:02:03 -0700 Subject: [PATCH] [SkPDFDevice] Enable pathops-based inverse fills Keeping the old compile guard for clipping only. BUG=skia:3749 R=halcanary@google.com,caryclark@google.com,reed@google.com Review URL: https://codereview.chromium.org/1099953002 --- include/config/SkUserConfig.h | 10 +++++----- src/pdf/SkPDFDevice.cpp | 8 ++------ src/pdf/SkPDFDevice.h | 2 -- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h index 607b26ad3d..43cf7ce880 100644 --- a/include/config/SkUserConfig.h +++ b/include/config/SkUserConfig.h @@ -151,13 +151,13 @@ //#define SK_SUPPORT_GPU 1 -/* The PDF generation code uses Path Ops to generate inverse fills and complex - * clipping paths, but at this time, Path Ops is not release ready yet. So, - * the code is hidden behind this #define guard. If you are feeling adventurous - * and want the latest and greatest PDF generation code, uncomment the #define. +/* The PDF generation code uses Path Ops to handle complex clipping paths, + * but at this time, Path Ops is not release ready yet. So, the code is + * hidden behind this #define guard. If you are feeling adventurous and + * want the latest and greatest PDF generation code, uncomment the #define. * When Path Ops is release ready, the define guards and this user config * define should be removed entirely. */ -//#define SK_PDF_USE_PATHOPS +//#define SK_PDF_USE_PATHOPS_CLIPPING #endif diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 1b16397512..b08bb174b1 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -328,7 +328,6 @@ static void emit_clip(SkPath* clipPath, SkRect* clipRect, } } -#ifdef SK_PDF_USE_PATHOPS /* Calculate an inverted path's equivalent non-inverted path, given the * canvas bounds. * outPath may alias with invPath (since this is supported by PathOps). @@ -343,6 +342,7 @@ static bool calculate_inverse_path(const SkRect& bounds, const SkPath& invPath, return Op(clipPath, invPath, kIntersect_PathOp, outPath); } +#ifdef SK_PDF_USE_PATHOPS_CLIPPING // Sanity check the numerical values of the SkRegion ops and PathOps ops // enums so region_op_to_pathops_op can do a straight passthrough cast. // If these are failing, it may be necessary to make region_op_to_pathops_op @@ -440,7 +440,7 @@ void GraphicStackState::updateClip(const SkClipStack& clipStack, SkMatrix transform; transform.setTranslate(translation.fX, translation.fY); -#ifdef SK_PDF_USE_PATHOPS +#ifdef SK_PDF_USE_PATHOPS_CLIPPING SkPath clipPath; if (get_clip_stack_path(transform, clipStack, clipRegion, &clipPath)) { emit_clip(&clipPath, NULL, fContentStream); @@ -951,11 +951,9 @@ void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& origPath, return; } -#ifdef SK_PDF_USE_PATHOPS if (handleInversePath(d, origPath, paint, pathIsMutable, prePathMatrix)) { return; } -#endif if (handleRectAnnotation(pathPtr->getBounds(), matrix, paint)) { return; @@ -1363,7 +1361,6 @@ void SkPDFDevice::writeContent(SkWStream* out) const { SkPDFDevice::copyContentEntriesToData(fContentEntries.get(), out); } -#ifdef SK_PDF_USE_PATHOPS /* Draws an inverse filled path by using Path Ops to compute the positive * inverse using the current clip as the inverse bounds. * Return true if this was an inverse path and was properly handled, @@ -1429,7 +1426,6 @@ bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, drawPath(d, modifiedPath, noInversePaint, prePathMatrix, true); return true; } -#endif bool SkPDFDevice::handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, const SkPaint& p) { diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index a701405241..2850cf943c 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -290,11 +290,9 @@ private: */ void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; -#ifdef SK_PDF_USE_PATHOPS bool handleInversePath(const SkDraw& d, const SkPath& origPath, const SkPaint& paint, bool pathIsMutable, const SkMatrix* prePathMatrix = NULL); -#endif bool handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, const SkPaint& paint); bool handlePointAnnotation(const SkPoint* points, size_t count,