Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
PathTextSlide::WavyGlyphAnimator Class Reference
Inheritance diagram for PathTextSlide::WavyGlyphAnimator:
PathTextSlide::MovingGlyphAnimator PathTextSlide::GlyphAnimator

Public Member Functions

 WavyGlyphAnimator (Glyph *glyphs)
 
 ~WavyGlyphAnimator () override
 
void reset (SkRandom *rand, int screenWidth, int screenHeight) override
 
void runAnimationTask (double t, double dt, int width, int height) override
 
void swapAnimationBuffers () override
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from PathTextSlide::MovingGlyphAnimator
 MovingGlyphAnimator (Glyph *glyphs)
 
 ~MovingGlyphAnimator () override
 
void reset (SkRandom *rand, int screenWidth, int screenHeight) override
 
bool animate (double nanos, int screenWidth, int screenHeight) final
 
virtual void runAnimationTask (double t, double dt, int w, int h)
 
virtual void swapAnimationBuffers ()
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from PathTextSlide::GlyphAnimator
 GlyphAnimator (Glyph *glyphs)
 
virtual void reset (SkRandom *, int screenWidth, int screenHeight)
 
virtual bool animate (double nanos, int screenWidth, int screenHeight)
 
virtual void draw (SkCanvas *canvas)
 
virtual ~GlyphAnimator ()
 

Additional Inherited Members

- Protected Attributes inherited from PathTextSlide::MovingGlyphAnimator
Velocity fVelocities [kNumPaths]
 
std::unique_ptr< SkMatrix[]> fFrontMatrices
 
std::unique_ptr< SkMatrix[]> fBackMatrices
 
SkTaskGroup fBackgroundAnimationTask
 
double fLastTick
 
- Protected Attributes inherited from PathTextSlide::GlyphAnimator
Glyph *const fGlyphs
 

Detailed Description

Definition at line 261 of file PathTextSlide.cpp.

Constructor & Destructor Documentation

◆ WavyGlyphAnimator()

PathTextSlide::WavyGlyphAnimator::WavyGlyphAnimator ( Glyph glyphs)
inline

Definition at line 263 of file PathTextSlide.cpp.

265 , fFrontPaths(new SkPath[kNumPaths])
266 , fBackPaths(new SkPath[kNumPaths]) {
267 }
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
Definition: SkPath.h:59

◆ ~WavyGlyphAnimator()

PathTextSlide::WavyGlyphAnimator::~WavyGlyphAnimator ( )
inlineoverride

Definition at line 269 of file PathTextSlide.cpp.

Member Function Documentation

◆ draw()

void PathTextSlide::WavyGlyphAnimator::draw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from PathTextSlide::MovingGlyphAnimator.

Definition at line 336 of file PathTextSlide.cpp.

336 {
337 for (int i = 0; i < kNumPaths; ++i) {
338 canvas->drawPath(fFrontPaths[i], fGlyphs[i].fPaint);
339 }
340 }
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747

◆ reset()

void PathTextSlide::WavyGlyphAnimator::reset ( SkRandom rand,
int  screenWidth,
int  screenHeight 
)
inlineoverridevirtual

Reimplemented from PathTextSlide::MovingGlyphAnimator.

Definition at line 273 of file PathTextSlide.cpp.

273 {
274 fWaves.reset(*rand, screenWidth, screenHeight);
275 this->MovingGlyphAnimator::reset(rand, screenWidth, screenHeight);
276 std::copy(fBackPaths.get(), fBackPaths.get() + kNumPaths, fFrontPaths.get());
277 }
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
Definition: SkSwizzler.cpp:31
void reset(SkRandom *rand, int screenWidth, int screenHeight) override

◆ runAnimationTask()

void PathTextSlide::WavyGlyphAnimator::runAnimationTask ( double  t,
double  dt,
int  width,
int  height 
)
inlineoverridevirtual

Called on a background thread. Here we can only modify fBackPaths.

Reimplemented from PathTextSlide::MovingGlyphAnimator.

Definition at line 282 of file PathTextSlide.cpp.

282 {
283 const float tsec = static_cast<float>(t);
285
286 for (int i = 0; i < kNumPaths; ++i) {
287 const Glyph& glyph = fGlyphs[i];
288 const SkMatrix& backMatrix = fBackMatrices[i];
289
290 const skvx::float2 matrix[3] = {
291 skvx::float2(backMatrix.getScaleX(), backMatrix.getSkewY()),
292 skvx::float2(backMatrix.getSkewX(), backMatrix.getScaleY()),
293 skvx::float2(backMatrix.getTranslateX(), backMatrix.getTranslateY())
294 };
295
296 SkPath* backpath = &fBackPaths[i];
297 backpath->reset();
299
300 for (auto [verb, pts, w] : SkPathPriv::Iterate(glyph.fPath)) {
301 switch (verb) {
302 case SkPathVerb::kMove: {
303 SkPoint pt = fWaves.apply(tsec, matrix, pts[0]);
304 backpath->moveTo(pt.x(), pt.y());
305 break;
306 }
307 case SkPathVerb::kLine: {
308 SkPoint endpt = fWaves.apply(tsec, matrix, pts[1]);
309 backpath->lineTo(endpt.x(), endpt.y());
310 break;
311 }
312 case SkPathVerb::kQuad: {
313 SkPoint controlPt = fWaves.apply(tsec, matrix, pts[1]);
314 SkPoint endpt = fWaves.apply(tsec, matrix, pts[2]);
315 backpath->quadTo(controlPt.x(), controlPt.y(), endpt.x(), endpt.y());
316 break;
317 }
318 case SkPathVerb::kClose: {
319 backpath->close();
320 break;
321 }
324 SK_ABORT("Unexpected path verb");
325 break;
326 }
327 }
328 }
329 }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
virtual void runAnimationTask(double t, double dt, int w, int h)
std::unique_ptr< SkMatrix[]> fBackMatrices
SkScalar getSkewY() const
Definition: SkMatrix.h:430
SkScalar getTranslateY() const
Definition: SkMatrix.h:452
SkScalar getSkewX() const
Definition: SkMatrix.h:438
SkScalar getScaleX() const
Definition: SkMatrix.h:415
SkScalar getScaleY() const
Definition: SkMatrix.h:422
SkScalar getTranslateX() const
Definition: SkMatrix.h:445
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & reset()
Definition: SkPath.cpp:370
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746
SkPath & close()
Definition: SkPath.cpp:823
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Vec< 2, float > float2
Definition: SkVx.h:1145
SkScalar w
int32_t height
int32_t width
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
Definition: SkVx.h:83

◆ swapAnimationBuffers()

void PathTextSlide::WavyGlyphAnimator::swapAnimationBuffers ( )
inlineoverridevirtual

Reimplemented from PathTextSlide::MovingGlyphAnimator.

Definition at line 331 of file PathTextSlide.cpp.

331 {
333 std::swap(fFrontPaths, fBackPaths);
334 }
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341

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