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
This commit is contained in:
commit-bot@chromium.org 2013-10-14 15:28:01 +00:00
Родитель da30055b29
Коммит 2887119a63
2 изменённых файлов: 9 добавлений и 11 удалений

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -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() {