skia2/site/user/api/SkAutoCanvasRestore_Reference.md
Cary Clark 777eede780 fix bookmaker
Remove references to old SkPaint::Hinting.

Also fix bug recently introduced that made
unlinkable words use the last link found.

TBR=reed@google.com

Docs-Preview: https://skia.org/?cl=170266
Bug: skia:
Change-Id: I8b83bcb479bd3f79699a1c74818a817190fd42a5
Reviewed-on: https://skia-review.googlesource.com/c/170266
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-11-09 21:33:54 +00:00

3.9 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 SkCanvas::save() count. Optionally saves SkCanvas clip and SkCanvas matrix.

Parameters

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

Return Value

utility to restore SkCanvas state on destructor

Example

See Also

SkCanvas::save SkCanvas::restore


~SkAutoCanvasRestore()

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

See Also

SkCanvas::save SkCanvas::restore


void restore()

Restores SkCanvas 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