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" |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 6 | #include "SkTDict.h" |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 7 | #include "SkTRegistry.h" |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 8 | |
| 9 | class SkCanvas; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 10 | class SkPaint; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 11 | |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame^] | 12 | class SkTriState { |
| 13 | public: |
| 14 | enum State { |
| 15 | kDefault, |
| 16 | kTrue, |
| 17 | kFalse |
| 18 | }; |
| 19 | }; |
| 20 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 21 | class SkBenchmark : public SkRefCnt { |
| 22 | public: |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 23 | SkBenchmark(void* defineDict); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 24 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 25 | const char* getName(); |
| 26 | SkIPoint getSize(); |
| 27 | void draw(SkCanvas*); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 28 | |
| 29 | void setForceAlpha(int alpha) { |
| 30 | fForceAlpha = alpha; |
| 31 | } |
| 32 | |
| 33 | void setForceAA(bool aa) { |
| 34 | fForceAA = aa; |
| 35 | } |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 36 | |
| 37 | void setForceFilter(bool filter) { |
| 38 | fForceFilter = filter; |
| 39 | } |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame^] | 40 | |
| 41 | void setDither(SkTriState::State state) { |
| 42 | fDither = state; |
| 43 | } |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 44 | |
| 45 | const char* findDefine(const char* key) const; |
| 46 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 47 | protected: |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 48 | void setupPaint(SkPaint* paint); |
| 49 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 50 | virtual const char* onGetName() = 0; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 51 | virtual void onDraw(SkCanvas*) = 0; |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 52 | |
| 53 | virtual SkIPoint onGetSize(); |
| 54 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 55 | private: |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 56 | const SkTDict<const char*>* fDict; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 57 | int fForceAlpha; |
| 58 | bool fForceAA; |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 59 | bool fForceFilter; |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame^] | 60 | SkTriState::State fDither; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | static inline SkIPoint SkMakeIPoint(int x, int y) { |
| 64 | SkIPoint p; |
| 65 | p.set(x, y); |
| 66 | return p; |
| 67 | } |
| 68 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 69 | typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry; |
| 70 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 71 | #endif |
| 72 | |