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 setStrokeWidth(SkScalar width)45 void setStrokeWidth(SkScalar width) { 46 strokeWidth = width; 47 fHasStrokeWidth = true; 48 } 49 getStrokeWidth()50 SkScalar getStrokeWidth() { 51 return strokeWidth; 52 } 53 hasStrokeWidth()54 bool hasStrokeWidth() { 55 return fHasStrokeWidth; 56 } 57 58 const char* findDefine(const char* key) const; 59 bool findDefine32(const char* key, int32_t* value) const; 60 bool findDefineScalar(const char* key, SkScalar* value) const; 61 62 protected: 63 void setupPaint(SkPaint* paint); 64 65 virtual const char* onGetName() = 0; 66 virtual void onDraw(SkCanvas*) = 0; 67 68 virtual SkIPoint onGetSize(); 69 70 private: 71 const SkTDict<const char*>* fDict; 72 int fForceAlpha; 73 bool fForceAA; 74 bool fForceFilter; 75 SkTriState::State fDither; 76 bool fHasStrokeWidth; 77 SkScalar strokeWidth; 78 }; 79 80 typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry; 81 82 #endif 83