Make 'rotate' animate in SampleApp.
R=reed@google.com
Review URL: https://codereview.chromium.org/18948002
git-svn-id: http://skia.googlecode.com/svn/trunk@9946 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 3825197..f379f99 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -782,6 +782,7 @@
fNClip = false;
fAnimating = false;
fRotate = false;
+ fRotateAnimTime = 0;
fPerspAnim = false;
fPerspAnimTime = 0;
fRequestGrabImage = false;
@@ -1411,12 +1412,15 @@
void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
if (fRotate) {
+ fRotateAnimTime += SampleCode::GetAnimSecondsDelta();
+
SkScalar cx = this->width() / 2;
SkScalar cy = this->height() / 2;
canvas->translate(cx, cy);
- canvas->rotate(SkIntToScalar(30));
+ canvas->rotate(fRotateAnimTime * 10);
canvas->translate(-cx, -cy);
}
+
if (fPerspAnim) {
fPerspAnimTime += SampleCode::GetAnimSecondsDelta();
@@ -1443,7 +1447,7 @@
} else {
(void)SampleView::SetRepeatDraw(child, 1);
}
- if (fPerspAnim) {
+ if (fPerspAnim || fRotate) {
this->inval(NULL);
}
}
@@ -1766,6 +1770,7 @@
break;
case 'r':
fRotate = !fRotate;
+ fRotateAnimTime = 0;
this->inval(NULL);
this->updateTitle();
return true;