Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: samplecode/SampleApp.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch all existing animations to use animatePulse Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SampleArc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index dd771cec2d47d160b634ed7e0a33d703215de7f8..5b8ed96905ae64434b5d9348e424efc0595beb67 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
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SampleArc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698