Picture records drawing commands made to Canvas. The command stream may be played in whole or in part at a later time.
Picture is an abstract class. Picture may be generated by Picture Recorder or Drawable, or from Picture previously saved to Data or Stream.
Picture may contain any Canvas drawing command, as well as one or more Canvas Matrix or Canvas Clip. Picture has a cull Rect, which is used as a bounding box hint. To limit Picture bounds, use Canvas Clip when recording or drawing Picture.
AbortCallback is an abstract class. An implementation of AbortCallback may passed as a parameter to SkPicture::playback, to stop it before all drawing commands have been processed.
If AbortCallback::abort returns true, SkPicture::playback is interrupted.
Has no effect.
abstract class cannot be instantiated
playback
Has no effect.
playback
Stops Picture playback when some condition is met. A subclass of AbortCallback provides an override for abort() that can stop SkPicture::playback.
The part of Picture drawn when aborted is undefined. Picture instantiations are free to stop drawing at different points during playback.
If the abort happens inside one or more calls to SkCanvas::save(), stack of Canvas Matrix and Canvas Clip values is restored to its state before SkPicture::playback was called.
true to stop playback
playback
Recreates Picture that was serialized into a stream. Returns constructed Picture if successful; otherwise, returns nullptr. Fails if data does not permit constructing valid Picture.
procs.fPictureProc permits supplying a custom function to decode Picture. If procs.fPictureProc is nullptr, default decoding is used. procs.fPictureCtx may be used to provide user context to procs.fPictureProc; procs.fPictureProc is called with a pointer to data, data byte length, and user context.
Picture constructed from stream data
MakeFromData[2] SkPictureRecorder
Recreates Picture that was serialized into data. Returns constructed Picture if successful; otherwise, returns nullptr. Fails if data does not permit constructing valid Picture.
procs.fPictureProc permits supplying a custom function to decode Picture. If procs.fPictureProc is nullptr, default decoding is used. procs.fPictureCtx may be used to provide user context to procs.fPictureProc; procs.fPictureProc is called with a pointer to data, data byte length, and user context.
Picture constructed from data
MakeFromStream SkPictureRecorder
procs.fPictureProc permits supplying a custom function to decode Picture. If procs.fPictureProc is nullptr, default decoding is used. procs.fPictureCtx may be used to provide user context to procs.fPictureProc; procs.fPictureProc is called with a pointer to data, data byte length, and user context.
Picture constructed from data
MakeFromStream SkPictureRecorder
Replays the drawing commands on the specified canvas. In the case that the commands are recorded, each command in the Picture is sent separately to canvas.
To add a single command to draw Picture to recording canvas, call SkCanvas::drawPicture instead.
SkCanvas::drawPicture[2][3][4]
Returns cull Rect for this picture, passed in when Picture was created. Returned Rect does not specify clipping Rect for Picture; cull is hint of Picture bounds.
Picture is free to discard recorded drawing commands that fall outside cull.
bounds passed when Picture was created
SkCanvas::clipRect[2][3]
Returns a non-zero value unique among Pictures in Skia process.
identifier for Picture
empty picture id = 1 placeholder id = 2
SkRefCnt
Returns storage containing Data describing Picture, using optional custom encoders.
procs.fPictureProc permits supplying a custom function to encode Picture. If procs.fPictureProc is nullptr, default encoding is used. procs.fPictureCtx may be used to provide user context to procs.fPictureProc; procs.fPictureProc is called with a pointer to Picture and user context.
storage containing serialized Picture
MakeFromData[2] SkData SkSerialProcs
Writes picture to stream, using optional custom encoders.
procs.fPictureProc permits supplying a custom function to encode Picture. If procs.fPictureProc is nullptr, default encoding is used. procs.fPictureCtx may be used to provide user context to procs.fPictureProc; procs.fPictureProc is called with a pointer to Picture and user context.
MakeFromStream SkWStream SkSerialProcs
Returns a placeholder SkPicture. Result does not draw, and contains only cull Rect, a hint of its bounds. Result is immutable; it cannot be changed later. Result identifier is unique.
Returned placeholder can be intercepted during playback to insert other commands into Canvas draw stream.
placeholder with unique identifier
MakeFromStream MakeFromData[2] uniqueID
Returns the approximate number of operations in Picture. Returned value may be greater or less than the number of SkCanvas calls recorded: some calls may be recorded as more than one operation, other calls may be optimized away.
approximate operation count
approximateBytesUsed
Returns the approximate byte size of Picture. Does not include large objects referenced by Picture.
approximate size
approximateOpCount