aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkClipStack.cpp14
-rw-r--r--src/core/SkClipStack.h3
-rw-r--r--src/pdf/SkPDFDevice.cpp34
3 files changed, 34 insertions, 17 deletions
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index bc8c5c5d62..f41945e090 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -580,6 +580,20 @@ void SkClipStack::restoreTo(int saveCount) {
}
}
+SkRect SkClipStack::bounds(const SkIRect& deviceBounds) const {
+ // TODO: optimize this.
+ SkRect r;
+ SkClipStack::BoundsType bounds;
+ this->getBounds(&r, &bounds);
+ if (bounds == SkClipStack::kInsideOut_BoundsType) {
+ return SkRect::Make(deviceBounds);
+ }
+ return r.intersect(SkRect::Make(deviceBounds)) ? r : SkRect::MakeEmpty();
+}
+
+// TODO: optimize this.
+bool SkClipStack::isEmpty(const SkIRect& r) const { return this->bounds(r).isEmpty(); }
+
void SkClipStack::getBounds(SkRect* canvFiniteBound,
BoundsType* boundType,
bool* isIntersectionOfRects) const {
diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h
index 2f24d69502..080712dfe3 100644
--- a/src/core/SkClipStack.h
+++ b/src/core/SkClipStack.h
@@ -353,6 +353,9 @@ public:
BoundsType* boundType,
bool* isIntersectionOfRects = NULL) const;
+ SkRect bounds(const SkIRect& deviceBounds) const;
+ bool isEmpty(const SkIRect& deviceBounds) const;
+
/**
* Returns true if the input (r)rect in device space is entirely contained
* by the clip. A return value of false does not guarantee that the (r)rect
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 2dff42e82e..b2c54fecce 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -565,7 +565,7 @@ void SkPDFDevice::drawPoints(const SkDraw& d,
// 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 (d.fRC->isEmpty()) {
+ if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
SkDraw pointDraw(d);
@@ -689,7 +689,7 @@ void SkPDFDevice::drawRect(const SkDraw& d,
r.sort();
if (paint.getPathEffect()) {
- if (d.fRC->isEmpty()) {
+ if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
SkPath path;
@@ -751,7 +751,7 @@ void SkPDFDevice::drawPath(const SkDraw& d,
}
if (paint.getPathEffect()) {
- if (d.fRC->isEmpty()) {
+ if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
if (!pathIsMutable) {
@@ -871,7 +871,7 @@ void SkPDFDevice::drawBitmap(const SkDraw& d,
const SkBitmap& bitmap,
const SkMatrix& matrix,
const SkPaint& srcPaint) {
- if (bitmap.drawsNothing() || d.fRC->isEmpty()) {
+ if (bitmap.drawsNothing() || d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
SkPaint paint = srcPaint;
@@ -893,7 +893,7 @@ void SkPDFDevice::drawSprite(const SkDraw& d,
int x,
int y,
const SkPaint& srcPaint) {
- if (bitmap.drawsNothing() || d.fRC->isEmpty()) {
+ if (bitmap.drawsNothing() || d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
SkPaint paint = srcPaint;
@@ -915,7 +915,7 @@ void SkPDFDevice::drawImage(const SkDraw& draw,
SkScalar y,
const SkPaint& srcPaint) {
SkPaint paint = srcPaint;
- if (!image || draw.fRC->isEmpty()) {
+ if (!image) {
return;
}
if (image->isOpaque()) {
@@ -1439,7 +1439,7 @@ void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode,
const SkPoint texs[], const SkColor colors[],
SkBlendMode, const uint16_t indices[],
int indexCount, const SkPaint& paint) {
- if (d.fRC->isEmpty()) {
+ if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
// TODO: implement drawVertices
@@ -1571,7 +1571,7 @@ bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath,
return false;
}
- if (d.fRC->isEmpty()) {
+ if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return false;
}
@@ -1598,7 +1598,6 @@ bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath,
// Get bounds of clip in current transform space
// (clip bounds are given in device space).
- SkRect bounds;
SkMatrix transformInverse;
SkMatrix totalMatrix = *d.fMatrix;
if (prePathMatrix) {
@@ -1607,7 +1606,7 @@ bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath,
if (!totalMatrix.invert(&transformInverse)) {
return false;
}
- bounds.set(d.fRC->getBounds());
+ SkRect bounds = SkRect::Make(d.fRC->getBounds());
transformInverse.mapRect(&bounds);
// Extend the bounds by the line width (plus some padding)
@@ -1745,16 +1744,16 @@ void SkPDFDevice::drawFormXObjectWithMask(int xObjectIndex,
}
SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* clipStack,
- const SkRegion& clipRegion,
- const SkMatrix& matrix,
- const SkPaint& paint,
- bool hasText,
- sk_sp<SkPDFObject>* dst) {
+ const SkRegion& clipRegion,
+ const SkMatrix& matrix,
+ const SkPaint& paint,
+ bool hasText,
+ sk_sp<SkPDFObject>* dst) {
*dst = nullptr;
if (clipRegion.isEmpty()) {
return nullptr;
}
-
+ SkASSERT(clipStack);
SkBlendMode blendMode = paint.getBlendMode();
// For the following modes, we want to handle source and destination
@@ -2275,7 +2274,8 @@ void SkPDFDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int x,
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
- const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
+ const SkIRect clipBounds =
+ draw.fClipStack->bounds(this->imageInfo().bounds()).roundOut().makeOffset(-x, -y);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
// TODO: Should PDF be operating in a specified color space? For now, run the filter
// in the same color space as the source (this is different from all other backends).