Skia
2D Graphics Library
SkImageGenerator Class Reference

#include <SkImageGenerator.h>

Classes

struct  Options
 

Public Member Functions

virtual ~SkImageGenerator ()
 The PixelRef which takes ownership of this SkImageGenerator will call the image generator's destructor. More...
 
uint32_t uniqueID () const
 
sk_sp< SkDatarefEncodedData ()
 Return a ref to the encoded (i.e. More...
 
const SkImageInfogetInfo () const
 Return the ImageInfo associated with this generator. More...
 
bool isValid (GrRecordingContext *context) const
 Can this generator be used to produce images that will be drawable to the specified context (or to CPU, if context is nullptr)? More...
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 Decode into the given pixels, a block of memory of size at least (info.fHeight - 1) * rowBytes + (info.fWidth * bytesPerPixel) More...
 
bool getPixels (const SkPixmap &pm)
 
bool queryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmapInfo *yuvaPixmapInfo) const
 If decoding to YUV is supported, this returns true. More...
 
bool getYUVAPlanes (const SkYUVAPixmaps &yuvaPixmaps)
 Returns true on success and false on failure. More...
 

Static Public Member Functions

static std::unique_ptr< SkImageGeneratorMakeFromEncoded (sk_sp< SkData >)
 If the default image decoder system can interpret the specified (encoded) data, then this returns a new ImageGenerator for it. More...
 
static std::unique_ptr< SkImageGeneratorMakeFromPicture (const SkISize &, sk_sp< SkPicture >, const SkMatrix *, const SkPaint *, SkImage::BitDepth, sk_sp< SkColorSpace >)
 Return a new image generator backed by the specified picture. More...
 

Protected Member Functions

 SkImageGenerator (const SkImageInfo &info, uint32_t uniqueId=kNeedNewImageUniqueID)
 
virtual sk_sp< SkDataonRefEncodedData ()
 
virtual bool onGetPixels (const SkImageInfo &, void *, size_t, const Options &)
 
virtual bool onIsValid (GrRecordingContext *) const
 
virtual bool onQueryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
 
virtual bool onGetYUVAPlanes (const SkYUVAPixmaps &)
 

Static Protected Attributes

static constexpr int kNeedNewImageUniqueID = 0
 

Friends

class SkImage_Lazy
 

Constructor & Destructor Documentation

◆ ~SkImageGenerator()

virtual SkImageGenerator::~SkImageGenerator ( )
inlinevirtual

The PixelRef which takes ownership of this SkImageGenerator will call the image generator's destructor.

◆ SkImageGenerator()

SkImageGenerator::SkImageGenerator ( const SkImageInfo info,
uint32_t  uniqueId = kNeedNewImageUniqueID 
)
protected

Member Function Documentation

◆ getInfo()

const SkImageInfo& SkImageGenerator::getInfo ( ) const
inline

Return the ImageInfo associated with this generator.

◆ getPixels() [1/2]

bool SkImageGenerator::getPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes 
)

Decode into the given pixels, a block of memory of size at least (info.fHeight - 1) * rowBytes + (info.fWidth * bytesPerPixel)

Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.

Parameters
infoA description of the format expected by the caller. This can simply be identical to the info returned by getInfo().

This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.

A size that does not match getInfo() implies a request to scale. If the generator cannot perform this scale, it will return false.

Returns
true on success.

◆ getPixels() [2/2]

bool SkImageGenerator::getPixels ( const SkPixmap pm)
inline

◆ getYUVAPlanes()

bool SkImageGenerator::getYUVAPlanes ( const SkYUVAPixmaps yuvaPixmaps)

Returns true on success and false on failure.

This always attempts to perform a full decode. To get the planar configuration without decoding use queryYUVAInfo().

Parameters
yuvaPixmapsContains preallocated pixmaps configured according to a successful call to queryYUVAInfo().

◆ isValid()

bool SkImageGenerator::isValid ( GrRecordingContext context) const
inline

Can this generator be used to produce images that will be drawable to the specified context (or to CPU, if context is nullptr)?

◆ MakeFromEncoded()

static std::unique_ptr<SkImageGenerator> SkImageGenerator::MakeFromEncoded ( sk_sp< SkData )
static

If the default image decoder system can interpret the specified (encoded) data, then this returns a new ImageGenerator for it.

Otherwise this returns NULL. Either way the caller is still responsible for managing their ownership of the data.

◆ MakeFromPicture()

static std::unique_ptr<SkImageGenerator> SkImageGenerator::MakeFromPicture ( const SkISize ,
sk_sp< SkPicture ,
const SkMatrix ,
const SkPaint ,
SkImage::BitDepth  ,
sk_sp< SkColorSpace  
)
static

Return a new image generator backed by the specified picture.

If the size is empty or the picture is NULL, this returns NULL. The optional matrix and paint arguments are passed to drawPicture() at rasterization time.

◆ onGetPixels()

virtual bool SkImageGenerator::onGetPixels ( const SkImageInfo ,
void *  ,
size_t  ,
const Options  
)
inlineprotectedvirtual

◆ onGetYUVAPlanes()

virtual bool SkImageGenerator::onGetYUVAPlanes ( const SkYUVAPixmaps )
inlineprotectedvirtual

◆ onIsValid()

virtual bool SkImageGenerator::onIsValid ( GrRecordingContext ) const
inlineprotectedvirtual

◆ onQueryYUVAInfo()

virtual bool SkImageGenerator::onQueryYUVAInfo ( const SkYUVAPixmapInfo::SupportedDataTypes ,
SkYUVAPixmapInfo  
) const
inlineprotectedvirtual

◆ onRefEncodedData()

virtual sk_sp<SkData> SkImageGenerator::onRefEncodedData ( )
inlineprotectedvirtual

◆ queryYUVAInfo()

bool SkImageGenerator::queryYUVAInfo ( const SkYUVAPixmapInfo::SupportedDataTypes supportedDataTypes,
SkYUVAPixmapInfo yuvaPixmapInfo 
) const

If decoding to YUV is supported, this returns true.

Otherwise, this returns false and the caller will ignore output parameter yuvaPixmapInfo.

Parameters
supportedDataTypesIndicates the data type/planar config combinations that are supported by the caller. If the generator supports decoding to YUV(A), but not as a type in supportedDataTypes, this method returns false.
yuvaPixmapInfoOutput parameter that specifies the planar configuration, subsampling, orientation, chroma siting, plane color types, and row bytes.

◆ refEncodedData()

sk_sp<SkData> SkImageGenerator::refEncodedData ( )
inline

Return a ref to the encoded (i.e.

compressed) representation of this data.

If non-NULL is returned, the caller is responsible for calling unref() on the data when it is finished.

◆ uniqueID()

uint32_t SkImageGenerator::uniqueID ( ) const
inline

Friends And Related Function Documentation

◆ SkImage_Lazy

friend class SkImage_Lazy
friend

Member Data Documentation

◆ kNeedNewImageUniqueID

constexpr int SkImageGenerator::kNeedNewImageUniqueID = 0
staticconstexprprotected

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