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
2019-10-11 15:46:30 +00:00
< div > < fiddle-embed name = "@AutoCanvasRestore_SkCanvas_star" > < / fiddle-embed > < / div >
2018-01-22 12:55:48 +00:00
### 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
2019-10-11 15:46:30 +00:00
< div > < fiddle-embed name = "@AutoCanvasRestore_restore" >
2018-01-22 12:55:48 +00:00
#### 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