1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=9f459b218ec079c1ada23f4412968f9a
5 REG_FIDDLE(AutoCanvasRestore_restore, 256, 256, true, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7 for (bool callRestore : { false, true } ) {
8 for (bool saveCanvas : {false, true} ) {
9 SkAutoCanvasRestore autoRestore(canvas, saveCanvas);
10 if (!saveCanvas) {
11 canvas->save();
12 }
13 SkDebugf("saveCanvas: %s before restore: %d\n",
14 saveCanvas ? "true" : "false", canvas->getSaveCount());
15 if (callRestore) autoRestore.restore();
16 SkDebugf("saveCanvas: %s after restore: %d\n",
17 saveCanvas ? "true" : "false", canvas->getSaveCount());
18 }
19 }
20 SkDebugf("final count: %d\n", canvas->getSaveCount());
21 }
22 } // END FIDDLE
23