add 'r' (rotate) 's' (scale) options to SampleApp to test those matrix ops on
all slides

add beforeChild/afterChild methods for parents to wack the canvas before/after
it draws. These are called after the std child-view translate and clip, unlike
beforeChildren/afterChildren



git-svn-id: http://skia.googlecode.com/svn/trunk@324 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 635fde1..263b898 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -134,7 +134,9 @@
     
     virtual SkCanvas* beforeChildren(SkCanvas*);
     virtual void afterChildren(SkCanvas*);
-
+    virtual void beforeChild(SkView* child, SkCanvas* canvas);
+    virtual void afterChild(SkView* child, SkCanvas* canvas);
+    
 	virtual bool onEvent(const SkEvent& evt);
 
 #if 0
@@ -164,6 +166,8 @@
     bool fUseClip;
     bool fRepeatDrawing;
     bool fAnimating;
+    bool fRotate;
+    bool fScale;
     
     int fScrollTestX, fScrollTestY;
     
@@ -205,6 +209,8 @@
     fUseClip = false;
     fRepeatDrawing = false;
     fAnimating = false;
+    fRotate = false;
+    fScale = false;
 
     fScrollTestX = fScrollTestY = 0;
 
@@ -344,6 +350,27 @@
     }
 }
 
+void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
+    if (fScale) {
+        SkScalar scale = SK_Scalar1 * 7 / 10;
+        SkScalar cx = this->width() / 2;
+        SkScalar cy = this->height() / 2;
+        canvas->translate(cx, cy);
+        canvas->scale(scale, scale);
+        canvas->translate(-cx, -cy);
+    }
+    if (fRotate) {
+        SkScalar cx = this->width() / 2;
+        SkScalar cy = this->height() / 2;
+        canvas->translate(cx, cy);
+        canvas->rotate(SkIntToScalar(30));
+        canvas->translate(-cx, -cy);
+    }
+}
+
+void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) {
+}
+
 static SkBitmap::Config gConfigCycle[] = {
     SkBitmap::kNo_Config,           // none -> none
     SkBitmap::kNo_Config,           // a1 -> none
@@ -443,6 +470,16 @@
             }
             return true;
         }
+        case 'r':
+            fRotate = !fRotate;
+            this->inval(NULL);
+            this->updateTitle();
+            return true;
+        case 's':
+            fScale = !fScale;
+            this->inval(NULL);
+            this->updateTitle();
+            return true;
         default:
             break;
     }
@@ -545,7 +582,13 @@
     if (fAnimating) {
         title.prepend("<A> ");
     }
-
+    if (fScale) {
+        title.prepend("<S> ");
+    }
+    if (fRotate) {
+        title.prepend("<R> ");
+    }
+    
     this->setTitle(title.c_str());
 }