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

An image generator that always creates a 1x1 single-frame green image. More...

Inheritance diagram for flutter::testing::SinglePixelImageGenerator:
flutter::ImageGenerator

Public Member Functions

 SinglePixelImageGenerator ()
 
 ~SinglePixelImageGenerator ()=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 always creates a 1x1 single-frame green image.

Definition at line 2280 of file shell_unittests.cc.

Constructor & Destructor Documentation

◆ SinglePixelImageGenerator()

flutter::testing::SinglePixelImageGenerator::SinglePixelImageGenerator ( )
inline

Definition at line 2282 of file shell_unittests.cc.

@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)

◆ ~SinglePixelImageGenerator()

flutter::testing::SinglePixelImageGenerator::~SinglePixelImageGenerator ( )
default

Member Function Documentation

◆ GetFrameCount()

unsigned int flutter::testing::SinglePixelImageGenerator::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 2287 of file shell_unittests.cc.

2287{ return 1; }

◆ GetFrameInfo()

const ImageGenerator::FrameInfo flutter::testing::SinglePixelImageGenerator::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 2291 of file shell_unittests.cc.

2291 {
2292 return {std::nullopt, 0, SkCodecAnimation::DisposalMethod::kKeep};
2293 }

◆ GetInfo()

const SkImageInfo & flutter::testing::SinglePixelImageGenerator::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 2285 of file shell_unittests.cc.

2285{ return info_; }

◆ GetPixels()

bool flutter::testing::SinglePixelImageGenerator::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 2299 of file shell_unittests.cc.

2303 {
2304 assert(info.width() == 1);
2305 assert(info.height() == 1);
2306 assert(row_bytes == 4);
2307
2308 reinterpret_cast<uint32_t*>(pixels)[0] = 0x00ff00ff;
2309 return true;
2310 };
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213

◆ GetPlayCount()

unsigned int flutter::testing::SinglePixelImageGenerator::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 2289 of file shell_unittests.cc.

2289{ return 1; }

◆ GetScaledDimensions()

SkISize flutter::testing::SinglePixelImageGenerator::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 2295 of file shell_unittests.cc.

2295 {
2296 return SkISize::Make(info_.width(), info_.height());
2297 }
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: