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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SkIntToScalar(225), SkIntToScalar(90), | 179 SkIntToScalar(225), SkIntToScalar(90), |
180 false); | 180 false); |
181 path.close(); | 181 path.close(); |
182 | 182 |
183 static const int testsPerCol = 8; | 183 static const int testsPerCol = 8; |
184 static const int rowHeight = 60; | 184 static const int rowHeight = 60; |
185 static const int colWidth = 300; | 185 static const int colWidth = 300; |
186 canvas->save(); | 186 canvas->save(); |
187 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) { | 187 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) { |
188 canvas->save(); | 188 canvas->save(); |
189 int i = 2*s; | 189 size_t i = 2*s; |
190 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 190 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
191 SkIntToScalar((i % testsPerCol) * rowHeight)); | 191 SkIntToScalar((i % testsPerCol) * rowHeight)); |
192 paint.setShader(shaders[s])->unref(); | 192 paint.setShader(shaders[s])->unref(); |
193 canvas->drawText(text, textLen, 0, textBase, paint); | 193 canvas->drawText(text, textLen, 0, textBase, paint); |
194 canvas->restore(); | 194 canvas->restore(); |
195 canvas->save(); | 195 canvas->save(); |
196 ++i; | 196 ++i; |
197 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 197 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
198 SkIntToScalar((i % testsPerCol) * rowHeight)); | 198 SkIntToScalar((i % testsPerCol) * rowHeight)); |
199 canvas->drawTextOnPath(text, textLen, path, NULL, paint); | 199 canvas->drawTextOnPath(text, textLen, path, NULL, paint); |
200 canvas->restore(); | 200 canvas->restore(); |
201 } | 201 } |
202 canvas->restore(); | 202 canvas->restore(); |
203 | 203 |
204 canvas->translate(0, SkIntToScalar(370)); | 204 canvas->translate(0, SkIntToScalar(370)); |
205 this->inval(NULL); | 205 this->inval(NULL); |
206 } | 206 } |
207 | 207 |
208 private: | 208 private: |
209 typedef SampleView INHERITED; | 209 typedef SampleView INHERITED; |
210 }; | 210 }; |
211 | 211 |
212 /////////////////////////////////////////////////////////////////////////////// | 212 /////////////////////////////////////////////////////////////////////////////// |
213 | 213 |
214 static SkView* MyFactory() { return new ShaderTextView; } | 214 static SkView* MyFactory() { return new ShaderTextView; } |
215 static SkViewRegister reg(MyFactory); | 215 static SkViewRegister reg(MyFactory); |
OLD | NEW |