diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-14 15:28:01 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-14 15:28:01 +0000 |
commit | 2887119a63e314704673b971e9bc9a3461313a2c (patch) | |
tree | 2ec03a9f1737305b8ec18c13dbf90b4bfcdf4f7c | |
parent | da30055b296faa5a100e474e0406ef4296c14241 (diff) |
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
-rw-r--r-- | bench/benchmain.cpp | 9 | ||||
-rw-r--r-- | include/core/SkCanvas.h | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index 6b52508163..944b114c51 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -598,9 +598,9 @@ int tool_main(int argc, char** argv) { // 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 @@ int tool_main(int argc, char** argv) { glContext->swapBuffers(); } #endif - if (NULL != canvas) { - canvas->restore(); - } } diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index cfc252fccf..dc3953ed4b 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1145,11 +1145,12 @@ private: */ class SkAutoCanvasRestore : SkNoncopyable { public: - SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas) { - SkASSERT(canvas); - fSaveCount = canvas->getSaveCount(); - if (doSave) { - canvas->save(); + SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveCount(0) { + if (fCanvas) { + fSaveCount = canvas->getSaveCount(); + if (doSave) { + canvas->save(); + } } } ~SkAutoCanvasRestore() { |