blob: c05189d0bb7052142ae5017e87bffce63d400f3a [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001#include "SampleCode.h"
2#include "SkView.h"
3#include "SkCanvas.h"
4#include "SkBlurMaskFilter.h"
5#include "SkCamera.h"
6#include "SkColorFilter.h"
7#include "SkColorPriv.h"
8#include "SkDevice.h"
9#include "SkGradientShader.h"
10#include "SkImageDecoder.h"
11#include "SkInterpolator.h"
12#include "SkMaskFilter.h"
13#include "SkPath.h"
14#include "SkRegion.h"
15#include "SkShader.h"
16#include "SkShaderExtras.h"
17#include "SkTime.h"
18#include "SkTypeface.h"
19#include "SkUtils.h"
20#include "SkKey.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000021#include "SkXfermode.h"
22#include "SkDrawFilter.h"
23
24#include "test.h"
25
26class TestsView : public SkView {
27public:
28 skia::Test::Iter fIter;
29
30 TestsView() {}
31
32protected:
33 // overrides from SkEventSink
34 virtual bool onQuery(SkEvent* evt) {
35 if (SampleCode::TitleQ(*evt)) {
36 SampleCode::TitleR(evt, "Tests");
37 return true;
38 }
39 return this->INHERITED::onQuery(evt);
40 }
41
42 void drawBG(SkCanvas* canvas) {
43 canvas->drawColor(SK_ColorWHITE);
44 }
45
46 virtual void onDraw(SkCanvas* canvas) {
47 this->drawBG(canvas);
48
49 skia::Test* test = fIter.next();
50 if (NULL == test) {
51 fIter.reset();
52 test = fIter.next();
53 }
54
55 SkIPoint size;
56 test->getSize(&size);
57
58 SkBitmap bitmap;
59 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.fX, size.fY);
60 bitmap.allocPixels();
61 bitmap.eraseColor(0);
62
63 SkCanvas c(bitmap);
64 test->draw(&c);
65
66 canvas->drawBitmap(bitmap, SkIntToScalar(10), SkIntToScalar(10), NULL);
67
68 SkString str;
69 test->getString(skia::Test::kTitle, &str);
70 SkDebugf("--- %s\n", str.c_str());
71 delete test;
72 }
73
74 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
75 this->inval(NULL);
76
77 return this->INHERITED::onFindClickHandler(x, y);
78 }
79
80 virtual bool onClick(Click* click) {
81 this->inval(NULL);
82 return this->INHERITED::onClick(click);
83 }
84
85 virtual bool handleKey(SkKey key) {
86 this->inval(NULL);
87 return true;
88 }
89
90private:
91 typedef SkView INHERITED;
92};
93
94//////////////////////////////////////////////////////////////////////////////
95
96static SkView* MyFactory() { return new TestsView; }
97static SkViewRegister reg(MyFactory);
98