Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::testing::UnknownImageGenerator Class Reference

An Image generator that pretends it can't recognize the data it was given. More...

Inheritance diagram for flutter::testing::UnknownImageGenerator:
flutter::ImageGenerator

Public Member Functions

 UnknownImageGenerator ()
 
 ~UnknownImageGenerator ()=default
 
const SkImageInfoGetInfo ()
 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...
 
unsigned int GetFrameCount () const
 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...
 
unsigned int GetPlayCount () const
 The number of times an animated image should play through before playback stops. More...
 
const ImageGenerator::FrameInfo GetFrameInfo (unsigned int frame_index)
 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...
 
SkISize GetScaledDimensions (float scale)
 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...
 
bool GetPixels (const SkImageInfo &info, void *pixels, size_t row_bytes, unsigned int frame_index, std::optional< unsigned int > prior_frame)
 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...
 
- Public Member Functions inherited from flutter::ImageGenerator
virtual ~ImageGenerator ()
 
virtual const SkImageInfoGetInfo ()=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< SkImageGetImage ()
 Creates an SkImage based on the current ImageInfo of this ImageGenerator. More...
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::ImageGenerator
static const unsigned int kInfinitePlayCount
 Frame count value to denote infinite looping. More...
 

Detailed Description

An Image generator that pretends it can't recognize the data it was given.

Definition at line 199 of file image_decoder_unittests.cc.

Constructor & Destructor Documentation

◆ UnknownImageGenerator()

flutter::testing::UnknownImageGenerator::UnknownImageGenerator ( )
inline

Definition at line 201 of file image_decoder_unittests.cc.

201: info_(SkImageInfo::MakeUnknown()){};
static SkImageInfo MakeUnknown()
Definition: SkImageInfo.h:357

◆ ~UnknownImageGenerator()

flutter::testing::UnknownImageGenerator::~UnknownImageGenerator ( )
default

Member Function Documentation

◆ GetFrameCount()

unsigned int flutter::testing::UnknownImageGenerator::GetFrameCount ( ) const
inlinevirtual

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.

Returns
The number of frames that the encoded image stores. This will always be 1 for single-frame images.

Implements flutter::ImageGenerator.

Definition at line 205 of file image_decoder_unittests.cc.

205{ return 1; }

◆ GetFrameInfo()

const ImageGenerator::FrameInfo flutter::testing::UnknownImageGenerator::GetFrameInfo ( unsigned int  frame_index)
inlinevirtual

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.

Parameters
[in]frame_indexThe index of the frame to get information about.
Returns
Information about the given frame. If the image is single-frame, a default result is returned.
See also
GetFrameCount

Implements flutter::ImageGenerator.

Definition at line 209 of file image_decoder_unittests.cc.

209 {
210 return {std::nullopt, 0, SkCodecAnimation::DisposalMethod::kKeep};
211 }

◆ GetInfo()

const SkImageInfo & flutter::testing::UnknownImageGenerator::GetInfo ( )
inlinevirtual

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.

Returns
Size and color information describing the image.
Note
This method is executed on the UI thread and used for layout purposes by the framework, and so this method should not perform long synchronous tasks.

Implements flutter::ImageGenerator.

Definition at line 203 of file image_decoder_unittests.cc.

203{ return info_; }

◆ GetPixels()

bool flutter::testing::UnknownImageGenerator::GetPixels ( const SkImageInfo info,
void *  pixels,
size_t  row_bytes,
unsigned int  frame_index,
std::optional< unsigned int prior_frame 
)
inlinevirtual

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]infoThe 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]pixelsThe location where the raw decoded image data should be written.
[in]row_bytesThe total number of bytes that should make up a single row of decoded image data (i.e. width * bytes_per_pixel).
[in]frame_indexWhich frame to decode. This is only useful for multi-frame images.
[in]prior_frameOptional 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

Implements flutter::ImageGenerator.

Definition at line 217 of file image_decoder_unittests.cc.

221 {
222 return false;
223 };

◆ GetPlayCount()

unsigned int flutter::testing::UnknownImageGenerator::GetPlayCount ( ) const
inlinevirtual

The number of times an animated image should play through before playback stops.

Returns
If this image is animated, the number of times the animation should play through is returned, otherwise it'll just return 1. If the animation should loop forever, kInfinitePlayCount is returned.

Implements flutter::ImageGenerator.

Definition at line 207 of file image_decoder_unittests.cc.

207{ return 1; }

◆ GetScaledDimensions()

SkISize flutter::testing::UnknownImageGenerator::GetScaledDimensions ( float  scale)
inlinevirtual

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.

Parameters
[in]scaleThe desired scale factor of the image for decoding.
Returns
The closest image size that can be used for efficiently decoding the image.
Note
This method is called prior to GetPixels in order to query for supported sizes.
See also
GetPixels

Implements flutter::ImageGenerator.

Definition at line 213 of file image_decoder_unittests.cc.

213 {
214 return SkISize::Make(info_.width(), info_.height());
215 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
int width() const
Definition: SkImageInfo.h:365
int height() const
Definition: SkImageInfo.h:371

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