1SkAutoCanvasRestore Reference
2===
3
4
5<a name='SkAutoCanvasRestore'></a>
6
7---
8
9<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
10class <a href='SkAutoCanvasRestore_Reference#SkAutoCanvasRestore'>SkAutoCanvasRestore</a> {
11
12    <a href='#SkAutoCanvasRestore_SkCanvas_star'>SkAutoCanvasRestore</a>(<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='SkCanvas_Reference#Canvas'>canvas</a>, bool doSave);
13    <a href='#SkAutoCanvasRestore_destructor'>~SkAutoCanvasRestore()</a>;
14    void <a href='#SkAutoCanvasRestore_restore'>restore()</a>;
15};
16
17</pre>
18
19Stack helper class calls <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_restoreToCount'>restoreToCount</a> when <a href='SkAutoCanvasRestore_Reference#SkAutoCanvasRestore'>SkAutoCanvasRestore</a>
20goes out of scope. Use this to guarantee that the <a href='SkCanvas_Reference#Canvas'>canvas</a> is restored to a known
21state.
22
23<a name='SkAutoCanvasRestore_SkCanvas_star'></a>
24
25---
26
27<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
28<a href='#SkAutoCanvasRestore_SkCanvas_star'>SkAutoCanvasRestore</a>(<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>* <a href='SkCanvas_Reference#Canvas'>canvas</a>, bool doSave)
29</pre>
30
31Preserves <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_save'>save()</a> count. Optionally saves <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> clip and <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> <a href='SkMatrix_Reference#Matrix'>matrix</a>.
32
33### Parameters
34
35<table>  <tr>    <td><a name='SkAutoCanvasRestore_SkCanvas_star_canvas'><code><strong>canvas</strong></code></a></td>
36    <td><a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> to guard</td>
37  </tr>
38  <tr>    <td><a name='SkAutoCanvasRestore_SkCanvas_star_doSave'><code><strong>doSave</strong></code></a></td>
39    <td>call <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_save'>save()</a></td>
40  </tr>
41</table>
42
43### Return Value
44
45utility to restore <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> state on destructor
46
47### Example
48
49<div><fiddle-embed name="466ef576b88e29d7252422db7adeed1c"></fiddle-embed></div>
50
51### See Also
52
53<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_save'>save</a> <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_restore'>restore</a>
54
55<a name='SkAutoCanvasRestore_destructor'></a>
56
57---
58
59<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
60<a href='#SkAutoCanvasRestore_destructor'>~SkAutoCanvasRestore()</a>
61</pre>
62
63Restores <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> to saved state. Destructor is called when container goes out of
64scope.
65
66### See Also
67
68<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_save'>save</a> <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_restore'>restore</a>
69
70<a name='SkAutoCanvasRestore_restore'></a>
71
72---
73
74<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
75void <a href='#SkAutoCanvasRestore_restore'>restore()</a>
76</pre>
77
78Restores <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a> to saved state immediately. Subsequent calls and
79<a href='#SkAutoCanvasRestore_destructor'>~SkAutoCanvasRestore()</a> have no effect.
80
81### Example
82
83<div><fiddle-embed name="9f459b218ec079c1ada23f4412968f9a">
84
85#### Example Output
86
87~~~~
88saveCanvas: false  before restore: 2
89saveCanvas: false  after restore: 2
90saveCanvas: true  before restore: 2
91saveCanvas: true  after restore: 2
92saveCanvas: false  before restore: 2
93saveCanvas: false  after restore: 1
94saveCanvas: true  before restore: 2
95saveCanvas: true  after restore: 1
96final count: 1
97~~~~
98
99</fiddle-embed></div>
100
101### See Also
102
103<a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_save'>save</a> <a href='SkCanvas_Reference#SkCanvas'>SkCanvas</a>::<a href='#SkCanvas_restore'>restore</a>
104
105