skia2/site/user/api/SkAutoCanvasRestore_Reference.md
Cary Clark a90ea228ab streamline web documentation
This is the next step in reducing the amount of typing
in bookmaker, and presenting a web-base interface that
more closely matches the include documentation.

Moving towards making xxx_Reference solely contain
use documentation, and xxx_Overview (unpublished)
contain theory of operation documentation.

Fixed quite a few bugs along the way, and made
function and member documentation tighter.

TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=160640
Change-Id: I763df4d59baa5dfd0177f0523294b5316434c4b0
Reviewed-on: https://skia-review.googlesource.com/c/160640
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
2018-10-16 17:35:54 +00:00

3.4 KiB

SkAutoCanvasRestore Reference


class SkAutoCanvasRestore {
public:
    SkAutoCanvasRestore(SkCanvas* canvas, bool doSave);
    ~SkAutoCanvasRestore();
    void restore();
};

Stack helper class calls SkCanvas::restoreToCount when SkAutoCanvasRestore goes out of scope. Use this to guarantee that the canvas is restored to a known state.


SkAutoCanvasRestore(SkCanvas* canvas, bool doSave)

Preserves Canvas save count. Optionally saves Canvas Clip and Canvas Matrix.

Parameters

canvas Canvas to guard
doSave call SkCanvas::save()

Return Value

utility to restore Canvas state on destructor

Example

See Also

SkCanvas::save SkCanvas::restore


~SkAutoCanvasRestore()

Restores Canvas to saved state. Destructor is called when container goes out of scope.

See Also

SkCanvas::save SkCanvas::restore


void restore()

Restores Canvas to saved state immediately. Subsequent calls and ~SkAutoCanvasRestore have no effect.

Example

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

See Also

SkCanvas::save SkCanvas::restore