The minimal interface necessary for defining a decoder that can be used for both single and multi-frame image decoding. Image generators can also optionally support decoding into a subscaled buffer. Implementers of ImageGenerator regularly keep internal state which is not thread safe, and so aliasing and parallel access should never be done with ImageGenerators.
More...
#include <image_generator.h>
Classes | |
| struct | FrameInfo |
| Info about a single frame in the context of a multi-frame image, useful for animation and blending. More... | |
Public Member Functions | |
| virtual | ~ImageGenerator () |
| virtual const SkImageInfo & | GetInfo ()=0 |
| Returns basic information about the contents of the encoded image. This information can almost always be collected by just interpreting the header of a decoded image. | |
| virtual unsigned int | GetFrameCount () const =0 |
Get the number of frames that the encoded image stores. This method is always expected to be called before GetFrameInfo, as the underlying image decoder may interpret frame information that is then used when calling GetFrameInfo. | |
| virtual unsigned int | GetPlayCount () const =0 |
| The number of times an animated image should play through before playback stops. | |
| virtual const FrameInfo | GetFrameInfo (unsigned int frame_index)=0 |
Get information about a single frame in the context of a multi-frame image, useful for animation and frame blending. This method should only ever be called after GetFrameCount has been called. This information is nonsensical for single-frame images. | |
| virtual SkISize | GetScaledDimensions (float scale)=0 |
| Given a scale value, find the closest image size that can be used for efficiently decoding the image. If subpixel image decoding is not supported by the decoder, this method should just return the original image size. | |
| virtual bool | GetPixels (const SkImageInfo &info, void *pixels, size_t row_bytes, unsigned int frame_index=0, std::optional< unsigned int > prior_frame=std::nullopt)=0 |
Decode the image into a given buffer. This method is currently always used for sub-pixel image decoding. For full-sized still images, GetImage is always attempted first. | |
| sk_sp< SkImage > | GetImage () |
Creates an SkImage based on the current ImageInfo of this ImageGenerator. | |
Static Public Attributes | |
| static const unsigned int | kInfinitePlayCount |
| Frame count value to denote infinite looping. | |
The minimal interface necessary for defining a decoder that can be used for both single and multi-frame image decoding. Image generators can also optionally support decoding into a subscaled buffer. Implementers of ImageGenerator regularly keep internal state which is not thread safe, and so aliasing and parallel access should never be done with ImageGenerators.
Definition at line 27 of file image_generator.h.
|
virtualdefault |
|
pure virtual |
Get the number of frames that the encoded image stores. This method is always expected to be called before GetFrameInfo, as the underlying image decoder may interpret frame information that is then used when calling GetFrameInfo.
Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::BuiltinSkiaImageGenerator, flutter::BuiltinSkiaCodecImageGenerator, flutter::APNGImageGenerator, and flutter::AndroidImageGenerator.
|
pure virtual |
Get information about a single frame in the context of a multi-frame image, useful for animation and frame blending. This method should only ever be called after GetFrameCount has been called. This information is nonsensical for single-frame images.
| [in] | frame_index | The index of the frame to get information about. |
GetFrameCount Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::BuiltinSkiaImageGenerator, flutter::BuiltinSkiaCodecImageGenerator, flutter::APNGImageGenerator, and flutter::AndroidImageGenerator.
| sk_sp< SkImage > flutter::ImageGenerator::GetImage | ( | ) |
Creates an SkImage based on the current ImageInfo of this ImageGenerator.
SkImage containing the decoded image data. Definition at line 19 of file image_generator.cc.
References FML_DLOG, GetInfo(), and GetPixels().
|
pure virtual |
Returns basic information about the contents of the encoded image. This information can almost always be collected by just interpreting the header of a decoded image.
Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::BuiltinSkiaImageGenerator, flutter::BuiltinSkiaCodecImageGenerator, flutter::APNGImageGenerator, and flutter::AndroidImageGenerator.
Referenced by GetImage().
|
pure virtual |
Decode the image into a given buffer. This method is currently always used for sub-pixel image decoding. For full-sized still images, GetImage is always attempted first.
| [in] | info | The desired size and color info of the decoded image to be returned. The implementation of GetScaledDimensions determines which sizes are supported by the image decoder. |
| [in] | pixels | The location where the raw decoded image data should be written. |
| [in] | row_bytes | The total number of bytes that should make up a single row of decoded image data (i.e. width * bytes_per_pixel). |
| [in] | frame_index | Which frame to decode. This is only useful for multi-frame images. |
| [in] | prior_frame | Optional frame index parameter for multi-frame images which specifies the previous frame that should be use for blending. This hints to the decoder that it should use a previously cached frame instead of decoding dependency frame(s). If an empty value is supplied, the decoder should decode any necessary frames first. |
GetScaledDimensions Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::APNGImageGenerator, flutter::AndroidImageGenerator, flutter::BuiltinSkiaImageGenerator, and flutter::BuiltinSkiaCodecImageGenerator.
Referenced by GetImage().
|
pure virtual |
The number of times an animated image should play through before playback stops.
kInfinitePlayCount is returned. Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::BuiltinSkiaImageGenerator, flutter::BuiltinSkiaCodecImageGenerator, flutter::APNGImageGenerator, and flutter::AndroidImageGenerator.
|
pure virtual |
Given a scale value, find the closest image size that can be used for efficiently decoding the image. If subpixel image decoding is not supported by the decoder, this method should just return the original image size.
| [in] | scale | The desired scale factor of the image for decoding. |
GetPixels in order to query for supported sizes. GetPixels Implemented in flutter::BuiltinSkiaImageGenerator, flutter::BuiltinSkiaCodecImageGenerator, flutter::APNGImageGenerator, flutter::AndroidImageGenerator, flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, and flutter::testing::SinglePixelImageGenerator.
|
static |
Frame count value to denote infinite looping.
Definition at line 30 of file image_generator.h.
Referenced by flutter::BuiltinSkiaCodecImageGenerator::GetPlayCount().