Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ZoomAnimation Class Reference
Inheritance diagram for ZoomAnimation:
SKPAnimationBench::Animation SkRefCnt SkRefCntBase

Public Member Functions

 ZoomAnimation (SkScalar zoomMax, double zoomPeriodMs)
 
const char * getTag () override
 
void preConcatFrameMatrix (double animationTimeMs, const SkIRect &devBounds, SkMatrix *drawMatrix) override
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Detailed Description

Definition at line 44 of file SKPAnimationBench.cpp.

Constructor & Destructor Documentation

◆ ZoomAnimation()

ZoomAnimation::ZoomAnimation ( SkScalar  zoomMax,
double  zoomPeriodMs 
)
inline

Definition at line 46 of file SKPAnimationBench.cpp.

47 : fZoomMax(zoomMax)
48 , fZoomPeriodMs(zoomPeriodMs) {
49 }

Member Function Documentation

◆ getTag()

const char * ZoomAnimation::getTag ( )
inlineoverridevirtual

Implements SKPAnimationBench::Animation.

Definition at line 51 of file SKPAnimationBench.cpp.

51{ return "zoom"; }

◆ preConcatFrameMatrix()

void ZoomAnimation::preConcatFrameMatrix ( double  animationTimeMs,
const SkIRect devBounds,
SkMatrix drawMatrix 
)
inlineoverridevirtual

Implements SKPAnimationBench::Animation.

Definition at line 53 of file SKPAnimationBench.cpp.

54 {
55 double t = fmod(animationTimeMs / fZoomPeriodMs, 1.0); // t is in [0, 1).
56 t = fabs(2 * t - 1); // Make t ping-pong between 0 and 1
57 SkScalar zoom = static_cast<SkScalar>(pow(fZoomMax, t));
58
59 SkPoint center = SkPoint::Make((devBounds.fLeft + devBounds.fRight) / 2.0f,
60 (devBounds.fTop + devBounds.fBottom) / 2.0f);
61 drawMatrix->preTranslate(center.fX, center.fY);
62 drawMatrix->preScale(zoom, zoom);
63 drawMatrix->preTranslate(-center.fX, -center.fY);
64 }
static SkScalar center(float pos0, float pos1)
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:315
float SkScalar
Definition extension.cpp:12
int32_t fBottom
larger y-axis bounds
Definition SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35
static constexpr SkPoint Make(float x, float y)

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