reed@android.com | 9b46e77 | 2009-06-05 12:24:41 +0000 | [diff] [blame^] | 1 | #include "SampleCode.h" |
| 2 | #include "SkView.h" |
| 3 | #include "SkCanvas.h" |
| 4 | #include "SkCornerPathEffect.h" |
| 5 | #include "SkCullPoints.h" |
| 6 | #include "SkGradientShader.h" |
| 7 | #include "SkPath.h" |
| 8 | #include "SkRegion.h" |
| 9 | #include "SkShader.h" |
| 10 | #include "SkUtils.h" |
| 11 | |
| 12 | class TestGLView : public SkView { |
| 13 | public: |
| 14 | TestGLView() { |
| 15 | } |
| 16 | |
| 17 | protected: |
| 18 | // overrides from SkEventSink |
| 19 | virtual bool onQuery(SkEvent* evt) { |
| 20 | if (SampleCode::TitleQ(*evt)) { |
| 21 | SampleCode::TitleR(evt, "TestGL"); |
| 22 | return true; |
| 23 | } |
| 24 | return this->INHERITED::onQuery(evt); |
| 25 | } |
| 26 | |
| 27 | void drawBG(SkCanvas* canvas) { |
| 28 | canvas->drawColor(0xFFDDDDDD); |
| 29 | } |
| 30 | |
| 31 | virtual void onDraw(SkCanvas* canvas) { |
| 32 | drawBG(canvas); |
| 33 | |
| 34 | SkRect r; |
| 35 | r.set(0, 0, 100, 100); |
| 36 | |
| 37 | canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
| 38 | |
| 39 | SkPaint paint; |
| 40 | paint.setAntiAlias(false); |
| 41 | paint.setColor(SK_ColorRED); |
| 42 | |
| 43 | canvas->drawRect(r, paint); |
| 44 | |
| 45 | canvas->translate(r.width() + SkIntToScalar(20), 0); |
| 46 | paint.setStyle(SkPaint::kStroke_Style); |
| 47 | canvas->drawRect(r, paint); |
| 48 | |
| 49 | canvas->translate(r.width() + SkIntToScalar(20), 0); |
| 50 | paint.setStrokeWidth(SkIntToScalar(5)); |
| 51 | canvas->drawRect(r, paint); |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | typedef SkView INHERITED; |
| 56 | }; |
| 57 | |
| 58 | ////////////////////////////////////////////////////////////////////////////// |
| 59 | |
| 60 | static SkView* MyFactory() { return new TestGLView; } |
| 61 | static SkViewRegister reg(MyFactory); |
| 62 | |