Flutter Engine
The Flutter Engine
AutoCanvasRestore_restore.cpp
Go to the documentation of this file.
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.
4REG_FIDDLE(AutoCanvasRestore_restore, 256, 256, true, 0) {
5void draw(SkCanvas* canvas) {
6 for (bool callRestore : { false, true } ) {
7 for (bool saveCanvas : {false, true} ) {
8 SkAutoCanvasRestore autoRestore(canvas, saveCanvas);
9 if (!saveCanvas) {
10 canvas->save();
11 }
12 SkDebugf("saveCanvas: %s before restore: %d\n",
13 saveCanvas ? "true" : "false", canvas->getSaveCount());
14 if (callRestore) autoRestore.restore();
15 SkDebugf("saveCanvas: %s after restore: %d\n",
16 saveCanvas ? "true" : "false", canvas->getSaveCount());
17 }
18 }
19 SkDebugf("final count: %d\n", canvas->getSaveCount());
20}
21} // END FIDDLE
REG_FIDDLE(AutoCanvasRestore_restore, 256, 256, true, 0)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
int getSaveCount() const
Definition: SkCanvas.cpp:431
int save()
Definition: SkCanvas.cpp:447