add SampleCode::GetAnimTime() so slides go through a central location for
animation timing. This allows us to "freeze" time in order to do things like
draw multiple times to test clipping.



git-svn-id: http://skia.googlecode.com/svn/trunk@444 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 2d0da1f..8fcdfa8 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -6,6 +6,7 @@
 #include "SkPaint.h"
 #include "SkPicture.h"
 #include "SkStream.h"
+#include "SkTime.h"
 #include "SkWindow.h"
 
 #include "SampleCode.h"
@@ -121,6 +122,18 @@
     evt->setScalars(gPrefSizeEvtName, 2, size);
 }
 
+static SkMSec gAnimTime;
+SkMSec SampleCode::GetAnimTime() { return gAnimTime; }
+
+SkScalar SampleCode::GetAnimScalar(SkScalar speed, SkScalar period) {
+    SkScalar seconds = SkFloatToScalar(gAnimTime / 1000.0f);
+    SkScalar value = SkScalarMul(speed, seconds);
+    if (period) {
+        value = SkScalarMod(value, period);
+    }
+    return value;
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 class SampleWindow : public SkOSWindow {
@@ -241,10 +254,13 @@
     delete fGLCanvas;
 }
 
-#define XCLIP_N  4
-#define YCLIP_N  1
+#define XCLIP_N  8
+#define YCLIP_N  8
 
 void SampleWindow::draw(SkCanvas* canvas) {
+    // update the animation time
+    gAnimTime = SkTime::GetMSecs();
+
     if (fNClip) {
      //   this->INHERITED::draw(canvas);
      //   SkBitmap orig = capture_bitmap(canvas);