2018-01-22 12:55:48 +00:00
SkAutoCanvasRestore Reference
===
2018-10-16 14:30:28 +00:00
2018-10-08 18:57:48 +00:00
< a name = 'SkAutoCanvasRestore' > < / a >
2018-10-16 14:30:28 +00:00
---
2018-10-08 18:57:48 +00:00
< pre style = "padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0 " >
2018-11-07 19:59:03 +00:00
class < a href = 'SkAutoCanvasRestore_Reference#SkAutoCanvasRestore' > SkAutoCanvasRestore< / a > {
2018-11-29 17:05:25 +00:00
< a href = '#SkAutoCanvasRestore_SkCanvas_star' > SkAutoCanvasRestore< / a > (< a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > * < a href = 'SkCanvas_Reference#Canvas' > canvas< / a > , bool doSave);
< a href = '#SkAutoCanvasRestore_destructor' > ~SkAutoCanvasRestore()< / a > ;
2018-11-09 21:04:58 +00:00
void < a href = '#SkAutoCanvasRestore_restore' > restore()< / a > ;
2018-10-08 18:57:48 +00:00
};
2018-11-29 17:05:25 +00:00
2018-10-08 18:57:48 +00:00
< / pre >
2018-01-22 12:55:48 +00:00
2018-11-09 21:04:58 +00:00
Stack helper class calls < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > ::< a href = '#SkCanvas_restoreToCount' > restoreToCount< / a > when < a href = 'SkAutoCanvasRestore_Reference#SkAutoCanvasRestore' > SkAutoCanvasRestore< / a >
goes out of scope. Use this to guarantee that the < a href = 'SkCanvas_Reference#Canvas' > canvas< / a > is restored to a known
state.
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_SkCanvas_star' > < / a >
2018-10-16 14:30:28 +00:00
---
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
2018-11-29 17:05:25 +00:00
< a href = '#SkAutoCanvasRestore_SkCanvas_star' > SkAutoCanvasRestore< / a > (< a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > * < a href = 'SkCanvas_Reference#Canvas' > canvas< / a > , bool doSave)
2018-01-22 12:55:48 +00:00
< / pre >
2018-11-09 21:04:58 +00:00
Preserves < 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 > .
2018-01-22 12:55:48 +00:00
### Parameters
2018-05-16 11:07:07 +00:00
< table > < tr > < td > < a name = 'SkAutoCanvasRestore_SkCanvas_star_canvas' > < code > < strong > canvas< / strong > < / code > < / a > < / td >
2018-11-09 21:04:58 +00:00
< td > < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > to guard< / td >
2018-05-16 11:07:07 +00:00
< / tr >
< tr > < td > < a name = 'SkAutoCanvasRestore_SkCanvas_star_doSave' > < code > < strong > doSave< / strong > < / code > < / a > < / td >
2018-11-07 19:59:03 +00:00
< td > call < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > ::< a href = '#SkCanvas_save' > save()< / a > < / td >
2018-01-22 12:55:48 +00:00
< / tr >
< / table >
### Return Value
2018-11-09 21:04:58 +00:00
utility to restore < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > state on destructor
2018-01-22 12:55:48 +00:00
### Example
< div > < fiddle-embed name = "466ef576b88e29d7252422db7adeed1c" > < / fiddle-embed > < / div >
### See Also
2018-11-07 19:59:03 +00:00
< 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 >
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_destructor' > < / a >
2018-10-16 14:30:28 +00:00
---
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
2018-11-29 17:05:25 +00:00
< a href = '#SkAutoCanvasRestore_destructor' > ~SkAutoCanvasRestore()< / a >
2018-01-22 12:55:48 +00:00
< / pre >
2018-11-09 21:04:58 +00:00
Restores < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > to saved state. Destructor is called when container goes out of
2018-01-22 12:55:48 +00:00
scope.
### See Also
2018-11-07 19:59:03 +00:00
< 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 >
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_restore' > < / a >
2018-10-16 14:30:28 +00:00
---
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
2018-11-07 19:59:03 +00:00
void < a href = '#SkAutoCanvasRestore_restore' > restore()< / a >
2018-01-22 12:55:48 +00:00
< / pre >
2018-11-09 21:04:58 +00:00
Restores < a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > to saved state immediately. Subsequent calls and
2018-11-29 17:05:25 +00:00
< a href = '#SkAutoCanvasRestore_destructor' > ~SkAutoCanvasRestore()< / a > have no effect.
2018-01-22 12:55:48 +00:00
### Example
< div > < fiddle-embed name = "9f459b218ec079c1ada23f4412968f9a" >
#### Example Output
~~~~
saveCanvas: false before restore: 2
saveCanvas: false after restore: 2
saveCanvas: true before restore: 2
saveCanvas: true after restore: 2
saveCanvas: false before restore: 2
saveCanvas: false after restore: 1
saveCanvas: true before restore: 2
saveCanvas: true after restore: 1
final count: 1
~~~~
< / fiddle-embed > < / div >
### See Also
2018-11-07 19:59:03 +00:00
< 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 >
2018-01-22 12:55:48 +00:00