skia2/docs/SkAutoCanvasRestore_Reference.bmh
Cary Clark 08895c4814 auto table generation
Replace manually entered summary tables with ones that are populated
and sorted by bookmaker. This introduces a slight regression for
anonymous enums but fixes a lot of bugs and omissions.

The format is

#Topic somethingTopical
#Populate
##

where somethingTopical is one of Subtopics, Constructors, Constants,
Classes_and_Structs, Members, Member_Functions, and Related_Functions.

Fix the bad formatting in SkCanvas reference. The #Error tag was
was corrupting the markdown table. Remove the tag and replace it
with #NoExample.

Next up: revise self-check to know about populated topics.

TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=102080
Bug: skia:6898
Change-Id: Idef5d1c14c740c18a81d6a5106182788dd2a09e1
Reviewed-on: https://skia-review.googlesource.com/102080
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-02-01 15:09:17 +00:00

106 lines
2.5 KiB
Plaintext

#Topic Automatic_Canvas_Restore
#Subtopic Overview
#Subtopic Subtopics
#Populate
##
##
#Class SkAutoCanvasRestore
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.
#Subtopic Constructors
#Populate
##
#Subtopic Member_Functions
#Populate
##
#Method SkAutoCanvasRestore(SkCanvas* canvas, bool doSave)
#Line # preserves Canvas save count ##
Preserves Canvas save count. Optionally saves Canvas_Clip and Canvas_Matrix.
#Param canvas Canvas to guard ##
#Param doSave call SkCanvas::save() ##
#Return utility to restore Canvas state on destructor ##
#Example
#Height 128
SkPaint p;
p.setAntiAlias(true);
p.setTextSize(64);
for (SkScalar sx : { -1, 1 } ) {
for (SkScalar sy : { -1, 1 } ) {
SkAutoCanvasRestore autoRestore(canvas, true);
SkMatrix m = SkMatrix::MakeAll(sx, 1, 96, 0, sy, 64, 0, 0, 1);
canvas->concat(m);
canvas->drawString("R", 0, 0, p);
}
}
##
#SeeAlso SkCanvas::save SkCanvas::restore
##
#Method ~SkAutoCanvasRestore()
#Line # restores Canvas to saved state ##
Restores Canvas to saved state. Destructor is called when container goes out of
scope.
#NoExample
##
#SeeAlso SkCanvas::save SkCanvas::restore
##
#Method void restore()
#Line # restores Canvas to saved state ##
Restores Canvas to saved state immediately. Subsequent calls and
~SkAutoCanvasRestore have no effect.
#Example
for (bool callRestore : { false, true } ) {
for (bool saveCanvas : {false, true} ) {
SkAutoCanvasRestore autoRestore(canvas, saveCanvas);
if (!saveCanvas) {
canvas->save();
}
SkDebugf("saveCanvas: %s before restore: %d\n",
saveCanvas ? "true" : "false", canvas->getSaveCount());
if (callRestore) autoRestore.restore();
SkDebugf("saveCanvas: %s after restore: %d\n",
saveCanvas ? "true" : "false", canvas->getSaveCount());
}
}
SkDebugf("final count: %d\n", canvas->getSaveCount());
#StdOut
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
##
##
#SeeAlso SkCanvas::save SkCanvas::restore
##
#Class SkAutoCanvasRestore ##
#Topic Automatic_Canvas_Restore ##