aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/fontmgr.cpp
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-16 20:31:11 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-16 20:31:11 +0000
commit069975678aaca6dc767e9fef3d743694443223f1 (patch)
tree30ffc7da8cd28988ab72b4f167b63c4c956cac5f /gm/fontmgr.cpp
parentece1a77aa5f7deb8ecee4ea04fba01e58531b66c (diff)
allow both GDI and DW fontmgrs at the same time
BUG= R=bungeman@google.com Committed: https://code.google.com/p/skia/source/detail?r=10718 Review URL: https://codereview.chromium.org/23058002 git-svn-id: http://skia.googlecode.com/svn/trunk@10788 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/fontmgr.cpp')
-rw-r--r--gm/fontmgr.cpp25
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