2018-01-22 12:55:48 +00:00
SkAutoCanvasRestore Reference
===
2018-05-16 11:07:07 +00:00
# <a name='Automatic_Canvas_Restore'>Automatic Canvas Restore</a>
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
# <a name='SkAutoCanvasRestore'>Class SkAutoCanvasRestore</a>
Stack helper class calls < a href = 'SkCanvas_Reference#SkCanvas_restoreToCount' > SkCanvas::restoreToCount< / a > when < a href = '#SkAutoCanvasRestore' > SkAutoCanvasRestore< / a >
goes out of scope. Use this to guarantee that the canvas is restored to a known
state.
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
## Overview
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< table style = 'border-collapse: collapse; width: 62.5em' >
< tr >< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Topic</ th >
< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Description</ th ></ tr >
< tr style = 'background-color: #f0f0f0 ; ' >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' >< a href = '#Constructor' > Constructors</ a ></ td >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > functions that construct < a href = '#SkAutoCanvasRestore' > SkAutoCanvasRestore</ a ></ td >
< / tr >
< tr >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' >< a href = '#Member_Function' > Functions</ a ></ td >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > global and class member functions</ td >
< / tr >
< / table >
2018-02-01 14:37:32 +00:00
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
## <a name='Constructor'>Constructor</a>
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
SkAutoCanvasRestore can be constructed or initialized by these functions, including C++ class constructors.
< table style = 'border-collapse: collapse; width: 62.5em' >
< tr >< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Topic</ th >
< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Description</ th ></ tr >
< tr style = 'background-color: #f0f0f0 ; ' >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' >< a href = '#SkAutoCanvasRestore_SkCanvas_star' > SkAutoCanvasRestore(SkCanvas* canvas, bool doSave)</ a ></ td >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > preserves < a href = 'SkCanvas_Reference#Canvas' > Canvas</ a > save count</ td >
< / tr >
< tr >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' >< a href = '#SkAutoCanvasRestore_destructor' > ~SkAutoCanvasRestore()</ a ></ td >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > restores < a href = 'SkCanvas_Reference#Canvas' > Canvas</ a > to saved state</ td >
< / tr >
< / table >
## <a name='Member_Function'>Member Function</a>
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
SkAutoCanvasRestore member functions read and modify the structure properties.
< table style = 'border-collapse: collapse; width: 62.5em' >
< tr >< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Topic</ th >
< th style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > Description</ th ></ tr >
< tr style = 'background-color: #f0f0f0 ; ' >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' >< a href = '#SkAutoCanvasRestore_restore' > restore</ a ></ td >
< td style = 'text-align: left; border: 2px solid #dddddd ; padding: 8px; ' > restores < a href = 'SkCanvas_Reference#Canvas' > Canvas</ a > to saved state</ td >
< / tr >
< / table >
2018-01-22 12:55:48 +00:00
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_SkCanvas_star' > < / a >
2018-01-22 12:55:48 +00:00
## SkAutoCanvasRestore
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
< a href = '#SkAutoCanvasRestore' > SkAutoCanvasRestore< / a > (< a href = 'SkCanvas_Reference#SkCanvas' > SkCanvas< / a > * canvas, bool doSave)
2018-01-22 12:55:48 +00:00
< / pre >
2018-05-16 11:07:07 +00:00
Preserves < a href = 'SkCanvas_Reference#Canvas' > Canvas< / a > save count. Optionally saves < a href = 'SkCanvas_Reference#Clip' > Canvas Clip< / a > and < a href = 'SkCanvas_Reference#Matrix' > Canvas 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 >
< td > < a href = 'SkCanvas_Reference#Canvas' > Canvas< / a > to guard< / td >
< / tr >
< tr > < td > < a name = 'SkAutoCanvasRestore_SkCanvas_star_doSave' > < code > < strong > doSave< / strong > < / code > < / a > < / td >
< td > call < a href = 'SkCanvas_Reference#SkCanvas_save' > SkCanvas::save()< / a > < / td >
2018-01-22 12:55:48 +00:00
< / tr >
< / table >
### Return Value
2018-05-16 11:07:07 +00:00
utility to restore < a href = 'SkCanvas_Reference#Canvas' > Canvas< / a > state on destructor
2018-01-22 12:55:48 +00:00
### Example
< div > < fiddle-embed name = "466ef576b88e29d7252422db7adeed1c" > < / fiddle-embed > < / div >
### See Also
2018-05-16 11:07:07 +00:00
< a href = 'SkCanvas_Reference#SkCanvas_save' > SkCanvas::save< / a > < a href = 'SkCanvas_Reference#SkCanvas_restore' > SkCanvas::restore< / a >
2018-01-22 12:55:48 +00:00
---
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_destructor' > < / a >
2018-01-22 12:55:48 +00:00
## ~SkAutoCanvasRestore
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
< a href = '#SkAutoCanvasRestore_destructor' > ~SkAutoCanvasRestore< / a > ()
2018-01-22 12:55:48 +00:00
< / pre >
2018-05-30 13:21:49 +00:00
Restores < a href = 'SkCanvas_Reference#Canvas' > Canvas< / a > to saved state. < a href = 'undocumented#Destructor' > Destructor< / a > is called when container goes out of
2018-01-22 12:55:48 +00:00
scope.
### See Also
2018-05-16 11:07:07 +00:00
< a href = 'SkCanvas_Reference#SkCanvas_save' > SkCanvas::save< / a > < a href = 'SkCanvas_Reference#SkCanvas_restore' > SkCanvas::restore< / a >
2018-01-22 12:55:48 +00:00
---
2018-05-16 11:07:07 +00:00
< a name = 'SkAutoCanvasRestore_restore' > < / a >
2018-01-22 12:55:48 +00:00
## restore
2018-05-16 11:07:07 +00:00
< pre style = "padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0 " >
void < a href = '#SkAutoCanvasRestore_restore' > restore< / a > ()
2018-01-22 12:55:48 +00:00
< / pre >
2018-05-16 11:07:07 +00:00
Restores < a href = 'SkCanvas_Reference#Canvas' > Canvas< / a > to saved state immediately. Subsequent calls and
< 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-05-16 11:07:07 +00:00
< a href = 'SkCanvas_Reference#SkCanvas_save' > SkCanvas::save< / a > < a href = 'SkCanvas_Reference#SkCanvas_restore' > SkCanvas::restore< / a >
2018-01-22 12:55:48 +00:00
---