blob: d0216725cfe5f2adafed091fc1e812149812f0c8 [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"
21#include "SkPorterDuff.h"
22#include "SkXfermode.h"
23#include "SkDrawFilter.h"
24
25#include "test.h"
26
27class TestsView : public SkView {
28public:
29 skia::Test::Iter fIter;
30
31 TestsView() {}
32
33protected:
34 // overrides from SkEventSink
35 virtual bool onQuery(SkEvent* evt) {
36 if (SampleCode::TitleQ(*evt)) {
37 SampleCode::TitleR(evt, "Tests");
38 return true;
39 }
40 return this->INHERITED::onQuery(evt);
41 }
42
43 void drawBG(SkCanvas* canvas) {
44 canvas->drawColor(SK_ColorWHITE);
45 }
46
47 virtual void onDraw(SkCanvas* canvas) {
48 this->drawBG(canvas);
49
50 skia::Test* test = fIter.next();
51 if (NULL == test) {
52 fIter.reset();
53 test = fIter.next();
54 }
55
56 SkIPoint size;
57 test->getSize(&size);
58
59 SkBitmap bitmap;
60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.fX, size.fY);
61 bitmap.allocPixels();
62 bitmap.eraseColor(0);
63
64 SkCanvas c(bitmap);
65 test->draw(&c);
66
67 canvas->drawBitmap(bitmap, SkIntToScalar(10), SkIntToScalar(10), NULL);
68
69 SkString str;
70 test->getString(skia::Test::kTitle, &str);
71 SkDebugf("--- %s\n", str.c_str());
72 delete test;
73 }
74
75 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
76 this->inval(NULL);
77
78 return this->INHERITED::onFindClickHandler(x, y);
79 }
80
81 virtual bool onClick(Click* click) {
82 this->inval(NULL);
83 return this->INHERITED::onClick(click);
84 }
85
86 virtual bool handleKey(SkKey key) {
87 this->inval(NULL);
88 return true;
89 }
90
91private:
92 typedef SkView INHERITED;
93};
94
95//////////////////////////////////////////////////////////////////////////////
96
97static SkView* MyFactory() { return new TestsView; }
98static SkViewRegister reg(MyFactory);
99