OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class SimpleClipGM : public GM { | 42 class SimpleClipGM : public GM { |
43 public: | 43 public: |
44 enum SkGeomTypes { | 44 enum SkGeomTypes { |
45 kRect_GeomType, | 45 kRect_GeomType, |
46 kPath_GeomType, | 46 kPath_GeomType, |
47 kAAClip_GeomType | 47 kAAClip_GeomType |
48 }; | 48 }; |
49 | 49 |
50 SimpleClipGM(SkGeomTypes geomType) | 50 SimpleClipGM(SkGeomTypes geomType) |
51 : fGeomType(geomType) { | 51 : fGeomType(geomType) { |
| 52 } |
52 | 53 |
| 54 protected: |
| 55 void onOnceBeforeDraw() SK_OVERRIDE { |
53 // offset the rects a bit so we get anti-aliasing in the rect case | 56 // offset the rects a bit so we get anti-aliasing in the rect case |
54 fBase.set(100.65f, | 57 fBase.set(100.65f, |
55 100.65f, | 58 100.65f, |
56 150.65f, | 59 150.65f, |
57 150.65f); | 60 150.65f); |
58 fRect = fBase; | 61 fRect = fBase; |
59 fRect.inset(5, 5); | 62 fRect.inset(5, 5); |
60 fRect.offset(25, 25); | 63 fRect.offset(25, 25); |
61 | 64 |
62 fBasePath.addRoundRect(fBase, SkIntToScalar(5), SkIntToScalar(5)); | 65 fBasePath.addRoundRect(fBase, SkIntToScalar(5), SkIntToScalar(5)); |
63 fRectPath.addRoundRect(fRect, SkIntToScalar(5), SkIntToScalar(5)); | 66 fRectPath.addRoundRect(fRect, SkIntToScalar(5), SkIntToScalar(5)); |
64 INHERITED::setBGColor(0xFFDDDDDD); | 67 INHERITED::setBGColor(0xFFDDDDDD); |
65 } | 68 } |
66 | 69 |
67 protected: | |
68 void buildRgn(SkAAClip* clip, SkRegion::Op op) { | 70 void buildRgn(SkAAClip* clip, SkRegion::Op op) { |
69 clip->setPath(fBasePath, NULL, true); | 71 clip->setPath(fBasePath, NULL, true); |
70 | 72 |
71 SkAAClip clip2; | 73 SkAAClip clip2; |
72 clip2.setPath(fRectPath, NULL, true); | 74 clip2.setPath(fRectPath, NULL, true); |
73 clip->op(clip2, op); | 75 clip->op(clip2, op); |
74 } | 76 } |
75 | 77 |
76 void drawOrig(SkCanvas* canvas) { | 78 void drawOrig(SkCanvas* canvas) { |
77 SkPaint paint; | 79 SkPaint paint; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 }; | 194 }; |
193 | 195 |
194 ////////////////////////////////////////////////////////////////////////////// | 196 ////////////////////////////////////////////////////////////////////////////// |
195 | 197 |
196 // rects | 198 // rects |
197 DEF_GM( return new SimpleClipGM(SimpleClipGM::kRect_GeomType); ) | 199 DEF_GM( return new SimpleClipGM(SimpleClipGM::kRect_GeomType); ) |
198 DEF_GM( return new SimpleClipGM(SimpleClipGM::kPath_GeomType); ) | 200 DEF_GM( return new SimpleClipGM(SimpleClipGM::kPath_GeomType); ) |
199 DEF_GM( return new SimpleClipGM(SimpleClipGM::kAAClip_GeomType); ) | 201 DEF_GM( return new SimpleClipGM(SimpleClipGM::kAAClip_GeomType); ) |
200 | 202 |
201 } | 203 } |
OLD | NEW |