From 00f30bdc9e34b013da54b4406f36556c5be8d041 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 2 Sep 2014 12:03:31 -0700 Subject: 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 --- tools/DumpRecord.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'tools/DumpRecord.cpp') diff --git a/tools/DumpRecord.cpp b/tools/DumpRecord.cpp index 6e679a5430..c505123acd 100644 --- a/tools/DumpRecord.cpp +++ b/tools/DumpRecord.cpp @@ -20,6 +20,7 @@ public: 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 @@ public: } } - unsigned index() const { return fDraw.index(); } - void next() { fDraw.next(); } - template void operator()(const T& command) { Timer timer; @@ -71,7 +69,7 @@ private: 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 @@ private: int fDigits; int fIndent; + int fIndex; SkRecords::Draw fDraw; const bool fTimeWithCommand; }; @@ -105,9 +104,8 @@ private: void DumpRecord(const SkRecord& record, SkCanvas* canvas, bool timeWithCommand) { - for (Dumper dumper(canvas, record.count(), timeWithCommand); - dumper.index() < record.count(); - dumper.next()) { - record.visit(dumper.index(), dumper); + Dumper dumper(canvas, record.count(), timeWithCommand); + for (unsigned i = 0; i < record.count(); i++) { + record.visit(i, dumper); } } -- cgit v1.2.3