reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame^] | 1 | #ifndef SkBenchmark_DEFINED |
| 2 | #define SkBenchmark_DEFINED |
| 3 | |
| 4 | #include "SkRefCnt.h" |
| 5 | #include "SkPoint.h" |
| 6 | |
| 7 | class SkCanvas; |
| 8 | |
| 9 | class SkBenchmark : public SkRefCnt { |
| 10 | public: |
| 11 | const char* getName(); |
| 12 | SkIPoint getSize(); |
| 13 | void draw(SkCanvas*); |
| 14 | |
| 15 | protected: |
| 16 | virtual const char* onGetName() = 0; |
| 17 | virtual SkIPoint onGetSize() = 0; |
| 18 | virtual void onDraw(SkCanvas*) = 0; |
| 19 | }; |
| 20 | |
| 21 | static inline SkIPoint SkMakeIPoint(int x, int y) { |
| 22 | SkIPoint p; |
| 23 | p.set(x, y); |
| 24 | return p; |
| 25 | } |
| 26 | |
| 27 | /////////////////////////////////////////////////////////////////////////////// |
| 28 | |
| 29 | template <typename T> class SkTRegistry : SkNoncopyable { |
| 30 | public: |
| 31 | typedef T* (*Factory)(); |
| 32 | |
| 33 | SkTRegistry(Factory fact) { |
| 34 | fFact = fact; |
| 35 | fChain = gHead; |
| 36 | gHead = this; |
| 37 | } |
| 38 | |
| 39 | static const SkTRegistry* Head() { return gHead; } |
| 40 | |
| 41 | SkTRegistry* next() const { return fChain; } |
| 42 | Factory factory() const { return fFact; } |
| 43 | |
| 44 | private: |
| 45 | Factory fFact; |
| 46 | SkTRegistry* fChain; |
| 47 | |
| 48 | static SkTRegistry* gHead; |
| 49 | }; |
| 50 | |
| 51 | template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead; |
| 52 | |
| 53 | #endif |
| 54 | |