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

Unified Diff: samplecode/SampleApp.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SPACE to toggle animations 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
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index dd771cec2d47d160b634ed7e0a33d703215de7f8..0a1100ec2b5edf4705dd4ff934033d8380b143b2 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -662,6 +662,20 @@ static bool curr_title(SkWindow* wind, SkString* title) {
return false;
}
+bool SampleWindow::sendAnimatePulse() {
+ SkView* view = curr_view(this);
+ if (SampleView::IsSampleView(view)) {
+ if (fDoAnimate) {
+ SkMSec now = SkTime::GetMSecs();
+ return ((SampleView*)view)->animatePulse(now);
+ } else {
+ // 0 signals the view that we are no longer animating
+ ((SampleView*)view)->animatePulse(0);
+ }
+ }
+ return false;
+}
+
void SampleWindow::setZoomCenter(float x, float y)
{
fZoomCenterX = x;
@@ -823,6 +837,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
fDeviceType = kANGLE_DeviceType;
#endif
+ fDoAnimate = false;
fUseClip = false;
fNClip = false;
fAnimating = false;
@@ -1130,6 +1145,10 @@ void SampleWindow::draw(SkCanvas* canvas) {
this->postInvalDelay();
}
+ if (this->sendAnimatePulse()) {
+ this->inval(NULL);
+ }
+
// do this last
fDevManager->publishCanvas(fDeviceType, canvas, this);
}
@@ -1709,6 +1728,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
« gm/gm.h ('K') | « samplecode/SampleApp.h ('k') | samplecode/SampleCode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698