Fixed two sub-optimal iterator uses
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 16 Jul 2012 21:20:03 +0000 (21:20 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 16 Jul 2012 21:20:03 +0000 (21:20 +0000)
http://codereview.appspot.com/6409048/

git-svn-id: http://skia.googlecode.com/svn/trunk@4633 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkCanvas.cpp
src/pdf/SkPDFDevice.cpp

index a65f454ef26e7e2544ec11cf9a9aefb609ccf22e..567e5f5c15aa404d9b6b04bac7d674c32d8213cb 100644 (file)
@@ -534,8 +534,7 @@ SkISize SkCanvas::getDeviceSize() const {
 
 SkDevice* SkCanvas::getDevice() const {
     // return root device
-    SkDeque::F2BIter iter(fMCStack);
-    MCRec*           rec = (MCRec*)iter.next();
+    MCRec* rec = (MCRec*) fMCStack.front();
     SkASSERT(rec && rec->fLayer);
     return rec->fLayer->fDevice;
 }
index bba703c23c624b48aa915dda14cbf6689925da9c..691ee26f24e178a2a19be2ca153ba3b16b7eed66 100644 (file)
@@ -222,16 +222,15 @@ void GraphicStackState::pop() {
 // and asserts that "prefix" will be a prefix to "stack."
 static void skip_clip_stack_prefix(const SkClipStack& prefix,
                                    const SkClipStack& stack,
-                                   SkClipStack::B2FIter* iter) {
+                                   SkClipStack::Iter* iter) {
     SkClipStack::B2FIter prefixIter(prefix);
-    iter->reset(stack);
+    iter->reset(stack, SkClipStack::Iter::kFront_IterStart);
 
     const SkClipStack::B2FIter::Clip* prefixEntry;
     const SkClipStack::B2FIter::Clip* iterEntry;
 
-    int count = 0;
     for (prefixEntry = prefixIter.next(); prefixEntry;
-            prefixEntry = prefixIter.next(), count++) {
+            prefixEntry = prefixIter.next()) {
         iterEntry = iter->next();
         SkASSERT(iterEntry);
         // Because of SkClipStack does internal intersection, the last clip
@@ -243,12 +242,8 @@ static void skip_clip_stack_prefix(const SkClipStack& prefix,
                     (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();
-            }
+            // back up the iterator by one
+            iter->prev();
             prefixEntry = prefixIter.next();
             break;
         }
@@ -305,7 +300,7 @@ void GraphicStackState::updateClip(const SkClipStack& clipStack,
     // initial clip on the parent layer.  (This means there's a bug if the user
     // expands the clip and then uses any xfer mode that uses dst:
     // http://code.google.com/p/skia/issues/detail?id=228 )
-    SkClipStack::B2FIter iter;
+    SkClipStack::Iter iter;
     skip_clip_stack_prefix(fEntries[0].fClipStack, clipStack, &iter);
 
     // If the clip stack does anything other than intersect or if it uses