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 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 | 13 |
14 namespace skiagm { | 14 namespace skiagm { |
15 | 15 |
16 class ComplexClip2GM : public GM { | 16 class ComplexClip2GM : public GM { |
17 public: | 17 public: |
18 enum Clip { | 18 enum Clip { |
19 kRect_Clip, | 19 kRect_Clip, |
20 kRRect_Clip, | 20 kRRect_Clip, |
21 kPath_Clip | 21 kPath_Clip |
22 }; | 22 }; |
23 | 23 |
24 ComplexClip2GM(Clip clip, bool antiAlias) | 24 ComplexClip2GM(Clip clip, bool antiAlias) |
25 : fClip(clip) | 25 : fClip(clip) |
26 , fAntiAlias(antiAlias) { | 26 , fAntiAlias(antiAlias) { |
| 27 } |
| 28 |
| 29 protected: |
| 30 virtual void onOnceBeforeDraw() { |
27 this->setBGColor(SkColorSetRGB(0xDD,0xA0,0xDD)); | 31 this->setBGColor(SkColorSetRGB(0xDD,0xA0,0xDD)); |
28 | 32 |
29 // offset the rects a bit so we get antialiasing even in the rect case | 33 // offset the rects a bit so we get antialiasing even in the rect case |
30 SkScalar xA = 0.65f; | 34 SkScalar xA = 0.65f; |
31 SkScalar xB = 10.65f; | 35 SkScalar xB = 10.65f; |
32 SkScalar xC = 20.65f; | 36 SkScalar xC = 20.65f; |
33 SkScalar xD = 30.65f; | 37 SkScalar xD = 30.65f; |
34 SkScalar xE = 40.65f; | 38 SkScalar xE = 40.65f; |
35 SkScalar xF = 50.65f; | 39 SkScalar xF = 50.65f; |
36 | 40 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 SkRandom r; | 88 SkRandom r; |
85 for (int i = 0; i < kRows; ++i) { | 89 for (int i = 0; i < kRows; ++i) { |
86 for (int j = 0; j < kCols; ++j) { | 90 for (int j = 0; j < kCols; ++j) { |
87 for (int k = 0; k < 5; ++k) { | 91 for (int k = 0; k < 5; ++k) { |
88 fOps[j*kRows+i][k] = ops[r.nextU() % SK_ARRAY_COUNT(ops)]; | 92 fOps[j*kRows+i][k] = ops[r.nextU() % SK_ARRAY_COUNT(ops)]; |
89 } | 93 } |
90 } | 94 } |
91 } | 95 } |
92 } | 96 } |
93 | 97 |
94 protected: | |
95 | |
96 static const int kRows = 5; | 98 static const int kRows = 5; |
97 static const int kCols = 5; | 99 static const int kCols = 5; |
98 static const int kPadX = 20; | 100 static const int kPadX = 20; |
99 static const int kPadY = 20; | 101 static const int kPadY = 20; |
100 | 102 |
101 static const char* ClipStr(Clip clip) { | 103 static const char* ClipStr(Clip clip) { |
102 switch (clip) { | 104 switch (clip) { |
103 case kRect_Clip: | 105 case kRect_Clip: |
104 return "rect"; | 106 return "rect"; |
105 case kRRect_Clip: | 107 case kRRect_Clip: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, false); ) | 208 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, false); ) |
207 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, false); ) | 209 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, false); ) |
208 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, false); ) | 210 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, false); ) |
209 | 211 |
210 // aa | 212 // aa |
211 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, true); ) | 213 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, true); ) |
212 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, true); ) | 214 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, true); ) |
213 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, true); ) | 215 DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, true); ) |
214 | 216 |
215 } | 217 } |
OLD | NEW |