Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPicture Class Referenceabstract

An SkPicture records drawing commands made to a canvas to be played back at a later time. More...

#include <SkPicture.h>

Inheritance diagram for SkPicture:
SkRefCnt SkRefCntBase

Classes

class  AbortCallback
 Subclasses of this can be passed to playback(). More...
 
struct  DeletionMessage
 

Public Types

typedef bool(* InstallPixelRefProc )(const void *src, size_t length, SkBitmap *dst)
 Function signature defining a function that sets up an SkBitmap from encoded data. More...
 

Public Member Functions

virtual void playback (SkCanvas *, AbortCallback *=NULL) const =0
 Replays the drawing commands on the specified canvas. More...
 
virtual SkRect cullRect () const =0
 Return a cull rect for this picture. More...
 
uint32_t uniqueID () const
 Returns a non-zero value unique among all pictures. More...
 
sk_sp< SkDataserialize (SkPixelSerializer *=nullptr) const
 Serialize the picture to SkData. More...
 
void serialize (SkWStream *, SkPixelSerializer *=nullptr) const
 Serialize to a stream. More...
 
void flatten (SkWriteBuffer &) const
 Serialize to a buffer.
 
virtual bool willPlayBackBitmaps () const =0
 Returns true if any bitmaps may be produced when this SkPicture is replayed.
 
virtual int approximateOpCount () const =0
 Return the approximate number of operations in this picture. More...
 
virtual size_t approximateBytesUsed () const =0
 Returns the approximate byte size of this picture, not including large ref'd objects. More...
 
virtual const SkBigPicture * asSkBigPicture () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 Default construct, initializing the reference count to 1.
 
virtual ~SkRefCntBase ()
 Destruct, asserting that the reference count is 1.
 
int32_t getRefCnt () const
 Return the reference count. More...
 
void validate () const
 
bool unique () const
 May return true if the caller is the only owner. More...
 
void ref () const
 Increment the reference count. More...
 
void unref () const
 Decrement the reference count. More...
 

Static Public Member Functions

static sk_sp< SkPictureMakeFromStream (SkStream *, SkImageDeserializer *)
 Recreate a picture that was serialized into a stream. More...
 
static sk_sp< SkPictureMakeFromStream (SkStream *)
 
static sk_sp< SkPictureMakeFromData (const void *data, size_t size, SkImageDeserializer *=nullptr)
 
static sk_sp< SkPictureMakeFromData (const SkData *data, SkImageDeserializer *=nullptr)
 
static sk_sp< SkPictureMakeFromBuffer (SkReadBuffer &)
 Recreate a picture that was serialized into a buffer. More...
 
static bool InternalOnly_StreamIsSKP (SkStream *, SkPictInfo *)
 Return true if the SkStream/Buffer represents a serialized picture, and fills out SkPictInfo. More...
 
static bool InternalOnly_BufferIsSKP (SkReadBuffer *, SkPictInfo *)
 
static void SetPictureIOSecurityPrecautionsEnabled_Dangerous (bool set)
 
static bool PictureIOSecurityPrecautionsEnabled ()
 

Private Member Functions

void serialize (SkWStream *, SkPixelSerializer *, SkRefCntSet *typefaces) const
 
virtual int numSlowPaths () const =0
 
SkPictInfo createHeader () const
 
SkPictureData * backport () const
 

Static Private Member Functions

static sk_sp< SkPictureMakeFromStream (SkStream *, SkImageDeserializer *, SkTypefacePlayback *)
 
static bool IsValidPictInfo (const SkPictInfo &info)
 
static sk_sp< SkPictureForwardport (const SkPictInfo &, const SkPictureData *, SkReadBuffer *buffer)
 

Private Attributes

uint32_t fUniqueID
 

Static Private Attributes

static const uint32_t MIN_PICTURE_VERSION = 51
 
static const uint32_t CURRENT_PICTURE_VERSION = 55
 

Friends

class SkBigPicture
 
class SkEmptyPicture
 
template<typename >
class SkMiniPicture
 
class SkPictureData
 
class SkPictureGpuAnalyzer
 
struct SkPathCounter
 

Additional Inherited Members

- Protected Member Functions inherited from SkRefCntBase
void internal_dispose_restore_refcnt_to_1 () const
 Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called or if they choose not to call the destructor (e.g. More...
 

Detailed Description

An SkPicture records drawing commands made to a canvas to be played back at a later time.

This base class handles serialization and a few other miscellany.

Member Typedef Documentation

typedef bool(* SkPicture::InstallPixelRefProc)(const void *src, size_t length, SkBitmap *dst)

Function signature defining a function that sets up an SkBitmap from encoded data.

On success, the SkBitmap should have its Config, width, height, rowBytes and pixelref set. If the installed pixelref has decoded the data into pixels, then the src buffer need not be copied. If the pixelref defers the actual decode until its lockPixels() is called, then it must make a copy of the src buffer.

Parameters
srcEncoded data.
lengthSize of the encoded data, in bytes.
dstSkBitmap to install the pixel ref on.
boolWhether or not a pixel ref was successfully installed.

Member Function Documentation

virtual size_t SkPicture::approximateBytesUsed ( ) const
pure virtual

Returns the approximate byte size of this picture, not including large ref'd objects.

virtual int SkPicture::approximateOpCount ( ) const
pure virtual

Return the approximate number of operations in this picture.

This number may be greater or less than the number of SkCanvas calls recorded: some calls may be recorded as more than one operation, or some calls may be optimized away.

virtual SkRect SkPicture::cullRect ( ) const
pure virtual

Return a cull rect for this picture.

Ops recorded into this picture that attempt to draw outside the cull might not be drawn.

static bool SkPicture::InternalOnly_StreamIsSKP ( SkStream ,
SkPictInfo *   
)
static

Return true if the SkStream/Buffer represents a serialized picture, and fills out SkPictInfo.

After this function returns, the data source is not rewound so it will have to be manually reset before passing to CreateFromStream or CreateFromBuffer. Note, CreateFromStream and CreateFromBuffer perform this check internally so these entry points are intended for stand alone tools. If false is returned, SkPictInfo is unmodified.

static sk_sp<SkPicture> SkPicture::MakeFromBuffer ( SkReadBuffer &  )
static

Recreate a picture that was serialized into a buffer.

If the creation requires bitmap decoding, the decoder must be set on the SkReadBuffer parameter by calling SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer().

Parameters
SkReadBufferSerialized picture data.
Returns
A new SkPicture representing the serialized data, or NULL if the buffer is invalid.
static sk_sp<SkPicture> SkPicture::MakeFromStream ( SkStream ,
SkImageDeserializer  
)
static

Recreate a picture that was serialized into a stream.

Any serialized images in the stream will be passed the image-deserializer, or if that is null, to the default deserializer that will call SkImage::MakeFromEncoded().

virtual void SkPicture::playback ( SkCanvas ,
AbortCallback = NULL 
) const
pure virtual

Replays the drawing commands on the specified canvas.

Note that this has the effect of unfurling this picture into the destination canvas. Using the SkCanvas::drawPicture entry point gives the destination canvas the option of just taking a ref.

Parameters
canvasthe canvas receiving the drawing commands.
callbacka callback that allows interruption of playback
sk_sp<SkData> SkPicture::serialize ( SkPixelSerializer = nullptr) const

Serialize the picture to SkData.

If non nullptr, pixel-serializer will be used to customize how images reference by the picture are serialized/compressed.

void SkPicture::serialize ( SkWStream ,
SkPixelSerializer = nullptr 
) const

Serialize to a stream.

If non nullptr, pixel-serializer will be used to customize how images reference by the picture are serialized/compressed.

uint32_t SkPicture::uniqueID ( ) const

Returns a non-zero value unique among all pictures.


The documentation for this class was generated from the following file: