skia2/site/user/api/SkAutoCanvasRestore_Reference.md
Hal Canary 2f0ca4dbf0 Docs: Update docs to point at named fiddles
for x in docs/examples/* ; do
      if grep -q '// Disabled' $x; then
        continue
      fi
      HASH=$(sed -n 's#^// HASH=\(.*\)$#\1#p' $x)
      NAME=$(sed -n 's#^REG_FIDDLE(\([^,]*\),.*$#\1#p' $x)
      FILES="$(grep -l $HASH site/user/api/*.md)"
      if [ "$FILES" ] ; then
        echo $HASH $NAME $FILES;
        sed -i "s/$HASH/@$NAME/g" $FILES
      fi
    done

https://skia.org/user/api/SkAutoCanvasRestore_Reference?cl=248158
https://skia.org/user/api/SkBitmap_Reference?cl=248158
https://skia.org/user/api/SkBlendMode_Reference?cl=248158
https://skia.org/user/api/SkCanvas_Reference?cl=248158
https://skia.org/user/api/SkColor4f_Reference?cl=248158
https://skia.org/user/api/SkColor_Reference?cl=248158
https://skia.org/user/api/SkFont_Reference?cl=248158
https://skia.org/user/api/SkIPoint_Reference?cl=248158
https://skia.org/user/api/SkIRect_Reference?cl=248158
https://skia.org/user/api/SkImageInfo_Reference?cl=248158
https://skia.org/user/api/SkImage_Reference?cl=248158
https://skia.org/user/api/SkMatrix_Reference?cl=248158
https://skia.org/user/api/SkPaint_Reference?cl=248158
https://skia.org/user/api/SkPath_Reference?cl=248158
https://skia.org/user/api/SkPicture_Reference?cl=248158
https://skia.org/user/api/SkPixmap_Reference?cl=248158
https://skia.org/user/api/SkPoint_Reference?cl=248158
https://skia.org/user/api/SkRRect_Reference?cl=248158
https://skia.org/user/api/SkRect_Reference?cl=248158
https://skia.org/user/api/SkRegion_Reference?cl=248158
https://skia.org/user/api/SkSurface_Reference?cl=248158
https://skia.org/user/api/SkTextBlobBuilder_Reference?cl=248158
https://skia.org/user/api/SkTextBlob_Reference?cl=248158

No-Try: true
Change-Id: I29ff57f3c1dd9f27f67be5511c942e7108908642
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248158
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner aka dogben <benjaminwagner@google.com>
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
2019-10-11 16:57:05 +00:00

3.8 KiB

SkAutoCanvasRestore Reference


class SkAutoCanvasRestore {

    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