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
// 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;
glContext->swapBuffers();
}
#endif
- if (NULL != canvas) {
- canvas->restore();
- }
}
*/
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() {