save/restore the canvas around every bench draw call
BUG=
Committed: http://code.google.com/p/skia/source/detail?r=11728
R=djsollen@google.com, reed@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/26848013
git-svn-id: http://skia.googlecode.com/svn/trunk@11755 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 6b52508..944b114 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -598,9 +598,9 @@
// as we can flush and/or swap buffers to keep the GPU from
// queuing up too much work.
for (int loopCount = loopsPerIter; loopCount > 0; ) {
- if (NULL != canvas) {
- canvas->save();
- }
+ // Save and restore around each call to draw() to guarantee a pristine canvas.
+ SkAutoCanvasRestore saveRestore(canvas, true/*also save*/);
+
if (frameIntervalComputed && loopCount > loopsPerFrame) {
bench->setLoops(loopsPerFrame);
loopCount -= loopsPerFrame;
@@ -628,9 +628,6 @@
glContext->swapBuffers();
}
#endif
- if (NULL != canvas) {
- canvas->restore();
- }
}