diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h index ae0b974d6..6e8da76d2 100644 --- a/include/core/SkClipStack.h +++ b/include/core/SkClipStack.h @@ -43,6 +43,7 @@ public: struct Clip { friend bool operator==(const Clip& a, const Clip& b); + friend bool operator!=(const Clip& a, const Clip& b); const SkRect* fRect; // if non-null, this is a rect clip const SkPath* fPath; // if non-null, this is a path clip SkRegion::Op fOp; diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp index 5ffa5b1d9..4ad4d4192 100644 --- a/src/core/SkClipStack.cpp +++ b/src/core/SkClipStack.cpp @@ -188,6 +188,11 @@ bool operator==(const SkClipStack::B2FIter::Clip& a, ((a.fPath == NULL && b.fPath == NULL) || *a.fPath == *b.fPath); } +bool operator!=(const SkClipStack::B2FIter::Clip& a, + const SkClipStack::B2FIter::Clip& b) { + return !(a == b); +} + SkClipStack::B2FIter::B2FIter(const SkClipStack& stack) { this->reset(stack); } diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 1fe1734e9..4c0021a66 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -233,11 +233,29 @@ static void skip_clip_stack_prefix(const SkClipStack& prefix, const SkClipStack::B2FIter::Clip* prefixEntry; const SkClipStack::B2FIter::Clip* iterEntry; + int count = 0; for (prefixEntry = prefixIter.next(); prefixEntry; - prefixEntry = prefixIter.next()) { + prefixEntry = prefixIter.next(), count++) { iterEntry = iter->next(); SkASSERT(iterEntry); - SkASSERT(*prefixEntry == *iterEntry); + // Because of SkClipStack does internal intersection, the last clip + // entry may differ. + if(*prefixEntry != *iterEntry) { + SkASSERT(prefixEntry->fOp == SkRegion::kIntersect_Op); + SkASSERT(iterEntry->fOp == SkRegion::kIntersect_Op); + SkASSERT((iterEntry->fRect == NULL) == + (prefixEntry->fRect == NULL)); + SkASSERT((iterEntry->fPath == NULL) == + (prefixEntry->fPath == NULL)); + // We need to back up the iterator by one but don't have that + // function, so reset and go forward by one less. + iter->reset(stack); + for (int i = 0; i < count; i++) { + iter->next(); + } + prefixEntry = prefixIter.next(); + break; + } } SkASSERT(prefixEntry == NULL);