Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkAnimationDraw Class Reference

Public Member Functions

 SkAnimationDraw ()=default
 
 ~SkAnimationDraw ()=default
 
 operator bool () const
 
void draw (SkSize size, SkCanvas *canvas)
 
void load (const void *data, size_t length)
 
void seek (double time)
 
float duration ()
 
SkSize size ()
 

Detailed Description

Definition at line 16 of file SkottieViewController.mm.

Constructor & Destructor Documentation

◆ SkAnimationDraw()

SkAnimationDraw::SkAnimationDraw ( )
default

◆ ~SkAnimationDraw()

SkAnimationDraw::~SkAnimationDraw ( )
default

Member Function Documentation

◆ draw()

void SkAnimationDraw::draw ( SkSize  size,
SkCanvas canvas 
)
inline

Definition at line 23 of file SkottieViewController.mm.

23 {
24 if (size.width() != fSize.width() || size.height() != fSize.height()) {
25 // Cache the current matrix; change only if size changes.
26 if (fAnimationSize.width() > 0 && fAnimationSize.height() > 0) {
27 float scale = std::min(size.width() / fAnimationSize.width(),
28 size.height() / fAnimationSize.height());
29 fMatrix.setScaleTranslate(
30 scale, scale,
31 (size.width() - fAnimationSize.width() * scale) * 0.5f,
32 (size.height() - fAnimationSize.height() * scale) * 0.5f);
33 } else {
34 fMatrix = SkMatrix();
35 }
36 fSize = size;
37 }
38 canvas->concat(fMatrix);
39 SkRect rect = {0, 0, fAnimationSize.width(), fAnimationSize.height()};
41 fAnimation->render(canvas);
42 }
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty)
Definition: SkMatrix.h:1803
void render(SkCanvas *canvas, const SkRect *dst=nullptr) const
Definition: Skottie.cpp:482
static float min(float r, float g, float b)
Definition: hsl.cpp:48
constexpr SkColor4f kWhite
Definition: SkColor.h:439
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
const Scalar scale
SkScalar width() const
Definition: SkSize.h:76
SkScalar height() const
Definition: SkSize.h:77

◆ duration()

float SkAnimationDraw::duration ( )
inline

Definition at line 53 of file SkottieViewController.mm.

53{ return fAnimation ? fAnimation->duration() : 0; }
double duration() const
Definition: Skottie.h:268

◆ load()

void SkAnimationDraw::load ( const void *  data,
size_t  length 
)
inline

Definition at line 44 of file SkottieViewController.mm.

44 {
46 fAnimation = builder.make((const char*)data, (size_t)length);
47 fSize = {0, 0};
48 fAnimationSize = fAnimation ? fAnimation->size() : SkSize{0, 0};
49 }
const SkSize & size() const
Definition: Skottie.h:286
size_t length
Definition: SkSize.h:52
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ operator bool()

SkAnimationDraw::operator bool ( ) const
inlineexplicit

Definition at line 21 of file SkottieViewController.mm.

21{ return fAnimation != nullptr; }

◆ seek()

void SkAnimationDraw::seek ( double  time)
inline

Definition at line 51 of file SkottieViewController.mm.

51{ if (fAnimation) { fAnimation->seekFrameTime(time, nullptr); } }
void seekFrameTime(double t, sksg::InvalidationController *=nullptr)
Definition: Skottie.cpp:530
static double time(int loops, Benchmark *bench, Target *target)
Definition: nanobench.cpp:394

◆ size()

SkSize SkAnimationDraw::size ( )
inline

Definition at line 55 of file SkottieViewController.mm.

55{ return fAnimationSize; }

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