blob: a9c4085eb8037a4305a08e2e188a31f4d1e7a885 [file] [log] [blame]
reed@android.combd700c32009-01-05 03:34:50 +00001#ifndef SkBenchmark_DEFINED
2#define SkBenchmark_DEFINED
3
4#include "SkRefCnt.h"
5#include "SkPoint.h"
reed@android.come9d00602009-09-02 21:12:42 +00006#include "SkTDict.h"
reed@android.comf523e252009-01-26 23:15:37 +00007#include "SkTRegistry.h"
reed@android.combd700c32009-01-05 03:34:50 +00008
9class SkCanvas;
reed@android.com4bc19832009-01-19 20:08:35 +000010class SkPaint;
reed@android.combd700c32009-01-05 03:34:50 +000011
reed@android.com4e635f92009-10-19 17:39:46 +000012class SkTriState {
13public:
14 enum State {
15 kDefault,
16 kTrue,
17 kFalse
18 };
19};
20
reed@android.combd700c32009-01-05 03:34:50 +000021class SkBenchmark : public SkRefCnt {
22public:
reed@android.come9d00602009-09-02 21:12:42 +000023 SkBenchmark(void* defineDict);
reed@android.com4bc19832009-01-19 20:08:35 +000024
reed@android.combd700c32009-01-05 03:34:50 +000025 const char* getName();
26 SkIPoint getSize();
27 void draw(SkCanvas*);
reed@android.com4bc19832009-01-19 20:08:35 +000028
29 void setForceAlpha(int alpha) {
30 fForceAlpha = alpha;
31 }
32
33 void setForceAA(bool aa) {
34 fForceAA = aa;
35 }
reed@android.com29348cb2009-08-04 18:17:15 +000036
37 void setForceFilter(bool filter) {
38 fForceFilter = filter;
39 }
reed@android.com4e635f92009-10-19 17:39:46 +000040
41 void setDither(SkTriState::State state) {
42 fDither = state;
43 }
reed@android.come9d00602009-09-02 21:12:42 +000044
45 const char* findDefine(const char* key) const;
46
reed@android.combd700c32009-01-05 03:34:50 +000047protected:
reed@android.com4bc19832009-01-19 20:08:35 +000048 void setupPaint(SkPaint* paint);
49
reed@android.combd700c32009-01-05 03:34:50 +000050 virtual const char* onGetName() = 0;
reed@android.combd700c32009-01-05 03:34:50 +000051 virtual void onDraw(SkCanvas*) = 0;
reed@android.comf523e252009-01-26 23:15:37 +000052
53 virtual SkIPoint onGetSize();
54
reed@android.com4bc19832009-01-19 20:08:35 +000055private:
reed@android.come9d00602009-09-02 21:12:42 +000056 const SkTDict<const char*>* fDict;
reed@android.com4bc19832009-01-19 20:08:35 +000057 int fForceAlpha;
58 bool fForceAA;
reed@android.com29348cb2009-08-04 18:17:15 +000059 bool fForceFilter;
reed@android.com4e635f92009-10-19 17:39:46 +000060 SkTriState::State fDither;
reed@android.combd700c32009-01-05 03:34:50 +000061};
62
63static inline SkIPoint SkMakeIPoint(int x, int y) {
64 SkIPoint p;
65 p.set(x, y);
66 return p;
67}
68
reed@android.comf523e252009-01-26 23:15:37 +000069typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
70
reed@android.combd700c32009-01-05 03:34:50 +000071#endif
72