migrate some samples over to SampleView, for FPS measurements



git-svn-id: http://skia.googlecode.com/svn/trunk@1166 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 78ec56f..99ceb3e 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -39,7 +39,7 @@
 
 static void postInvalDelay(SkEventSinkID sinkID) {
     SkEvent* evt = new SkEvent(view_inval_msg);
-    evt->post(sinkID, 10);
+    evt->post(sinkID, 1);
 }
 
 static bool isInvalEvent(const SkEvent& evt) {
@@ -849,16 +849,20 @@
         canvas->setDrawFilter(new FlagsDrawFilter(fLCDState, fAAState))->unref();
     }
 
-    SampleView::SetRepeatDraw(child, fMeasureFPS ? FPS_REPEAT_COUNT : 1);
     if (fMeasureFPS) {
-        fMeasureFPS_Time = SkTime::GetMSecs();
+        fMeasureFPS_Time = 0;   // 0 means the child is not aware of repeat-draw
+        if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) {
+            fMeasureFPS_Time = SkTime::GetMSecs();
+        }
+    } else {
+        (void)SampleView::SetRepeatDraw(child, 1);
     }
 }
 
 void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) {
     canvas->setDrawFilter(NULL);
 
-    if (fMeasureFPS) {
+    if (fMeasureFPS && fMeasureFPS_Time) {
         fMeasureFPS_Time = SkTime::GetMSecs() - fMeasureFPS_Time;
         this->updateTitle();
         postInvalDelay(this->getSinkID());
@@ -1314,10 +1318,10 @@
 
 static const char repeat_count_tag[] = "sample-set-repeat-count";
 
-void SampleView::SetRepeatDraw(SkView* view, int count) {
+bool SampleView::SetRepeatDraw(SkView* view, int count) {
     SkEvent evt(repeat_count_tag);
     evt.setFast32(count);
-    (void)view->doEvent(evt);
+    return view->doEvent(evt);
 }
 
 bool SampleView::onEvent(const SkEvent& evt) {
@@ -1341,7 +1345,7 @@
 }
 
 void SampleView::onDrawBackground(SkCanvas* canvas) {
-    canvas->drawColor(SK_ColorWHITE);
+    canvas->drawColor(fBGColor);
 }
 
 ///////////////////////////////////////////////////////////////////////////////