Skia
2D Graphics Library
|
Base-class for objects that draw into SkCanvas. More...
#include <SkDrawable.h>
Classes | |
class | GpuDrawHandler |
When using the GPU backend it is possible for a drawable to execute using the underlying 3D API rather than the SkCanvas API. More... | |
Public Types | |
enum | Type { kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type , kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type } |
typedef sk_sp< SkFlattenable >(* | Factory) (SkReadBuffer &) |
Public Member Functions | |
void | draw (SkCanvas *, const SkMatrix *=nullptr) |
Draws into the specified content. More... | |
void | draw (SkCanvas *, SkScalar x, SkScalar y) |
std::unique_ptr< GpuDrawHandler > | snapGpuDrawHandler (GrBackendApi backendApi, const SkMatrix &matrix, const SkIRect &clipBounds, const SkImageInfo &bufferInfo) |
Snaps off a GpuDrawHandler to represent the state of the SkDrawable at the time the snap is called. More... | |
sk_sp< SkPicture > | makePictureSnapshot () |
Returns an SkPicture with the contents of this SkDrawable. More... | |
uint32_t | getGenerationID () |
Return a unique value for this instance. More... | |
SkRect | getBounds () |
Return the (conservative) bounds of what the drawable will draw. More... | |
size_t | approximateBytesUsed () |
Return approximately how many bytes would be freed if this drawable is destroyed. More... | |
void | notifyDrawingChanged () |
Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationID() is called. More... | |
SkFlattenable::Type | getFlattenableType () const override |
Factory | getFactory () const override |
Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten(). More... | |
const char * | getTypeName () const override |
Returns the name of the object's class. More... | |
virtual void | flatten (SkWriteBuffer &) const |
Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()). More... | |
sk_sp< SkData > | serialize (const SkSerialProcs *=nullptr) const |
size_t | serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) 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 SkFlattenable::Type | GetFlattenableType () |
static sk_sp< SkDrawable > | Deserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr) |
static Factory | NameToFactory (const char name[]) |
static const char * | FactoryToName (Factory) |
static void | Register (const char name[], Factory) |
static sk_sp< SkFlattenable > | Deserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr) |
Protected Member Functions | |
SkDrawable () | |
virtual SkRect | onGetBounds ()=0 |
virtual size_t | onApproximateBytesUsed () |
virtual void | onDraw (SkCanvas *)=0 |
virtual std::unique_ptr< GpuDrawHandler > | onSnapGpuDrawHandler (GrBackendApi, const SkMatrix &, const SkIRect &, const SkImageInfo &) |
virtual std::unique_ptr< GpuDrawHandler > | onSnapGpuDrawHandler (GrBackendApi, const SkMatrix &) |
virtual sk_sp< SkPicture > | onMakePictureSnapshot () |
Default implementation calls onDraw() with a canvas that records into a picture. More... | |
Base-class for objects that draw into SkCanvas.
The object has a generation ID, which is guaranteed to be unique across all drawables. To allow for clients of the drawable that may want to cache the results, the drawable must change its generation ID whenever its internal state changes such that it will draw differently.
|
inherited |
|
inherited |
|
protected |
size_t SkDrawable::approximateBytesUsed | ( | ) |
Return approximately how many bytes would be freed if this drawable is destroyed.
The base implementation returns 0 to indicate that this is unknown.
|
inlinestatic |
|
staticinherited |
Draws into the specified content.
The drawing sequence will be balanced upon return (i.e. the saveLevel() on the canvas will match what it was when draw() was called, and the current matrix and clip settings will not be changed.
|
staticinherited |
|
inlinevirtualinherited |
Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).
DEPRECATED public : will move to protected ... use serialize() instead
Reimplemented in SkLayerDrawLooper.
SkRect SkDrawable::getBounds | ( | ) |
Return the (conservative) bounds of what the drawable will draw.
If the drawable can change what it draws (e.g. animation or in response to some external change), then this must return a bounds that is always valid for all possible states.
|
inlineoverridevirtual |
Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten().
Implements SkFlattenable.
|
inlinestatic |
|
inlineoverridevirtual |
Implements SkFlattenable.
uint32_t SkDrawable::getGenerationID | ( | ) |
Return a unique value for this instance.
If two calls to this return the same value, it is presumed that calling the draw() method will render the same thing as well.
Subclasses that change their state should call notifyDrawingChanged() to ensure that a new value will be returned the next time it is called.
|
inlineoverridevirtual |
Returns the name of the object's class.
Implements SkFlattenable.
Returns an SkPicture with the contents of this SkDrawable.
|
staticinherited |
void SkDrawable::notifyDrawingChanged | ( | ) |
Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationID() is called.
Typically this is called by the object itself, in response to its internal state changing.
|
protectedvirtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineinherited |
Increment the reference count.
Must be balanced by a call to unref().
|
staticinherited |
|
inherited |
|
inherited |
|
inline |
Snaps off a GpuDrawHandler to represent the state of the SkDrawable at the time the snap is called.
This is used for executing GPU backend specific draws intermixed with normal Skia GPU draws. The GPU API, which will be used for the draw, as well as the full matrix, device clip bounds and imageInfo of the target buffer are passed in as inputs.
|
inlineinherited |
May return true if the caller is the only owner.
Ensures that all previous owner's actions are complete.
|
inlineinherited |
Decrement the reference count.
If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.