Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
SkImageGenerator Class Reference

#include <SkImageGenerator.h>

Inheritance diagram for SkImageGenerator:
EmptyGenerator GrTextureGenerator MyImageGenerator RasterGenerator SkCodecImageGenerator SkPictureImageGenerator TestImageGenerator GrAHardwareBufferImageGenerator GrBackendTextureImageGenerator GrExternalTextureGenerator TextureGenerator TextureSourceImageGenerator

Classes

struct  Options
 

Public Member Functions

virtual ~SkImageGenerator ()
 
uint32_t uniqueID () const
 
sk_sp< SkDatarefEncodedData ()
 
const SkImageInfogetInfo () const
 
bool isValid (GrRecordingContext *context) const
 
bool isProtected () const
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
bool getPixels (const SkPixmap &pm)
 
bool queryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmapInfo *yuvaPixmapInfo) const
 
bool getYUVAPlanes (const SkYUVAPixmaps &yuvaPixmaps)
 
virtual bool isTextureGenerator () const
 

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 onIsProtected () const
 
virtual bool onQueryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
 
virtual bool onGetYUVAPlanes (const SkYUVAPixmaps &)
 

Protected Attributes

const SkImageInfo fInfo
 

Static Protected Attributes

static constexpr int kNeedNewImageUniqueID = 0
 

Detailed Description

Definition at line 28 of file SkImageGenerator.h.

Constructor & Destructor Documentation

◆ ~SkImageGenerator()

virtual SkImageGenerator::~SkImageGenerator ( )
inlinevirtual

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

Definition at line 34 of file SkImageGenerator.h.

34{ }

◆ SkImageGenerator()

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

Definition at line 14 of file SkImageGenerator.cpp.

15 : fInfo(info)
17{}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static constexpr int kNeedNewImageUniqueID
const SkImageInfo fInfo
uint32_t uniqueID() const
static uint32_t ImageID()

Member Function Documentation

◆ getInfo()

const SkImageInfo & SkImageGenerator::getInfo ( ) const
inline

Return the ImageInfo associated with this generator.

Definition at line 52 of file SkImageGenerator.h.

52{ return fInfo; }

◆ 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.

Definition at line 19 of file SkImageGenerator.cpp.

19 {
20 if (kUnknown_SkColorType == info.colorType()) {
21 return false;
22 }
23 if (nullptr == pixels) {
24 return false;
25 }
26 if (rowBytes < info.minRowBytes()) {
27 return false;
28 }
29
30 Options defaultOpts;
31 return this->onGetPixels(info, pixels, rowBytes, defaultOpts);
32}
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
virtual bool onGetPixels(const SkImageInfo &, void *, size_t, const Options &)

◆ getPixels() [2/2]

bool SkImageGenerator::getPixels ( const SkPixmap pm)
inline

Definition at line 93 of file SkImageGenerator.h.

93 {
94 return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes());
95 }
bool getPixels(const SkImageInfo &info, void *pixels, size_t rowBytes)
size_t rowBytes() const
Definition SkPixmap.h:145
const SkImageInfo & info() const
Definition SkPixmap.h:135
void * writable_addr() const
Definition SkPixmap.h:483

◆ 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().

Definition at line 42 of file SkImageGenerator.cpp.

42 {
43 return this->onGetYUVAPlanes(yuvaPixmaps);
44}
virtual bool onGetYUVAPlanes(const SkYUVAPixmaps &)

◆ isProtected()

bool SkImageGenerator::isProtected ( ) const
inline

Will this generator produce protected content

Definition at line 65 of file SkImageGenerator.h.

65 {
66 return this->onIsProtected();
67 }
virtual bool onIsProtected() const

◆ isTextureGenerator()

virtual bool SkImageGenerator::isTextureGenerator ( ) const
inlinevirtual

Reimplemented in GrTextureGenerator.

Definition at line 121 of file SkImageGenerator.h.

121{ return false; }

◆ 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)?

Definition at line 58 of file SkImageGenerator.h.

58 {
59 return this->onIsValid(context);
60 }
virtual bool onIsValid(GrRecordingContext *) const

◆ onGetPixels()

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

Reimplemented in SkPictureImageGenerator, RasterGenerator, TestImageGenerator, and SkCodecImageGenerator.

Definition at line 130 of file SkImageGenerator.h.

130{ return false; }

◆ onGetYUVAPlanes()

virtual bool SkImageGenerator::onGetYUVAPlanes ( const SkYUVAPixmaps )
inlineprotectedvirtual

Reimplemented in SkCodecImageGenerator.

Definition at line 135 of file SkImageGenerator.h.

135{ return false; }

◆ onIsProtected()

virtual bool SkImageGenerator::onIsProtected ( ) const
inlineprotectedvirtual

Reimplemented in GrBackendTextureImageGenerator.

Definition at line 132 of file SkImageGenerator.h.

132{ return false; }

◆ onIsValid()

virtual bool SkImageGenerator::onIsValid ( GrRecordingContext ) const
inlineprotectedvirtual

Reimplemented in GrAHardwareBufferImageGenerator, and GrBackendTextureImageGenerator.

Definition at line 131 of file SkImageGenerator.h.

131{ return true; }

◆ onQueryYUVAInfo()

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

Reimplemented in SkCodecImageGenerator.

Definition at line 133 of file SkImageGenerator.h.

134 { return false; }

◆ onRefEncodedData()

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

Reimplemented in SkCodecImageGenerator.

Definition at line 128 of file SkImageGenerator.h.

128{ return nullptr; }

◆ 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.

Definition at line 34 of file SkImageGenerator.cpp.

35 {
36 SkASSERT(yuvaPixmapInfo);
37
38 return this->onQueryYUVAInfo(supportedDataTypes, yuvaPixmapInfo) &&
39 yuvaPixmapInfo->isSupported(supportedDataTypes);
40}
#define SkASSERT(cond)
Definition SkAssert.h:116
virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
bool isSupported(const SupportedDataTypes &) const

◆ 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.

Definition at line 45 of file SkImageGenerator.h.

45 {
46 return this->onRefEncodedData();
47 }
virtual sk_sp< SkData > onRefEncodedData()

◆ uniqueID()

uint32_t SkImageGenerator::uniqueID ( ) const
inline

Definition at line 36 of file SkImageGenerator.h.

36{ return fUniqueID; }

Member Data Documentation

◆ fInfo

const SkImageInfo SkImageGenerator::fInfo
protected

Definition at line 137 of file SkImageGenerator.h.

◆ kNeedNewImageUniqueID

constexpr int SkImageGenerator::kNeedNewImageUniqueID = 0
staticconstexprprotected

Definition at line 124 of file SkImageGenerator.h.


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