Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skresources::MultiFrameImageAsset Class Referencefinal

#include <SkResources.h>

Inheritance diagram for skresources::MultiFrameImageAsset:
skresources::ImageAsset SkRefCnt SkRefCntBase

Public Member Functions

bool isMultiFrame () override
 
sk_sp< SkImagegetFrame (float t) override
 
- Public Member Functions inherited from skresources::ImageAsset
virtual bool isMultiFrame ()=0
 
virtual sk_sp< SkImagegetFrame (float t)
 
virtual FrameData getFrameData (float t)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< MultiFrameImageAssetMake (sk_sp< SkData >, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
 
static sk_sp< MultiFrameImageAssetMake (std::unique_ptr< SkCodec >, ImageDecodeStrategy=ImageDecodeStrategy::kLazyDecode)
 

Additional Inherited Members

- Public Types inherited from skresources::ImageAsset
enum class  SizeFit {
  kFill = SkMatrix::kFill_ScaleToFit , kStart = SkMatrix::kStart_ScaleToFit , kCenter = SkMatrix::kCenter_ScaleToFit , kEnd = SkMatrix::kEnd_ScaleToFit ,
  kNone
}
 

Detailed Description

Definition at line 100 of file SkResources.h.

Member Function Documentation

◆ getFrame()

sk_sp< SkImage > skresources::MultiFrameImageAsset::getFrame ( float  t)
overridevirtual

DEPRECATED: override getFrameData() instead.

Returns the SkImage for a given frame.

If the image asset is static, getFrame() is only called once, at animation load time. Otherwise, this gets invoked every time the animation time is adjusted (on every seek).

Embedders should cache and serve the same SkImage whenever possible, for efficiency.

Parameters
tFrame time code, in seconds, relative to the image layer timeline origin (in-point).

Reimplemented from skresources::ImageAsset.

Definition at line 175 of file SkResources.cpp.

175 {
176 // For static images we can reuse the cached frame
177 // (which includes the optional pre-decode step).
178 if (!fCachedFrame || this->isMultiFrame()) {
179 fCachedFrame = this->generateFrame(t);
180 }
181
182 return fCachedFrame;
183}

◆ isMultiFrame()

bool skresources::MultiFrameImageAsset::isMultiFrame ( )
overridevirtual

Returns true if the image asset is animated.

Implements skresources::ImageAsset.

Definition at line 131 of file SkResources.cpp.

131 {
132 return fPlayer->duration() > 0;
133}

◆ Make() [1/2]

sk_sp< MultiFrameImageAsset > skresources::MultiFrameImageAsset::Make ( sk_sp< SkData data,
ImageDecodeStrategy  strat = ImageDecodeStrategy::kLazyDecode 
)
static

Definition at line 110 of file SkResources.cpp.

110 {
111 if (auto codec = SkCodec::MakeFromData(std::move(data))) {
112 return sk_sp<MultiFrameImageAsset>(new MultiFrameImageAsset(
113 std::make_unique<SkAnimCodecPlayer>(std::move(codec)), strat));
114 }
115
116 return nullptr;
117}
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition: SkCodec.cpp:241
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Make() [2/2]

sk_sp< MultiFrameImageAsset > skresources::MultiFrameImageAsset::Make ( std::unique_ptr< SkCodec codec,
ImageDecodeStrategy  strat = ImageDecodeStrategy::kLazyDecode 
)
static

Definition at line 119 of file SkResources.cpp.

119 {
120 SkASSERT(codec);
121 return sk_sp<MultiFrameImageAsset>(new MultiFrameImageAsset(
122 std::make_unique<SkAnimCodecPlayer>(std::move(codec)), strat));
123}
#define SkASSERT(cond)
Definition: SkAssert.h:116

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