OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 typedef SkScalar (*MakePathProc)(SkPath*); | 10 typedef SkScalar (*MakePathProc)(SkPath*); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 make_star_5, | 110 make_star_5, |
111 make_star_13, | 111 make_star_13, |
112 make_line, | 112 make_line, |
113 }; | 113 }; |
114 | 114 |
115 #define N SK_ARRAY_COUNT(gProcs) | 115 #define N SK_ARRAY_COUNT(gProcs) |
116 | 116 |
117 class PathFillGM : public skiagm::GM { | 117 class PathFillGM : public skiagm::GM { |
118 SkPath fPath[N]; | 118 SkPath fPath[N]; |
119 SkScalar fDY[N]; | 119 SkScalar fDY[N]; |
120 public: | 120 protected: |
121 PathFillGM() { | 121 void onOnceBeforeDraw() SK_OVERRIDE { |
122 for (size_t i = 0; i < N; i++) { | 122 for (size_t i = 0; i < N; i++) { |
123 fDY[i] = gProcs[i](&fPath[i]); | 123 fDY[i] = gProcs[i](&fPath[i]); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 protected: | |
128 | 127 |
129 SkString onShortName() SK_OVERRIDE { | 128 SkString onShortName() SK_OVERRIDE { |
130 return SkString("pathfill"); | 129 return SkString("pathfill"); |
131 } | 130 } |
132 | 131 |
133 SkISize onISize() SK_OVERRIDE { | 132 SkISize onISize() SK_OVERRIDE { |
134 return SkISize::Make(640, 480); | 133 return SkISize::Make(640, 480); |
135 } | 134 } |
136 | 135 |
137 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 136 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
138 SkPaint paint; | 137 SkPaint paint; |
139 paint.setAntiAlias(true); | 138 paint.setAntiAlias(true); |
140 | 139 |
141 for (size_t i = 0; i < N; i++) { | 140 for (size_t i = 0; i < N; i++) { |
142 canvas->drawPath(fPath[i], paint); | 141 canvas->drawPath(fPath[i], paint); |
143 canvas->translate(SkIntToScalar(0), fDY[i]); | 142 canvas->translate(SkIntToScalar(0), fDY[i]); |
144 } | 143 } |
145 } | 144 } |
146 | 145 |
147 private: | 146 private: |
148 typedef skiagm::GM INHERITED; | 147 typedef skiagm::GM INHERITED; |
149 }; | 148 }; |
150 | 149 |
151 // test inverse-fill w/ a clip that completely excludes the geometry | 150 // test inverse-fill w/ a clip that completely excludes the geometry |
152 class PathInverseFillGM : public skiagm::GM { | 151 class PathInverseFillGM : public skiagm::GM { |
153 SkPath fPath[N]; | 152 SkPath fPath[N]; |
154 SkScalar fDY[N]; | 153 SkScalar fDY[N]; |
155 public: | 154 protected: |
156 PathInverseFillGM() { | 155 void onOnceBeforeDraw() SK_OVERRIDE { |
157 for (size_t i = 0; i < N; i++) { | 156 for (size_t i = 0; i < N; i++) { |
158 fDY[i] = gProcs[i](&fPath[i]); | 157 fDY[i] = gProcs[i](&fPath[i]); |
159 } | 158 } |
160 } | 159 } |
161 | 160 |
162 protected: | |
163 | |
164 SkString onShortName() SK_OVERRIDE { | 161 SkString onShortName() SK_OVERRIDE { |
165 return SkString("pathinvfill"); | 162 return SkString("pathinvfill"); |
166 } | 163 } |
167 | 164 |
168 SkISize onISize() SK_OVERRIDE { | 165 SkISize onISize() SK_OVERRIDE { |
169 return SkISize::Make(450, 220); | 166 return SkISize::Make(450, 220); |
170 } | 167 } |
171 | 168 |
172 static void show(SkCanvas* canvas, const SkPath& path, const SkPaint& paint, | 169 static void show(SkCanvas* canvas, const SkPath& path, const SkPaint& paint, |
173 const SkRect* clip, SkScalar top, const SkScalar bottom) { | 170 const SkRect* clip, SkScalar top, const SkScalar bottom) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 typedef skiagm::GM INHERITED; | 212 typedef skiagm::GM INHERITED; |
216 }; | 213 }; |
217 | 214 |
218 /////////////////////////////////////////////////////////////////////////////// | 215 /////////////////////////////////////////////////////////////////////////////// |
219 | 216 |
220 static skiagm::GM* MyFactory(void*) { return new PathFillGM; } | 217 static skiagm::GM* MyFactory(void*) { return new PathFillGM; } |
221 static skiagm::GMRegistry reg(MyFactory); | 218 static skiagm::GMRegistry reg(MyFactory); |
222 | 219 |
223 static skiagm::GM* F1(void*) { return new PathInverseFillGM; } | 220 static skiagm::GM* F1(void*) { return new PathInverseFillGM; } |
224 static skiagm::GMRegistry gR1(F1); | 221 static skiagm::GMRegistry gR1(F1); |
OLD | NEW |