SkRecordPartialDraw with less code duplication

BUG=skia:
R=robertphillips@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/527423002
diff --git a/tools/DumpRecord.cpp b/tools/DumpRecord.cpp
index 6e679a5..c505123 100644
--- a/tools/DumpRecord.cpp
+++ b/tools/DumpRecord.cpp
@@ -20,6 +20,7 @@
     explicit Dumper(SkCanvas* canvas, int count, bool timeWithCommand)
         : fDigits(0)
         , fIndent(0)
+        , fIndex(0)
         , fDraw(canvas)
         , fTimeWithCommand(timeWithCommand) {
         while (count > 0) {
@@ -28,9 +29,6 @@
         }
     }
 
-    unsigned index() const { return fDraw.index(); }
-    void next() { fDraw.next(); }
-
     template <typename T>
     void operator()(const T& command) {
         Timer timer;
@@ -71,7 +69,7 @@
         if (!fTimeWithCommand) {
             printf("%6.1f ", time * 1000);
         }
-        printf("%*d ", fDigits, fDraw.index());
+        printf("%*d ", fDigits, fIndex++);
         for (int i = 0; i < fIndent; i++) {
             putchar('\t');
         }
@@ -96,6 +94,7 @@
 
     int fDigits;
     int fIndent;
+    int fIndex;
     SkRecords::Draw fDraw;
     const bool fTimeWithCommand;
 };
@@ -105,9 +104,8 @@
 void DumpRecord(const SkRecord& record,
                   SkCanvas* canvas,
                   bool timeWithCommand) {
-    for (Dumper dumper(canvas, record.count(), timeWithCommand);
-         dumper.index() < record.count();
-         dumper.next()) {
-        record.visit<void>(dumper.index(), dumper);
+    Dumper dumper(canvas, record.count(), timeWithCommand);
+    for (unsigned i = 0; i < record.count(); i++) {
+        record.visit<void>(i, dumper);
     }
 }