2018-01-22 12:55:48 +00:00
|
|
|
#Topic Automatic_Canvas_Restore
|
|
|
|
|
2018-02-01 14:37:32 +00:00
|
|
|
#Subtopic Overview
|
2018-02-06 14:41:53 +00:00
|
|
|
#Subtopic Subtopic
|
2018-02-01 14:37:32 +00:00
|
|
|
#Populate
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2018-01-22 12:55:48 +00:00
|
|
|
#Class SkAutoCanvasRestore
|
|
|
|
|
2018-04-03 12:43:27 +00:00
|
|
|
Stack helper class calls SkCanvas::restoreToCount when SkAutoCanvasRestore
|
2018-01-22 12:55:48 +00:00
|
|
|
goes out of scope. Use this to guarantee that the canvas is restored to a known
|
|
|
|
state.
|
|
|
|
|
2018-02-06 14:41:53 +00:00
|
|
|
#Subtopic Constructor
|
2018-02-01 14:37:32 +00:00
|
|
|
#Populate
|
|
|
|
##
|
2018-01-22 12:55:48 +00:00
|
|
|
|
2018-02-06 14:41:53 +00:00
|
|
|
#Subtopic Member_Function
|
2018-02-01 14:37:32 +00:00
|
|
|
#Populate
|
|
|
|
##
|
2018-01-22 12:55:48 +00:00
|
|
|
|
|
|
|
#Method SkAutoCanvasRestore(SkCanvas* canvas, bool doSave)
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # preserves Canvas save count ##
|
2018-01-22 12:55:48 +00:00
|
|
|
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()
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # restores Canvas to saved state ##
|
2018-01-22 12:55:48 +00:00
|
|
|
Restores Canvas to saved state. Destructor is called when container goes out of
|
|
|
|
scope.
|
|
|
|
|
|
|
|
#NoExample
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkCanvas::save SkCanvas::restore
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Method void restore()
|
2018-02-07 12:27:09 +00:00
|
|
|
#In Member_Function
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # restores Canvas to saved state ##
|
2018-01-22 12:55:48 +00:00
|
|
|
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 ##
|