aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2017-01-03 13:32:36 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-04 14:51:09 +0000
commit3546ff10c2e1e91f5afe1efaab4e5e14f71689d1 (patch)
treecbcf83ae724df22c6cc5704a75be9095a28058db /gm
parent8bc9f7b32867cb46fd7b56c11bf9dfa79a7d246e (diff)
Stage SkFontMgr factories to return smart pointers.
All the SkFontMgr factories currently return bare pointers and sometimes even document the ownership rules. Since such factories can be implemented by external ports, the ownership rules should be explicit in order to prevent simple reference counting issues. Change-Id: I25b598ce0954cd473a3fb1f8adc0cb86331583ca Reviewed-on: https://skia-review.googlesource.com/6533 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/fontmgr.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp
index 216fdd8249..18fc1d9250 100644
--- a/gm/fontmgr.cpp
+++ b/gm/fontmgr.cpp
@@ -55,6 +55,7 @@ static const char* ja = "ja";
class FontMgrGM : public skiagm::GM {
public:
+#ifdef SK_LEGACY_FONTMGR_FACTORY
FontMgrGM(SkFontMgr* fontMgr = nullptr) {
SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
@@ -68,6 +69,21 @@ public:
fName.append(sk_tool_utils::platform_os_name());
fName.append(sk_tool_utils::platform_extra_config("GDI"));
}
+#else
+ FontMgrGM(sk_sp<SkFontMgr> fontMgr = nullptr) {
+ SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
+
+ fName.set("fontmgr_iter");
+ if (fontMgr) {
+ fName.append("_factory");
+ fFM = std::move(fontMgr);
+ } else {
+ fFM = SkFontMgr::RefDefault();
+ }
+ fName.append(sk_tool_utils::platform_os_name());
+ fName.append(sk_tool_utils::platform_extra_config("GDI"));
+ }
+#endif
protected:
SkString onShortName() override {
@@ -225,7 +241,11 @@ public:
}
fName.append(sk_tool_utils::platform_os_name());
fName.append(sk_tool_utils::platform_extra_config("GDI"));
+#ifdef SK_LEGACY_FONTMGR_FACTORY
fFM.reset(SkFontMgr::RefDefault());
+#else
+ fFM = SkFontMgr::RefDefault();
+#endif
}
static void show_bounds(SkCanvas* canvas, const SkPaint& paint, SkScalar x, SkScalar y,