Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkCodecImageGenerator Class Reference

#include <SkCodecImageGenerator.h>

Inheritance diagram for SkCodecImageGenerator:
SkImageGenerator

Public Member Functions

SkISize getScaledDimensions (float desiredScale) const
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const SkCodec::Options *options=nullptr)
 
int getFrameCount ()
 
bool getFrameInfo (int index, SkCodec::FrameInfo *info) const
 
int getRepetitionCount ()
 
- Public Member Functions inherited from SkImageGenerator
virtual ~SkImageGenerator ()
 
uint32_t uniqueID () const
 
sk_sp< SkDatarefEncodedData ()
 
const SkImageInfogetInfo () const
 
bool isValid (GrRecordingContext *context) const
 
bool isProtected () const
 
bool getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
bool getPixels (const SkPixmap &pm)
 
bool queryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmapInfo *yuvaPixmapInfo) const
 
bool getYUVAPlanes (const SkYUVAPixmaps &yuvaPixmaps)
 
virtual bool isTextureGenerator () const
 

Static Public Member Functions

static std::unique_ptr< SkImageGeneratorMakeFromEncodedCodec (sk_sp< SkData >, std::optional< SkAlphaType >=std::nullopt)
 
static std::unique_ptr< SkImageGeneratorMakeFromCodec (std::unique_ptr< SkCodec >, std::optional< SkAlphaType >=std::nullopt)
 

Protected Member Functions

sk_sp< SkDataonRefEncodedData () override
 
bool onGetPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const Options &opts) override
 
bool onQueryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const override
 
bool onGetYUVAPlanes (const SkYUVAPixmaps &yuvaPixmaps) override
 
- Protected Member Functions inherited from SkImageGenerator
 SkImageGenerator (const SkImageInfo &info, uint32_t uniqueId=kNeedNewImageUniqueID)
 
virtual bool onIsValid (GrRecordingContext *) const
 
virtual bool onIsProtected () const
 

Additional Inherited Members

- Protected Attributes inherited from SkImageGenerator
const SkImageInfo fInfo
 
- Static Protected Attributes inherited from SkImageGenerator
static constexpr int kNeedNewImageUniqueID = 0
 

Detailed Description

Definition at line 24 of file SkCodecImageGenerator.h.

Member Function Documentation

◆ getFrameCount()

int SkCodecImageGenerator::getFrameCount ( )
inline

Return the number of frames in the image.

May require reading through the stream.

Definition at line 76 of file SkCodecImageGenerator.h.

76{ return fCodec->getFrameCount(); }

◆ getFrameInfo()

bool SkCodecImageGenerator::getFrameInfo ( int  index,
SkCodec::FrameInfo info 
) const
inline

Return info about a single frame.

Only supported by multi-frame images. Does not read through the stream, so it should be called after getFrameCount() to parse any frames that have not already been parsed.

Definition at line 85 of file SkCodecImageGenerator.h.

85 {
86 return fCodec->getFrameInfo(index, info);
87 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213

◆ getPixels()

bool SkCodecImageGenerator::getPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const SkCodec::Options options = nullptr 
)

Decode into the given pixels, a block of memory of size at least (info.fHeight - 1) * rowBytes + (info.fWidth * bytesPerPixel)

Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.

Parameters
infoA description of the format expected by the caller. This can simply be identical to the info returned by getInfo().

This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.

A size that does not match getInfo() implies a request to scale. If the generator cannot perform this scale, it will return false.

Returns
true on success.

Definition at line 71 of file SkCodecImageGenerator.cpp.

71 {
72 SkPixmap dst(info, pixels, rowBytes);
73
74 auto decode = [this, options](const SkPixmap& pm) {
75 SkCodec::Result result = fCodec->getPixels(pm, options);
76 switch (result) {
80 return true;
81 default:
82 return false;
83 }
84 };
85
86 return SkPixmapUtils::Orient(dst, fCodec->getOrigin(), decode);
87}
const char * options
@ kIncompleteInput
Definition SkCodec.h:84
@ kSuccess
Definition SkCodec.h:80
@ kErrorInInput
Definition SkCodec.h:91
GAsyncResult * result
SK_API bool Orient(const SkPixmap &dst, const SkPixmap &src, SkEncodedOrigin origin)
dst
Definition cp.py:12
static DecodeResult decode(std::string path)

◆ getRepetitionCount()

int SkCodecImageGenerator::getRepetitionCount ( )
inline

Return the number of times to repeat, if this image is animated. This number does not include the first play through of each frame. For example, a repetition count of 4 means that each frame is played 5 times and then the animation stops.

It can return kRepetitionCountInfinite, a negative number, meaning that the animation should loop forever.

May require reading the stream to find the repetition count.

As such, future decoding calls may require a rewind.

For still (non-animated) image codecs, this will return 0.

Definition at line 103 of file SkCodecImageGenerator.h.

103{ return fCodec->getRepetitionCount(); }

◆ getScaledDimensions()

SkISize SkCodecImageGenerator::getScaledDimensions ( float  desiredScale) const

Return a size that approximately supports the desired scale factor. The codec may not be able to scale efficiently to the exact scale factor requested, so return a size that approximates that scale. The returned value is the codec's suggestion for the closest valid scale that it can natively support.

This is similar to SkCodec::getScaledDimensions, but adjusts the returned dimensions based on the image's EXIF orientation.

Definition at line 111 of file SkCodecImageGenerator.cpp.

111 {
112 SkISize size = fCodec->getScaledDimensions(desiredScale);
113 if (SkEncodedOriginSwapsWidthHeight(fCodec->getOrigin())) {
114 std::swap(size.fWidth, size.fHeight);
115 }
116 return size;
117}
static bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ MakeFromCodec()

std::unique_ptr< SkImageGenerator > SkCodecImageGenerator::MakeFromCodec ( std::unique_ptr< SkCodec codec,
std::optional< SkAlphaType at = std::nullopt 
)
static

Definition at line 31 of file SkCodecImageGenerator.cpp.

32 {
33 return codec ? std::unique_ptr<SkImageGenerator>(
34 new SkCodecImageGenerator(std::move(codec), at))
35 : nullptr;
36}

◆ MakeFromEncodedCodec()

std::unique_ptr< SkImageGenerator > SkCodecImageGenerator::MakeFromEncodedCodec ( sk_sp< SkData data,
std::optional< SkAlphaType at = std::nullopt 
)
static

Definition at line 21 of file SkCodecImageGenerator.cpp.

22 {
23 auto codec = SkCodec::MakeFromData(data);
24 if (codec == nullptr) {
25 return nullptr;
26 }
27
28 return std::unique_ptr<SkImageGenerator>(new SkCodecImageGenerator(std::move(codec), at));
29}
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition SkCodec.cpp:241

◆ onGetPixels()

bool SkCodecImageGenerator::onGetPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const Options opts 
)
overrideprotectedvirtual

Reimplemented from SkImageGenerator.

Definition at line 89 of file SkCodecImageGenerator.cpp.

90 {
91 return this->getPixels(requestInfo, requestPixels, requestRowBytes, nullptr);
92}
bool getPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkCodec::Options *options=nullptr)

◆ onGetYUVAPlanes()

bool SkCodecImageGenerator::onGetYUVAPlanes ( const SkYUVAPixmaps yuvaPixmaps)
overrideprotectedvirtual

Reimplemented from SkImageGenerator.

Definition at line 100 of file SkCodecImageGenerator.cpp.

100 {
101 switch (fCodec->getYUVAPlanes(yuvaPixmaps)) {
105 return true;
106 default:
107 return false;
108 }
109}

◆ onQueryYUVAInfo()

bool SkCodecImageGenerator::onQueryYUVAInfo ( const SkYUVAPixmapInfo::SupportedDataTypes supportedDataTypes,
SkYUVAPixmapInfo yuvaPixmapInfo 
) const
overrideprotectedvirtual

Reimplemented from SkImageGenerator.

Definition at line 94 of file SkCodecImageGenerator.cpp.

96 {
97 return fCodec->queryYUVAInfo(supportedDataTypes, yuvaPixmapInfo);
98}

◆ onRefEncodedData()

sk_sp< SkData > SkCodecImageGenerator::onRefEncodedData ( )
overrideprotectedvirtual

Reimplemented from SkImageGenerator.

Definition at line 58 of file SkCodecImageGenerator.cpp.

58 {
59 SkASSERT(fCodec);
60 if (!fCachedData) {
61 std::unique_ptr<SkStream> stream = fCodec->getEncodedData();
62 fCachedData = stream->getData();
63 if (!fCachedData) {
64 // stream should already be a copy of the underlying stream.
65 fCachedData = SkData::MakeFromStream(stream.get(), stream->getLength());
66 }
67 }
68 return fCachedData;
69}
#define SkASSERT(cond)
Definition SkAssert.h:116
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
Definition SkData.cpp:208

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