diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-14 18:59:28 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-14 18:59:28 +0000 |
commit | 7d65dee1892615f76a40604691b026eb00dc2d11 (patch) | |
tree | 3f553295bab60f06d14f123fe4e63e4ec489ec54 /gm/fontmgr.cpp | |
parent | 04507b9fd957b2a85b4558607ea7f685b3453ec9 (diff) |
allow both GDI and DW fontmgrs at the same time
BUG=
R=bungeman@google.com
Review URL: https://codereview.chromium.org/23058002
git-svn-id: http://skia.googlecode.com/svn/trunk@10718 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/fontmgr.cpp')
-rw-r--r-- | gm/fontmgr.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index 70b91150d0..9c300ab502 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -11,6 +11,11 @@ #include "SkGraphics.h" #include "SkTypeface.h" +#ifdef SK_BUILD_FOR_WIN + extern SkFontMgr* SkFontMgr_New_GDI(); + extern SkFontMgr* SkFontMgr_New_DirectWrite(); +#endif + // limit this just so we don't take too long to draw #define MAX_FAMILIES 30 @@ -22,13 +27,21 @@ static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x, class FontMgrGM : public skiagm::GM { public: - FontMgrGM() { + FontMgrGM(SkFontMgr* (*factory)() = NULL) { SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); + + fName.set("fontmgr_iter"); + if (factory) { + fName.append("_factory"); + fFM.reset(factory()); + } else { + fFM.reset(SkFontMgr::RefDefault()); + } } protected: virtual SkString onShortName() { - return SkString("fontmgr_iter"); + return fName; } virtual SkISize onISize() { @@ -43,7 +56,7 @@ protected: paint.setSubpixelText(true); paint.setTextSize(17); - SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); + SkFontMgr* fm = fFM; int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); for (int i = 0; i < count; ++i) { @@ -79,6 +92,8 @@ protected: } private: + SkAutoTUnref<SkFontMgr> fFM; + SkString fName; typedef GM INHERITED; }; @@ -181,3 +196,7 @@ private: DEF_GM( return SkNEW(FontMgrGM); ) DEF_GM( return SkNEW(FontMgrMatchGM); ) + +#ifdef SK_BUILD_FOR_WIN + DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite)); ) +#endif |