aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-25 01:27:52 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-25 01:27:52 +0000
commit8887ede82465687355c7a1c51e4553e99b2fb15a (patch)
treefcaa71142fba19c2040f01446a1af052fd4e8bfe /src
parent19e3c1ed1b20ce93cc092d25c3637b62f90c5bc5 (diff)
[PDF] Improve the SkClipStack skipping prefix code.
Because of intersecting done in SkClipStack, we may have to do more work in the last entry of the prefix. Review URL: http://codereview.appspot.com/4530066 git-svn-id: http://skia.googlecode.com/svn/trunk@1418 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkClipStack.cpp5
-rw-r--r--src/pdf/SkPDFDevice.cpp22
2 files changed, 25 insertions, 2 deletions
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index 5ffa5b1d95..4ad4d41926 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 1fe1734e93..4c0021a666 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);