Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::testing::FakeImageGenerator Class Reference
Inheritance diagram for flutter::testing::FakeImageGenerator:
flutter::ImageGenerator

Public Member Functions

 FakeImageGenerator (int identifiableFakeWidth)
 
 ~FakeImageGenerator ()=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.
 
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.
 
unsigned int GetPlayCount () const
 The number of times an animated image should play through before playback stops.
 
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.
 
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.
 
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.
 
- Public Member Functions inherited from flutter::ImageGenerator
virtual ~ImageGenerator ()
 
sk_sp< SkImageGetImage ()
 Creates an SkImage based on the current ImageInfo of this ImageGenerator.
 

Additional Inherited Members

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

Detailed Description

Definition at line 51 of file image_generator_registry_unittests.cc.

Constructor & Destructor Documentation

◆ FakeImageGenerator()

flutter::testing::FakeImageGenerator::FakeImageGenerator ( int  identifiableFakeWidth)
inlineexplicit

Definition at line 53 of file image_generator_registry_unittests.cc.

54 : info_(SkImageInfo::Make(identifiableFakeWidth,
55 identifiableFakeWidth,
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ ~FakeImageGenerator()

flutter::testing::FakeImageGenerator::~FakeImageGenerator ( )
default

Member Function Documentation

◆ GetFrameCount()

unsigned int flutter::testing::FakeImageGenerator::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 61 of file image_generator_registry_unittests.cc.

61{ return 1; }

◆ GetFrameInfo()

const ImageGenerator::FrameInfo flutter::testing::FakeImageGenerator::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 65 of file image_generator_registry_unittests.cc.

◆ GetInfo()

const SkImageInfo & flutter::testing::FakeImageGenerator::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 59 of file image_generator_registry_unittests.cc.

59{ return info_; }

◆ GetPixels()

bool flutter::testing::FakeImageGenerator::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 73 of file image_generator_registry_unittests.cc.

77 {
78 return false;
79 };

◆ GetPlayCount()

unsigned int flutter::testing::FakeImageGenerator::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 63 of file image_generator_registry_unittests.cc.

63{ return 1; }

◆ GetScaledDimensions()

SkISize flutter::testing::FakeImageGenerator::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 69 of file image_generator_registry_unittests.cc.

69 {
70 return SkISize::Make(info_.width(), info_.height());
71 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
int width() const
int height() const

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