update to SampleView



git-svn-id: http://skia.googlecode.com/svn/trunk@1460 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 727d93e..bee965c 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1477,8 +1477,6 @@
 
 
 void SampleView::onDraw(SkCanvas* canvas) {
-    this->onDrawBackground(canvas);
-
 #ifdef TEST_GPIPE
     SimplePC controller(canvas);
     SkGPipeWriter writer;
@@ -1489,6 +1487,8 @@
     }
 #endif
 
+    this->onDrawBackground(canvas);
+
     for (int i = 0; i < fRepeatCount; i++) {
         SkAutoCanvasRestore acr(canvas, true);
         this->onDrawContent(canvas);
diff --git a/samplecode/SampleMeasure.cpp b/samplecode/SampleMeasure.cpp
index eb7a288..8078e03 100644
--- a/samplecode/SampleMeasure.cpp
+++ b/samplecode/SampleMeasure.cpp
@@ -34,8 +34,7 @@
     { ONE,   true,   true    }
 };
 
-static void doMeasure(SkCanvas* canvas, const SkPaint& paint, const char text[])
-{
+static void doMeasure(SkCanvas* canvas, const SkPaint& paint, const char text[]) {
     SkScalar    dy = paint.getFontMetrics(NULL);
 
     size_t      len = strlen(text);
@@ -80,55 +79,33 @@
     }
 }
 
-class MeasureView : public SkView {
+class MeasureView : public SampleView {
 public:
     SkPaint fPaint;
 
-	MeasureView()
-    {
+	MeasureView() {
         fPaint.setAntiAlias(true);
         fPaint.setTextSize(SkIntToScalar(64));
+        this->setBGColor(0xFFDDDDDD);
     }
 
 protected:
     // overrides from SkEventSink
-    virtual bool onQuery(SkEvent* evt)
-    {
-        if (SampleCode::TitleQ(*evt))
-        {
+    virtual bool onQuery(SkEvent* evt) {
+        if (SampleCode::TitleQ(*evt)) {
             SampleCode::TitleR(evt, "Measure");
             return true;
         }
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas)
-    {
-        canvas->drawColor(0xFFDDDDDD);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas)
-    {
-        this->drawBG(canvas);
-        
+    virtual void onDrawContent(SkCanvas* canvas) {
         canvas->translate(fPaint.getTextSize(), fPaint.getTextSize());
         doMeasure(canvas, fPaint, "Hamburgefons");
     }
     
-    virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) 
-    {
-     //   fSweep += SK_Scalar1;
-        this->inval(NULL);
-        return this->INHERITED::onFindClickHandler(x, y);
-    }
-    
-    virtual bool onClick(Click* click) 
-    {
-        return this->INHERITED::onClick(click);
-    }
-    
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleNinePatch.cpp b/samplecode/SampleNinePatch.cpp
index 99c337b..e158287 100644
--- a/samplecode/SampleNinePatch.cpp
+++ b/samplecode/SampleNinePatch.cpp
@@ -6,7 +6,7 @@
 #include "SkPaint.h"
 #include "SkUnPreMultiply.h"
 
-class NinePatchView : public SkView {
+class NinePatchView : public SampleView {
 public:
     SkBitmap fBM;
 
@@ -34,7 +34,7 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas) {
+    virtual void onDrawBackground(SkCanvas* canvas) {
         SkPaint p;
         p.setDither(true);
         p.setColor(0xFF909090);
@@ -69,11 +69,7 @@
         }
     }
 
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-
-      //  canvas->scale(1.5f, 1.5f);
-        
+    virtual void onDrawContent(SkCanvas* canvas) {
         canvas->drawBitmap(fBM, 0, 0);
         
         SkIRect margins;
@@ -108,7 +104,7 @@
     }
 private:
     SkScalar fX, fY;
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleOvalTest.cpp b/samplecode/SampleOvalTest.cpp
index daa479b..f625529 100644
--- a/samplecode/SampleOvalTest.cpp
+++ b/samplecode/SampleOvalTest.cpp
@@ -5,7 +5,7 @@
 static const int kILimit = 101;
 static const SkScalar kLimit = SK_Scalar1 * kILimit;
 
-class OvalTestView : public SkView {
+class OvalTestView : public SampleView {
 public:
     SkSize      fSize;
     SkPMColor   fInsideColor;   // signals an interior pixel that was not set
@@ -20,6 +20,8 @@
 
         fInsideColor = SkPreMultiplyColor(SK_ColorRED);
         fOutsideColor = SkPreMultiplyColor(SK_ColorGREEN);
+
+        this->setBGColor(0xFFDDDDDD);
     }
 
 protected:
@@ -32,10 +34,6 @@
         return this->INHERITED::onQuery(evt);
     }
 
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(0xFFDDDDDD);
-    }
-
     void drawOval() {
         SkCanvas canvas(fBitmap);
         SkPaint p;
@@ -72,9 +70,7 @@
         return flatc + buldgec;
     }
 
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-
+    virtual void onDrawContent(SkCanvas* canvas) {
         this->drawOval();
         int flatCount, buldgeCount;
         this->checkOval(&flatCount, &buldgeCount);
@@ -104,7 +100,7 @@
     }
 
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleOverflow.cpp b/samplecode/SampleOverflow.cpp
index 229683f..d3ecff7 100644
--- a/samplecode/SampleOverflow.cpp
+++ b/samplecode/SampleOverflow.cpp
@@ -70,7 +70,7 @@
 #endif
 }
 
-class OverflowView : public SkView {
+class OverflowView : public SampleView {
 public:
 	OverflowView() {}
 
@@ -84,19 +84,13 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(SK_ColorWHITE);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-
+    virtual void onDrawContent(SkCanvas* canvas) {
         DrawRoundRect();
         TestOverflowHitTest();
     }
     
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SamplePageFlip.cpp b/samplecode/SamplePageFlip.cpp
index 29f0180..7c5bf48 100644
--- a/samplecode/SamplePageFlip.cpp
+++ b/samplecode/SamplePageFlip.cpp
@@ -90,7 +90,7 @@
 #endif
 };
 
-class PageFlipView : public SkView {
+class PageFlipView : public SampleView {
 public:
     
     enum { N = SK_ARRAY_COUNT(gConfigs) };
@@ -115,6 +115,7 @@
             status = pthread_create(&fThreads[i], &attr,  draw_proc, &fBitmaps[i]);
             SkASSERT(0 == status);
         }
+        this->setBGColor(0xFFDDDDDD);
     }
     
     virtual ~PageFlipView() {
@@ -135,15 +136,8 @@
         }
         return this->INHERITED::onQuery(evt);
     }
-    
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(0xFFDDDDDD);
-//        canvas->drawColor(SK_ColorWHITE);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-        
+
+    virtual void onDrawContent(SkCanvas* canvas) {
         SkScalar x = SkIntToScalar(10);
         SkScalar y = SkIntToScalar(10);
         for (int i = 0; i < N; i++) {
@@ -163,7 +157,7 @@
     }
     
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp
index a126cbf..8139171 100644
--- a/samplecode/SamplePathClip.cpp
+++ b/samplecode/SamplePathClip.cpp
@@ -14,58 +14,7 @@
 #include "SkTime.h"
 #include "SkTypeface.h"
 
-#if 0
-static void CFString2SkString(CFStringRef ref, SkString* str) {
-    str->reset();
-    int count = CFStringGetLength(ref);
-    for (int i = 0; i < count; i++) {
-        SkString tmp;
-        UniChar c = CFStringGetCharacterAtIndex(ref, i);
-        tmp.setUTF16(&c, 1);
-        str->append(tmp);
-    }
-}
-
-static size_t get_table_size(ATSFontRef font, uint32_t tableTag) {
-    ByteCount size;
-    OSStatus status = ATSFontGetTable(font, tableTag, 0, 0, NULL, &size);
-    if (status) {
-        SkDebugf("*** ATSFontGetTable returned %d\n", status);
-        size = -1;
-    }
-    return size;
-}
-
-static void test_ats() {
-    OSStatus status;
-    ATSFontIterator iter;
-    status = ATSFontIteratorCreate(kATSFontContextLocal, NULL, NULL,
-                                   kATSOptionFlagsUnRestrictedScope, &iter);
-
-    for (int index = 0;; index++) {
-        ATSFontRef fontRef;
-        status = ATSFontIteratorNext(iter, &fontRef);
-        if (status) {
-            break;
-        }
-        
-        CFStringRef name;
-        SkString str;
-        ATSFontGetName(fontRef, kATSOptionFlagsDefault, &name);
-        CFString2SkString(name, &str);
-        if (str.size() > 0 && str.c_str()[0] != '.') {
-            SkDebugf("[%3d] font %x cmap %d 'name' %d <%s>\n", index, fontRef,
-                     get_table_size(fontRef, 'cmap'),
-                     get_table_size(fontRef, 'name'),
-                     str.c_str());
-        }
-        CFRelease(name);
-    }
-    ATSFontIteratorRelease(&iter);
-}
-#endif
-
-class PathClipView : public SkView {
+class PathClipView : public SampleView {
 public:
     SkRect fOval;
     SkPoint fCenter;
@@ -89,13 +38,7 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(SK_ColorWHITE);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-        
+    virtual void onDrawContent(SkCanvas* canvas) {
         SkRect oval = fOval;
         oval.offset(fCenter.fX - oval.centerX(), fCenter.fY - oval.centerY());
         
@@ -131,7 +74,7 @@
     }
     
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleRepeatTile.cpp b/samplecode/SampleRepeatTile.cpp
index 755473f..9867074 100644
--- a/samplecode/SampleRepeatTile.cpp
+++ b/samplecode/SampleRepeatTile.cpp
@@ -35,9 +35,11 @@
     paint->setShader(shader)->unref();
 }
 
-class RepeatTileView : public SkView {
+class RepeatTileView : public SampleView {
 public:
-	RepeatTileView() {}
+	RepeatTileView() {
+        this->setBGColor(SK_ColorGRAY);
+    }
 
 protected:
     // overrides from SkEventSink
@@ -49,13 +51,7 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(SK_ColorGRAY);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-        
+    virtual void onDrawContent(SkCanvas* canvas) {
         SkPaint paint;
         make_paint(&paint, SkShader::kRepeat_TileMode);
         
@@ -80,7 +76,7 @@
     }
 
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleSVG.cpp b/samplecode/SampleSVG.cpp
deleted file mode 100644
index fdb1d54..0000000
--- a/samplecode/SampleSVG.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "SampleCode.h"
-#include "SkView.h"
-#include "SkBlurMaskFilter.h"
-#include "SkCanvas.h"
-#include "SkGradientShader.h"
-#include "SkGraphics.h"
-#include "SkImageDecoder.h"
-#include "SkPath.h"
-#include "SkRandom.h"
-#include "SkRegion.h"
-#include "SkShader.h"
-#include "SkUtils.h"
-#include "SkXfermode.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
-#include "SkTime.h"
-#include "SkTypeface.h"
-#include "SkTextBox.h"
-#include "SkOSFile.h"
-#include "SkStream.h"
-
-#include "SkSVGParser.h"
-
-class SVGView : public SkView {
-public:    
-	SVGView() {
-		SkXMLParserError err;
-		SkFILEStream stream("/testsvg2.svg");
-		SkSVGParser parser(&err);
-		if (parser.parse(stream)) {
-			const char* text = parser.getFinal();
-			SkFILEWStream output("/testanim.txt");
-			output.write(text, strlen(text));
-		}
-	}
-    
-protected:
-    // overrides from SkEventSink
-    virtual bool onQuery(SkEvent* evt)  {
-        if (SampleCode::TitleQ(*evt)) {
-            SkString str("SVG");
-            SampleCode::TitleR(evt, str.c_str());
-            return true;
-        }
-        return this->INHERITED::onQuery(evt);
-    }
-    
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(SK_ColorWHITE);
-    }
-    
-    virtual void onDraw(SkCanvas* canvas) {
-        this->drawBG(canvas);
-    }
-    
-    virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
-        return new Click(this);
-    }
-    
-    virtual bool onClick(Click* click) {
-        int y = click->fICurr.fY;
-        if (y < 0) {
-            y = 0;
-        } else if (y > 255) {
-            y = 255;
-        }
-        fByte = y;
-        this->inval(NULL);
-        return true;
-    }
-    
-private:
-    int fByte;
-
-    typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new SVGView; }
-static SkViewRegister reg(MyFactory);
-
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index 3d2a61e..3b7d05b 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -749,7 +749,7 @@
     texteffect_slide
 };
 
-class SlideView : public SkView {
+class SlideView : public SampleView {
     int fIndex;
 public:
     SlideView() {
@@ -770,6 +770,7 @@
             str.printf("/skimages/slide_%d.png", i);
             SkImageEncoder::EncodeFile(str.c_str(), bm, SkImageEncoder::kPNG_Type, 100);
         }
+        this->setBGColor(BG_COLOR);
     }
     
 protected:
@@ -782,8 +783,7 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    virtual void onDraw(SkCanvas* canvas) {
-        canvas->drawColor(BG_COLOR);
+    virtual void onDrawContent(SkCanvas* canvas) {
         gProc[fIndex](canvas);
     }
 
@@ -794,7 +794,7 @@
     }
 
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp
index 3691ac6..ae630ef 100644
--- a/samplecode/SampleStrokePath.cpp
+++ b/samplecode/SampleStrokePath.cpp
@@ -88,7 +88,7 @@
     { SkPaint::kStrokeAndFill_Style,    SkPaint::kMiter_Join,   10 },
 };
 
-class StrokePathView : public SkView {
+class StrokePathView : public SampleView {
     SkScalar    fWidth;
     SkPath      fPath;
 public:
@@ -111,6 +111,8 @@
         scale_to_width(&fPath, fWidth);
         const SkRect& bounds = fPath.getBounds();
         fPath.offset(-bounds.fLeft, -bounds.fTop);
+
+        this->setBGColor(0xFFDDDDDD);
     }
     
 protected:
@@ -123,10 +125,6 @@
         return this->INHERITED::onQuery(evt);
     }
     
-    void drawBG(SkCanvas* canvas) {
-        canvas->drawColor(0xFFDDDDDD);
-    }
-    
     SkRandom rand;
     
     void drawSet(SkCanvas* canvas, SkPaint* paint) {
@@ -141,9 +139,7 @@
         }
     }
 
-    virtual void onDraw(SkCanvas* canvas) {
-        drawBG(canvas);
-        //return;
+    virtual void onDrawContent(SkCanvas* canvas) {
         test_huge_stroke(canvas); return;
         canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
 
@@ -211,7 +207,7 @@
         return this->INHERITED::onFindClickHandler(x, y);
     }
 private:
-    typedef SkView INHERITED;
+    typedef SampleView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleTests.cpp b/samplecode/SampleTests.cpp
index a97c622..4ce8640 100644
--- a/samplecode/SampleTests.cpp
+++ b/samplecode/SampleTests.cpp
@@ -1,4 +1,4 @@
-#include "SampleCode.h"
+utils#include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"