| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| 11 #include "SkTypeface.h" | 11 #include "SkTypeface.h" |
| 12 | 12 |
| 13 // GM to stress the GPU font cache | 13 // GM to stress the GPU font cache |
| 14 | 14 |
| 15 static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x, | 15 static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x, |
| 16 SkScalar y, const SkPaint& paint) { | 16 SkScalar y, const SkPaint& paint) { |
| 17 canvas->drawText(text.c_str(), text.size(), x, y, paint); | 17 canvas->drawText(text.c_str(), text.size(), x, y, paint); |
| 18 return x + paint.measureText(text.c_str(), text.size()); | 18 return x + paint.measureText(text.c_str(), text.size()); |
| 19 } | 19 } |
| 20 | 20 |
| 21 class FontCacheGM : public skiagm::GM { | 21 class FontCacheGM : public skiagm::GM { |
| 22 public: | 22 public: |
| 23 FontCacheGM() { | 23 FontCacheGM() { |
| 24 fTypefaces[0] = NULL; | 24 fTypefaces[0] = nullptr; |
| 25 fTypefaces[1] = NULL; | 25 fTypefaces[1] = nullptr; |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual ~FontCacheGM() { | 28 virtual ~FontCacheGM() { |
| 29 SkSafeUnref(fTypefaces[0]); | 29 SkSafeUnref(fTypefaces[0]); |
| 30 SkSafeUnref(fTypefaces[1]); | 30 SkSafeUnref(fTypefaces[1]); |
| 31 } | 31 } |
| 32 | 32 |
| 33 protected: | 33 protected: |
| 34 SkString onShortName() override { | 34 SkString onShortName() override { |
| 35 return SkString("fontcache"); | 35 return SkString("fontcache"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 SkTypeface* fTypefaces[2]; | 79 SkTypeface* fTypefaces[2]; |
| 80 typedef GM INHERITED; | 80 typedef GM INHERITED; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 | 83 |
| 84 ////////////////////////////////////////////////////////////////////////////// | 84 ////////////////////////////////////////////////////////////////////////////// |
| 85 | 85 |
| 86 DEF_GM(return new FontCacheGM;) | 86 DEF_GM(return new FontCacheGM;) |
| OLD | NEW |