• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SkBenchmark_DEFINED
2 #define SkBenchmark_DEFINED
3 
4 #include "SkRefCnt.h"
5 #include "SkPoint.h"
6 #include "SkTDict.h"
7 #include "SkTRegistry.h"
8 
9 class SkCanvas;
10 class SkPaint;
11 
12 class SkTriState {
13 public:
14     enum State {
15         kDefault,
16         kTrue,
17         kFalse
18     };
19 };
20 
21 class SkBenchmark : public SkRefCnt {
22 public:
23     SkBenchmark(void* defineDict);
24 
25     const char* getName();
26     SkIPoint getSize();
27     void draw(SkCanvas*);
28 
setForceAlpha(int alpha)29     void setForceAlpha(int alpha) {
30         fForceAlpha = alpha;
31     }
32 
setForceAA(bool aa)33     void setForceAA(bool aa) {
34         fForceAA = aa;
35     }
36 
setForceFilter(bool filter)37     void setForceFilter(bool filter) {
38         fForceFilter = filter;
39     }
40 
setDither(SkTriState::State state)41     void setDither(SkTriState::State state) {
42         fDither = state;
43     }
44 
45     const char* findDefine(const char* key) const;
46     bool findDefine32(const char* key, int32_t* value) const;
47     bool findDefineScalar(const char* key, SkScalar* value) const;
48 
49 protected:
50     void setupPaint(SkPaint* paint);
51 
52     virtual const char* onGetName() = 0;
53     virtual void onDraw(SkCanvas*) = 0;
54 
55     virtual SkIPoint onGetSize();
56 
57 private:
58     const SkTDict<const char*>* fDict;
59     int     fForceAlpha;
60     bool    fForceAA;
61     bool    fForceFilter;
62     SkTriState::State  fDither;
63 };
64 
65 typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
66 
67 #endif
68 
69