diff options
author | Florin Malita <fmalita@chromium.org> | 2017-12-01 17:13:22 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-03 01:15:32 +0000 |
commit | d75f3f99d47b4750bcaa687a9404d4e30c8b0af8 (patch) | |
tree | c806994b469c32b3a81b59f02abeca0746f33e77 | |
parent | 1ec99b9b8e27245a69e1bc5a22c2b60e386d3fe2 (diff) |
Fix SVGPong slide crash in Viewer
SVGPong relies on onOnceBeforeDraw() to initialize, but when switching
slides via Viewer's UI, onAnimate() is fired before the first paint.
Change-Id: I7be133072ec635975f7463538cd42edb69696b3f
Reviewed-on: https://skia-review.googlesource.com/79424
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
-rw-r--r-- | samplecode/SampleSVGPong.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/samplecode/SampleSVGPong.cpp b/samplecode/SampleSVGPong.cpp index 590ec1824b..9fc7953048 100644 --- a/samplecode/SampleSVGPong.cpp +++ b/samplecode/SampleSVGPong.cpp @@ -179,19 +179,21 @@ protected: } bool onAnimate(const SkAnimTimer& timer) override { - SkScalar dt = (timer.msec() - fLastTick) * fTimeScale; - fLastTick = timer.msec(); - - fPaddle0.posTick(dt); - fPaddle1.posTick(dt); - fBall.posTick(dt); + // onAnimate may fire before the first draw. + if (fDom) { + SkScalar dt = (timer.msec() - fLastTick) * fTimeScale; + fLastTick = timer.msec(); - this->enforceConstraints(); + fPaddle0.posTick(dt); + fPaddle1.posTick(dt); + fBall.posTick(dt); - fPaddle0.updateDom(); - fPaddle1.updateDom(); - fBall.updateDom(); + this->enforceConstraints(); + fPaddle0.updateDom(); + fPaddle1.updateDom(); + fBall.updateDom(); + } return true; } |