| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 | 8 |
| 9 #include "gm.h" | 9 #include "gm.h" |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return bounds; | 210 return bounds; |
| 211 } | 211 } |
| 212 | 212 |
| 213 virtual void setFont(SkPaint* paint) { | 213 virtual void setFont(SkPaint* paint) { |
| 214 sk_tool_utils::set_portable_typeface_always(paint); | 214 sk_tool_utils::set_portable_typeface_always(paint); |
| 215 } | 215 } |
| 216 | 216 |
| 217 virtual const char* text() const { return "Hello, Skia!"; } | 217 virtual const char* text() const { return "Hello, Skia!"; } |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 struct BmpText : public Text { | |
| 221 void setFont(SkPaint* paint) override { | |
| 222 if (!fTypeface) { | |
| 223 fTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")
); | |
| 224 } | |
| 225 paint->setTypeface(fTypeface); | |
| 226 } | |
| 227 | |
| 228 const char* text() const override { return "Hi, Skia!"; } | |
| 229 | |
| 230 SkAutoTUnref<SkTypeface> fTypeface; | |
| 231 }; | |
| 232 fPrims.push_back(SkNEW(Rect)); | 220 fPrims.push_back(SkNEW(Rect)); |
| 233 fPrims.push_back(SkNEW(Circle)); | 221 fPrims.push_back(SkNEW(Circle)); |
| 234 fPrims.push_back(SkNEW(RRect)); | 222 fPrims.push_back(SkNEW(RRect)); |
| 235 fPrims.push_back(SkNEW(DRRect)); | 223 fPrims.push_back(SkNEW(DRRect)); |
| 236 fPrims.push_back(SkNEW(Path)); | 224 fPrims.push_back(SkNEW(Path)); |
| 237 fPrims.push_back(SkNEW(Points(SkCanvas::kPoints_PointMode))); | 225 fPrims.push_back(SkNEW(Points(SkCanvas::kPoints_PointMode))); |
| 238 fPrims.push_back(SkNEW(Points(SkCanvas::kLines_PointMode))); | 226 fPrims.push_back(SkNEW(Points(SkCanvas::kLines_PointMode))); |
| 239 fPrims.push_back(SkNEW(Points(SkCanvas::kPolygon_PointMode))); | 227 fPrims.push_back(SkNEW(Points(SkCanvas::kPolygon_PointMode))); |
| 240 fPrims.push_back(SkNEW(Text)); | 228 fPrims.push_back(SkNEW(Text)); |
| 241 fPrims.push_back(SkNEW(BmpText)); | |
| 242 } | 229 } |
| 243 | 230 |
| 244 void onDraw(SkCanvas* canvas) override { | 231 void onDraw(SkCanvas* canvas) override { |
| 245 // This GM exists to test a specific feature of the GPU backend. It does
not work with the | 232 // This GM exists to test a specific feature of the GPU backend. It does
not work with the |
| 246 // sw rasterizer, tile modes, etc. | 233 // sw rasterizer, tile modes, etc. |
| 247 if (NULL == canvas->getGrContext()) { | 234 if (NULL == canvas->getGrContext()) { |
| 248 this->drawGpuOnlyMessage(canvas); | 235 this->drawGpuOnlyMessage(canvas); |
| 249 return; | 236 return; |
| 250 } | 237 } |
| 251 SkPaint paint; | 238 SkPaint paint; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 }; | 292 }; |
| 306 | 293 |
| 307 SkTArray<Prim*> fPrims; | 294 SkTArray<Prim*> fPrims; |
| 308 | 295 |
| 309 typedef GM INHERITED; | 296 typedef GM INHERITED; |
| 310 }; | 297 }; |
| 311 | 298 |
| 312 DEF_GM( return SkNEW(DCShaderGM); ) | 299 DEF_GM( return SkNEW(DCShaderGM); ) |
| 313 } | 300 } |
| 314 #endif | 301 #endif |
| OLD | NEW |