Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkImageGenerator Class Reference
Inheritance diagram for SkImageGenerator:

Classes

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

Public Member Functions

virtual ~SkImageGenerator ()
 The PixelRef which takes ownership of this SkImageGenerator will call the image generator's destructor.
 
uint32_t uniqueID () const
 
SkDatarefEncodedData ()
 Return a ref to the encoded (i.e. More...
 
const SkImageInfogetInfo () const
 Return the ImageInfo associated with this generator.
 
bool isValid (GrContext *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)?
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const Options *options)
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 Simplified version of getPixels() that uses the default Options.
 
bool queryYUV8 (SkYUVSizeInfo *sizeInfo, SkYUVColorSpace *colorSpace) const
 If decoding to YUV is supported, this returns true. More...
 
bool getYUV8Planes (const SkYUVSizeInfo &sizeInfo, void *planes[3])
 Returns true on success and false on failure. More...
 
sk_sp< GrTextureProxy > generateTexture (GrContext *, const SkImageInfo &info, const SkIPoint &origin)
 If the generator can natively/efficiently return its pixels as a GPU image (backed by a texture) this will return that image. More...
 

Static Public Member Functions

static std::unique_ptr
< SkImageGenerator
MakeFromEncoded (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
< SkImageGenerator
MakeFromPicture (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 Types

enum  { kNeedNewImageUniqueID = 0 }
 
enum  TexGenType { kNone, kCheap, kExpensive }
 

Protected Member Functions

 SkImageGenerator (const SkImageInfo &info, uint32_t uniqueId=kNeedNewImageUniqueID)
 
virtual SkDataonRefEncodedData ()
 
virtual bool onGetPixels (const SkImageInfo &, void *, size_t, const Options &)
 
virtual bool onIsValid (GrContext *) const
 
virtual bool onQueryYUV8 (SkYUVSizeInfo *, SkYUVColorSpace *) const
 
virtual bool onGetYUV8Planes (const SkYUVSizeInfo &, void *[3])
 
virtual TexGenType onCanGenerateTexture () const
 
virtual sk_sp< GrTextureProxy > onGenerateTexture (GrContext *, const SkImageInfo &, const SkIPoint &)
 

Static Private Member Functions

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

Private Attributes

const SkImageInfo fInfo
 
const uint32_t fUniqueID
 

Friends

class SkImage_Lazy
 

Member Function Documentation

sk_sp<GrTextureProxy> SkImageGenerator::generateTexture ( GrContext ,
const SkImageInfo info,
const SkIPoint origin 
)

If the generator can natively/efficiently return its pixels as a GPU image (backed by a texture) this will return that image.

If not, this will return NULL.

This routine also supports retrieving only a subset of the pixels. That subset is specified by the following rectangle:

subset = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height())

If subset is not contained inside the generator's bounds, this returns false.

whole = SkIRect::MakeWH(getInfo().width(), getInfo().height())
if (!whole.contains(subset)) {
    return false;
}

Regarding the GrContext parameter:

It must be non-NULL. The generator should only succeed if:

  • its internal context is the same
  • it can somehow convert its texture into one that is valid for the provided context.
bool SkImageGenerator::getYUV8Planes ( const SkYUVSizeInfo sizeInfo,
void *  planes[3] 
)

Returns true on success and false on failure.

This always attempts to perform a full decode. If the client only wants size, it should call queryYUV8().

Parameters
sizeInfoNeeds to exactly match the values returned by the query, except the WidthBytes may be larger than the recommendation (but not smaller).
planesMemory for each of the Y, U, and V planes.
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.

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.

bool SkImageGenerator::queryYUV8 ( SkYUVSizeInfo sizeInfo,
SkYUVColorSpace *  colorSpace 
) const

If decoding to YUV is supported, this returns true.

Otherwise, this returns false and does not modify any of the parameters.

Parameters
sizeInfoOutput parameter indicating the sizes and required allocation widths of the Y, U, and V planes.
colorSpaceOutput parameter.
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.


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