diff options
| author | reed <reed@chromium.org> | 2015-02-01 19:01:04 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2015-02-01 19:01:04 -0800 |
| commit | d9adfe6a223955bc69c8c7661ab8e0a078afbc32 (patch) | |
| tree | b3ae977babf890649bce0538e6b6cb766a948219 /samplecode/SampleApp.cpp | |
| parent | 47471cf19c1b386212ab0401190ac40cdeb95d1f (diff) | |
allow GMs to animate
BUG=skia:
Review URL: https://codereview.chromium.org/888283002
Diffstat (limited to 'samplecode/SampleApp.cpp')
| -rw-r--r-- | samplecode/SampleApp.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index dd771cec2d..5b8ed96905 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -662,6 +662,19 @@ static bool curr_title(SkWindow* wind, SkString* title) { return false; } +bool SampleWindow::sendAnimatePulse() { + SkView* view = curr_view(this); + if (SampleView::IsSampleView(view)) { + if (fDoAnimate) { + return ((SampleView*)view)->animatePulse(gAnimTime, gAnimTimePrev); + } else { + // 0 signals the view that we are no longer animating + ((SampleView*)view)->animatePulse(0, 0); + } + } + return false; +} + void SampleWindow::setZoomCenter(float x, float y) { fZoomCenterX = x; @@ -823,6 +836,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev fDeviceType = kANGLE_DeviceType; #endif + fDoAnimate = true; fUseClip = false; fNClip = false; fAnimating = false; @@ -1130,6 +1144,10 @@ void SampleWindow::draw(SkCanvas* canvas) { this->postInvalDelay(); } + if (this->sendAnimatePulse()) { + this->inval(NULL); + } + // do this last fDevManager->publishCanvas(fDeviceType, canvas, this); } @@ -1709,6 +1727,12 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { } switch (uni) { + case ' ': + fDoAnimate = !fDoAnimate; + if (this->sendAnimatePulse()) { + this->inval(NULL); + } + break; case 'B': post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox")), curr_view(this)); // Cannot call updateTitle() synchronously, because the toggleBBox event is still in |
