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 "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
11 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
13 | 13 |
14 #ifdef SK_BUILD_FOR_WIN | 14 #ifdef SK_BUILD_FOR_WIN |
15 #include "SkTypeface_win.h" | 15 #include "SkTypeface_win.h" |
16 #endif | 16 #endif |
17 | 17 |
18 // limit this just so we don't take too long to draw | 18 // limit this just so we don't take too long to draw |
19 #define MAX_FAMILIES 30 | 19 #define MAX_FAMILIES 30 |
20 | 20 |
21 static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x, | 21 static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x, |
22 SkScalar y, const SkPaint& paint) { | 22 SkScalar y, const SkPaint& paint) { |
23 canvas->drawText(text.c_str(), text.size(), x, y, paint); | 23 canvas->drawText(text.c_str(), text.size(), x, y, paint); |
24 return x + paint.measureText(text.c_str(), text.size()); | 24 return x + paint.measureText(text.c_str(), text.size()); |
25 } | 25 } |
26 | 26 |
27 class FontMgrGM : public skiagm::GM { | 27 class FontMgrGM : public skiagm::GM { |
28 public: | 28 public: |
29 FontMgrGM(SkFontMgr* (*factory)() = NULL) { | 29 FontMgrGM(SkFontMgr* fontMgr = NULL) { |
30 SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); | 30 SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); |
31 | 31 |
32 fName.set("fontmgr_iter"); | 32 fName.set("fontmgr_iter"); |
33 if (factory) { | 33 if (fontMgr) { |
34 fName.append("_factory"); | 34 fName.append("_factory"); |
35 fFM.reset(factory()); | 35 fFM.reset(fontMgr); |
36 } else { | 36 } else { |
37 fFM.reset(SkFontMgr::RefDefault()); | 37 fFM.reset(SkFontMgr::RefDefault()); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 protected: | 41 protected: |
42 virtual SkString onShortName() { | 42 virtual SkString onShortName() { |
43 return fName; | 43 return fName; |
44 } | 44 } |
45 | 45 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 private: | 188 private: |
189 typedef GM INHERITED; | 189 typedef GM INHERITED; |
190 }; | 190 }; |
191 | 191 |
192 ////////////////////////////////////////////////////////////////////////////// | 192 ////////////////////////////////////////////////////////////////////////////// |
193 | 193 |
194 DEF_GM( return SkNEW(FontMgrGM); ) | 194 DEF_GM( return SkNEW(FontMgrGM); ) |
195 DEF_GM( return SkNEW(FontMgrMatchGM); ) | 195 DEF_GM( return SkNEW(FontMgrMatchGM); ) |
196 | 196 |
197 #ifdef SK_BUILD_FOR_WIN | 197 #ifdef SK_BUILD_FOR_WIN |
198 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite)); ) | 198 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) |
199 #endif | 199 #endif |
OLD | NEW |