OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef skiagm_DEFINED | 8 #ifndef skiagm_DEFINED |
9 #define skiagm_DEFINED | 9 #define skiagm_DEFINED |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 SkISize::Make(W, H))); ) \ | 33 SkISize::Make(W, H))); ) \ |
34 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS) | 34 void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS) |
35 | 35 |
36 namespace skiagm { | 36 namespace skiagm { |
37 | 37 |
38 class GM { | 38 class GM { |
39 public: | 39 public: |
40 GM(); | 40 GM(); |
41 virtual ~GM(); | 41 virtual ~GM(); |
42 | 42 |
43 enum Flags { | |
44 kSkipPDF_Flag = 1 << 0, | |
45 kSkipPicture_Flag = 1 << 1, | |
46 kSkipPipe_Flag = 1 << 2, | |
47 kSkipPipeCrossProcess_Flag = 1 << 3, | |
48 kSkipTiled_Flag = 1 << 4, | |
49 kSkip565_Flag = 1 << 5, | |
50 kSkipScaledReplay_Flag = 1 << 6, | |
51 kSkipGPU_Flag = 1 << 7, | |
52 kSkipPDFRasterization_Flag = 1 << 8, | |
53 | |
54 kGPUOnly_Flag = 1 << 9, | |
55 | |
56 kNoBBH_Flag = 1 << 11, // May draw wrong using a bou
nding-box hierarchy | |
57 }; | |
58 | |
59 enum Mode { | 43 enum Mode { |
60 kGM_Mode, | 44 kGM_Mode, |
61 kSample_Mode, | 45 kSample_Mode, |
62 kBench_Mode, | 46 kBench_Mode, |
63 }; | 47 }; |
64 | 48 |
65 void setMode(Mode mode) { fMode = mode; } | 49 void setMode(Mode mode) { fMode = mode; } |
66 Mode getMode() const { return fMode; } | 50 Mode getMode() const { return fMode; } |
67 | 51 |
68 void draw(SkCanvas*); | 52 void draw(SkCanvas*); |
69 void drawBackground(SkCanvas*); | 53 void drawBackground(SkCanvas*); |
70 void drawContent(SkCanvas*); | 54 void drawContent(SkCanvas*); |
71 | 55 |
72 SkISize getISize() { return this->onISize(); } | 56 SkISize getISize() { return this->onISize(); } |
73 const char* getName(); | 57 const char* getName(); |
74 | 58 |
75 virtual bool runAsBench() const { return false; } | 59 virtual bool runAsBench() const { return false; } |
76 | 60 |
77 uint32_t getFlags() const { | |
78 return this->onGetFlags(); | |
79 } | |
80 | |
81 SkScalar width() { | 61 SkScalar width() { |
82 return SkIntToScalar(this->getISize().width()); | 62 return SkIntToScalar(this->getISize().width()); |
83 } | 63 } |
84 SkScalar height() { | 64 SkScalar height() { |
85 return SkIntToScalar(this->getISize().height()); | 65 return SkIntToScalar(this->getISize().height()); |
86 } | 66 } |
87 | 67 |
88 // TODO(vandebo) Instead of exposing this, we should run all the GMs | 68 // TODO(vandebo) Instead of exposing this, we should run all the GMs |
89 // with and without an initial transform. | 69 // with and without an initial transform. |
90 // Most GMs will return the identity matrix, but some PDFs tests | 70 // Most GMs will return the identity matrix, but some PDFs tests |
(...skipping 20 matching lines...) Expand all Loading... |
111 void setStarterMatrix(const SkMatrix& matrix) { | 91 void setStarterMatrix(const SkMatrix& matrix) { |
112 fStarterMatrix = matrix; | 92 fStarterMatrix = matrix; |
113 } | 93 } |
114 | 94 |
115 protected: | 95 protected: |
116 virtual void onOnceBeforeDraw() {} | 96 virtual void onOnceBeforeDraw() {} |
117 virtual void onDraw(SkCanvas*) = 0; | 97 virtual void onDraw(SkCanvas*) = 0; |
118 virtual void onDrawBackground(SkCanvas*); | 98 virtual void onDrawBackground(SkCanvas*); |
119 virtual SkISize onISize() = 0; | 99 virtual SkISize onISize() = 0; |
120 virtual SkString onShortName() = 0; | 100 virtual SkString onShortName() = 0; |
121 virtual uint32_t onGetFlags() const { return 0; } | 101 |
122 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); } | 102 virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); } |
123 | 103 |
124 private: | 104 private: |
125 Mode fMode; | 105 Mode fMode; |
126 SkString fShortName; | 106 SkString fShortName; |
127 SkColor fBGColor; | 107 SkColor fBGColor; |
128 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp | 108 bool fCanvasIsDeferred; // work-around problem in srcmode.cpp |
129 bool fHaveCalledOnceBeforeDraw; | 109 bool fHaveCalledOnceBeforeDraw; |
130 SkMatrix fStarterMatrix; | 110 SkMatrix fStarterMatrix; |
131 }; | 111 }; |
(...skipping 11 matching lines...) Expand all Loading... |
143 SkISize onISize() SK_OVERRIDE; | 123 SkISize onISize() SK_OVERRIDE; |
144 SkString onShortName() SK_OVERRIDE; | 124 SkString onShortName() SK_OVERRIDE; |
145 private: | 125 private: |
146 SkString fName; | 126 SkString fName; |
147 void (*fDrawProc)(SkCanvas*); | 127 void (*fDrawProc)(SkCanvas*); |
148 SkISize fSize; | 128 SkISize fSize; |
149 }; | 129 }; |
150 } | 130 } |
151 | 131 |
152 #endif | 132 #endif |
OLD | NEW |