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 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 SkPath path; | 161 SkPath path; |
162 path.arcTo(SkRect::MakeXYWH(SkIntToScalar(-40), SkIntToScalar(15), | 162 path.arcTo(SkRect::MakeXYWH(SkIntToScalar(-40), SkIntToScalar(15), |
163 SkIntToScalar(300), SkIntToScalar(90)), | 163 SkIntToScalar(300), SkIntToScalar(90)), |
164 SkIntToScalar(225), SkIntToScalar(90), | 164 SkIntToScalar(225), SkIntToScalar(90), |
165 false); | 165 false); |
166 path.close(); | 166 path.close(); |
167 | 167 |
168 static const int testsPerCol = 8; | 168 static const int testsPerCol = 8; |
169 static const int rowHeight = 60; | 169 static const int rowHeight = 60; |
170 static const int colWidth = 300; | 170 static const int colWidth = 300; |
| 171 SkCanvas::TextOnPathMethod method = SkCanvas::kStretch_TextOnPathMethod; |
171 canvas->save(); | 172 canvas->save(); |
172 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) { | 173 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) { |
173 canvas->save(); | 174 canvas->save(); |
174 size_t i = 2*s; | 175 size_t i = 2*s; |
175 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 176 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
176 SkIntToScalar((i % testsPerCol) * rowHeight)); | 177 SkIntToScalar((i % testsPerCol) * rowHeight)); |
177 paint.setShader(shaders[s])->unref(); | 178 paint.setShader(shaders[s])->unref(); |
178 canvas->drawText(text, textLen, 0, textBase, paint); | 179 canvas->drawText(text, textLen, 0, textBase, paint); |
179 canvas->restore(); | 180 canvas->restore(); |
180 canvas->save(); | 181 canvas->save(); |
181 ++i; | 182 ++i; |
182 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 183 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
183 SkIntToScalar((i % testsPerCol) * rowHeight)); | 184 SkIntToScalar((i % testsPerCol) * rowHeight)); |
184 canvas->drawTextOnPath(text, textLen, path, NULL, paint); | 185 canvas->drawTextOnPath(text, textLen, path, NULL, method, paint); |
185 canvas->restore(); | 186 canvas->restore(); |
186 } | 187 } |
187 canvas->restore(); | 188 canvas->restore(); |
188 } | 189 } |
189 | 190 |
190 private: | 191 private: |
191 typedef SampleView INHERITED; | 192 typedef SampleView INHERITED; |
192 }; | 193 }; |
193 | 194 |
194 /////////////////////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////////////////////// |
195 | 196 |
196 static SkView* MyFactory() { return new ShaderTextView; } | 197 static SkView* MyFactory() { return new ShaderTextView; } |
197 static SkViewRegister reg(MyFactory); | 198 static SkViewRegister reg(MyFactory); |
OLD | NEW |