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/include/views/SkView.h b/include/views/SkView.h
index d5d89df..050deba 100644
--- a/include/views/SkView.h
+++ b/include/views/SkView.h
@@ -296,8 +296,16 @@
         request, return true so the request will not continue to propogate to the parent.
     */
     virtual bool    handleInval(const SkRect&);
+    //! called once before all of the children are drawn (or clipped/translated)
     virtual SkCanvas* beforeChildren(SkCanvas* c) { return c; }
+    //! called once after all of the children are drawn (or clipped/translated)
     virtual void afterChildren(SkCanvas* orig) {}
+
+    //! called right before this child's onDraw is called
+    virtual void beforeChild(SkView* child, SkCanvas* canvas) {}
+    //! called right after this child's onDraw is called
+    virtual void afterChild(SkView* child, SkCanvas* canvas) {}
+
     /** Override this if you might handle the click
     */
     virtual Click*  onFindClickHandler(SkScalar x, SkScalar y);
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());
 }
 
diff --git a/src/views/SkView.cpp b/src/views/SkView.cpp
index a027744..f8008af 100644
--- a/src/views/SkView.cpp
+++ b/src/views/SkView.cpp
@@ -95,8 +95,14 @@
 		canvas->clipRect(r);
 		canvas->translate(fLoc.fX, fLoc.fY);
 
+        if (fParent) {
+            fParent->beforeChild(this, canvas);
+        }
 		this->onDraw(canvas);
-
+        if (fParent) {
+            fParent->afterChild(this, canvas);
+        }
+        
 		B2FIter	iter(this);
 		SkView*	child;