From abf8e41ccb1f0ab86296c01f68027627d1ce15ef Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Mon, 24 Sep 2018 11:37:23 -0400 Subject: [PATCH] SkPDF: simplify SkPDFDevice::drawPaint. Now just calls drawRect with the current clip's bounding box. This might be slightly more efficient for the rasterizer. Deletes 20 lines of code, making things more maintainable. remove internalDrawPaint(). Of 702 test images: 692 produced identical results. 19 produced slightly different PDFs that render identically. 1 rendered impoerceptable differently in perspective. Change-Id: I5539e58c8a27ead461922a04f2518daa1c7995ba Reviewed-on: https://skia-review.googlesource.com/156366 Commit-Queue: Ben Wagner Auto-Submit: Hal Canary Reviewed-by: Ben Wagner --- src/pdf/SkPDFDevice.cpp | 37 ++++++++----------------------------- src/pdf/SkPDFDevice.h | 2 -- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 764909406c..b7867eb4df 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -593,40 +593,19 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v } void SkPDFDevice::drawPaint(const SkPaint& srcPaint) { + SkMatrix inverse; + if (!this->ctm().invert(&inverse)) { + return; + } + SkRect bbox = this->cs().bounds(this->bounds()); + inverse.mapRect(&bbox); + bbox.roundOut(&bbox); if (this->hasEmptyClip()) { return; } SkPaint newPaint = srcPaint; - remove_color_filter(&newPaint); - replace_srcmode_on_opaque_paint(&newPaint); newPaint.setStyle(SkPaint::kFill_Style); - - SkMatrix ctm = this->ctm(); - if (ctm.getType() & SkMatrix::kPerspective_Mask) { - if (newPaint.getShader()) { - transform_shader(&newPaint, ctm); - } - ctm = SkMatrix::I(); - } - ScopedContentEntry content(this, this->cs(), ctm, newPaint); - this->internalDrawPaint(newPaint, content.entry()); -} - -void SkPDFDevice::internalDrawPaint(const SkPaint& paint, - SkPDFDevice::ContentEntry* contentEntry) { - if (!contentEntry) { - return; - } - SkRect bbox = SkRect::Make(this->imageInfo().dimensions()); - SkMatrix inverse; - if (!contentEntry->fState.fMatrix.invert(&inverse)) { - return; - } - inverse.mapRect(&bbox); - - SkPDFUtils::AppendRectangle(bbox, &contentEntry->fContent); - SkPDFUtils::PaintPath(paint.getStyle(), SkPath::kWinding_FillType, - &contentEntry->fContent); + this->drawRect(bbox, newPaint); } void SkPDFDevice::drawPoints(SkCanvas::PointMode mode, diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 1ae3f95224..2d3cc43d52 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -210,8 +210,6 @@ private: void internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset); - void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry); - void internalDrawImageRect(SkKeyedImage, const SkRect* src, const SkRect& dst,