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 ImageGenerator
s.
More...
#include <image_generator.h>
|
struct | FrameInfo |
| Info about a single frame in the context of a multi-frame image, useful for animation and blending. More...
|
|
|
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. More...
|
|
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 . More...
|
|
virtual unsigned int | GetPlayCount () const =0 |
| The number of times an animated image should play through before playback stops. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
sk_sp< SkImage > | GetImage () |
| Creates an SkImage based on the current ImageInfo of this ImageGenerator . More...
|
|
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 ImageGenerator
s.
- See also
ImageGenerator::GetScaledDimensions
Definition at line 27 of file image_generator.h.
◆ ~ImageGenerator()
flutter::ImageGenerator::~ImageGenerator |
( |
| ) |
|
|
virtualdefault |
◆ GetFrameCount()
virtual unsigned int flutter::ImageGenerator::GetFrameCount |
( |
| ) |
const |
|
pure virtual |
◆ GetFrameInfo()
virtual const FrameInfo flutter::ImageGenerator::GetFrameInfo |
( |
unsigned int |
frame_index | ) |
|
|
pure virtual |
◆ GetImage()
Creates an SkImage
based on the current ImageInfo
of this ImageGenerator
.
- Returns
- A new
SkImage
containing the decoded image data.
Definition at line 19 of file image_generator.cc.
19 {
21
24 FML_DLOG(
ERROR) <<
"Failed to allocate memory for bitmap of size "
25 <<
info.computeMinByteSize() <<
"B";
26 return nullptr;
27 }
28
29 const auto& pixmap =
bitmap.pixmap();
30 if (!
GetPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes())) {
32 return nullptr;
33 }
36}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
virtual const SkImageInfo & GetInfo()=0
Returns basic information about the contents of the encoded image. This information can almost always...
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 decodi...
#define FML_DLOG(severity)
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
◆ GetInfo()
virtual const SkImageInfo & flutter::ImageGenerator::GetInfo |
( |
| ) |
|
|
pure virtual |
◆ GetPixels()
virtual bool flutter::ImageGenerator::GetPixels |
( |
const SkImageInfo & |
info, |
|
|
void * |
pixels, |
|
|
size_t |
row_bytes, |
|
|
unsigned int |
frame_index = 0 , |
|
|
std::optional< unsigned int > |
prior_frame = std::nullopt |
|
) |
| |
|
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.
- Parameters
-
[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. |
- Returns
- True if the image was successfully decoded.
- Note
- This method performs potentially long synchronous work, and so it should never be executed on the UI thread. Image decoders do not require GPU acceleration, and so threads without a GPU context may also be used.
- See also
GetScaledDimensions
Implemented in flutter::testing::UnknownImageGenerator, flutter::testing::FakeImageGenerator, flutter::testing::SinglePixelImageGenerator, flutter::APNGImageGenerator, flutter::AndroidImageGenerator, flutter::BuiltinSkiaImageGenerator, and flutter::BuiltinSkiaCodecImageGenerator.
◆ GetPlayCount()
virtual unsigned int flutter::ImageGenerator::GetPlayCount |
( |
| ) |
const |
|
pure virtual |
◆ GetScaledDimensions()
virtual SkISize flutter::ImageGenerator::GetScaledDimensions |
( |
float |
scale | ) |
|
|
pure virtual |
◆ kInfinitePlayCount
const unsigned int flutter::ImageGenerator::kInfinitePlayCount |
|
static |
Initial value:=
static float max(float r, float g, float b)
Frame count value to denote infinite looping.
Definition at line 30 of file image_generator.h.
The documentation for this class was generated from the following files: