epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 8 | #ifndef SkBenchmark_DEFINED |
| 9 | #define SkBenchmark_DEFINED |
| 10 | |
| 11 | #include "SkRefCnt.h" |
| 12 | #include "SkPoint.h" |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 13 | #include "SkTDict.h" |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 14 | #include "SkTRegistry.h" |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 15 | |
| 16 | class SkCanvas; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 17 | class SkPaint; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 18 | |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 19 | class SkTriState { |
| 20 | public: |
| 21 | enum State { |
| 22 | kDefault, |
| 23 | kTrue, |
| 24 | kFalse |
| 25 | }; |
| 26 | }; |
| 27 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 28 | class SkBenchmark : public SkRefCnt { |
| 29 | public: |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 30 | SkBenchmark(void* defineDict); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 31 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 32 | const char* getName(); |
| 33 | SkIPoint getSize(); |
| 34 | void draw(SkCanvas*); |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 35 | |
| 36 | void setForceAlpha(int alpha) { |
| 37 | fForceAlpha = alpha; |
| 38 | } |
| 39 | |
| 40 | void setForceAA(bool aa) { |
| 41 | fForceAA = aa; |
| 42 | } |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 43 | |
| 44 | void setForceFilter(bool filter) { |
| 45 | fForceFilter = filter; |
| 46 | } |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 47 | |
| 48 | void setDither(SkTriState::State state) { |
| 49 | fDither = state; |
| 50 | } |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 51 | |
agl@chromium.org | 652807b | 2010-04-27 15:47:34 +0000 | [diff] [blame] | 52 | void setStrokeWidth(SkScalar width) { |
| 53 | strokeWidth = width; |
| 54 | fHasStrokeWidth = true; |
| 55 | } |
| 56 | |
| 57 | SkScalar getStrokeWidth() { |
| 58 | return strokeWidth; |
| 59 | } |
| 60 | |
| 61 | bool hasStrokeWidth() { |
| 62 | return fHasStrokeWidth; |
| 63 | } |
| 64 | |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 65 | const char* findDefine(const char* key) const; |
reed@android.com | 0c9da39 | 2010-02-22 19:50:13 +0000 | [diff] [blame] | 66 | bool findDefine32(const char* key, int32_t* value) const; |
| 67 | bool findDefineScalar(const char* key, SkScalar* value) const; |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 68 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 69 | protected: |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 70 | void setupPaint(SkPaint* paint); |
| 71 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 72 | virtual const char* onGetName() = 0; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 73 | virtual void onDraw(SkCanvas*) = 0; |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 74 | |
| 75 | virtual SkIPoint onGetSize(); |
| 76 | |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 77 | private: |
reed@android.com | e9d0060 | 2009-09-02 21:12:42 +0000 | [diff] [blame] | 78 | const SkTDict<const char*>* fDict; |
reed@android.com | 4bc1983 | 2009-01-19 20:08:35 +0000 | [diff] [blame] | 79 | int fForceAlpha; |
| 80 | bool fForceAA; |
reed@android.com | 29348cb | 2009-08-04 18:17:15 +0000 | [diff] [blame] | 81 | bool fForceFilter; |
reed@android.com | 4e635f9 | 2009-10-19 17:39:46 +0000 | [diff] [blame] | 82 | SkTriState::State fDither; |
agl@chromium.org | 652807b | 2010-04-27 15:47:34 +0000 | [diff] [blame] | 83 | bool fHasStrokeWidth; |
| 84 | SkScalar strokeWidth; |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 87 | typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry; |
| 88 | |
reed@android.com | bd700c3 | 2009-01-05 03:34:50 +0000 | [diff] [blame] | 89 | #endif |