reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 1 | #ifndef skiagm_DEFINED |
| 2 | #define skiagm_DEFINED |
| 3 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 4 | #include "SkCanvas.h" |
| 5 | #include "SkPaint.h" |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 6 | #include "SkRefCnt.h" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 7 | #include "SkSize.h" |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 8 | #include "SkString.h" |
| 9 | #include "SkTRegistry.h" |
| 10 | |
| 11 | namespace skiagm { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 12 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 13 | static inline SkISize make_isize(int w, int h) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 14 | SkISize sz; |
| 15 | sz.set(w, h); |
| 16 | return sz; |
| 17 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 18 | |
| 19 | class GM { |
| 20 | public: |
| 21 | GM(); |
| 22 | virtual ~GM(); |
| 23 | |
| 24 | void draw(SkCanvas*); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 25 | SkISize getISize() { return this->onISize(); } |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 26 | const char* shortName() { |
| 27 | if (fShortName.size() == 0) { |
| 28 | fShortName = this->onShortName(); |
| 29 | } |
| 30 | return fShortName.c_str(); |
| 31 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 32 | |
| 33 | protected: |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 34 | virtual void onDraw(SkCanvas*) = 0; |
| 35 | virtual SkISize onISize() = 0; |
| 36 | virtual SkString onShortName() = 0; |
| 37 | |
| 38 | private: |
| 39 | SkString fShortName; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | typedef SkTRegistry<GM*, void*> GMRegistry; |
| 43 | } |
| 44 | |
| 45 | #endif |