SkPDF: filter out empty clip draws more often
Change-Id: Iff89f95b25ef9c5f57b64affc63bd77c46acd9a6
Reviewed-on: https://skia-review.googlesource.com/113273
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 01bd0a6..58151cc 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -558,6 +558,9 @@
}
void SkPDFDevice::drawPaint(const SkPaint& srcPaint) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkPaint newPaint = srcPaint;
remove_color_filter(&newPaint);
replace_srcmode_on_opaque_paint(&newPaint);
@@ -595,6 +598,9 @@
size_t count,
const SkPoint* points,
const SkPaint& srcPaint) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkPaint passedPaint = srcPaint;
remove_color_filter(&passedPaint);
replace_srcmode_on_opaque_paint(&passedPaint);
@@ -609,9 +615,6 @@
// We only use this when there's a path effect because of the overhead
// of multiple calls to setUpContentEntry it causes.
if (passedPaint.getPathEffect()) {
- if (this->cs().isEmpty(this->bounds())) {
- return;
- }
draw_points(mode, count, points, passedPaint,
this->devClipBounds(), this->ctm(), this);
return;
@@ -719,6 +722,9 @@
void SkPDFDevice::drawRect(const SkRect& rect,
const SkPaint& srcPaint) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkPaint paint = srcPaint;
remove_color_filter(&paint);
replace_srcmode_on_opaque_paint(&paint);
@@ -726,9 +732,6 @@
r.sort();
if (paint.getPathEffect() || paint.getMaskFilter()) {
- if (this->cs().isEmpty(this->bounds())) {
- return;
- }
SkPath path;
path.addRect(r);
this->drawPath(path, paint, nullptr, true);
@@ -745,6 +748,9 @@
void SkPDFDevice::drawRRect(const SkRRect& rrect,
const SkPaint& srcPaint) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkPaint paint = srcPaint;
remove_color_filter(&paint);
replace_srcmode_on_opaque_paint(&paint);
@@ -755,6 +761,9 @@
void SkPDFDevice::drawOval(const SkRect& oval,
const SkPaint& srcPaint) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkPaint paint = srcPaint;
remove_color_filter(&paint);
replace_srcmode_on_opaque_paint(&paint);
@@ -849,6 +858,9 @@
const SkPaint& srcPaint,
const SkMatrix* prePathMatrix,
bool pathIsMutable) {
+ if (clipStack.isEmpty(this->bounds())) {
+ return;
+ }
SkPaint paint = srcPaint;
remove_color_filter(&paint);
replace_srcmode_on_opaque_paint(&paint);
@@ -1348,7 +1360,7 @@
if (0 == sourceByteCount || !sourceText || srcPaint.getTextSize() <= 0) {
return;
}
- if (this->cs().isEmpty(this->bounds())) {
+ if (this->hasEmptyClip()) {
return;
}
NOT_IMPLEMENTED(srcPaint.isVerticalText(), false);
@@ -1638,7 +1650,7 @@
}
void SkPDFDevice::drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) {
- if (this->cs().isEmpty(this->bounds())) {
+ if (this->hasEmptyClip()) {
return;
}
// TODO: implement drawVertices
@@ -1763,7 +1775,7 @@
return false;
}
- if (this->cs().isEmpty(this->bounds())) {
+ if (this->hasEmptyClip()) {
return false;
}
@@ -2242,6 +2254,9 @@
const SkRect& dst,
const SkPaint& srcPaint,
const SkMatrix& ctm) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
if (!imageSubset) {
return;
}
@@ -2489,6 +2504,9 @@
void SkPDFDevice::drawSpecial(SkSpecialImage* srcImg, int x, int y, const SkPaint& paint,
SkImage* clipImage, const SkMatrix& clipMatrix) {
+ if (this->hasEmptyClip()) {
+ return;
+ }
SkASSERT(!srcImg->isTextureBacked());
//TODO: clipImage support